diff options
author | dawes <dawes> | 2000-11-07 22:09:53 +0000 |
---|---|---|
committer | dawes <dawes> | 2000-11-07 22:09:53 +0000 |
commit | 38b17cc33454f7fb15124f3d6662db17742608b1 (patch) | |
tree | 423153b840a37e05f2d1815324f3d97066b1b199 | |
parent | 2a014014a640a61a548dab6701a371d8d81ee8f2 (diff) |
Initial revision
77 files changed, 21570 insertions, 0 deletions
diff --git a/xc/config/cf/iPAQH3600.cf b/xc/config/cf/iPAQH3600.cf new file mode 100644 index 000000000..2b06c657e --- /dev/null +++ b/xc/config/cf/iPAQH3600.cf @@ -0,0 +1,109 @@ +/* $XFree86: xc/config/cf/iPAQH3600.cf,v 1.2 2000/10/10 14:05:48 tsi Exp $ */ +/* + * This configuration file contains additional configuration needed + * to cross compile X for the Compaq iPAQ H3600 PocketPC. + * To use this, add the following to host.def: + #define KDriveXServer YES + #define XiPAQH3500Server YES + */ + +#define CrossCompiling YES + +#undef i386Architecture +#define Arm32Architecture + +#undef OptimizedCDebugFlags +#define OptimizedCDebugFlags -O2 +#define ServerCDebugFlags -O2 +#undef StandardDefines +#define StandardDefines -Dlinux -D__arm__ -D_POSIX_SOURCE \ + -D_BSD_SOURCE -D_GNU_SOURCE -DX_LOCALE +#undef CcCmd +#define StdIncDir /skiff/local/arm-linux/include +#define PreIncDir +#undef PostIncDir +#define PostIncDir /skiff/local/lib/gcc-lib/arm-linux/2.95.2/include +#define CcCmd /skiff/local/bin/arm-linux-gcc +#define DoRanlibCmd YES +#define RanlibCmd /skiff/local/bin/arm-linux-ranlib +#undef ExtraLoadFlags +#define ExtraLoadFlags +#define FbNoPixelAddrCode +#undef TermcapLibrary +#define TermcapLibrary -ltermcap + +#undef LdPostLib +#define LdPostLib -L/skiff/local/arm-linux/lib + +#undef XfbdevServer +#define XfbdevServer YES +#undef BuildXprint +#define BuildLBX NO +#define BuildFonts NO +#define BuildAppgroup NO +#define BuildRECORD NO +#define BuildDBE NO +#define BuildXCSecurity NO +#define ItsyCompilerBug YES +#define FontServerAccess NO +#define ServerXdmcpDefines /**/ + +#undef ExtensionOSDefines +#define ExtensionOSDefines + +#define ProjectRoot /usr/X11R6 + +#define GzipFontCompression YES + +#define KdriveServerExtraDefines -DITSY -DMAXSCREENS=1 + +#define HostLinkRule(target, flags, src, libs) cc -I$(BUILDINCDIR) -o target src + +/* ComplexHostProgramTarget - Compile a program such that we can run + * it on this host, i.e., don't use the default cross compiler. + */ +#ifndef ComplexHostProgramTarget +#define ComplexHostProgramTarget(program) @@\ + CC=cc @@\ + STD_INCLUDES= @@\ + CFLAGS=$(TOP_INCLUDES) $(INCLUDES) $(BOOTSTRAPCFLAGS) @@\ +EXTRA_LOAD_FLAGS= @@\ + PROGRAM = program @@\ + @@\ +AllTarget(program) @@\ + @@\ +program: $(OBJS) $(DEPLIBS) @@\ + RemoveTargetProgram($@) @@\ + HostLinkRule($@,$(_NOOP_),$(OBJS),$(DEPLIBS) $(LOCAL_LIBRARIES)) @@\ + @@\ +DependTarget() @@\ + @@\ +LintTarget() @@\ + @@\ +clean:: @@\ + RemoveFile(ProgramTargetName(program)) +#endif /* ComplexHostProgramTarget */ + +#ifndef SimpleHostProgramTarget +#define SimpleHostProgramTarget(program) @@\ + SRCS = program.c @@\ + @@\ + CC=cc @@\ + STD_INCLUDES= @@\ + CFLAGS=$(TOP_INCLUDES) $(INCLUDES) $(BOOTSTRAPCFLAGS) @@\ +EXTRA_LOAD_FLAGS= @@\ + PROGRAM = program @@\ + @@\ +AllTarget(program) @@\ + @@\ +program: program.o $(DEPLIBS) @@\ + RemoveTargetProgram($@) @@\ + HostLinkRule($@,$(_NOOP_),program.o,$(DEPLIBS) $(LOCAL_LIBRARIES)) @@\ + @@\ +DependTarget() @@\ + @@\ +LintTarget() @@\ + @@\ +clean:: @@\ + RemoveFile(ProgramTargetName(program)) +#endif /* SimpleHostProgramTarget */ diff --git a/xc/lib/X11/lcUniConv/iso8859_9e.h b/xc/lib/X11/lcUniConv/iso8859_9e.h new file mode 100644 index 000000000..b2ff2eb6e --- /dev/null +++ b/xc/lib/X11/lcUniConv/iso8859_9e.h @@ -0,0 +1,101 @@ +/* $XFree86: xc/lib/X11/lcUniConv/iso8859_9e.h,v 1.1 2000/10/27 20:26:07 dawes Exp $ */ + +/* + * ISO-8859-9E + */ + +static const unsigned short iso8859_9e_2uni[96] = { + /* 0xa0 */ + 0x00a0, 0x017d, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x012c, 0x00a7, + 0x016c, 0x00a9, 0x01e6, 0x00ab, 0x014a, 0x00ad, 0x00ae, 0x019f, + /* 0xb0 */ + 0x00b0, 0x017e, 0x00b2, 0x00b3, 0x01d1, 0x00b5, 0x012d, 0x00b7, + 0x016d, 0x00b9, 0x01e7, 0x00bb, 0x014b, 0x01d2, 0x0178, 0x0275, + /* 0xc0 */ + 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x018f, 0x00c7, + 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, + /* 0xd0 */ + 0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00dd, + 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df, + /* 0xe0 */ + 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x0259, 0x00e7, + 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, + /* 0xf0 */ + 0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00fd, + 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff, +}; + +static int +iso8859_9e_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n) +{ + unsigned char c = *s; + if (c >= 0xd0) + *pwc = (wchar_t) iso8859_9e_2uni[c-0xa0]; + else + *pwc = (wchar_t) c; + return 1; +} + +static const unsigned char iso8859_9e_page00[96] = { + 0xa0, 0x00, 0xa2, 0xa3, 0x00, 0xa5, 0x00, 0xa7, /* 0xa0-0xa7 */ + 0x00, 0xa9, 0x00, 0xab, 0x00, 0xad, 0xae, 0x00, /* 0xa8-0xaf */ + 0xb0, 0x00, 0xb2, 0xb3, 0x00, 0xb5, 0x00, 0xb7, /* 0xb0-0xb7 */ + 0x00, 0xb9, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0x00, 0xc7, /* 0xc0-0xc7 */ + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */ + 0x00, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0x00, /* 0xd0-0xd7 */ + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xd7, 0x00, 0xdf, /* 0xd8-0xdf */ + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0x00, 0xe7, /* 0xe0-0xe7 */ + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */ + 0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0x00, /* 0xf0-0xf7 */ + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xf7, 0x00, 0xff, /* 0xf8-0xff */ +}; +static const unsigned char iso8859_9e_page01[136] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0xf0, /* 0x18-0x1f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ + 0x00, 0x00, 0x00, 0x00, 0xa6, 0xb6, 0x00, 0x00, /* 0x28-0x2f */ + 0xdd, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ + 0x00, 0x00, 0xac, 0xbc, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xfe, /* 0x58-0x5f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ + 0x00, 0x00, 0x00, 0x00, 0xa8, 0xb8, 0x00, 0x00, /* 0x68-0x6f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ + 0xbe, 0x00, 0x00, 0x00, 0x00, 0xa1, 0xb1, 0x00, /* 0x78-0x7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, /* 0x88-0x8f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaf, /* 0x98-0x9f */ +}; +static const unsigned char iso8859_9e_page01_d[24] = { + 0x00, 0xb4, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xba, /* 0xe0-0xe7 */ +}; + +static int +iso8859_9e_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n) +{ + unsigned char c = 0; + if (wc < 0x00a0) { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = iso8859_9e_page00[wc-0x00a0]; + else if (wc >= 0x0118 && wc < 0x01a0) + c = iso8859_9e_page01[wc-0x0118]; + else if (wc >= 0x01d0 && wc < 0x01e8) + c = iso8859_9e_page01_d[wc-0x01d0]; + else if (wc == 0x0275) + c = 0xbf; + else if (wc == 0x20ac) + c = 0xa4; + if (c != 0) { + *r = c; + return 1; + } + return RET_ILSEQ; +} diff --git a/xc/lib/X11/lcUniConv/koi8_c.h b/xc/lib/X11/lcUniConv/koi8_c.h new file mode 100644 index 000000000..7eb5cb9d3 --- /dev/null +++ b/xc/lib/X11/lcUniConv/koi8_c.h @@ -0,0 +1,103 @@ +/* $XFree86: xc/lib/X11/lcUniConv/koi8_c.h,v 1.1 2000/10/27 20:26:08 dawes Exp $ */ + +/* + * KOI8-C + */ + +static const unsigned short koi8_c_2uni[128] = { + /* 0x80 */ + 0x0493, 0x0497, 0x049b, 0x049d, 0x04a3, 0x04af, 0x04b1, 0x04b3, + 0x04b7, 0x04b9, 0x04bb, 0x2580, 0x04d9, 0x04e3, 0x04e9, 0x04ef, + /* 0x90 */ + 0x0492, 0x0496, 0x049a, 0x049c, 0x04a2, 0x04ae, 0x04b0, 0x04b2, + 0x04b6, 0x04b8, 0x04ba, 0x2321, 0x04d8, 0x04e2, 0x04e8, 0x04ee, + /* 0xa0 */ + 0x00a0, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457, + 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x0491, 0x045e, 0x045f, + /* 0xb0 */ + 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407, + 0x0486, 0x0409, 0x040a, 0x040b, 0x040c, 0x0490, 0x040e, 0x040f, + /* 0xc0 */ + 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, + 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, + /* 0xd0 */ + 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, + 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a, + /* 0xe0 */ + 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, + 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, + /* 0xf0 */ + 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, + 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a, +}; + +static int +koi8_c_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n) +{ + unsigned char c = *s; + if (c < 0x80) + *pwc = (wchar_t) c; + else + *pwc = (wchar_t) koi8_c_2uni[c-0x80]; + return 1; +} + +static const unsigned char koi8_c_page00[1] = { + 0xa0, /* 0xa0-0xa7 */ +}; +static const unsigned char koi8_c_page04[240] = { + 0x00, 0xb3, 0xb1, 0xb2, 0xb4, 0xb5, 0xb6, 0xb7, /* 0x00-0x07 */ + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0x00, 0xbe, 0xbf, /* 0x08-0x0f */ + 0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, /* 0x10-0x17 */ + 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, /* 0x18-0x1f */ + 0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, /* 0x20-0x27 */ + 0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, /* 0x28-0x2f */ + 0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, /* 0x30-0x37 */ + 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, /* 0x38-0x3f */ + 0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, /* 0x40-0x47 */ + 0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1, /* 0x48-0x4f */ + 0x00, 0xa3, 0xa1, 0xa2, 0xa4, 0xa5, 0xa6, 0xa7, /* 0x50-0x57 */ + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0x00, 0xae, 0xaf, /* 0x58-0x5f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ + 0xbd, 0xad, 0x90, 0x80, 0x00, 0x00, 0x91, 0x81, /* 0x90-0x97 */ + 0x00, 0x00, 0x92, 0x82, 0x93, 0x83, 0x00, 0x00, /* 0x98-0x9f */ + 0x00, 0x00, 0x94, 0x84, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x85, /* 0xa8-0xaf */ + 0x96, 0x86, 0x97, 0x87, 0x00, 0x00, 0x98, 0x88, /* 0xb0-0xb7 */ + 0x99, 0x89, 0x9a, 0x8a, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ + 0x9c, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ + 0x00, 0x00, 0x9d, 0x8d, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ + 0x9e, 0x8e, 0x00, 0x00, 0x00, 0x00, 0x9f, 0x8f, /* 0xe8-0xef */ +}; +static const unsigned char koi8_c_page22[1] = { + 0xb0, /* 0x16-0x16 */ +}; + +static int +koi8_c_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n) +{ + unsigned char c = 0; + if (wc < 0x0080) { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00a1) + c = koi8_c_page00[wc-0x00a0]; + else if (wc >= 0x0400 && wc < 0x04ef) + c = koi8_c_page04[wc-0x0400]; + else if (wc >= 0x2216 && wc < 0x2217) + c = koi8_c_page22[wc-0x2216]; + if (c != 0) { + *r = c; + return 1; + } + return RET_ILSEQ; +} diff --git a/xc/lib/X11/lcUniConv/microsoft_cp1251.h b/xc/lib/X11/lcUniConv/microsoft_cp1251.h new file mode 100644 index 000000000..89c1031ee --- /dev/null +++ b/xc/lib/X11/lcUniConv/microsoft_cp1251.h @@ -0,0 +1,112 @@ +/* $XFree86: xc/lib/X11/lcUniConv/microsoft_cp1251.h,v 1.1 2000/10/27 20:26:08 dawes Exp $ */ + +/* + * MICROSOFT-CP1251 + */ + +static const unsigned short microsoft_cp1251_2uni[128] = { + /* 0x80 */ + 0x0402, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021, + 0x20ac, 0x2030, 0x0409, 0x2039, 0x040a, 0x040c, 0x040b, 0x040f, + /* 0x90 */ + 0x0452, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, + 0x98, 0x2122, 0x0459, 0x203a, 0x045a, 0x045c, 0x045b, 0x045f, + /* 0xa0 */ + 0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7, + 0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407, + /* 0xb0 */ + 0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7, + 0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457, + /* 0xc0 */ + 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, + 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, + /* 0xd0 */ + 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, + 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, + /* 0xe0 */ + 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, + 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, + /* 0xf0 */ + 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, + 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, +}; + +static int +microsoft_cp1251_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n) +{ + unsigned char c = *s; + if (c < 0xa0) + *pwc = (wchar_t) c; + else + *pwc = (wchar_t) microsoft_cp1251_2uni[c-0xa0]; + return 1; +} + +static const unsigned char microsoft_cp1251_page00[32] = { + 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */ + 0x00, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0x00, /* 0xa8-0xaf */ + 0xb0, 0xb1, 0x00, 0x00, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ + 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ +}; +static const unsigned char microsoft_cp1251_page04[152] = { + 0x00, 0xa8, 0x80, 0x81, 0xaa, 0xbd, 0xb2, 0xaf, /* 0x00-0x07 */ + 0xa3, 0x8a, 0x8c, 0x8e, 0x8d, 0x00, 0xa1, 0x8f, /* 0x08-0x0f */ + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x10-0x17 */ + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x18-0x1f */ + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x20-0x27 */ + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0x28-0x2f */ + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x30-0x37 */ + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x38-0x3f */ + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x40-0x47 */ + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0x48-0x4f */ + 0x00, 0xb8, 0x90, 0x83, 0xba, 0xbe, 0xb3, 0xbf, /* 0x50-0x57 */ + 0xbc, 0x9a, 0x9c, 0x9e, 0x9d, 0x00, 0xa2, 0x9f, /* 0x58-0x5f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ + 0xa5, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ +}; +static const unsigned char microsoft_cp1251_page20[48] = { + 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */ + 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ + 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ + 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ +}; +static const unsigned char microsoft_cp1251_page21[24] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb9, 0x00, /* 0x10-0x17 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ + 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ +}; +static const unsigned char microsoft_cp1251_page22[1] = { + 0xb0, /* 0x16-0x16 */ +}; + +static int +microsoft_cp1251_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n) +{ + unsigned char c = 0; + if (wc < 0x0080) { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00bc) + c = microsoft_cp1251_page00[wc-0x00a0]; + else if (wc >= 0x0400 && wc < 0x0492) + c = microsoft_cp1251_page04[wc-0x0400]; + else if (wc >= 0x2010 && wc < 0x203b) + c = microsoft_cp1251_page20[wc-0x2010]; + else if (wc == 0x20ac) + c = 0x88; + else if (wc >= 0x2110 && wc < 0x2123) + c = microsoft_cp1251_page21[wc-0x2110]; + if (c != 0) { + *r = c; + return 1; + } + return RET_ILSEQ; +} diff --git a/xc/lib/X11/lcUniConv/microsoft_cp1255.h b/xc/lib/X11/lcUniConv/microsoft_cp1255.h new file mode 100644 index 000000000..4bc403563 --- /dev/null +++ b/xc/lib/X11/lcUniConv/microsoft_cp1255.h @@ -0,0 +1,112 @@ +/* $XFree86: xc/lib/X11/lcUniConv/microsoft_cp1255.h,v 1.1 2000/10/27 20:26:09 dawes Exp $ */ + +/* + * MICROSOFT-CP1251 + */ + +static const unsigned short microsoft_cp1255_2uni[128] = { + /* 0x80 */ + 0x0402, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021, + 0x20ac, 0x2030, 0x0409, 0x2039, 0x040a, 0x040c, 0x040b, 0x040f, + /* 0x90 */ + 0x0452, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, + 0x98, 0x2122, 0x0459, 0x203a, 0x045a, 0x045c, 0x045b, 0x045f, + /* 0xa0 */ + 0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7, + 0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407, + /* 0xb0 */ + 0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7, + 0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457, + /* 0xc0 */ + 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, + 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, + /* 0xd0 */ + 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, + 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, + /* 0xe0 */ + 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, + 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, + /* 0xf0 */ + 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, + 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, +}; + +static int +microsoft_cp1255_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n) +{ + unsigned char c = *s; + if (c < 0xa0) + *pwc = (wchar_t) c; + else + *pwc = (wchar_t) microsoft_cp1255_2uni[c-0xa0]; + return 1; +} + +static const unsigned char microsoft_cp1255_page00[32] = { + 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */ + 0x00, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0x00, /* 0xa8-0xaf */ + 0xb0, 0xb1, 0x00, 0x00, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ + 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ +}; +static const unsigned char microsoft_cp1255_page04[152] = { + 0x00, 0xa8, 0x80, 0x81, 0xaa, 0xbd, 0xb2, 0xaf, /* 0x00-0x07 */ + 0xa3, 0x8a, 0x8c, 0x8e, 0x8d, 0x00, 0xa1, 0x8f, /* 0x08-0x0f */ + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x10-0x17 */ + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x18-0x1f */ + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x20-0x27 */ + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0x28-0x2f */ + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x30-0x37 */ + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x38-0x3f */ + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x40-0x47 */ + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0x48-0x4f */ + 0x00, 0xb8, 0x90, 0x83, 0xba, 0xbe, 0xb3, 0xbf, /* 0x50-0x57 */ + 0xbc, 0x9a, 0x9c, 0x9e, 0x9d, 0x00, 0xa2, 0x9f, /* 0x58-0x5f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ + 0xa5, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ +}; +static const unsigned char microsoft_cp1255_page20[48] = { + 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */ + 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ + 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ + 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ +}; +static const unsigned char microsoft_cp1255_page21[24] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb9, 0x00, /* 0x10-0x17 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ + 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ +}; +static const unsigned char microsoft_cp1255_page22[1] = { + 0xb0, /* 0x16-0x16 */ +}; + +static int +microsoft_cp1255_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n) +{ + unsigned char c = 0; + if (wc < 0x0080) { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00bc) + c = microsoft_cp1255_page00[wc-0x00a0]; + else if (wc >= 0x0400 && wc < 0x0492) + c = microsoft_cp1255_page04[wc-0x0400]; + else if (wc >= 0x2010 && wc < 0x203b) + c = microsoft_cp1255_page20[wc-0x2010]; + else if (wc == 0x20ac) + c = 0x88; + else if (wc >= 0x2110 && wc < 0x2123) + c = microsoft_cp1255_page21[wc-0x2110]; + if (c != 0) { + *r = c; + return 1; + } + return RET_ILSEQ; +} diff --git a/xc/lib/X11/lcUniConv/microsoft_cp1256.h b/xc/lib/X11/lcUniConv/microsoft_cp1256.h new file mode 100644 index 000000000..847f292b8 --- /dev/null +++ b/xc/lib/X11/lcUniConv/microsoft_cp1256.h @@ -0,0 +1,112 @@ +/* $XFree86: xc/lib/X11/lcUniConv/microsoft_cp1256.h,v 1.1 2000/10/27 20:26:09 dawes Exp $ */ + +/* + * MICROSOFT-CP1251 + */ + +static const unsigned short microsoft_cp1256_2uni[128] = { + /* 0x80 */ + 0x0402, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021, + 0x20ac, 0x2030, 0x0409, 0x2039, 0x040a, 0x040c, 0x040b, 0x040f, + /* 0x90 */ + 0x0452, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, + 0x98, 0x2122, 0x0459, 0x203a, 0x045a, 0x045c, 0x045b, 0x045f, + /* 0xa0 */ + 0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7, + 0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407, + /* 0xb0 */ + 0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7, + 0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457, + /* 0xc0 */ + 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, + 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, + /* 0xd0 */ + 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, + 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, + /* 0xe0 */ + 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, + 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, + /* 0xf0 */ + 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, + 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, +}; + +static int +microsoft_cp1256_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n) +{ + unsigned char c = *s; + if (c < 0xa0) + *pwc = (wchar_t) c; + else + *pwc = (wchar_t) microsoft_cp1256_2uni[c-0xa0]; + return 1; +} + +static const unsigned char microsoft_cp1256_page00[32] = { + 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */ + 0x00, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0x00, /* 0xa8-0xaf */ + 0xb0, 0xb1, 0x00, 0x00, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ + 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ +}; +static const unsigned char microsoft_cp1256_page04[152] = { + 0x00, 0xa8, 0x80, 0x81, 0xaa, 0xbd, 0xb2, 0xaf, /* 0x00-0x07 */ + 0xa3, 0x8a, 0x8c, 0x8e, 0x8d, 0x00, 0xa1, 0x8f, /* 0x08-0x0f */ + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x10-0x17 */ + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x18-0x1f */ + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x20-0x27 */ + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0x28-0x2f */ + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x30-0x37 */ + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x38-0x3f */ + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x40-0x47 */ + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0x48-0x4f */ + 0x00, 0xb8, 0x90, 0x83, 0xba, 0xbe, 0xb3, 0xbf, /* 0x50-0x57 */ + 0xbc, 0x9a, 0x9c, 0x9e, 0x9d, 0x00, 0xa2, 0x9f, /* 0x58-0x5f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ + 0xa5, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ +}; +static const unsigned char microsoft_cp1256_page20[48] = { + 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */ + 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ + 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ + 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ +}; +static const unsigned char microsoft_cp1256_page21[24] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb9, 0x00, /* 0x10-0x17 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ + 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ +}; +static const unsigned char microsoft_cp1256_page22[1] = { + 0xb0, /* 0x16-0x16 */ +}; + +static int +microsoft_cp1256_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n) +{ + unsigned char c = 0; + if (wc < 0x0080) { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00bc) + c = microsoft_cp1256_page00[wc-0x00a0]; + else if (wc >= 0x0400 && wc < 0x0492) + c = microsoft_cp1256_page04[wc-0x0400]; + else if (wc >= 0x2010 && wc < 0x203b) + c = microsoft_cp1256_page20[wc-0x2010]; + else if (wc == 0x20ac) + c = 0x88; + else if (wc >= 0x2110 && wc < 0x2123) + c = microsoft_cp1256_page21[wc-0x2110]; + if (c != 0) { + *r = c; + return 1; + } + return RET_ILSEQ; +} diff --git a/xc/lib/X11/lcUniConv/tatar_cyr.h b/xc/lib/X11/lcUniConv/tatar_cyr.h new file mode 100644 index 000000000..7ef91d29d --- /dev/null +++ b/xc/lib/X11/lcUniConv/tatar_cyr.h @@ -0,0 +1,123 @@ +/* $XFree86: xc/lib/X11/lcUniConv/tatar_cyr.h,v 1.1 2000/10/27 20:26:10 dawes Exp $ */ + +/* + * TATAR-CYR + */ + +static const unsigned short tatar_cyr_2uni[128] = { + /* 0x80 */ + 0x04d8, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021, + 0x20ac, 0x2030, 0x04e8, 0x2039, 0x04ae, 0x0496, 0x04a2, 0x04ba, + /* 0x90 */ + 0x04d9, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, + 0x98, 0x2122, 0x04e9, 0x203a, 0x04af, 0x0497, 0x04a3, 0x04bb, + /* 0xa0 */ + 0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7, + 0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407, + /* 0xb0 */ + 0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7, + 0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457, + /* 0xc0 */ + 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, + 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, + /* 0xd0 */ + 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, + 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, + /* 0xe0 */ + 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, + 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, + /* 0xf0 */ + 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, + 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, +}; + +static int +tatar_cyr_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n) +{ + unsigned char c = *s; + if (c < 0xa0) + *pwc = (wchar_t) c; + else + *pwc = (wchar_t) tatar_cyr_2uni[c-0xa0]; + return 1; +} + +static const unsigned char tatar_cyr_page00[32] = { + 0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */ + 0x00, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0x00, /* 0xa8-0xaf */ + 0xb0, 0xb1, 0x00, 0x00, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ + 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ +}; +static const unsigned char tatar_cyr_page04[240] = { + 0x00, 0xa8, 0x00, 0x81, 0xaa, 0xbd, 0xb2, 0xaf, /* 0x00-0x07 */ + 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa1, 0x00, /* 0x08-0x0f */ + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x10-0x17 */ + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x18-0x1f */ + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x20-0x27 */ + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0x28-0x2f */ + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x30-0x37 */ + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x38-0x3f */ + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x40-0x47 */ + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0x48-0x4f */ + 0x00, 0xb8, 0x00, 0x83, 0xba, 0xbe, 0xb3, 0xbf, /* 0x50-0x57 */ + 0xbc, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa2, 0x00, /* 0x58-0x5f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ + 0xa5, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x8d, 0x9d, /* 0x90-0x97 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ + 0x00, 0x00, 0x8e, 0x9e, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x9c, /* 0xa8-0xaf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ + 0x00, 0x00, 0x8f, 0x9f, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ + 0x80, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ + 0x8a, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ +}; +static const unsigned char tatar_cyr_page20[48] = { + 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */ + 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ + 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ + 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ +}; +static const unsigned char tatar_cyr_page21[24] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb9, 0x00, /* 0x10-0x17 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ + 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ +}; +static const unsigned char tatar_cyr_page22[1] = { + 0xb0, /* 0x16-0x16 */ +}; + +static int +tatar_cyr_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n) +{ + unsigned char c = 0; + if (wc < 0x0080) { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00bc) + c = tatar_cyr_page00[wc-0x00a0]; + else if (wc >= 0x0400 && wc < 0x04ef) + c = tatar_cyr_page04[wc-0x0400]; + else if (wc >= 0x2010 && wc < 0x203b) + c = tatar_cyr_page20[wc-0x2010]; + else if (wc == 0x20ac) + c = 0x88; + else if (wc >= 0x2110 && wc < 0x2123) + c = tatar_cyr_page21[wc-0x2110]; + if (c != 0) { + *r = c; + return 1; + } + return RET_ILSEQ; +} diff --git a/xc/lib/Xft/Imakefile b/xc/lib/Xft/Imakefile new file mode 100644 index 000000000..5d64ab62b --- /dev/null +++ b/xc/lib/Xft/Imakefile @@ -0,0 +1,54 @@ +XCOMM $XFree86: xc/lib/Xft/Imakefile,v 1.3 2000/10/13 13:41:17 keithp Exp $ + +#define DoNormalLib NormalLibXft +#define DoSharedLib SharedLibXft +#define DoExtraLib SharedLibXft +#define DoDebugLib DebugLibXft +#define DoProfileLib ProfileLibXft +#define HasSharedData YES +#define LibName Xft +#define SoRev SOXFTREV +#define IncSubdir X11 +#define IncSubSubdir Xft + +#include <Threads.tmpl> + +INCLUDES=$(FREETYPE2INCLUDES) +DEFINES=$(FREETYPE2DEFINES) + +#ifndef XftLibDir +#define XftLibDir $(LIBDIR) +#endif +#ifndef XftType1Dir +#define XftType1Dir $(LIBDIR)/fonts/Type1 +#endif + +XFTLIBDIR=XftLibDir +XFTCONFIG=$(XFTLIBDIR)/XftConfig + +TYPE1DIR=XftType1Dir +CONFIG_DEFS=-DXFT_TYPE1_DIR=\"$(TYPE1DIR)\" +DEFINES=-DXFT_DEFAULT_PATH=\"$(XFTCONFIG)\" +REQUIREDLIBS=$(LDPRELIBS) $(XRENDER) $(XLIB) $(FREETYPE2LIB) + +HEADERS = Xft.h + SRCS = drawstr.c extents.c glyphs.c lex.c load.c match.c metrics.c parse.c + OBJS = drawstr.o extents.o glyphs.o lex.o load.o match.o metrics.o parse.o + +#include <Library.tmpl> + +#if DoSharedLib && SharedDataSeparation +SpecialCObjectRule(sharedlib,NullParameter,$(SHLIBDEF)) +#endif + +CppFileTarget(XftConfig,XftConfig.cpp,$(CONFIG_DEFS),$(ICONFIGFILES)) + +#if InstallFSConfig +InstallNonExecFile(XftConfig,$(XFTLIBDIR)) +#else +InstallNonExecFileNoClobber(XftConfig,$(XFTLIBDIR)) +#endif + +MANSUFFIX = $(LIBMANSUFFIX) +InstallManPage(Xft,$(LIBMANDIR)) +DependTarget() diff --git a/xc/lib/Xft/Xft.h b/xc/lib/Xft/Xft.h new file mode 100644 index 000000000..c77585dc0 --- /dev/null +++ b/xc/lib/Xft/Xft.h @@ -0,0 +1,117 @@ +/* + * $XFree86: xc/lib/Xft/Xft.h,v 1.3 2000/10/13 13:41:17 keithp 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. + */ + +#ifndef _XFT_H_ +#define _XFT_H_ + +typedef struct _XftFontName { + unsigned long mask; + char *face; + char *encoding; + char *file; + int size; + int rotation; + int spacing; +} XftFontName; + +#define XftFontNameFace 0x1 +#define XftFontNameEncoding 0x2 +#define XftFontNameFile 0x4 +#define XftFontNameSize 0x8 +#define XftFontNameRotation 0x10 +#define XftFontNameSpacing 0x20 + +#define XftFontSpacingAny 0 +#define XftFontSpacingMono 1 +#define XftFontSpacingCell 2 + +typedef struct _XftFont XftFont; + +typedef struct _XftDraw XftDraw; + +/* load.c */ +XftFont * +XftLoadFont (Display *dpy, XftFontName *name); + +void +XftFreeFont (Display *dpy, XftFont *font); + +/* metrics.c */ +int +XftFontAscent(Display *dpy, XftFont *font); + +int +XftFontDescent(Display *dpy, XftFont *font); + +int +XftFontHeight(Display *dpy, XftFont *font); + +int +XftFontMaxAdvanceWidth (Display *dpy, XftFont *font); + +void +XftExtentsString (Display *dpy, + XftFont *font, + unsigned char *string, + int len, + XGlyphInfo *extents); + +void +XftDrawString (Display *dpy, + Picture src, + XftFont *font, + Picture dst, + int srcx, + int srcy, + int x, + int y, + unsigned char *string, + int len); + +XftDraw * +XftCreateDraw (Display *dpy, + Drawable draw, + Visual *visual, + char *name); + +void +XftTransparentString (Display *dpy, + XftDraw *draw, + unsigned long fg, + int x, + int y, + unsigned char *string, + int len); + +void +XftOpaqueString (Display *dpy, + XftDraw *draw, + unsigned long fg, + unsigned long bg, + int x, + int y, + unsigned char *string, + int len); + +#endif /* _XFT_H_ */ diff --git a/xc/lib/Xft/Xft.man b/xc/lib/Xft/Xft.man new file mode 100644 index 000000000..449f87d54 --- /dev/null +++ b/xc/lib/Xft/Xft.man @@ -0,0 +1,150 @@ +.\" +.\" $XFree86: xc/lib/Xft/Xft.man,v 1.1 2000/10/05 18:05:26 keithp 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. +.\" +.de TQ +.br +.ns +.TP \\$1 +.. +.TH XFT 3 "Version 1.0" "XFree86" + +.SH NAME + XFT \- X FreeType interface library + +.SH DESCRIPTION +.B Xft +is a simple library designed to interface the FreeType rasterizer with the X +Rendering Extension. This manual page barely scratches the surface of this +library. + +.SH DATATYPES + +.B XftFont +is an opaque pointer to a font object containing references to both the X +server GlyphSet and the FreeType outline data. + +.B XftFontName +contains matching information for accessing fonts. Each field is matched +with a bit in the mask indicating whether that field has valid data. + +.Ds 0 +.TA .5i 3i +.ta .5i 3i +typedef struct _XftFontName { + unsigned long mask; + char *face; + char *encoding; + char *file; + int size; + int rotation; + int spacing; +} XftFontName; + +#define XftFontNameFace 0x1 +#define XftFontNameEncoding 0x2 +#define XftFontNameFile 0x4 +#define XftFontNameSize 0x8 +#define XftFontNameRotation 0x10 +#define XftFontNameSpacing 0x20 + +#define XftFontSpacingAny 0 +#define XftFontSpacingMono 1 +#define XftFontSpacingCell 2 + +.SH FUNCTIONS +XftFont * +XftLoadFont (Display *dpy, XftFontName *name); + +void +XftFreeFont (Display *dpy, XftFont *font); + +int +XftFontAscent(Display *dpy, XftFont *font); + +int +XftFontDescent(Display *dpy, XftFont *font); + +int +XftFontHeight(Display *dpy, XftFont *font); + +int +XftFontMaxAdvanceWidth (Display *dpy, XftFont *font); + +void +XftExtentsString (Display *dpy, + XftFont *font, + unsigned char *string, + int len, + XGlyphInfo *extents); + +void +XftDrawString (Display *dpy, + Picture src, + XftFont *font, + Picture dst, + int srcx, + int srcy, + int x, + int y, + char *string, + int len); + +.SH XftConfig +The +.B XftConfig +file contains instructions for converting an XftFontName structure into +a usable set of glyphs. XftFontNames are refined through a series of +matching and editing steps. + +ents : ents ent + | + ; +ent : edit + | path + | dir + ; +edit : MATCH patterns EDIT patterns + ; +patterns: pattern patterns + | + ; +pattern : FACE EQUAL STRING + | ENCODING EQUAL STRING + | FILE EQUAL STRING + | SIZE EQUAL NUMBER + | ROTATION EQUAL NUMBER + | SPACING EQUAL NUMBER + ; +path : PATH STRING + ; +dir : DIR STRING + ; + + +.SH RESTRICTIONS +.B Xft +will probably change radically in the future; weak attempts will be made to +retain some level of source-file compatibility. + +.SH AUTHOR +Keith Packard, member of the XFree86 Project, Inc. diff --git a/xc/lib/Xft/XftConfig.cpp b/xc/lib/Xft/XftConfig.cpp new file mode 100644 index 000000000..6718d428d --- /dev/null +++ b/xc/lib/Xft/XftConfig.cpp @@ -0,0 +1,58 @@ +# $XFree86: xc/lib/Xft/XftConfig.cpp,v 1.3 2000/10/10 14:05:48 tsi Exp $ +# +# Unspecified mono-spaced font gets courier +# + +MATCH spacing = 2 EDIT face = "Courier" +MATCH spacing = 1 EDIT face = "Courier" +MATCH spacing = 0 EDIT face = "Charter" + +DIR XFT_TYPE1_DIR + +# +# Check users config file +# +PATH "?~/.xftconfig" + +# Here are the fonts +MATCH face = "utopia" EDIT file = "UTRG____.pfa" +MATCH face = "utopia italic" EDIT file = "UTI_____.pfa" +MATCH face = "utopia bold" EDIT file = "UTB_____.pfa" +MATCH face = "utopia bold italic" EDIT file = "UTBI____.pfa" + +# +# Two courier fonts; pick which goes first +# +MATCH face = "courier" EDIT file = "c0419bt_.pfb" +MATCH face = "courier italic" EDIT file = "c0582bt_.pfb" +MATCH face = "courier bold" EDIT file = "c0583bt_.pfb" +MATCH face = "courier bold italic" EDIT file = "c0611bt_.pfb" + +MATCH face = "courier" EDIT file = "cour.pfa" +MATCH face = "courier italic" EDIT file = "couri.pfa" +MATCH face = "courier bold" EDIT file = "courb.pfa" +MATCH face = "courier bold italic" EDIT file = "courbi.pfa" + +MATCH face = "charter" EDIT file = "c0648bt_.pfb" +MATCH face = "charter italic" EDIT file = "c0649bt_.pfb" +MATCH face = "charter bold" EDIT file = "c0632bt_.pfb" +MATCH face = "charter bold italic" EDIT file = "c0633bt_.pfb" + +MATCH face = "cursor" EDIT file = "cursor.pfa" + +MATCH face = "lucidux serif" EDIT file = "lcdxrr.pfa" +MATCH face = "lucidux serif oblique" EDIT file = "lcdxro.pfa" +MATCH face = "lucidux sans" EDIT file = "lcdxsr.pfa" +MATCH face = "lucidux sans oblique" EDIT file = "lcdxso.pfa" +MATCH face = "lucidux mono" EDIT file = "lcdxmr.pfa" +MATCH face = "lucidux mono oblique" EDIT file = "lcdxmo.pfa" + +# +# Fill in underspecified fonts with default values +# +MATCH +EDIT + encoding = "iso8859-1" + size = 768 # 12 pixels + rotation = 0 + diff --git a/xc/lib/Xft/drawstr.c b/xc/lib/Xft/drawstr.c new file mode 100644 index 000000000..a9f1f1336 --- /dev/null +++ b/xc/lib/Xft/drawstr.c @@ -0,0 +1,88 @@ +/* + * $XFree86: xc/lib/Xft/drawstr.c,v 1.3 2000/10/13 13:41:17 keithp 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 "xftint.h" + +#define STEP 256 + +void +_XftCheckGlyph (Display *dpy, XftFont *font, unsigned long glyph, + unsigned long *missing, int *nmissing) +{ + XGlyphInfo **realized; + int nrealized; + int n; + + if (glyph >= font->nrealized) + { + nrealized = glyph + STEP; + if (font->realized) + realized = (XGlyphInfo **) realloc ((void *) font->realized, + nrealized * sizeof (XGlyphInfo *)); + else + realized = malloc (nrealized * sizeof (XGlyphInfo *)); + if (!realized) + return; + memset (realized + font->nrealized, 0, + (nrealized - font->nrealized) * sizeof (XGlyphInfo *)); + font->realized = realized; + font->nrealized = nrealized; + } + if (!font->realized[glyph]) + { + font->realized[glyph] = malloc (sizeof (XGlyphInfo)); + n = *nmissing; + missing[n++] = glyph; + if (n == XFT_NMISSING) + { + _XftLoadGlyphs (dpy, font, missing, n); + n = 0; + } + *nmissing = n; + } +} + +void +XftDrawString (Display *dpy, Picture src, XftFont *font, Picture dst, + int srcx, int srcy, + int x, int y, + unsigned char *string, int len) +{ + unsigned long missing[XFT_NMISSING]; + int nmissing; + unsigned char *s; + int l; + + s = string; + l = len; + nmissing = 0; + while (l--) + _XftCheckGlyph (dpy, font, (unsigned long) *s++, missing, &nmissing); + if (nmissing) + _XftLoadGlyphs (dpy, font, missing, nmissing); + XRenderCompositeString8 (dpy, PictOpOver, src, dst, + font->format, font->glyphset, + srcx, srcy, x, y, (char *) string, len); +} + diff --git a/xc/lib/Xft/extents.c b/xc/lib/Xft/extents.c new file mode 100644 index 000000000..cccfc8c68 --- /dev/null +++ b/xc/lib/Xft/extents.c @@ -0,0 +1,80 @@ +/* + * $XFree86: xc/lib/Xft/extents.c,v 1.1 2000/10/05 18:05:26 keithp 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 "xftint.h" + +void +XftExtentsString (Display *dpy, + XftFont *font, + unsigned char *string, + int len, + XGlyphInfo *extents) +{ + unsigned long missing[XFT_NMISSING]; + int nmissing; + unsigned char *s; + int l; + XGlyphInfo *gi; + int x, y; + + s = string; + l = len; + nmissing = 0; + while (l--) + _XftCheckGlyph (dpy, font, (unsigned long) *s++, missing, &nmissing); + if (nmissing) + _XftLoadGlyphs (dpy, font, missing, nmissing); + + if (!len) + { + extents->width = 0; + extents->height = 0; + extents->x = 0; + extents->y = 0; + extents->yOff = 0; + extents->xOff = 0; + return; + } + len--; + gi = font->realized[*string++]; + *extents = *gi; + x = gi->xOff; + y = gi->yOff; + while (len--) + { + gi = font->realized[*string++]; + if (gi->x + x < extents->x) + extents->x = gi->x + x; + if (gi->y + y < extents->y) + extents->y = gi->y + y; + if (gi->width + x > extents->width) + extents->width = gi->width + x; + if (gi->height + y > extents->height) + extents->height = gi->height + y; + x += gi->xOff; + y += gi->yOff; + } + extents->xOff = x; + extents->yOff = y; +} diff --git a/xc/lib/Xft/glyphs.c b/xc/lib/Xft/glyphs.c new file mode 100644 index 000000000..d0f108334 --- /dev/null +++ b/xc/lib/Xft/glyphs.c @@ -0,0 +1,145 @@ +/* + * $XFree86: xc/lib/Xft/glyphs.c,v 1.2 2000/10/13 13:41:17 keithp 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 "xftint.h" +#include <freetype/ftoutln.h> + +void +_XftLoadGlyphs (Display *dpy, XftFont *font, unsigned long *glyphs, int nglyph) +{ + FT_Error error; + FT_ULong charcode; + FT_GlyphSlot glyph; + XGlyphInfo *gi; + Glyph g; + unsigned char bufLocal[4096]; + unsigned char *bufBitmap = bufLocal; + unsigned char *b; + int bufSize = sizeof (bufLocal); + int size, pitch; + int width; + int height; + int i; + int left, right, top, bottom; + FT_Bitmap ftbit; + + while (nglyph--) + { + charcode = (FT_ULong) *glyphs++; + error = FT_Load_Char (font->face, charcode, 0/*|FT_LOAD_NO_HINTING */); + if (error) + continue; + +#define FLOOR(x) ((x) & -64) +#define CEIL(x) (((x)+63) & -64) +#define TRUNC(x) ((x) >> 6) + + glyph = font->face->glyph; + + left = FLOOR( glyph->metrics.horiBearingX ); + right = CEIL( glyph->metrics.horiBearingX + glyph->metrics.width ); + width = TRUNC(right - left); + + top = CEIL( glyph->metrics.horiBearingY ); + bottom = FLOOR( glyph->metrics.horiBearingY - glyph->metrics.height ); + height = TRUNC( top - bottom ); + + if ( glyph->format == ft_glyph_format_outline ) + { + pitch = (width + 3) & ~3; + size = pitch * height; + + if (size > bufSize) + { + if (bufBitmap != bufLocal) + free (bufBitmap); + bufBitmap = malloc (size); + if (!bufBitmap) + continue; + bufSize = size; + } + memset (bufBitmap, 0, size); + + ftbit.width = width; + ftbit.rows = height; + ftbit.pitch = pitch; + ftbit.pixel_mode = ft_pixel_mode_grays; + ftbit.buffer = bufBitmap; + + FT_Outline_Translate ( &glyph->outline, -left, -bottom ); + + FT_Outline_Get_Bitmap( _XftFTlibrary, &glyph->outline, &ftbit ); + i = size; + b = (unsigned char *) bufBitmap; +#if 0 + while (i--) + { + v = *b; + *b = v << 1 | v >> 7; + b++; + } + { + int x, y; + + printf ("Charcode %d(%c):\n", charcode, charcode); + for (y = 0; y < height; y++) + { + for (x = 0; x < width; x++) + { + v = bufBitmap[y * pitch + x]; + if (v) + printf ("*"); + else + printf (" "); + } + printf ("\n"); + } + printf ("\n"); + } +#endif + } + else + { + printf ("glyph (%c) %d missing\n", (int) charcode, (int) charcode); + continue; + } + + gi = font->realized[charcode]; + gi->width = width; + gi->height = height; + gi->x = -TRUNC(left); + gi->y = TRUNC(top); + if (font->monospace) + gi->xOff = XftFontMaxAdvanceWidth (dpy, font); + else + gi->xOff = (glyph->metrics.horiAdvance + 0x20) >> 6; + gi->yOff = 0; + g = charcode; + + XRenderAddGlyphs (dpy, font->glyphset, &g, gi, 1, + (char *) bufBitmap, size); + } + if (bufBitmap != bufLocal) + free (bufBitmap); +} diff --git a/xc/lib/Xft/lex.c b/xc/lib/Xft/lex.c new file mode 100644 index 000000000..c58b9182a --- /dev/null +++ b/xc/lib/Xft/lex.c @@ -0,0 +1,131 @@ +/* + * $XFree86: xc/lib/Xft/lex.c,v 1.1 2000/10/05 18:05:26 keithp 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 "xftint.h" +#include <ctype.h> + +static struct { + int token; + char *name; +} tokens[] = { + { XFT_MATCH, "match", }, + { XFT_EDIT, "edit", }, + { XFT_PATH, "path", }, + { XFT_DIR, "dir", }, + { XFT_FACE, "face", }, + { XFT_ENCODING, "encoding", }, + { XFT_FILE, "file", }, + { XFT_SIZE, "size", }, + { XFT_ROTATION, "rotation", }, + { XFT_SPACING, "spacing", }, +}; + +#define NUM_TOKEN (sizeof (tokens) / sizeof (tokens[0])) + +int +_XftLex (XftParseState *s) +{ + int c; + int len; + int i; + +again: + while ((c = getc(s->file)) != EOF) + { + if (!isspace(c)) + break; + if (c == '\n') + ++s->line; + } + if (c == EOF) + return s->token = XFT_EOF; + switch (c) { + case '=': + return s->token = XFT_EQUAL; + case '#': + while ((c = getc(s->file)) != EOF) + { + if (c == '\n') + { + ++s->line; + goto again; + } + } + return s->token = XFT_EOF; + case '"': + len = 0; + while ((c = getc(s->file)) != EOF) + { + switch (c) { + case '"': + break; + case '\\': + c = getc(s->file); + if (c == EOF) + break; + default: + if (c == '\n') + ++s->line; + if (len < XFT_MAX_STRING - 1) + s->string[len++] = c; + continue; + } + break; + } + s->string[len] = '\0'; + return s->token = XFT_STRING; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + s->number = c - '0'; + while ((c = getc(s->file)) != EOF) + { + if (!isdigit (c)) + break; + s->number = s->number * 10 + (c - '0'); + } + if (c != EOF) + ungetc (c, s->file); + return s->token = XFT_NUMBER; + default: + if (isalpha (c)) + { + len = 1; + s->string[0] = tolower (c); + while ((c = getc(s->file)) != EOF) + { + if (!isalpha (c)) + break; + if (len < XFT_MAX_STRING-1) + s->string[len++] = tolower (c); + } + if (c != EOF) + ungetc (c, s->file); + s->string[len] = '\0'; + for (i = 0; i < NUM_TOKEN; i++) + if (!strcmp (tokens[i].name, s->string)) + return s->token = tokens[i].token; + } + return s->token = XFT_ERROR; + } +} diff --git a/xc/lib/Xft/load.c b/xc/lib/Xft/load.c new file mode 100644 index 000000000..57494dc80 --- /dev/null +++ b/xc/lib/Xft/load.c @@ -0,0 +1,145 @@ +/* + * $XFree86: xc/lib/Xft/load.c,v 1.3 2000/10/13 13:41:17 keithp 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 "xftint.h" + +FT_Library _XftFTlibrary; + +XftFont * +XftLoadFont (Display *dpy, XftFontName *name) +{ + XftFontName resolved; + XftFont *font; + XRenderPictFormat pf, *format; + int height, ascent, descent; + int extra; + int div; + + pf.depth = 8; + pf.type = PictTypeDirect; + pf.direct.alpha = 0; + pf.direct.alphaMask = 0xff; + format = XRenderFindFormat(dpy, + PictFormatType| + PictFormatDepth| + PictFormatAlpha| + PictFormatAlphaMask, + &pf, 0); + if (!format) + goto bail0; + if (!XftMatch (name, &resolved)) + goto bail1; + if ((resolved.mask & XftFontNameFile) == 0) + goto bail1; + if ((resolved.mask & XftFontNameSize) == 0) + resolved.size = 12 * 64; + if ((resolved.mask & XftFontNameRotation) == 0) + resolved.rotation = 0; + if ((resolved.mask & XftFontNameSpacing) == 0) + resolved.spacing = XftFontSpacingAny; + font = malloc (sizeof (XftFont)); + if (!font) + goto bail1; + if (!_XftFTlibrary) + { + if (FT_Init_FreeType( &_XftFTlibrary )) + goto bail2; + } + + if (FT_New_Face( _XftFTlibrary, resolved.file, 0, &font->face)) + goto bail1; + + font->size = resolved.size; + font->min_char = 0; + font->max_char = 255; + font->realized = 0; + font->nrealized = 0; + font->monospace = resolved.spacing != XftFontSpacingAny; + font->format = format; + + height = font->face->height; + ascent = font->face->ascender; + descent = font->face->descender; + if (descent < 0) descent = - descent; + extra = (height - (ascent + descent)); + if (extra > 0) + { + ascent = ascent + extra / 2; + descent = height - ascent; + } + else if (extra < 0) + height = ascent + descent; + div = font->face->units_per_EM; + if (height > div * 5) + div *= 10; + + font->descent = descent * font->size / (64 * div); + font->ascent = ascent * font->size / (64 * div); + font->height = height * font->size / (64 * div); + font->max_advance_width = font->face->max_advance_width * font->size / (64 * font->face->units_per_EM); + +#if 0 + if ( FT_Set_Char_Size (font->face, 0, font->size, 72, 72)) + goto bail3; +#endif + if ( FT_Set_Pixel_Sizes (font->face, font->size >> 6, font->size >> 6)) + goto bail3; +#if 0 + for (charmap = 0; charmap < font->face->num_charmaps; charmap++) + if (font->face->charmaps[charmap]->encoding == ft_encoding_unicode) + break; + + if (charmap == font->face->num_charmaps) + goto bail3; + + error = FT_Set_Charmap(font->face, + font->face->charmaps[charmap]); + + if (error) + goto bail3; +#endif + font->glyphset = XRenderCreateGlyphSet (dpy, format); + + return font; +bail3: + FT_Done_Face (font->face); +bail2: + free (font); +bail1: + if (resolved.face != name->face) + free (resolved.face); + if (resolved.file != name->file) + free (resolved.file); + if (resolved.encoding != name->encoding) + free (resolved.encoding); +bail0: + return 0; +} + +void +XftFreeFont (Display *dpy, XftFont *font) +{ + FT_Done_Face (font->face); + free (font); +} diff --git a/xc/lib/Xft/match.c b/xc/lib/Xft/match.c new file mode 100644 index 000000000..14f872390 --- /dev/null +++ b/xc/lib/Xft/match.c @@ -0,0 +1,37 @@ +/* + * $XFree86: xc/lib/Xft/match.c,v 1.1 2000/10/05 18:05:27 keithp 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 <stdio.h> +#include "xftint.h" + +Bool +XftMatch (XftFontName *pattern, XftFontName *result) +{ + char *path; + path = getenv ("XFT_PATH"); + if (!path) + path = XFT_DEFAULT_PATH; + *result = *pattern; + return _XftParsePathList (path, 0, result); +} diff --git a/xc/lib/Xft/metrics.c b/xc/lib/Xft/metrics.c new file mode 100644 index 000000000..215a708a8 --- /dev/null +++ b/xc/lib/Xft/metrics.c @@ -0,0 +1,49 @@ +/* + * $XFree86: xc/lib/Xft/metrics.c,v 1.1 2000/10/05 18:05:27 keithp 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 "xftint.h" + +int +XftFontAscent (Display *dpy, XftFont *font) +{ + return font->ascent; +} + +int +XftFontDescent (Display *dpy, XftFont *font) +{ + return font->descent; +} + +int +XftFontHeight (Display *dpy, XftFont *font) +{ + return font->height; +} + +int +XftFontMaxAdvanceWidth (Display *dpy, XftFont *font) +{ + return font->max_advance_width; +} diff --git a/xc/lib/Xft/parse.c b/xc/lib/Xft/parse.c new file mode 100644 index 000000000..c2a714b4a --- /dev/null +++ b/xc/lib/Xft/parse.c @@ -0,0 +1,644 @@ +/* + * $XFree86: xc/lib/Xft/parse.c,v 1.2 2000/10/05 22:57:04 keithp 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 "xftint.h" +#include <string.h> +#include <unistd.h> +#include <ctype.h> + +static Bool dbg; + +#define DBG(L, F) if (dbg >= L) fprintf F; + +static void +_XftParseError (XftParseState *s) +{ + if (s->token != XFT_ERROR) + fprintf (stderr, "Xft parse error line %d\n", s->line); + s->token = XFT_ERROR; +} + +static char * +_XftSaveString (char *string) +{ + char *s = malloc (strlen (string) + 1); + if (s) + strcpy (s, string); + return s; +} + +static char * +_XftSaveFile (char *dir, char *string) +{ + char file[XFT_MAX_STRING]; + char *colon; + + if (*string != '/') + { + while (dir && *dir) + { + colon = strchr (dir, ':'); + if (colon) + { + strncpy (file, dir, colon - dir); + file[colon-dir] = '\0'; + dir = colon + 1; + } + else + { + strcpy (file, dir); + dir = 0; + } + strcat (file, "/"); + strcat (file, string); + if (access (file, R_OK) == 0) + return _XftSaveString (file); + } + } else if (access (string, R_OK) == 0) + return _XftSaveString (string); + return 0; +} + +static Bool +_XftStrImatch (char *a, char *b) +{ + char ac, bc; + for (;;) + { + ac = *a++; + bc = *b++; + if (!ac) + return !bc; + if (isupper (ac)) + ac = tolower (ac); + if (isupper (bc)) + bc = tolower (bc); + if (ac != bc) + return False; + } +} + +static void +_XftParsePattern (XftParseState *s) +{ + int token = s->token; + switch (s->token) { + case XFT_FACE: + case XFT_ENCODING: + case XFT_FILE: + _XftLex (s); + switch (s->token) { + case XFT_EQUAL: + _XftLex (s); + switch (s->token) { + case XFT_STRING: + switch (s->state) { + case XftMatching: + switch (token) { + case XFT_FACE: + if ((s->name->mask & XftFontNameFace) && + !_XftStrImatch (s->string, s->name->face)) + { + DBG (2,(stderr, "\tface mismatch \"%s\"\n", s->string)); + s->state = XftSkipping; + } + else + { + DBG (1,(stderr, "\tface match \"%s\"\n", s->string)); + } + break; + case XFT_ENCODING: + if ((s->name->mask & XftFontNameEncoding) && + !_XftStrImatch (s->string, s->name->encoding)) + { + DBG (2,(stderr, "\tencoding mismatch \"%s\"\n", s->string)); + s->state = XftSkipping; + } + else + { + DBG (1,(stderr, "\tencoding match \"%s\"\n", s->string)); + } + break; + case XFT_FILE: + if ((s->name->mask & XftFontNameFile) && + !_XftStrImatch (s->string, s->name->file)) + { + DBG (2,(stderr, "\tfile mismatch \"%s\"\n", s->string)); + s->state = XftSkipping; + } + else + { + DBG (1,(stderr, "\tfile match \"%s\"\n", s->string)); + } + break; + } + break; + case XftSkipping: + break; + case XftEditing: + switch (token) { + case XFT_FACE: + if (!(s->name->mask & XftFontNameFace)) + { + s->name->face = _XftSaveString (s->string); + DBG (1, (stderr, "\tsetting face \"%s\"\n", s->name->face)); + } + else + { + DBG (2, (stderr, "\tnot setting face \"%s\"\n", s->string)); + } + break; + case XFT_ENCODING: + if (!(s->name->mask & XftFontNameEncoding)) + { + s->name->encoding = _XftSaveString (s->string); + s->name->mask |= XftFontNameEncoding; + DBG (1, (stderr, "\tsetting encoding \"%s\"\n", s->name->encoding)); + } + else + { + DBG (2, (stderr, "\tnot setting face \"%s\"\n", s->string)); + } + break; + case XFT_FILE: + if (!(s->name->mask & XftFontNameFile)) + { + s->name->file = _XftSaveFile (s->dir, s->string); + s->name->mask |= XftFontNameFile; + DBG (1, (stderr, "\tsetting file \"%s\"\n", s->name->file)); + } + else + { + DBG (2, (stderr, "\tnot setting file \"%s\"\n", s->string)); + } + break; + } + } + _XftLex (s); + break; + default: + _XftParseError (s); + break; + } + break; + default: + _XftParseError (s); + break; + } + break; + case XFT_SIZE: + case XFT_ROTATION: + case XFT_SPACING: + _XftLex (s); + switch (s->token) { + case XFT_EQUAL: + _XftLex (s); + switch (s->token) { + case XFT_NUMBER: + switch (s->state) { + case XftMatching: + switch (token) { + case XFT_SIZE: + if ((s->name->mask & XftFontNameSize) && + s->number != s->name->size) + { + s->state = XftSkipping; + DBG (2,(stderr, "\tsize mismatch %d\n", s->number)); + } + else + { + DBG (1,(stderr, "\tsize match %d\n", s->number)); + } + break; + case XFT_ROTATION: + if ((s->name->mask & XftFontNameRotation) && + s->number != s->name->rotation) + { + s->state = XftSkipping; + DBG (2,(stderr, "\trotation mismatch %d\n", s->number)); + } + else + { + DBG (1,(stderr, "\trotation match %d\n", s->number)); + } + break; + case XFT_SPACING: + if ((s->name->mask & XftFontNameSpacing) && + s->number != s->name->spacing) + { + s->state = XftSkipping; + DBG (2,(stderr, "\tspacing mismatch %d\n", s->number)); + } + else + { + DBG (1,(stderr, "\trotation match %d\n", s->number)); + } + break; + } + case XftSkipping: + break; + case XftEditing: + switch (token) { + case XFT_SIZE: + DBG (1,(stderr, "\t editing size %d: ", s->number)); + if (!(s->name->mask & XftFontNameSize)) + { + s->name->size = s->number; + DBG (1,(stderr, "replacing %d\n", s->number)); + s->name->mask |= XftFontNameSize; + } + else + { + DBG (1,(stderr, "already set\n")); + } + break; + case XFT_ROTATION: + DBG (1,(stderr, "\t editing size %d: ", s->number)); + if (!(s->name->mask & XftFontNameRotation)) + { + s->name->rotation = s->number; + DBG (1,(stderr, "replacing %d\n", s->number)); + s->name->mask |= XftFontNameRotation; + } + else + { + DBG (1,(stderr, "already set\n")); + } + break; + case XFT_SPACING: + DBG (1,(stderr, "\t editing size %d: ", s->number)); + if (!(s->name->mask & XftFontNameSpacing)) + { + s->name->spacing = s->number; + DBG (1,(stderr, "replacing %d\n", s->number)); + s->name->mask |= XftFontNameSpacing; + } + else + { + DBG (1,(stderr, "already set\n")); + } + break; + } + } + _XftLex (s); + break; + default: + _XftParseError (s); + break; + } + break; + default: + _XftParseError (s); + break; + } + break; + default: + _XftParseError (s); + break; + } +} + +static void +_XftParsePatterns (XftParseState *s) +{ + for (;;) + { + switch (s->token) { + case XFT_FACE: + case XFT_ENCODING: + case XFT_FILE: + case XFT_SIZE: + case XFT_ROTATION: + case XFT_SPACING: + _XftParsePattern (s); + break; + case XFT_MATCH: + case XFT_EDIT: + case XFT_PATH: + case XFT_DIR: + case XFT_EOF: + return; + default: + _XftParseError (s); + return; + } + } +} + +static void +_XftParseEdit (XftParseState *s) +{ + switch (s->token) { + case XFT_MATCH: + _XftLex (s); + s->state = XftMatching; + switch (s->token) { + case XFT_FACE: + case XFT_ENCODING: + case XFT_FILE: + case XFT_SIZE: + case XFT_ROTATION: + case XFT_SPACING: + case XFT_EDIT: + _XftParsePatterns (s); + break; + default: + _XftParseError (s); + return; + } + switch (s->token) { + case XFT_EDIT: + _XftLex (s); + if (s->state == XftMatching) + s->state = XftEditing; + switch (s->token) { + case XFT_FACE: + case XFT_ENCODING: + case XFT_FILE: + case XFT_SIZE: + case XFT_ROTATION: + case XFT_SPACING: + case XFT_MATCH: + case XFT_PATH: + case XFT_DIR: + case XFT_EOF: + _XftParsePatterns (s); + break; + default: + _XftParseError (s); + return; + } + break; + default: + _XftParseError (s); + return; + } + break; + default: + _XftParseError (s); + return; + } +} + +static void +_XftParsePath (XftParseState *s) +{ + switch (s->token) { + case XFT_PATH: + _XftLex (s); + switch (s->token) { + case XFT_STRING: + if (!_XftParsePathList (s->string, s->dir, s->name)) + s->token = XFT_ERROR; + else + _XftLex (s); + break; + default: + _XftParseError (s); + break; + } + break; + default: + _XftParseError (s); + return; + } +} + +static void +_XftParseDir (XftParseState *s) +{ + int len, olen; + char *ndir; + char *add; + + switch (s->token) { + case XFT_DIR: + _XftLex (s); + switch (s->token) { + case XFT_STRING: + if (!strcmp (s->string, ".")) + { + add = strrchr (s->filename, '/'); + if (add) + { + len = add - s->filename; + add = s->filename; + } + else + { + len = strlen (s->string); + add = s->string; + } + } + else + { + len = strlen (s->string); + add = s->string; + } + if (s->dir) + { + olen = strlen (s->dir); + ndir = realloc (s->dir, olen + len + 2); + } + else + { + olen = 0; + ndir = malloc (len + 1); + } + if (ndir) + { + if (olen) + ndir[olen++] = ':'; + strncpy (ndir + olen, add, len); + ndir[olen+len] = '\0'; + DBG (1,(stderr, "\tadding font file directory \"%s\"\n", ndir+olen)); + s->dir = ndir; + } + _XftLex (s); + break; + default: + _XftParseError (s); + break; + } + break; + default: + _XftParseError (s); + return; + } +} + +static void +_XftParseEnt (XftParseState *s) +{ + switch (s->token) { + case XFT_MATCH: + _XftParseEdit (s); + return; + case XFT_PATH: + _XftParsePath (s); + return; + case XFT_DIR: + _XftParseDir (s); + return; + default: + _XftParseError (s); + return; + } +} + +static void +_XftParseEnts (XftParseState *s) +{ + for (;;) + { + switch (s->token) { + case XFT_MATCH: + case XFT_PATH: + case XFT_DIR: + _XftParseEnt (s); + break; + case XFT_EOF: + return; + default: + _XftParseError (s); + return; + } + } +} + +static Bool +_XftParse (XftParseState *s) +{ + _XftLex (s); + _XftParseEnts (s); + if (s->token == XFT_ERROR) + return False; + return True; +} + +static Bool +_XftParsePathElt (char *elt, char *dir, XftFontName *result) +{ + XftParseState state; + Bool ret = False; + + if (*elt == '?') + { + ret = True; + elt++; + } + DBG (1,(stderr, "Parsing Xft config file \"%s\"\n", elt)); + state.file = fopen (elt, "r"); + if (!state.file) + { + DBG (1,(stderr, "Failed to open\n")); + return ret; + } + state.filename = elt; + state.line = 1; + state.token = XFT_EOF; + state.number = 0; + state.string[0] = '\0'; + state.state = XftMatching; + state.name = result; + if (dir) + state.dir = _XftSaveString (dir); + else + state.dir = 0; + ret = _XftParse (&state); + fclose (state.file); + DBG (1,(stderr, "Finished parsing \"%s\":\n" + "\t\tface \"%s\"\n" + "\t\tencoding \"%s\"\n" + "\t\tfile \"%s\"\n" + "\t\tsize %d\n" + "\t\trotation %d\n" + "\t\tspacing %d\n\n", + elt, + result->mask & XftFontNameFace ? result->face : "(no face)", + result->mask & XftFontNameEncoding ? result->encoding : "(no encoding)", + result->mask & XftFontNameFile ? result->file : "(no file)", + result->mask & XftFontNameSize ? result->size / 64 : -1, + result->mask & XftFontNameRotation ? result->rotation : -1, + result->mask & XftFontNameSpacing ? result->spacing : -1)); + return ret; +} + +Bool +_XftParsePathList (char *path, char *dir, XftFontName *result) +{ + char file[XFT_MAX_STRING], *home, *rest; + char *colon; + char *d; + + d = getenv ("XFT_DEBUG"); + if (d) + { + dbg = atoi(d); + if (dbg == 0) dbg = 1; + } + else + dbg = 0; + + while (path && *path) + { + rest = file; + if (*path == '?') + *rest++ = *path++; + if (*path == '~') + { + home = getenv ("HOME"); + if (home) + { + strcpy (rest, home); + rest = file + strlen (file); + } + else + rest = 0; + path++; + } + colon = strchr (path, ':'); + if (!colon) + { + if (rest) + strcpy (rest, path); + path = colon; + } + else + { + if (rest) + { + strncpy (rest, path, colon-path); + rest[colon-path] = '\0'; + } + path = colon + 1; + } + if (rest) + { + if (!_XftParsePathElt (file, dir, result)) + return False; + } + } + return True; +} diff --git a/xc/lib/Xft/xftint.h b/xc/lib/Xft/xftint.h new file mode 100644 index 000000000..7007cc202 --- /dev/null +++ b/xc/lib/Xft/xftint.h @@ -0,0 +1,149 @@ +/* + * $XFree86: xc/lib/Xft/xftint.h,v 1.2 2000/10/13 13:41:17 keithp 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. + */ + +#ifndef _XFTINT_H_ +#define _XFTINT_H_ + +#include <X11/Xlib.h> +#include <X11/extensions/render.h> +#include <X11/extensions/Xrender.h> +#include "Xft.h" +#include <freetype/freetype.h> +#include <stdlib.h> +#include <stdio.h> + +FT_Library library; + +struct _XftFont { + GlyphSet glyphset; + int min_char; + int max_char; + int size; + XRenderPictFormat *format; + XGlyphInfo **realized; + int nrealized; + int ascent; + int descent; + int height; + int max_advance_width; + Bool monospace; + FT_Face face; /* handle to face object */ +}; + +#define CACHE_SIZE 4 + +struct _XftDraw { + Drawable draw; + GC draw_gc; + Bool render; + struct { + unsigned long pixel; + unsigned long color; + int use; + } cache[CACHE_SIZE]; + union { + struct { + XftFont *font; + Picture pict; + Pixmap fg_pix; + Picture fg_pict; + GC fg_gc; + } render; + struct { + XFontStruct *font; + } core; + } u; +}; + +#ifndef XFT_DEFAULT_PATH +#define XFT_DEFAULT_PATH "/usr/X11R6/lib/X11/XftConfig" +#endif + +#define XFT_MAX_STRING 2048 + +typedef enum _XftMatchState { XftMatching, XftSkipping, XftEditing } XftMatchState; + +typedef enum _XftMatchToken { + XFT_ERROR, + XFT_EOF, + + XFT_EQUAL, + XFT_STRING, + XFT_NUMBER, + + XFT_MATCH, + XFT_EDIT, + XFT_PATH, + XFT_DIR, + XFT_FACE, + XFT_ENCODING, + XFT_FILE, + XFT_SIZE, + XFT_ROTATION, + XFT_SPACING +} XftMatchToken; + +typedef struct _XftParseState { + FILE *file; + char *filename; + int line; + XftMatchToken token; + int number; + char string[XFT_MAX_STRING]; + char *dir; + XftMatchState state; + XftFontName *name; +} XftParseState; + +/* drawstr.c */ +#define XFT_NMISSING 128 + +void +_XftCheckGlyph (Display *dpy, XftFont *font, unsigned long glyph, + unsigned long *missing, int *nmissing); + +/* extents.c */ + +/* glyphs.c */ +void +_XftLoadGlyphs (Display *dpy, XftFont *font, unsigned long *glyphs, int nglyph); + +/* lex.c */ +int +_XftLex (XftParseState *s); + +/* load.c */ +extern FT_Library _XftFTlibrary; + +/* match.c */ + +Bool +XftMatch (XftFontName *pattern, XftFontName *result); + +/* parse.c */ + +Bool +_XftParsePathList (char *path, char *dir, XftFontName *result); + +#endif /* _XFTINT_H_ */ diff --git a/xc/lib/Xp/XpExtUtil.h b/xc/lib/Xp/XpExtUtil.h new file mode 100644 index 000000000..d7ae0f630 --- /dev/null +++ b/xc/lib/Xp/XpExtUtil.h @@ -0,0 +1,35 @@ +/* $XFree86: xc/lib/Xp/XpExtUtil.h,v 1.1 2000/09/26 15:56:57 tsi 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, + * 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. + */ + +#ifndef _XPEXTUTIL_H +#define _XPEXTUTIL_H 1 + +#include "extutil.h" + +extern XEXT_FIND_DISPLAY_PROTO(xp_find_display); + +#endif /* _XPEXTUTIL_H */ diff --git a/xc/nls/Compose/iso8859-13 b/xc/nls/Compose/iso8859-13 new file mode 100644 index 000000000..deb52dd16 --- /dev/null +++ b/xc/nls/Compose/iso8859-13 @@ -0,0 +1,433 @@ +# $XFree86: xc/nls/Compose/iso8859-13,v 1.1 2000/10/27 18:30:50 dawes Exp $ +# +# ISO 8859-13 (Latin7) Compose Sequence +# +# Sequence Definition +# +# <Multi_key> Means <Compose> +# Special Character +# Right-hand side (Accented Alphabet) +# These compose sequences are pure supposition on my part. +# It would be nice to know what the real cultural conventions +# are for compose sequences. +<Multi_key> <plus> <plus> : "#" numbersign +<Multi_key> <apostrophe> <space> : "'" apostrophe +<Multi_key> <space> <apostrophe> : "'" apostrophe +<Multi_key> <A> <T> : "@" at +<Multi_key> <parenleft> <parenleft> : "[" bracketleft +<Multi_key> <slash> <slash> : "\\" backslash +<Multi_key> <slash> <less> : "\\" backslash +<Multi_key> <less> <slash> : "\\" backslash +<Multi_key> <parenright> <parenright> : "]" bracketright +<Multi_key> <asciicircum> <space> : "^" asciicircum +<Multi_key> <space> <asciicircum> : "^" asciicircum +<Multi_key> <greater> <space> : "^" asciicircum +<Multi_key> <space> <greater> : "^" asciicircum +<Multi_key> <grave> <space> : "`" grave +<Multi_key> <space> <grave> : "`" grave +<Multi_key> <less> <apostrophe> : "`" grave +<Multi_key> <apostrophe> <less> : "`" grave +<Multi_key> <parenleft> <minus> : "{" braceleft +<Multi_key> <minus> <parenleft> : "{" braceleft +<Multi_key> <slash> <asciicircum> : "|" bar +<Multi_key> <asciicircum> <slash> : "|" bar +<Multi_key> <parenright> <minus> : "}" braceright +<Multi_key> <minus> <parenright> : "}" braceright +<Multi_key> <asciitilde> <space> : "~" asciitilde +<Multi_key> <space> <asciitilde> : "~" asciitilde +<Multi_key> <minus> <space> : "~" asciitilde +<Multi_key> <space> <minus> : "~" asciitilde +<Multi_key> <greater> <quotedbl> : "\241" rightdoublequotemark +<Multi_key> <quotedbl> <greater> : "\241" rightdoublequotemark +<Multi_key> <greater> <comma> : "\245" doublelowquotemark +<Multi_key> <comma> <greater> : "\245" doublelowquotemark +<Multi_key> <less> <quotedbl> : "\264" leftdoublequotemark +<Multi_key> <quotedbl> <less> : "\264" leftdoublequotemark +<Multi_key> <less> <less> : "\253" guillemotleft +<Multi_key> <greater> <greater> : "\273" guillemotright +<Multi_key> <apostrophe> <apostrophe> : "\377" rightsinglequotemark +<Multi_key> <greater> <apostrophe> : "\377" rightsinglequotemark +<Multi_key> <apostrophe> <greater> : "\377" rightsinglequotemark +<Multi_key> <c> <slash> : "\242" cent +<Multi_key> <slash> <c> : "\242" cent +<Multi_key> <C> <slash> : "\242" cent +<Multi_key> <slash> <C> : "\242" cent +<Multi_key> <C> <bar> : "\242" cent +<Multi_key> <bar> <C> : "\242" cent +<Multi_key> <c> <bar> : "\242" cent +<Multi_key> <bar> <c> : "\242" cent +<Multi_key> <l> <minus> : "\243" sterling +<Multi_key> <minus> <l> : "\243" sterling +<Multi_key> <L> <minus> : "\243" sterling +<Multi_key> <minus> <L> : "\243" sterling +<Multi_key> <l> <equal> : "\243" sterling +<Multi_key> <equal> <l> : "\243" sterling +<Multi_key> <L> <equal> : "\243" sterling +<Multi_key> <equal> <L> : "\243" sterling +<Multi_key> <c> <o> : "\251" copyright +<Multi_key> <o> <c> : "\251" copyright +<Multi_key> <C> <O> : "\251" copyright +<Multi_key> <O> <C> : "\251" copyright +<Multi_key> <c> <O> : "\251" copyright +<Multi_key> <O> <c> : "\251" copyright +<Multi_key> <C> <o> : "\251" copyright +<Multi_key> <o> <C> : "\251" copyright +<Multi_key> <c> <0> : "\251" copyright +<Multi_key> <0> <c> : "\251" copyright +<Multi_key> <C> <0> : "\251" copyright +<Multi_key> <0> <C> : "\251" copyright +<Multi_key> <parenleft> <c> : "\251" copyright +<Multi_key> <s> <o> : "\247" section +<Multi_key> <o> <s> : "\247" section +<Multi_key> <S> <O> : "\247" section +<Multi_key> <O> <S> : "\247" section +<Multi_key> <S> <exclam> : "\247" section +<Multi_key> <exclam> <S> : "\247" section +<Multi_key> <s> <exclam> : "\247" section +<Multi_key> <exclam> <s> : "\247" section +<Multi_key> <S> <0> : "\247" section +<Multi_key> <0> <S> : "\247" section +<Multi_key> <s> <0> : "\247" section +<Multi_key> <0> <s> : "\247" section +<Multi_key> <x> <o> : "\244" currency +<Multi_key> <o> <x> : "\244" currency +<Multi_key> <X> <O> : "\244" currency +<Multi_key> <O> <X> : "\244" currency +<Multi_key> <x> <O> : "\244" currency +<Multi_key> <O> <x> : "\244" currency +<Multi_key> <X> <o> : "\244" currency +<Multi_key> <o> <X> : "\244" currency +<Multi_key> <x> <0> : "\244" currency +<Multi_key> <0> <x> : "\244" currency +<Multi_key> <X> <0> : "\244" currency +<Multi_key> <0> <X> : "\244" currency +<Multi_key> <0> <asciicircum> : "\260" degree +<Multi_key> <asciicircum> <0> : "\260" degree +<Multi_key> <0> <asterisk> : "\260" degree +<Multi_key> <asterisk> <0> : "\260" degree +<Multi_key> <plus> <minus> : "\261" plusminus +<Multi_key> <minus> <plus> : "\261" plusminus +<Multi_key> <m> <u> : "\265" mu +<Multi_key> <slash> <u> : "\265" mu +<Multi_key> <u> <slash> : "\265" mu +<Multi_key> <slash> <U> : "\265" mu +<Multi_key> <U> <slash> : "\265" mu +<Multi_key> <1> <asciicircum> : "\271" onesuperior +<Multi_key> <asciicircum> <1> : "\271" onesuperior +<Multi_key> <S> <1> : "\271" onesuperior +<Multi_key> <1> <S> : "\271" onesuperior +<Multi_key> <s> <1> : "\271" onesuperior +<Multi_key> <1> <s> : "\271" onesuperior +<Multi_key> <2> <asciicircum> : "\262" twosuperior +<Multi_key> <asciicircum> <2> : "\262" twosuperior +<Multi_key> <S> <2> : "\262" twosuperior +<Multi_key> <2> <S> : "\262" twosuperior +<Multi_key> <s> <2> : "\262" twosuperior +<Multi_key> <2> <s> : "\262" twosuperior +<Multi_key> <3> <asciicircum> : "\263" threesuperior +<Multi_key> <asciicircum> <3> : "\263" threesuperior +<Multi_key> <S> <3> : "\263" threesuperior +<Multi_key> <3> <S> : "\263" threesuperior +<Multi_key> <s> <3> : "\263" threesuperior +<Multi_key> <3> <s> : "\263" threesuperior +<Multi_key> <p> <exclam> : "\266" paragraph +<Multi_key> <exclam> <p> : "\266" paragraph +<Multi_key> <P> <exclam> : "\266" paragraph +<Multi_key> <exclam> <P> : "\266" paragraph +<Multi_key> <period> <asciicircum> : "\267" periodcentered +<Multi_key> <asciicircum> <period> : "\267" periodcentered +<Multi_key> <period> <period> : "\267" periodcentered +<Multi_key> <1> <4> : "\274" onequarter +<Multi_key> <1> <2> : "\275" onehalf +<Multi_key> <3> <4> : "\276" threequarters +<Multi_key> <question> <question> : "\277" questiondown +<Multi_key> <space> <space> : "\240" nobreakspace +<Multi_key> <bar> <bar> : "\246" brokenbar +<Multi_key> <exclam> <asciicircum> : "\246" brokenbar +<Multi_key> <asciicircum> <exclam> : "\246" brokenbar +<Multi_key> <V> <B> : "\246" brokenbar +<Multi_key> <B> <V> : "\246" brokenbar +<Multi_key> <v> <b> : "\246" brokenbar +<Multi_key> <b> <v> : "\246" brokenbar +<Multi_key> <minus> <comma> : "\254" notsign +<Multi_key> <comma> <minus> : "\254" notsign +<Multi_key> <minus> <minus> : "\255" hyphen +<Multi_key> <R> <O> : "\256" registered +<Multi_key> <O> <R> : "\256" registered +<Multi_key> <parenleft> <r> : "\256" registered +<Multi_key> <minus> <colon> : "\367" division +<Multi_key> <colon> <minus> : "\367" division +<Multi_key> <x> <x> : "\327" multiply +# Accented Alphabet +<Multi_key> <A> <semicolon> : "\300" Aogonek +<Multi_key> <semicolon> <A> : "\300" Aogonek +<Multi_key> <A> <comma> : "\300" Aogonek +<Multi_key> <comma> <A> : "\300" Aogonek +<Multi_key> <R> <comma> : "\252" Rcedilla +<Multi_key> <comma> <R> : "\252" Rcedilla +<Multi_key> <L> <comma> : "\317" Lcedilla +<Multi_key> <comma> <L> : "\317" Lcedilla +<Multi_key> <S> <exclam> : "\247" section +<Multi_key> <exclam> <S> : "\247" section +<Multi_key> <s> <exclam> : "\247" section +<Multi_key> <exclam> <s> : "\247" section +<Multi_key> <S> <less> : "\320" Scaron +<Multi_key> <less> <S> : "\320" Scaron +<Multi_key> <E> <minus> : "\307" Emacron +<Multi_key> <minus> <E> : "\307" Emacron +<Multi_key> <E> <underscore> : "\307" Emacron +<Multi_key> <underscore> <E> : "\307" Emacron +<Multi_key> <G> <comma> : "\314" Gcedilla +<Multi_key> <comma> <G> : "\314" Gcedilla +<Multi_key> <minus> <minus> : "\255" hyphen +<Multi_key> <Z> <less> : "\336" Zcaron +<Multi_key> <less> <Z> : "\336" Zcaron +<Multi_key> <0> <asterisk> : "\260" degree +<Multi_key> <asterisk> <0> : "\260" degree +<Multi_key> <a> <semicolon> : "\340" aogonek +<Multi_key> <semicolon> <a> : "\340" aogonek +<Multi_key> <a> <comma> : "\340" aogonek +<Multi_key> <comma> <a> : "\340" aogonek +<Multi_key> <r> <comma> : "\272" rcedilla +<Multi_key> <comma> <r> : "\272" rcedilla +<Multi_key> <l> <comma> : "\357" lcedilla +<Multi_key> <comma> <l> : "\357" lcedilla +<Multi_key> <s> <less> : "\360" scaron +<Multi_key> <less> <s> : "\360" scaron +<Multi_key> <e> <minus> : "\347" emacron +<Multi_key> <minus> <e> : "\347" emacron +<Multi_key> <e> <underscore> : "\347" emacron +<Multi_key> <underscore> <e> : "\347" emacron +<Multi_key> <g> <comma> : "\354" gcedilla +<Multi_key> <comma> <g> : "\354" gcedilla +<Multi_key> <z> <less> : "\376" zcaron +<Multi_key> <less> <z> : "\376" zcaron +<Multi_key> <A> <underscore> : "\302" Amacron +<Multi_key> <underscore> <A> : "\302" Amacron +<Multi_key> <A> <minus> : "\302" Amacron +<Multi_key> <minus> <A> : "\302" Amacron +<Multi_key> <A> <quotedbl> : "\304" Adiaeresis +<Multi_key> <quotedbl> <A> : "\304" Adiaeresis +<Multi_key> <A> <asterisk> : "\305" Aring +<Multi_key> <asterisk> <A> : "\305" Aring +<Multi_key> <A> <A> : "\305" Aring +<Multi_key> <A> <O> : "\305" Aring +<Multi_key> <A> <E> : "\257" AE +<Multi_key> <I> <semicolon> : "\301" Iogonek +<Multi_key> <semicolon> <I> : "\301" Iogonek +<Multi_key> <I> <comma> : "\301" Iogonek +<Multi_key> <comma> <I> : "\301" Iogonek +<Multi_key> <C> <less> : "\310" Ccaron +<Multi_key> <less> <C> : "\310" Ccaron +<Multi_key> <E> <acute> : "\311" Eacute +<Multi_key> <acute> <E> : "\311" Eacute +<Multi_key> <E> <apostrophe> : "\311" Eacute +<Multi_key> <apostrophe> <E> : "\311" Eacute +<Multi_key> <E> <semicolon> : "\306" Eogonek +<Multi_key> <semicolon> <E> : "\306" Eogonek +<Multi_key> <E> <comma> : "\306" Eogonek +<Multi_key> <comma> <E> : "\306" Eogonek +<Multi_key> <E> <period> : "\313" Eabovedot +<Multi_key> <period> <E> : "\313" Eabovedot +<Multi_key> <I> <minus> : "\316" Imacron +<Multi_key> <minus> <I> : "\316" Imacron +<Multi_key> <I> <underscore> : "\316" Imacron +<Multi_key> <underscore> <I> : "\316" Imacron +<Multi_key> <N> <comma> : "\322" Ncedilla +<Multi_key> <comma> <N> : "\322" Ncedilla +<Multi_key> <O> <underscore> : "\324" Omacron +<Multi_key> <underscore> <O> : "\324" Omacron +<Multi_key> <O> <minus> : "\324" Omacron +<Multi_key> <minus> <O> : "\324" Omacron +<Multi_key> <K> <comma> : "\315" Kcedilla +<Multi_key> <comma> <K> : "\315" Kcedilla +<Multi_key> <O> <asciitilde> : "\325" Otilde +<Multi_key> <asciitilde> <O> : "\325" Otilde +<Multi_key> <O> <quotedbl> : "\326" Odiaeresis +<Multi_key> <quotedbl> <O> : "\326" Odiaeresis +<Multi_key> <x> <x> : "\327" multiply +<Multi_key> <O> <slash> : "\250" Ooblique +<Multi_key> <slash> <O> : "\250" Ooblique +<Multi_key> <o> <slash> : "\270" oslash +<Multi_key> <slash> <o> : "\270" oslash +<Multi_key> <U> <semicolon> : "\330" Uogonek +<Multi_key> <semicolon> <U> : "\330" Uogonek +<Multi_key> <U> <comma> : "\330" Uogonek +<Multi_key> <comma> <U> : "\330" Uogonek +<Multi_key> <U> <quotedbl> : "\334" Udiaeresis +<Multi_key> <quotedbl> <U> : "\334" Udiaeresis +<Multi_key> <U> <underscore> : "\333" Umacron +<Multi_key> <underscore> <U> : "\333" Umacron +<Multi_key> <U> <minus> : "\333" Umacron +<Multi_key> <minus> <U> : "\333" Umacron +<Multi_key> <s> <s> : "\337" ssharp +<Multi_key> <a> <underscore> : "\342" amacron +<Multi_key> <underscore> <a> : "\342" amacron +<Multi_key> <a> <minus> : "\342" amacron +<Multi_key> <minus> <a> : "\342" amacron +<Multi_key> <a> <quotedbl> : "\344" adiaeresis +<Multi_key> <quotedbl> <a> : "\344" adiaeresis +<Multi_key> <a> <asterisk> : "\345" aring +<Multi_key> <asterisk> <a> : "\345" aring +<Multi_key> <a> <a> : "\345" aring +<Multi_key> <a> <o> : "\345" aring +<Multi_key> <a> <e> : "\277" ae +<Multi_key> <i> <semicolon> : "\341" iogonek +<Multi_key> <semicolon> <i> : "\341" iogonek +<Multi_key> <i> <comma> : "\341" iogonek +<Multi_key> <comma> <i> : "\341" iogonek +<Multi_key> <c> <less> : "\350" ccaron +<Multi_key> <less> <c> : "\350" ccaron +<Multi_key> <e> <acute> : "\351" eacute +<Multi_key> <acute> <e> : "\351" eacute +<Multi_key> <e> <apostrophe> : "\351" eacute +<Multi_key> <apostrophe> <e> : "\351" eacute +<Multi_key> <e> <semicolon> : "\346" eogonek +<Multi_key> <semicolon> <e> : "\346" eogonek +<Multi_key> <e> <comma> : "\346" eogonek +<Multi_key> <comma> <e> : "\346" eogonek +<Multi_key> <e> <period> : "\353" eabovedot +<Multi_key> <period> <e> : "\353" eabovedot +<Multi_key> <i> <minus> : "\356" imacron +<Multi_key> <minus> <i> : "\356" imacron +<Multi_key> <i> <underscore> : "\356" imacron +<Multi_key> <underscore> <i> : "\356" imacron +<Multi_key> <n> <comma> : "\362" ncedilla +<Multi_key> <comma> <n> : "\362" ncedilla +<Multi_key> <o> <underscore> : "\364" omacron +<Multi_key> <underscore> <o> : "\364" omacron +<Multi_key> <o> <minus> : "\364" omacron +<Multi_key> <minus> <o> : "\364" omacron +<Multi_key> <k> <comma> : "\355" kcedilla +<Multi_key> <comma> <k> : "\355" kcedilla +<Multi_key> <o> <asciitilde> : "\365" otilde +<Multi_key> <asciitilde> <o> : "\365" otilde +<Multi_key> <o> <quotedbl> : "\366" odiaeresis +<Multi_key> <quotedbl> <o> : "\366" odiaeresis +<Multi_key> <o> <slash> : "\270" ooblique +<Multi_key> <slash> <o> : "\270" ooblique +<Multi_key> <u> <semicolon> : "\370" uogonek +<Multi_key> <semicolon> <u> : "\370" uogonek +<Multi_key> <u> <comma> : "\370" uogonek +<Multi_key> <comma> <u> : "\370" uogonek +<Multi_key> <u> <quotedbl> : "\374" udiaeresis +<Multi_key> <quotedbl> <u> : "\374" udiaeresis +<Multi_key> <u> <underscore> : "\373" umacron +<Multi_key> <underscore> <u> : "\373" umacron +<Multi_key> <u> <minus> : "\373" umacron +<Multi_key> <minus> <u> : "\373" umacron +<Multi_key> <C> <apostrophe> : "\303" Cacute +<Multi_key> <apostrophe> <C> : "\303" Cacute +<Multi_key> <c> <apostrophe> : "\343" cacute +<Multi_key> <apostrophe> <c> : "\343" cacute +<Multi_key> <O> <apostrophe> : "\323" Oacute +<Multi_key> <apostrophe> <O> : "\323" Oacute +<Multi_key> <o> <apostrophe> : "\363" oacute +<Multi_key> <apostrophe> <o> : "\363" oacute +<Multi_key> <Z> <apostrophe> : "\312" Zacute +<Multi_key> <apostrophe> <Z> : "\312" Zacute +<Multi_key> <z> <apostrophe> : "\352" zacute +<Multi_key> <apostrophe> <z> : "\352" zacute +<Multi_key> <N> <apostrophe> : "\321" Nacute +<Multi_key> <apostrophe> <N> : "\321" Nacute +<Multi_key> <n> <apostrophe> : "\361" nacute +<Multi_key> <apostrophe> <n> : "\361" nacute +<Multi_key> <L> <minus> : "\331" Lstroke +<Multi_key> <minus> <L> : "\331" Lstroke +<Multi_key> <L> <slash> : "\331" Lstroke +<Multi_key> <slash> <L> : "\331" Lstroke +<Multi_key> <l> <minus> : "\371" lstroke +<Multi_key> <minus> <l> : "\371" lstroke +<Multi_key> <l> <slash> : "\371" lstroke +<Multi_key> <slash> <l> : "\371" lstroke +<Multi_key> <S> <apostrophe> : "\332" Sacute +<Multi_key> <apostrophe> <S> : "\332" Sacute +<Multi_key> <s> <apostrophe> : "\372" sacute +<Multi_key> <apostrophe> <s> : "\372" sacute +<Multi_key> <Z> <period> : "\335" Zabovedot +<Multi_key> <period> <Z> : "\335" Zabovedot +<Multi_key> <z> <period> : "\375" zabovedot +<Multi_key> <period> <z> : "\375" zabovedot + +<dead_abovedot> <E> : "\313" Eabovedot +<dead_abovedot> <e> : "\353" eabovedot +<dead_abovedot> <Z> : "\335" Zabovedot +<dead_abovedot> <z> : "\375" zabovedot +<dead_abovedot> <dead_abovedot> : "\267" abovedot +<dead_abovering> <A> : "\305" Aring +<dead_abovering> <a> : "\345" aring +<dead_abovering> <E> : "\313" Eabovedot +<dead_abovering> <e> : "\353" eabovedot +<dead_abovering> <Z> : "\335" Zabovedot +<dead_abovering> <z> : "\375" zabovedot +<dead_abovedot> <A> : "\305" Aring +<dead_abovedot> <a> : "\345" aring +<dead_acute> <dead_acute> : "\377" rightsinglequotemark +<dead_acute> <C> : "\303" Cacute +<dead_acute> <E> : "\311" Eacute +<dead_acute> <Z> : "\312" Zacute +<dead_acute> <N> : "\321" Nacute +<dead_acute> <O> : "\323" Oacute +<dead_acute> <S> : "\332" Sacute +<dead_acute> <c> : "\343" cacute +<dead_acute> <e> : "\351" eacute +<dead_acute> <z> : "\352" zacute +<dead_acute> <n> : "\361" nacute +<dead_acute> <o> : "\363" oacute +<dead_acute> <s> : "\372" sacute +<dead_caron> <C> : "\310" Ccaron +<dead_caron> <S> : "\320" Scaron +<dead_caron> <Z> : "\336" Zcaron +<dead_caron> <s> : "\350" ccaron +<dead_caron> <s> : "\360" scaron +<dead_caron> <z> : "\376" zcaron +<dead_cedilla> <R> : "\252" Rcedilla +<dead_cedilla> <G> : "\314" Gcedilla +<dead_cedilla> <K> : "\315" Kcedilla +<dead_cedilla> <L> : "\317" Lcedilla +<dead_cedilla> <N> : "\322" Ncedilla +<dead_cedilla> <r> : "\272" rcedilla +<dead_cedilla> <g> : "\354" gcedilla +<dead_cedilla> <k> : "\355" kcedilla +<dead_cedilla> <l> : "\357" lcedilla +<dead_cedilla> <n> : "\362" ncedilla +<dead_diaeresis> <A> : "\304" Adiaeresis +<dead_diaeresis> <O> : "\326" Odiaeresis +<dead_diaeresis> <U> : "\334" Udiaeresis +<dead_diaeresis> <a> : "\344" adiaeresis +<dead_diaeresis> <o> : "\366" odiaeresis +<dead_diaeresis> <u> : "\374" udiaeresis +<dead_macron> <A> : "\302" Amacron +<dead_macron> <E> : "\307" Emacron +<dead_macron> <I> : "\316" Imacron +<dead_macron> <O> : "\324" Omacron +<dead_macron> <U> : "\333" Umacron +<dead_macron> <a> : "\342" amacron +<dead_macron> <e> : "\347" emacron +<dead_macron> <i> : "\356" imacron +<dead_macron> <o> : "\364" omacron +<dead_macron> <u> : "\373" umacron +<dead_macron> <macron> : "\255" macron +<dead_macron> <dead_macron> : "\255" macron +<dead_ogonek> <A> : "\300" Aogonek +<dead_ogonek> <I> : "\301" Iogonek +<dead_ogonek> <E> : "\306" Eogonek +<dead_ogonek> <U> : "\330" Uogonek +<dead_ogonek> <a> : "\340" aogonek +<dead_ogonek> <i> : "\341" iogonek +<dead_ogonek> <e> : "\346" eogonek +<dead_ogonek> <u> : "\370" uogonek +<dead_abovering> <A> : "\305" Aring +<dead_abovering> <a> : "\345" aring +<dead_abovering> <E> : "\313" Eabovedot +<dead_abovering> <e> : "\353" eabovedot +<dead_abovering> <Z> : "\335" Zabovedot +<dead_abovering> <z> : "\375" zabovedot +<dead_abovering> <ring> : "\260" ring +<dead_abovering> <dead_abovering> : "\260" ring +<dead_tilde> <O> : "\325" Otilde +<dead_tilde> <o> : "\365" otilde +<dead_tilde> <asciitilde> : "~" asciitilde +<dead_tilde> <dead_tilde> : "~" asciitilde + +# End of Sequence Definition diff --git a/xc/nls/Compose/iso8859-9e b/xc/nls/Compose/iso8859-9e new file mode 100644 index 000000000..cacf087b6 --- /dev/null +++ b/xc/nls/Compose/iso8859-9e @@ -0,0 +1,489 @@ +# +# ISO 8859-9e (Latin??) Compose Sequence +# +# Sequence Definition +# +# $XFree86: xc/nls/Compose/iso8859-9e,v 1.1 2000/10/27 18:30:51 dawes Exp $ +# +# <Multi_key> Means <Compose> +# Special Character +<Multi_key> <plus> <plus> : "#" numbersign +<Multi_key> <apostrophe> <space> : "'" apostrophe +<Multi_key> <space> <apostrophe> : "'" apostrophe +<Multi_key> <A> <A> : "@" at +<Multi_key> <parenleft> <parenleft> : "[" bracketleft +<Multi_key> <slash> <slash> : "\\" backslash +<Multi_key> <slash> <less> : "\\" backslash +<Multi_key> <less> <slash> : "\\" backslash +<Multi_key> <parenright> <parenright> : "]" bracketright +<Multi_key> <asciicircum> <space> : "^" asciicircum +<Multi_key> <space> <asciicircum> : "^" asciicircum +<Multi_key> <greater> <space> : "^" asciicirum +<Multi_key> <space> <greater> : "^" asciicirum +<Multi_key> <grave> <space> : "`" grave +<Multi_key> <space> <grave> : "`" grave +<Multi_key> <parenleft> <minus> : "{" braceleft +<Multi_key> <minus> <parenleft> : "{" braceleft +<Multi_key> <slash> <asciicircum> : "|" bar +<Multi_key> <asciicircum> <slash> : "|" bar +<Multi_key> <V> <L> : "|" bar +<Multi_key> <L> <V> : "|" bar +<Multi_key> <v> <l> : "|" bar +<Multi_key> <l> <v> : "|" bar +<Multi_key> <parenright> <minus> : "}" braceright +<Multi_key> <minus> <parenright> : "}" braceright +<Multi_key> <asciitilde> <space> : "~" asciitilde +<Multi_key> <space> <asciitilde> : "~" asciitilde +<Multi_key> <minus> <space> : "~" asciitilde +<Multi_key> <space> <minus> : "~" asciitilde +<Multi_key> <exclam> <exclam> : "\241" exclamdown +<Multi_key> <c> <slash> : "\242" cent +<Multi_key> <slash> <c> : "\242" cent +<Multi_key> <C> <slash> : "\242" cent +<Multi_key> <slash> <C> : "\242" cent +<Multi_key> <C> <bar> : "\242" cent +<Multi_key> <bar> <C> : "\242" cent +<Multi_key> <c> <bar> : "\242" cent +<Multi_key> <bar> <c> : "\242" cent +<Multi_key> <l> <minus> : "\243" sterling +<Multi_key> <minus> <l> : "\243" sterling +<Multi_key> <L> <minus> : "\243" sterling +<Multi_key> <minus> <L> : "\243" sterling +<Multi_key> <l> <equal> : "\243" sterling +<Multi_key> <equal> <l> : "\243" sterling +<Multi_key> <L> <equal> : "\243" sterling +<Multi_key> <equal> <L> : "\243" sterling +<Multi_key> <C> <equal> : "\244" EuroSign +<Multi_key> <equal> <C> : "\244" EuroSign +<Multi_key> <e> <equal> : "\244" EuroSign +<Multi_key> <equal> <e> : "\244" EuroSign +<Multi_key> <y> <minus> : "\245" yen +<Multi_key> <minus> <y> : "\245" yen +<Multi_key> <Y> <minus> : "\245" yen +<Multi_key> <minus> <Y> : "\245" yen +<Multi_key> <y> <equal> : "\245" yen +<Multi_key> <equal> <y> : "\245" yen +<Multi_key> <Y> <equal> : "\245" yen +<Multi_key> <equal> <Y> : "\245" yen +<Multi_key> <s> <o> : "\247" section +<Multi_key> <o> <s> : "\247" section +<Multi_key> <S> <O> : "\247" section +<Multi_key> <O> <S> : "\247" section +<Multi_key> <S> <exclam> : "\247" section +<Multi_key> <exclam> <S> : "\247" section +<Multi_key> <s> <exclam> : "\247" section +<Multi_key> <exclam> <s> : "\247" section +<Multi_key> <S> <0> : "\247" section +<Multi_key> <0> <S> : "\247" section +<Multi_key> <s> <0> : "\247" section +<Multi_key> <0> <s> : "\247" section +<Multi_key> <c> <o> : "\251" copyright +<Multi_key> <o> <c> : "\251" copyright +<Multi_key> <C> <O> : "\251" copyright +<Multi_key> <O> <C> : "\251" copyright +<Multi_key> <c> <O> : "\251" copyright +<Multi_key> <O> <c> : "\251" copyright +<Multi_key> <C> <o> : "\251" copyright +<Multi_key> <o> <C> : "\251" copyright +<Multi_key> <c> <0> : "\251" copyright +<Multi_key> <0> <c> : "\251" copyright +<Multi_key> <C> <0> : "\251" copyright +<Multi_key> <0> <C> : "\251" copyright +<Multi_key> <parenleft> <c> : "\251" copyright +<Multi_key> <a> <underscore> : "\252" ordfeminine +<Multi_key> <underscore> <a> : "\252" ordfeminine +<Multi_key> <A> <underscore> : "\252" ordfeminine +<Multi_key> <underscore> <A> : "\252" ordfeminine +<Multi_key> <o> <underscore> : "\272" masculine +<Multi_key> <underscore> <o> : "\272" masculine +<Multi_key> <O> <underscore> : "\272" masculine +<Multi_key> <underscore> <O> : "\272" masculine +<Multi_key> <less> <less> : "\253" guillemotleft +<Multi_key> <greater> <greater> : "\273" guillemotright +<Multi_key> <0> <asciicircum> : "\260" degree +<Multi_key> <asciicircum> <0> : "\260" degree +<Multi_key> <0> <asterisk> : "\260" degree +<Multi_key> <asterisk> <0> : "\260" degree +<Multi_key> <plus> <minus> : "\261" plusminus +<Multi_key> <minus> <plus> : "\261" plusminus +<Multi_key> <slash> <u> : "\265" mu +<Multi_key> <u> <slash> : "\265" mu +<Multi_key> <slash> <U> : "\265" mu +<Multi_key> <U> <slash> : "\265" mu +<Multi_key> <1> <asciicircum> : "\271" onesuperior +<Multi_key> <asciicircum> <1> : "\271" onesuperior +<Multi_key> <S> <1> : "\271" onesuperior +<Multi_key> <1> <S> : "\271" onesuperior +<Multi_key> <s> <1> : "\271" onesuperior +<Multi_key> <1> <s> : "\271" onesuperior +<Multi_key> <2> <asciicircum> : "\262" twosuperior +<Multi_key> <asciicircum> <2> : "\262" twosuperior +<Multi_key> <S> <2> : "\262" twosuperior +<Multi_key> <2> <S> : "\262" twosuperior +<Multi_key> <s> <2> : "\262" twosuperior +<Multi_key> <2> <s> : "\262" twosuperior +<Multi_key> <3> <asciicircum> : "\263" threesuperior +<Multi_key> <asciicircum> <3> : "\263" threesuperior +<Multi_key> <S> <3> : "\263" threesuperior +<Multi_key> <3> <S> : "\263" threesuperior +<Multi_key> <s> <3> : "\263" threesuperior +<Multi_key> <3> <s> : "\263" threesuperior +<Multi_key> <p> <exclam> : "\266" paragraph +<Multi_key> <exclam> <p> : "\266" paragraph +<Multi_key> <P> <exclam> : "\266" paragraph +<Multi_key> <exclam> <P> : "\266" paragraph +<Multi_key> <period> <asciicircum> : "\267" periodcentered +<Multi_key> <asciicircum> <period> : "\267" periodcentered +<Multi_key> <period> <period> : "\267" periodcentered +<Multi_key> <question> <question> : "\277" questiondown +<Multi_key> <space> <space> : "\240" nobreakspace +<Multi_key> <minus> <comma> : "\254" notsign +<Multi_key> <comma> <minus> : "\254" notsign +<Multi_key> <minus> <minus> : "\255" hyphen +<Multi_key> <R> <O> : "\256" registered +<Multi_key> <O> <R> : "\256" registered +<Multi_key> <parenleft> <r> : "\256" registered +<Multi_key> <minus> <asciicircum> : "\257" macron +<Multi_key> <asciicircum> <minus> : "\257" macron +<Multi_key> <underscore> <asciicircum> : "\257" macron +<Multi_key> <asciicircum> <underscore> : "\257" macron +<Multi_key> <underscore> <underscore> : "\257" macron +<Multi_key> <minus> <colon> : "\367" division +<Multi_key> <colon> <minus> : "\367" division +<Multi_key> <x> <x> : "\327" multiply +<Multi_key> <apostrophe> <apostrophe> : "\264" acute +<Multi_key> <comma> <comma> : "\270" cedilla +<Multi_key> <quotedbl> <quotedbl> : "\250" diaeresis +# Accented Alphabet +<Multi_key> <A> <grave> : "\300" Agrave +<Multi_key> <grave> <A> : "\300" Agrave +<Multi_key> <A> <acute> : "\301" Aacute +<Multi_key> <acute> <A> : "\301" Aacute +<Multi_key> <A> <apostrophe> : "\301" Aacute +<Multi_key> <apostrophe> <A> : "\301" Aacute +<Multi_key> <A> <asciicircum> : "\302" Acircumflex +<Multi_key> <asciicircum> <A> : "\302" Acircumflex +<Multi_key> <A> <greater> : "\302" Acircumflex +<Multi_key> <greater> <A> : "\302" Acircumflex +<Multi_key> <A> <asciitilde> : "\303" Atilde +<Multi_key> <asciitilde> <A> : "\303" Atilde +<Multi_key> <A> <minus> : "\303" Atilde +<Multi_key> <minus> <A> : "\303" Atilde +<Multi_key> <A> <quotedbl> : "\304" Adiaeresis +<Multi_key> <quotedbl> <A> : "\304" Adiaeresis +<Multi_key> <A> <diaeresis> : "\304" Adiaeresis +<Multi_key> <diaeresis> <A> : "\304" Adiaeresis +<Multi_key> <A> <asterisk> : "\305" Aring +<Multi_key> <asterisk> <A> : "\305" Aring +<Multi_key> <A> <A> : "\305" Aring +<Multi_key> <E> <E> : "\306" SCHWA +<Multi_key> <a> <grave> : "\340" agrave +<Multi_key> <grave> <a> : "\340" agrave +<Multi_key> <a> <acute> : "\341" aacute +<Multi_key> <acute> <a> : "\341" aacute +<Multi_key> <a> <apostrophe> : "\341" aacute +<Multi_key> <apostrophe> <a> : "\341" aacute +<Multi_key> <a> <asciicircum> : "\342" acircumflex +<Multi_key> <asciicircum> <a> : "\342" acircumflex +<Multi_key> <a> <greater> : "\342" acircumflex +<Multi_key> <greater> <a> : "\342" acircumflex +<Multi_key> <a> <asciitilde> : "\343" atilde +<Multi_key> <asciitilde> <a> : "\343" atilde +<Multi_key> <a> <minus> : "\343" atilde +<Multi_key> <minus> <a> : "\343" atilde +<Multi_key> <a> <quotedbl> : "\344" adiaeresis +<Multi_key> <quotedbl> <a> : "\344" adiaeresis +<Multi_key> <a> <diaeresis> : "\344" adiaeresis +<Multi_key> <diaeresis> <a> : "\344" adiaeresis +<Multi_key> <a> <asterisk> : "\345" aring +<Multi_key> <asterisk> <a> : "\345" aring +<Multi_key> <a> <a> : "\345" aring +<Multi_key> <e> <e> : "\346" schwa +<Multi_key> <C> <comma> : "\307" Ccedilla +<Multi_key> <comma> <C> : "\307" Ccedilla +<Multi_key> <c> <comma> : "\347" ccedilla +<Multi_key> <comma> <c> : "\347" ccedilla +<Multi_key> <minus> <D> : "\320" ETH +<Multi_key> <D> <minus> : "\320" ETH +<Multi_key> <minus> <d> : "\360" eth +<Multi_key> <d> <minus> : "\360" eth +<Multi_key> <E> <grave> : "\310" Egrave +<Multi_key> <grave> <E> : "\310" Egrave +<Multi_key> <E> <acute> : "\311" Eacute +<Multi_key> <acute> <E> : "\311" Eacute +<Multi_key> <E> <apostrophe> : "\311" Eacute +<Multi_key> <apostrophe> <E> : "\311" Eacute +<Multi_key> <E> <asciicircum> : "\312" Ecircumflex +<Multi_key> <asciicircum> <E> : "\312" Ecircumflex +<Multi_key> <E> <greater> : "\312" Ecircumflex +<Multi_key> <greater> <E> : "\312" Ecircumflex +<Multi_key> <E> <quotedbl> : "\313" Ediaeresis +<Multi_key> <quotedbl> <E> : "\313" Ediaeresis +<Multi_key> <E> <diaeresis> : "\313" Ediaeresis +<Multi_key> <diaeresis> <E> : "\313" Ediaeresis +<Multi_key> <e> <grave> : "\350" egrave +<Multi_key> <grave> <e> : "\350" egrave +<Multi_key> <e> <acute> : "\351" eacute +<Multi_key> <acute> <e> : "\351" eacute +<Multi_key> <e> <apostrophe> : "\351" eacute +<Multi_key> <apostrophe> <e> : "\351" eacute +<Multi_key> <e> <asciicircum> : "\352" ecircumflex +<Multi_key> <asciicircum> <e> : "\352" ecircumflex +<Multi_key> <e> <greater> : "\352" ecircumflex +<Multi_key> <greater> <e> : "\352" ecircumflex +<Multi_key> <e> <quotedbl> : "\353" ediaeresis +<Multi_key> <quotedbl> <e> : "\353" ediaeresis +<Multi_key> <e> <diaeresis> : "\353" ediaeresis +<Multi_key> <diaeresis> <e> : "\353" ediaeresis +<Multi_key> <G> <U> : "\320" Gbreve +<Multi_key> <G> <parenleft> : "\320" Gbreve +<Multi_key> <parenleft> <G> : "\320" Gbreve +<Multi_key> <G> <breve> : "\320" Gbreve +<Multi_key> <breve> <G> : "\320" Gbreve +<Multi_key> <g> <U> : "\360" gbreve +<Multi_key> <g> <parenleft> : "\360" gbreve +<Multi_key> <parenleft> <g> : "\360" gbreve +<Multi_key> <g> <breve> : "\360" gbreve +<Multi_key> <breve> <g> : "\360" gbreve +<Multi_key> <I> <grave> : "\314" Igrave +<Multi_key> <grave> <I> : "\314" Igrave +<Multi_key> <I> <acute> : "\315" Iacute +<Multi_key> <acute> <I> : "\315" Iacute +<Multi_key> <I> <apostrophe> : "\315" Iacute +<Multi_key> <apostrophe> <I> : "\315" Iacute +<Multi_key> <I> <asciicircum> : "\316" Icircumflex +<Multi_key> <asciicircum> <I> : "\316" Icircumflex +<Multi_key> <I> <greater> : "\316" Icircumflex +<Multi_key> <greater> <I> : "\316" Icircumflex +<Multi_key> <I> <quotedbl> : "\317" Idiaeresis +<Multi_key> <quotedbl> <I> : "\317" Idiaeresis +<Multi_key> <I> <diaeresis> : "\317" Idiaeresis +<Multi_key> <diaeresis> <I> : "\317" Idiaeresis +<Multi_key> <I> <period> : "\335" Iabovedot +<Multi_key> <period> <I> : "\335" Iabovedot +<Multi_key> <i> <grave> : "\354" igrave +<Multi_key> <grave> <i> : "\354" igrave +<Multi_key> <i> <acute> : "\355" iacute +<Multi_key> <acute> <i> : "\355" iacute +<Multi_key> <i> <apostrophe> : "\355" iacute +<Multi_key> <apostrophe> <i> : "\355" iacute +<Multi_key> <i> <asciicircum> : "\356" icircumflex +<Multi_key> <asciicircum> <i> : "\356" icircumflex +<Multi_key> <i> <greater> : "\356" icircumflex +<Multi_key> <greater> <i> : "\356" icircumflex +<Multi_key> <i> <quotedbl> : "\357" idiaeresis +<Multi_key> <quotedbl> <i> : "\357" idiaeresis +<Multi_key> <i> <diaeresis> : "\357" idiaeresis +<Multi_key> <diaeresis> <i> : "\357" idiaeresis +<Multi_key> <i> <period> : "\375" idotless +<Multi_key> <period> <i> : "\375" idotless +<Multi_key> <N> <asciitilde> : "\321" Ntilde +<Multi_key> <asciitilde> <N> : "\321" Ntilde +<Multi_key> <N> <minus> : "\321" Ntilde +<Multi_key> <minus> <N> : "\321" Ntilde +<Multi_key> <n> <asciitilde> : "\361" ntilde +<Multi_key> <asciitilde> <n> : "\361" ntilde +<Multi_key> <n> <minus> : "\361" ntilde +<Multi_key> <minus> <n> : "\361" ntilde +<Multi_key> <O> <grave> : "\322" Ograve +<Multi_key> <grave> <O> : "\322" Ograve +<Multi_key> <O> <acute> : "\323" Oacute +<Multi_key> <acute> <O> : "\323" Oacute +<Multi_key> <O> <apostrophe> : "\323" Oacute +<Multi_key> <apostrophe> <O> : "\323" Oacute +<Multi_key> <O> <asciicircum> : "\324" Ocircumflex +<Multi_key> <asciicircum> <O> : "\324" Ocircumflex +<Multi_key> <O> <greater> : "\324" Ocircumflex +<Multi_key> <greater> <O> : "\324" Ocircumflex +<Multi_key> <O> <asciitilde> : "\325" Otilde +<Multi_key> <asciitilde> <O> : "\325" Otilde +<Multi_key> <O> <minus> : "\325" Otilde +<Multi_key> <minus> <O> : "\325" Otilde +<Multi_key> <O> <quotedbl> : "\326" Odiaeresis +<Multi_key> <quotedbl> <O> : "\326" Odiaeresis +<Multi_key> <O> <diaeresis> : "\326" Odiaeresis +<Multi_key> <diaeresis> <O> : "\326" Odiaeresis +<Multi_key> <O> <slash> : "\330" Ooblique +<Multi_key> <slash> <O> : "\330" Ooblique +<Multi_key> <O> <E> : "\274" OE +<Multi_key> <o> <grave> : "\362" ograve +<Multi_key> <grave> <o> : "\362" ograve +<Multi_key> <o> <acute> : "\363" oacute +<Multi_key> <acute> <o> : "\363" oacute +<Multi_key> <o> <apostrophe> : "\363" oacute +<Multi_key> <apostrophe> <o> : "\363" oacute +<Multi_key> <o> <asciicircum> : "\364" ocircumflex +<Multi_key> <asciicircum> <o> : "\364" ocircumflex +<Multi_key> <o> <greater> : "\364" ocircumflex +<Multi_key> <greater> <o> : "\364" ocircumflex +<Multi_key> <o> <asciitilde> : "\365" otilde +<Multi_key> <asciitilde> <o> : "\365" otilde +<Multi_key> <o> <minus> : "\365" otilde +<Multi_key> <minus> <o> : "\365" otilde +<Multi_key> <o> <quotedbl> : "\366" odiaeresis +<Multi_key> <quotedbl> <o> : "\366" odiaeresis +<Multi_key> <o> <diaeresis> : "\366" odiaeresis +<Multi_key> <diaeresis> <o> : "\366" odiaeresis +<Multi_key> <o> <slash> : "\370" oslash +<Multi_key> <slash> <o> : "\370" oslash +<Multi_key> <S> <cedilla> : "\336" Scedilla +<Multi_key> <S> <comma> : "\336" Scedilla +<Multi_key> <cedilla> <S> : "\336" Scedilla +<Multi_key> <cedilla> <s> : "\376" scedilla +<Multi_key> <comma> <S> : "\336" Scedilla +<Multi_key> <comma> <s> : "\376" scedilla +<Multi_key> <s> <cedilla> : "\376" scedilla +<Multi_key> <s> <comma> : "\376" scedilla +<Multi_key> <U> <grave> : "\331" Ugrave +<Multi_key> <grave> <U> : "\331" Ugrave +<Multi_key> <U> <acute> : "\332" Uacute +<Multi_key> <acute> <U> : "\332" Uacute +<Multi_key> <U> <apostrophe> : "\332" Uacute +<Multi_key> <apostrophe> <U> : "\332" Uacute +<Multi_key> <U> <asciicircum> : "\333" Ucircumflex +<Multi_key> <asciicircum> <U> : "\333" Ucircumflex +<Multi_key> <U> <greater> : "\333" Ucircumflex +<Multi_key> <greater> <U> : "\333" Ucircumflex +<Multi_key> <U> <quotedbl> : "\334" Udiaeresis +<Multi_key> <quotedbl> <U> : "\334" Udiaeresis +<Multi_key> <U> <diaeresis> : "\334" Udiaeresis +<Multi_key> <diaeresis> <U> : "\334" Udiaeresis +<Multi_key> <u> <grave> : "\371" ugrave +<Multi_key> <grave> <u> : "\371" ugrave +<Multi_key> <u> <acute> : "\372" uacute +<Multi_key> <acute> <u> : "\372" uacute +<Multi_key> <u> <apostrophe> : "\372" uacute +<Multi_key> <apostrophe> <u> : "\372" uacute +<Multi_key> <u> <asciicircum> : "\373" ucircumflex +<Multi_key> <asciicircum> <u> : "\373" ucircumflex +<Multi_key> <u> <greater> : "\373" ucircumflex +<Multi_key> <greater> <u> : "\373" ucircumflex +<Multi_key> <u> <quotedbl> : "\374" udiaeresis +<Multi_key> <quotedbl> <u> : "\374" udiaeresis +<Multi_key> <u> <diaeresis> : "\374" udiaeresis +<Multi_key> <diaeresis> <u> : "\374" udiaeresis +<Multi_key> <s> <s> : "\337" ssharp +<Multi_key> <T> <H> : "\336" THORN +<Multi_key> <t> <h> : "\376" thorn +<Multi_key> <Y> <acute> : "\327" Yacute +<Multi_key> <acute> <Y> : "\327" Yacute +<Multi_key> <Y> <apostrophe> : "\327" Yacute +<Multi_key> <apostrophe> <Y> : "\327" Yacute +<Multi_key> <Y> <quotedbl> : "\276" Ydiaeresis +<Multi_key> <quotedbl> <Y> : "\276" Ydiaeresis +<Multi_key> <Y> <diaeresis> : "\276" Ydiaeresis +<Multi_key> <diaeresis> <Y> : "\276" Ydiaeresis +<Multi_key> <y> <acute> : "\367" yacute +<Multi_key> <acute> <y> : "\367" yacute +<Multi_key> <y> <apostrophe> : "\367" yacute +<Multi_key> <apostrophe> <y> : "\367" yacute +<Multi_key> <y> <quotedbl> : "\377" ydiaeresis +<Multi_key> <quotedbl> <y> : "\377" ydiaeresis +<Multi_key> <y> <diaeresis> : "\377" ydiaeresis +<Multi_key> <diaeresis> <y> : "\377" ydiaeresis +<Multi_key> <Z> <less> : "\241" Zcaron +<Multi_key> <less> <Z> : "\241" Zcaron +<Multi_key> <z> <less> : "\261" zcaron +<Multi_key> <less> <z> : "\261" zcaron +<Multi_key> <v> <Z> : "\241" Zcaron +<Multi_key> <v> <z> : "\261" zcaron +<Multi_key> <G> <less> : "\252" Gcaron +<Multi_key> <less> <G> : "\252" Gcaron +<Multi_key> <g> <less> : "\272" gcaron +<Multi_key> <less> <g> : "\272" gcaron +<Multi_key> <v> <G> : "\252" Gcaron +<Multi_key> <v> <g> : "\272" gcaron +<Multi_key> <O> <less> : "\264" Ocaron +<Multi_key> <less> <O> : "\264" Ocaron +<Multi_key> <o> <less> : "\275" ocaron +<Multi_key> <less> <o> : "\275" ocaron +<Multi_key> <v> <O> : "\264" Ocaron +<Multi_key> <v> <o> : "\275" ocaron +# +# dead key accent keysyms +# Special Character +<dead_circumflex> <slash> : "|" bar +<dead_grave> <space> : "`" grave +<dead_acute> <space> : "'" apostrophe +<dead_diaeresis> <space> : "\250" diaeresis +<dead_circumflex> <space> : "^" asciicircum +<dead_tilde> <space> : "~" asciitilde +<dead_grave> <space> : "`" grave +<dead_acute> <space> : "'" apostrophe +<dead_circumflex> <0> : "\260" degree +<dead_circumflex> <1> : "\271" onesuperior +<dead_circumflex> <2> : "\262" twosuperior +<dead_circumflex> <3> : "\263" threesuperior +<dead_circumflex> <period> : "\267" periodcentered +<dead_cedilla> <minus> : "\254" notsign +<dead_circumflex> <minus> : "\257" macron +<dead_circumflex> <underscore> : "\257" macron +<dead_acute> <apostrophe> : "\264" acute +<dead_cedilla> <comma> : "\270" cedilla +<dead_diaeresis> <quotedbl> : "\250" diaeresis +# Accented Alphabet +<dead_abovering> <A> : "\305" Aring +<dead_abovering> <a> : "\345" aring +<dead_grave> <A> : "\300" Agrave +<dead_acute> <A> : "\301" Aacute +<dead_circumflex> <A> : "\302" Acircumflex +<dead_tilde> <A> : "\303" Atilde +<dead_diaeresis> <A> : "\304" Adiaeresis +<dead_grave> <a> : "\340" agrave +<dead_acute> <a> : "\341" aacute +<dead_circumflex> <a> : "\342" acircumflex +<dead_tilde> <a> : "\343" atilde +<dead_diaeresis> <a> : "\344" adiaeresis +<dead_cedilla> <C> : "\307" Ccedilla +<dead_cedilla> <c> : "\347" ccedilla +<dead_grave> <E> : "\310" Egrave +<dead_acute> <E> : "\311" Eacute +<dead_circumflex> <E> : "\312" Ecircumflex +<dead_diaeresis> <E> : "\313" Ediaeresis +<dead_grave> <e> : "\350" egrave +<dead_acute> <e> : "\351" eacute +<dead_circumflex> <e> : "\352" ecircumflex +<dead_diaeresis> <e> : "\353" ediaeresis +<dead_breve> <G> : "\320" Gbreve +<dead_breve> <g> : "\360" gbreve +<dead_abovedot> <I> : "\335" Iabovedot +<dead_grave> <I> : "\314" Igrave +<dead_acute> <I> : "\315" Iacute +<dead_circumflex> <I> : "\316" Icircumflex +<dead_diaeresis> <I> : "\317" Idiaeresis +<dead_abovedot> <i> : "\375" idotless +<dead_grave> <i> : "\354" igrave +<dead_acute> <i> : "\355" iacute +<dead_circumflex> <i> : "\356" icircumflex +<dead_diaeresis> <i> : "\357" idiaeresis +<dead_tilde> <N> : "\321" Ntilde +<dead_tilde> <n> : "\361" ntilde +<dead_grave> <O> : "\322" Ograve +<dead_acute> <O> : "\323" Oacute +<dead_circumflex> <O> : "\324" Ocircumflex +<dead_tilde> <O> : "\325" Otilde +<dead_diaeresis> <O> : "\326" Odiaeresis +<dead_grave> <o> : "\362" ograve +<dead_acute> <o> : "\363" oacute +<dead_circumflex> <o> : "\364" ocircumflex +<dead_tilde> <o> : "\365" otilde +<dead_diaeresis> <o> : "\366" odiaeresis +<dead_cedilla> <S> : "\336" Scedilla +<dead_cedilla> <s> : "\376" scedilla +<dead_grave> <U> : "\331" Ugrave +<dead_acute> <U> : "\332" Uacute +<dead_circumflex> <U> : "\333" Ucircumflex +<dead_diaeresis> <U> : "\334" Udiaeresis +<dead_grave> <u> : "\371" ugrave +<dead_acute> <u> : "\372" uacute +<dead_circumflex> <u> : "\373" ucircumflex +<dead_diaeresis> <u> : "\374" udiaeresis +<dead_acute> <Y> : "\327" Yacute +<dead_diaeresis> <Y> : "\276" Ydiaeresis +<dead_acute> <y> : "\367" yacute +<dead_diaeresis> <y> : "\377" ydiaeresis +<dead_caron> <Z> : "\241" Zcaron +<dead_caron> <z> : "\261" zcaron +<dead_caron> <G> : "\252" Gcaron +<dead_caron> <g> : "\272" gcaron +# End of Sequence Definition diff --git a/xc/nls/Compose/koi8-c b/xc/nls/Compose/koi8-c new file mode 100644 index 000000000..0a39f1be6 --- /dev/null +++ b/xc/nls/Compose/koi8-c @@ -0,0 +1,123 @@ +# +# koi8-c Compose Sequence +# +# Sequence Definition +# +# $XFree86: xc/nls/Compose/koi8-c,v 1.1 2000/10/27 18:30:52 dawes Exp $ +# + +# <Multi_key> Means <Compose> +# Special Character +<Multi_key> <plus> <plus> : "#" numbersign +<Multi_key> <apostrophe> <space> : "'" apostrophe +<Multi_key> <space> <apostrophe> : "'" apostrophe +<Multi_key> <A> <T> : "@" at +<Multi_key> <parenleft> <parenleft> : "[" bracketleft +<Multi_key> <slash> <slash> : "\\" backslash +<Multi_key> <slash> <less> : "\\" backslash +<Multi_key> <less> <slash> : "\\" backslash +<Multi_key> <parenright> <parenright> : "]" bracketright +<Multi_key> <asciicircum> <space> : "^" asciicircum +<Multi_key> <space> <asciicircum> : "^" asciicircum +<Multi_key> <greater> <space> : "^" asciicircum +<Multi_key> <space> <greater> : "^" asciicircum +<Multi_key> <grave> <space> : "`" grave +<Multi_key> <space> <grave> : "`" grave +<Multi_key> <parenleft> <minus> : "{" braceleft +<Multi_key> <minus> <parenleft> : "{" braceleft +<Multi_key> <slash> <asciicircum> : "|" bar +<Multi_key> <asciicircum> <slash> : "|" bar +<Multi_key> <V> <L> : "|" bar +<Multi_key> <L> <V> : "|" bar +<Multi_key> <v> <l> : "|" bar +<Multi_key> <l> <v> : "|" bar +<Multi_key> <parenright> <minus> : "}" braceright +<Multi_key> <minus> <parenright> : "}" braceright +<Multi_key> <asciitilde> <space> : "~" asciitilde +<Multi_key> <space> <asciitilde> : "~" asciitilde +<Multi_key> <minus> <space> : "~" asciitilde +<Multi_key> <space> <minus> : "~" asciitilde + +<Multi_key> <space> <space> : "\240" nobreakspace + +<Multi_key> <Cyrillic_ghe> <minus> : "\200" Cyrillic_ghe_bar +<Multi_key> <Cyrillic_GHE> <minus> : "\220" Cyrillic_GHE_bar +<Multi_key> <Cyrillic_zhe> <comma> : "\201" Cyrillic_zhe_descender +<Multi_key> <Cyrillic_ZHE> <comma> : "\221" Cyrillic_ZHE_descender +<Multi_key> <Cyrillic_ka> <comma> : "\202" Cyrillic_ka_descender +<Multi_key> <Cyrillic_KA> <comma> : "\222" Cyrillic_KA_descender +<Multi_key> <Cyrillic_ka> <slash> : "\203" Cyrillic_ka_vertstroke +<Multi_key> <Cyrillic_KA> <slash> : "\223" Cyrillic_KA_vertstroke +<Multi_key> <Cyrillic_ka> <bar> : "\203" Cyrillic_ka_vertstroke +<Multi_key> <Cyrillic_KA> <bar> : "\223" Cyrillic_KA_vertstroke +<Multi_key> <Cyrillic_en> <comma> : "\204" Cyrillic_en_descender +<Multi_key> <Cyrillic_EN> <comma> : "\224" Cyrillic_EN_descender +<Multi_key> <Cyrillic_u> <apostrophe> : "\205" Cyrillic_u_straight +<Multi_key> <Cyrillic_U> <apostrophe> : "\225" Cyrillic_U_straight +<Multi_key> <Cyrillic_u> <bar> : "\205" Cyrillic_u_straight +<Multi_key> <Cyrillic_U> <bar> : "\225" Cyrillic_U_straight +<Multi_key> <Cyrillic_u> <comma> : "\206" Cyrillic_u_straight_bar +<Multi_key> <Cyrillic_U> <comma> : "\226" Cyrillic_U_straight_bat +<Multi_key> <Cyrillic_u> <slash> : "\206" Cyrillic_u_straight_bar +<Multi_key> <Cyrillic_U> <slash> : "\226" Cyrillic_U_straight_bat +<Multi_key> <Cyrillic_ha> <comma> : "\207" Cyrillic_ha_descender +<Multi_key> <Cyrillic_HA> <comma> : "\227" Cyrillic_HA_descender +<Multi_key> <Cyrillic_che> <comma> : "\210" Cyrillic_che_descender +<Multi_key> <Cyrillic_CHE> <comma> : "\230" Cyrillic_CHE_descender +<Multi_key> <Cyrillic_che> <slash> : "\211" Cyrillic_che_vertstroke +<Multi_key> <Cyrillic_CHE> <slash> : "\231" Cyrillic_CHE_vertstroke +<Multi_key> <Cyrillic_che> <bar> : "\211" Cyrillic_che_vertstroke +<Multi_key> <Cyrillic_CHE> <bar> : "\231" Cyrillic_CHE_vertstroke +<Multi_key> <Cyrillic_ha> <apostrophe> : "\212" Cyrillic_shha +<Multi_key> <Cyrillic_HA> <apostrophe> : "\232" Cyrillic_SHHA +<Multi_key> <h> <apostrophe> : "\212" Cyrillic_shha +<Multi_key> <H> <apostrophe> : "\232" Cyrillic_SHHA +<Multi_key> <h> <h> : "\212" Cyrillic_shha +<Multi_key> <H> <H> : "\232" Cyrillic_SHHA +<Multi_key> <Cyrillic_ie> <Cyrillic_ie> : "\213" Cyrillic_schwa +<Multi_key> <Cyrillic_IE> <Cyrillic_IE> : "\233" Cyrillic_SCHWA +<Multi_key> <e> <e> : "\213" Cyrillic_schwa +<Multi_key> <E> <E> : "\233" Cyrillic_SCHWA +<Multi_key> <Cyrillic_i> <minus> : "\214" Cyrillic_i_macron +<Multi_key> <Cyrillic_I> <minus> : "\234" Cyrillic_I_macron +<Multi_key> <Cyrillic_o> <minus> : "\215" Cyrillic_o_bar +<Multi_key> <Cyrillic_O> <minus> : "\235" Cyrillic_O_bar +<Multi_key> <Cyrillic_u> <minus> : "\216" Cyrillic_u_macron +<Multi_key> <Cyrillic_U> <minus> : "\236" Cyrillic_U_macron + +<Multi_key> <Cyrillic_de> <Cyrillic_je> : "\241" Serbian_dje +<Multi_key> <Cyrillic_DE> <Cyrillic_JE> : "\261" Serbian_DJE +<Multi_key> <Cyrillic_ghe> <Cyrillic_je> : "\242" Macedonia_gje +<Multi_key> <Cyrillic_GHE> <Cyrillic_JE> : "\262" Macedonia_GJE +<Multi_key> <Cyrillic_shorti> <Cyrillic_o> : "\243" Cyrillic_io +<Multi_key> <Cyrillic_SHORTI> <Cyrillic_O> : "\263" Cyrillic_IO +<Multi_key> <Cyrillic_je> <Cyrillic_o> : "\243" Cyrillic_io +<Multi_key> <Cyrillic_JE> <Cyrillic_O> : "\263" Cyrillic_IO +<Multi_key> <Cyrillic_ie> <colon> : "\243" Cyrillic_io +<Multi_key> <Cyrillic_IE> <colon> : "\263" Cyrillic_IO + +<Multi_key> <Cyrillic_el> <Cyrillic_je> : "\251" Cyrillic_lje +<Multi_key> <Cyrillic_EL> <Cyrillic_JE> : "\271" Cyrillic_LJE +<Multi_key> <Cyrillic_en> <Cyrillic_je> : "\252" Cyrillic_nje +<Multi_key> <Cyrillic_EN> <Cyrillic_JE> : "\272" Cyrillic_NJE + +<Multi_key> <Cyrillic_shorti> <Cyrillic_u> : "\300" Cyrillic_yu +<Multi_key> <Cyrillic_SHORTI> <Cyrillic_U> : "\340" Cyrillic_YU +<Multi_key> <Cyrillic_je> <Cyrillic_u> : "\300" Cyrillic_yu +<Multi_key> <Cyrillic_JE> <Cyrillic_U> : "\340" Cyrillic_YU + +<Multi_key> <Cyrillic_te> <Cyrillic_es> : "\303" Cyrillic_tse +<Multi_key> <Cyrillic_TE> <Cyrillic_ES> : "\343" Cyrillic_TSE + +<Multi_key> <Cyrillic_shorti> <Cyrillic_a> : "\321" Cyrillic_ya +<Multi_key> <Cyrillic_SHORTI> <Cyrillic_A> : "\361" Cyrillic_YA +<Multi_key> <Cyrillic_je> <Cyrillic_a> : "\321" Cyrillic_ya +<Multi_key> <Cyrillic_JE> <Cyrillic_A> : "\361" Cyrillic_YA + + +<Multi_key> <Cyrillic_sha> <comma> : "\335" Cyrillic_shcha +<Multi_key> <Cyrillic_SHA> <comma> : "\375" Cyrillic_SHCHA + + + +# End of Sequence Definition diff --git a/xc/nls/XLC_LOCALE/iscii-dev b/xc/nls/XLC_LOCALE/iscii-dev new file mode 100644 index 000000000..06a69572e --- /dev/null +++ b/xc/nls/XLC_LOCALE/iscii-dev @@ -0,0 +1,58 @@ +XCOMM $XFree86: xc/nls/XLC_LOCALE/iscii-dev,v 1.1 2000/10/27 18:30:53 dawes Exp $ +XCOMM XLocale Database Sample for mulelao-1. +XCOMM + +XCOMM +XCOMM XLC_FONTSET category +XCOMM +XLC_FONTSET +XCOMM fs0 class (7 bit ASCII) +fs0 { + charset ISO8859-1:GL + font ISCII-DEV:GL; ISO8859-1:GL +} +XCOMM fs1 class +fs1 { + charset ISCII-DEV:GR + font ISCII-DEV:GR +} +END XLC_FONTSET + +XCOMM +XCOMM XLC_XLOCALE category +XCOMM +XLC_XLOCALE + +encoding_name ISCII-DEV +mb_cur_max 1 +state_depend_encoding False +#if WCHAR32 +wc_encoding_mask \x30000000 +wc_shift_bits 7 +#else +wc_encoding_mask \x00008080 +wc_shift_bits 8 +#endif + +XCOMM cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding ISCII-DEV:GL; ISO8859-1:GL +} + + +XCOMM cs1 class +cs1 { + side GR:Default + length 1 +#if WCHAR32 + wc_encoding \x30000000 +#else + wc_encoding \x00008080 +#endif + ct_encoding ISCII-DEV:GR; ISO8859-1:GR +} + +END XLC_XLOCALE diff --git a/xc/nls/XLC_LOCALE/isiri-3342 b/xc/nls/XLC_LOCALE/isiri-3342 new file mode 100644 index 000000000..5d6817afa --- /dev/null +++ b/xc/nls/XLC_LOCALE/isiri-3342 @@ -0,0 +1,58 @@ +XCOMM $XFree86: xc/nls/XLC_LOCALE/isiri-3342,v 1.1 2000/10/27 18:30:55 dawes Exp $ +XCOMM XLocale Database Sample for mulelao-1. +XCOMM + +XCOMM +XCOMM XLC_FONTSET category +XCOMM +XLC_FONTSET +XCOMM fs0 class (7 bit ASCII) +fs0 { + charset ISO8859-1:GL + font ISIRI-3342:GL; ISO8859-1:GL +} +XCOMM fs1 class +fs1 { + charset ISIRI-3342:GR + font ISIRI-3342:GR +} +END XLC_FONTSET + +XCOMM +XCOMM XLC_XLOCALE category +XCOMM +XLC_XLOCALE + +encoding_name ISIRI-3342 +mb_cur_max 1 +state_depend_encoding False +#if WCHAR32 +wc_encoding_mask \x30000000 +wc_shift_bits 7 +#else +wc_encoding_mask \x00008080 +wc_shift_bits 8 +#endif + +XCOMM cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding ISIRI-3342:GL; ISO8859-1:GL +} + + +XCOMM cs1 class +cs1 { + side GR:Default + length 1 +#if WCHAR32 + wc_encoding \x30000000 +#else + wc_encoding \x00008080 +#endif + ct_encoding ISIRI-3342:GR; ISO8859-1:GR +} + +END XLC_XLOCALE diff --git a/xc/nls/XLC_LOCALE/iso8859-13 b/xc/nls/XLC_LOCALE/iso8859-13 new file mode 100644 index 000000000..4faa32923 --- /dev/null +++ b/xc/nls/XLC_LOCALE/iso8859-13 @@ -0,0 +1,74 @@ +XCOMM $TOG: iso8859-13 /main/1 1998/05/20 13:49:21 kaleb $ +XCOMM XLocale Database Sample for iso8859-13. +XCOMM +XCOMM $XFree86: xc/nls/XLC_LOCALE/iso8859-13,v 1.1 2000/10/27 18:30:56 dawes Exp $ + +XCOMM +XCOMM XLC_FONTSET category +XCOMM +XLC_FONTSET +XCOMM fs0 class +fs0 { + charset { + name ISO8859-1:GL + } + font { + primary ISO8859-13:GL + substitute ISO8859-1:GL + vertical_rotate all + } +} +XCOMM fs1 class +fs1 { + charset { + name ISO8859-13:GR + } + font { + primary ISO8859-13:GR + } +} +END XLC_FONTSET + +XCOMM +XCOMM XLC_XLOCALE category +XCOMM +XLC_XLOCALE + +encoding_name ISO8859-13 +mb_cur_max 1 +state_depend_encoding False +#if WCHAR32 +wc_encoding_mask \x30000000 +wc_shift_bits 7 +#else +wc_encoding_mask \x00008080 +wc_shift_bits 8 +#endif + +#ifndef X_LOCALE +use_stdc_env True +force_convert_to_mb True +#endif + +XCOMM cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding ISO8859-13:GL; ISO8859-1:GL +} + + +XCOMM cs1 class +cs1 { + side GR:Default + length 1 +#if WCHAR32 + wc_encoding \x30000000 +#else + wc_encoding \x00008080 +#endif + ct_encoding ISO8859-13:GR +} + +END XLC_XLOCALE diff --git a/xc/nls/XLC_LOCALE/iso8859-9e b/xc/nls/XLC_LOCALE/iso8859-9e new file mode 100644 index 000000000..3b0e5a8d1 --- /dev/null +++ b/xc/nls/XLC_LOCALE/iso8859-9e @@ -0,0 +1,74 @@ +XCOMM $XConsortium: iso8859-9e /main/7 1996/09/28 16:51:50 rws $ +XCOMM XLocale Database Sample for iso8859-9e. +XCOMM +XCOMM $XFree86: xc/nls/XLC_LOCALE/iso8859-9e,v 1.2 2000/10/28 00:34:03 dawes Exp $ + +XCOMM +XCOMM XLC_FONTSET category +XCOMM +XLC_FONTSET +XCOMM fs0 class +fs0 { + charset { + name ISO8859-1:GL + } + font { + primary ISO8859-9E:GL + substitute ISO8859-1:GL + vertical_rotate all + } +} +XCOMM fs1 class +fs1 { + charset { + name ISO8859-9E:GR + } + font { + primary ISO8859-9E:GR + } +} +END XLC_FONTSET + +XCOMM +XCOMM XLC_XLOCALE category +XCOMM +XLC_XLOCALE + +encoding_name ISO8859-9E +mb_cur_max 1 +state_depend_encoding False +#if WCHAR32 +wc_encoding_mask \x30000000 +wc_shift_bits 7 +#else +wc_encoding_mask \x00008080 +wc_shift_bits 8 +#endif + +#ifndef X_LOCALE +use_stdc_env True +force_convert_to_mb True +#endif + +XCOMM cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding ISO8859-9E:GL; ISO8859-1:GL +} + + +XCOMM cs1 class +cs1 { + side GR:Default + length 1 +#if WCHAR32 + wc_encoding \x30000000 +#else + wc_encoding \x00008080 +#endif + ct_encoding ISO8859-9E:GR +} + +END XLC_XLOCALE diff --git a/xc/nls/XLC_LOCALE/koi8-c b/xc/nls/XLC_LOCALE/koi8-c new file mode 100644 index 000000000..ffe2b2ec1 --- /dev/null +++ b/xc/nls/XLC_LOCALE/koi8-c @@ -0,0 +1,58 @@ +XCOMM $XFree86: xc/nls/XLC_LOCALE/koi8-c,v 1.1 2000/10/27 18:30:56 dawes Exp $ +XCOMM XLocale Database Sample for koi8-c. +XCOMM + +XCOMM +XCOMM XLC_FONTSET category +XCOMM +XLC_FONTSET +XCOMM fs0 class (7 bit ASCII) +fs0 { + charset ISO8859-1:GL + font KOI8-C:GL; ISO8859-1:GL +} +XCOMM fs1 class +fs1 { + charset KOI8-C:GR + font KOI8-C:GR +} +END XLC_FONTSET + +XCOMM +XCOMM XLC_XLOCALE category +XCOMM +XLC_XLOCALE + +encoding_name KOI8-C +mb_cur_max 1 +state_depend_encoding False +#if WCHAR32 +wc_encoding_mask \x30000000 +wc_shift_bits 7 +#else +wc_encoding_mask \x00008080 +wc_shift_bits 8 +#endif + +XCOMM cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding KOI8-C:GL; ISO8859-1:GL +} + + +XCOMM cs1 class +cs1 { + side GR:Default + length 1 +#if WCHAR32 + wc_encoding \x30000000 +#else + wc_encoding \x00008080 +#endif + ct_encoding KOI8-C:GR; ISO8859-1:GR +} + +END XLC_XLOCALE diff --git a/xc/nls/XLC_LOCALE/microsoft-cp1251 b/xc/nls/XLC_LOCALE/microsoft-cp1251 new file mode 100644 index 000000000..98a3ffad2 --- /dev/null +++ b/xc/nls/XLC_LOCALE/microsoft-cp1251 @@ -0,0 +1,74 @@ +XCOMM $TOG: microsoft-cp1251 /main/1 1998/05/20 14:49:21 kaleb $ +XCOMM XLocale Database Sample for microsoft-cp1251. +XCOMM +XCOMM $XFree86: xc/nls/XLC_LOCALE/microsoft-cp1251,v 1.1 2000/10/27 18:30:56 dawes Exp $ + +XCOMM +XCOMM XLC_FONTSET category +XCOMM +XLC_FONTSET +XCOMM fs0 class +fs0 { + charset { + name ISO8859-1:GL + } + font { + primary MICROSOFT-CP1251:GL + substitute ISO8859-1:GL + vertical_rotate all + } +} +XCOMM fs1 class +fs1 { + charset { + name MICROSOFT-CP1251:GR + } + font { + primary MICROSOFT-CP1251:GR + } +} +END XLC_FONTSET + +XCOMM +XCOMM XLC_XLOCALE category +XCOMM +XLC_XLOCALE + +encoding_name MICROSOFT-CP1251 +mb_cur_max 1 +state_depend_encoding False +#if WCHAR32 +wc_encoding_mask \x30000000 +wc_shift_bits 7 +#else +wc_encoding_mask \x00008080 +wc_shift_bits 8 +#endif + +#ifndef X_LOCALE +use_stdc_env True +force_convert_to_mb True +#endif + +XCOMM cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding MICROSOFT-CP1251:GL; ISO8859-1:GL +} + + +XCOMM cs1 class +cs1 { + side GR:Default + length 1 +#if WCHAR32 + wc_encoding \x30000000 +#else + wc_encoding \x00008080 +#endif + ct_encoding MICROSOFT-CP1251:GR +} + +END XLC_XLOCALE diff --git a/xc/nls/XLC_LOCALE/microsoft-cp1255 b/xc/nls/XLC_LOCALE/microsoft-cp1255 new file mode 100644 index 000000000..ad84b5edd --- /dev/null +++ b/xc/nls/XLC_LOCALE/microsoft-cp1255 @@ -0,0 +1,74 @@ +XCOMM $TOG: microsoft-cp1255 /main/1 1998/05/20 14:49:21 kaleb $ +XCOMM XLocale Database Sample for microsoft-cp1255. +XCOMM +XCOMM $XFree86: xc/nls/XLC_LOCALE/microsoft-cp1255,v 1.1 2000/10/27 18:30:56 dawes Exp $ + +XCOMM +XCOMM XLC_FONTSET category +XCOMM +XLC_FONTSET +XCOMM fs0 class +fs0 { + charset { + name ISO8859-1:GL + } + font { + primary MICROSOFT-CP1255:GL + substitute ISO8859-1:GL + vertical_rotate all + } +} +XCOMM fs1 class +fs1 { + charset { + name MICROSOFT-CP1255:GR + } + font { + primary MICROSOFT-CP1255:GR + } +} +END XLC_FONTSET + +XCOMM +XCOMM XLC_XLOCALE category +XCOMM +XLC_XLOCALE + +encoding_name MICROSOFT-CP1255 +mb_cur_max 1 +state_depend_encoding False +#if WCHAR32 +wc_encoding_mask \x30000000 +wc_shift_bits 7 +#else +wc_encoding_mask \x00008080 +wc_shift_bits 8 +#endif + +#ifndef X_LOCALE +use_stdc_env True +force_convert_to_mb True +#endif + +XCOMM cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding MICROSOFT-CP1255:GL; ISO8859-1:GL +} + + +XCOMM cs1 class +cs1 { + side GR:Default + length 1 +#if WCHAR32 + wc_encoding \x30000000 +#else + wc_encoding \x00008080 +#endif + ct_encoding MICROSOFT-CP1255:GR +} + +END XLC_XLOCALE diff --git a/xc/nls/XLC_LOCALE/microsoft-cp1256 b/xc/nls/XLC_LOCALE/microsoft-cp1256 new file mode 100644 index 000000000..661af1066 --- /dev/null +++ b/xc/nls/XLC_LOCALE/microsoft-cp1256 @@ -0,0 +1,74 @@ +XCOMM $TOG: microsoft-cp1256 /main/1 1998/05/20 14:49:21 kaleb $ +XCOMM XLocale Database Sample for microsoft-cp1256. +XCOMM +XCOMM $XFree86: xc/nls/XLC_LOCALE/microsoft-cp1256,v 1.1 2000/10/27 18:30:57 dawes Exp $ + +XCOMM +XCOMM XLC_FONTSET category +XCOMM +XLC_FONTSET +XCOMM fs0 class +fs0 { + charset { + name ISO8859-1:GL + } + font { + primary MICROSOFT-CP1256:GL + substitute ISO8859-1:GL + vertical_rotate all + } +} +XCOMM fs1 class +fs1 { + charset { + name MICROSOFT-CP1256:GR + } + font { + primary MICROSOFT-CP1256:GR + } +} +END XLC_FONTSET + +XCOMM +XCOMM XLC_XLOCALE category +XCOMM +XLC_XLOCALE + +encoding_name MICROSOFT-CP1256 +mb_cur_max 1 +state_depend_encoding False +#if WCHAR32 +wc_encoding_mask \x30000000 +wc_shift_bits 7 +#else +wc_encoding_mask \x00008080 +wc_shift_bits 8 +#endif + +#ifndef X_LOCALE +use_stdc_env True +force_convert_to_mb True +#endif + +XCOMM cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding MICROSOFT-CP1256:GL; ISO8859-1:GL +} + + +XCOMM cs1 class +cs1 { + side GR:Default + length 1 +#if WCHAR32 + wc_encoding \x30000000 +#else + wc_encoding \x00008080 +#endif + ct_encoding MICROSOFT-CP1256:GR +} + +END XLC_XLOCALE diff --git a/xc/nls/XLC_LOCALE/nokhchi-1 b/xc/nls/XLC_LOCALE/nokhchi-1 new file mode 100644 index 000000000..8ff4933ed --- /dev/null +++ b/xc/nls/XLC_LOCALE/nokhchi-1 @@ -0,0 +1,58 @@ +XCOMM $XFree86: xc/nls/XLC_LOCALE/nokhchi-1,v 1.1 2000/10/27 18:30:57 dawes Exp $ +XCOMM XLocale Database Sample for mulelao-1. +XCOMM + +XCOMM +XCOMM XLC_FONTSET category +XCOMM +XLC_FONTSET +XCOMM fs0 class (7 bit ASCII) +fs0 { + charset ISO8859-1:GL + font NOKHCHI-1:GL; ISO8859-1:GL +} +XCOMM fs1 class +fs1 { + charset NOKHCHI-1:GR + font NOKHCHI-1:GR +} +END XLC_FONTSET + +XCOMM +XCOMM XLC_XLOCALE category +XCOMM +XLC_XLOCALE + +encoding_name NOKHCHI-1 +mb_cur_max 1 +state_depend_encoding False +#if WCHAR32 +wc_encoding_mask \x30000000 +wc_shift_bits 7 +#else +wc_encoding_mask \x00008080 +wc_shift_bits 8 +#endif + +XCOMM cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding NOKHCHI-1:GL; ISO8859-1:GL +} + + +XCOMM cs1 class +cs1 { + side GR:Default + length 1 +#if WCHAR32 + wc_encoding \x30000000 +#else + wc_encoding \x00008080 +#endif + ct_encoding NOKHCHI-1:GR; ISO8859-1:GR +} + +END XLC_XLOCALE diff --git a/xc/nls/XLC_LOCALE/tatar-cyr b/xc/nls/XLC_LOCALE/tatar-cyr new file mode 100644 index 000000000..b1960dee0 --- /dev/null +++ b/xc/nls/XLC_LOCALE/tatar-cyr @@ -0,0 +1,74 @@ +XCOMM $TOG: tatar-cyr /main/1 1998/05/20 14:49:21 kaleb $ +XCOMM XLocale Database Sample for tatar-cyr. +XCOMM +XCOMM $XFree86: xc/nls/XLC_LOCALE/tatar-cyr,v 1.1 2000/10/27 18:30:57 dawes Exp $ + +XCOMM +XCOMM XLC_FONTSET category +XCOMM +XLC_FONTSET +XCOMM fs0 class +fs0 { + charset { + name ISO8859-1:GL + } + font { + primary TATAR-CYR:GL + substitute ISO8859-1:GL + vertical_rotate all + } +} +XCOMM fs1 class +fs1 { + charset { + name TATAR-CYR:GR + } + font { + primary TATAR-CYR:GR + } +} +END XLC_FONTSET + +XCOMM +XCOMM XLC_XLOCALE category +XCOMM +XLC_XLOCALE + +encoding_name TATAR-CYR +mb_cur_max 1 +state_depend_encoding False +#if WCHAR32 +wc_encoding_mask \x30000000 +wc_shift_bits 7 +#else +wc_encoding_mask \x00008080 +wc_shift_bits 8 +#endif + +#ifndef X_LOCALE +use_stdc_env True +force_convert_to_mb True +#endif + +XCOMM cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding TATAR-CYR:GL; ISO8859-1:GL +} + + +XCOMM cs1 class +cs1 { + side GR:Default + length 1 +#if WCHAR32 + wc_encoding \x30000000 +#else + wc_encoding \x00008080 +#endif + ct_encoding TATAR-CYR:GR +} + +END XLC_XLOCALE diff --git a/xc/nls/XLC_LOCALE/tscii-0 b/xc/nls/XLC_LOCALE/tscii-0 new file mode 100644 index 000000000..05197e899 --- /dev/null +++ b/xc/nls/XLC_LOCALE/tscii-0 @@ -0,0 +1,58 @@ +XCOMM $XFree86: xc/nls/XLC_LOCALE/tscii-0,v 1.1 2000/10/27 18:30:57 dawes Exp $ +XCOMM XLocale Database Sample for mulelao-1. +XCOMM + +XCOMM +XCOMM XLC_FONTSET category +XCOMM +XLC_FONTSET +XCOMM fs0 class (7 bit ASCII) +fs0 { + charset ISO8859-1:GL + font TSCII-0:GL; ISO8859-1:GL +} +XCOMM fs1 class +fs1 { + charset TSCII-0:GR + font TSCII-0:GR +} +END XLC_FONTSET + +XCOMM +XCOMM XLC_XLOCALE category +XCOMM +XLC_XLOCALE + +encoding_name TSCII-0 +mb_cur_max 1 +state_depend_encoding False +#if WCHAR32 +wc_encoding_mask \x30000000 +wc_shift_bits 7 +#else +wc_encoding_mask \x00008080 +wc_shift_bits 8 +#endif + +XCOMM cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding TSCII-0:GL; ISO8859-1:GL +} + + +XCOMM cs1 class +cs1 { + side GR:Default + length 1 +#if WCHAR32 + wc_encoding \x30000000 +#else + wc_encoding \x00008080 +#endif + ct_encoding TSCII-0:GR; ISO8859-1:GR +} + +END XLC_XLOCALE diff --git a/xc/programs/Xserver/fb/fbcompose.c b/xc/programs/Xserver/fb/fbcompose.c new file mode 100644 index 000000000..b4f55c69e --- /dev/null +++ b/xc/programs/Xserver/fb/fbcompose.c @@ -0,0 +1,1067 @@ +/* + * $XFree86: xc/programs/Xserver/fb/fbcompose.c,v 1.4 2000/10/13 02:37:47 tsi 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 "fb.h" +#include "picturestr.h" +#include "mipict.h" +#include "fbpict.h" + +/* + * General purpose compositing code optimized for minimal memory + * references + * + * All work is done on canonical ARGB values, functions for fetching + * and storing these exist for each format. + */ + +/* + * Combine src and mask using IN + */ +CARD32 +fbCombineMask (FbCompositeOperand *src, + FbCompositeOperand *msk) +{ + CARD32 x; + CARD16 a; + CARD16 t; + CARD32 m,n,o,p; + + if (!msk) + return (*src->fetch) (src->line, src->offset); + + a = (*msk->fetch) (msk->line, msk->offset) >> 24; + if (!a) + return 0; + + x = (*src->fetch) (src->line, src->offset); + if (a == 0xff) + return x; + + m = FbIn(x,0,a,t); + n = FbIn(x,8,a,t); + o = FbIn(x,16,a,t); + p = FbIn(x,24,a,t); + return m|n|o|p; +} + +/* + * Combine src and mask using IN, generating only the alpha component + */ +CARD32 +fbCombineMaskAlpha (FbCompositeOperand *src, + FbCompositeOperand *msk) +{ + CARD32 x; + CARD16 a; + CARD16 t; + + if (!msk) + return (*src->fetch) (src->line, src->offset); + + a = (*msk->fetch) (msk->line, msk->offset) >> 24; + if (!a) + return 0; + + x = (*src->fetch) (src->line, src->offset); + if (a == 0xff) + return x; + + return FbIn(x,24,a,t); +} + +/* + * All of the composing functions + */ +void +fbCombineClear (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + (*dst->store) (dst->line, dst->offset, 0); +} + +void +fbCombineSrc (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + (*dst->store) (dst->line, dst->offset, fbCombineMask (src, msk)); +} + +void +fbCombineDst (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + /* noop */ +} + +void +fbCombineOver (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + CARD32 s, d; + CARD16 a; + CARD16 t; + CARD32 m,n,o,p; + + s = fbCombineMask (src, msk); + a = ~s >> 24; + if (a != 0xff) + { + if (a) + { + d = (*dst->fetch) (dst->line, dst->offset); + m = FbOver(s,d,0,a,t); + n = FbOver(s,d,8,a,t); + o = FbOver(s,d,16,a,t); + p = FbOver(s,d,24,a,t); + s = m|n|o|p; + } + (*dst->store) (dst->line, dst->offset, s); + } +} + +void +fbCombineOverReverse (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + CARD32 s, d; + CARD16 a; + CARD16 t; + CARD32 m,n,o,p; + + d = (*dst->fetch) (dst->line, dst->offset); + a = ~d >> 24; + if (a) + { + s = fbCombineMask (src, msk); + if (a != 0xff) + { + m = FbOver(d,s,0,a,t); + n = FbOver(d,s,8,a,t); + o = FbOver(d,s,16,a,t); + p = FbOver(d,s,24,a,t); + s = m|n|o|p; + } + (*dst->store) (dst->line, dst->offset, s); + } +} + +void +fbCombineIn (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + CARD32 s, d; + CARD16 a; + CARD16 t; + CARD32 m,n,o,p; + + d = (*dst->fetch) (dst->line, dst->offset); + a = d >> 24; + s = 0; + if (a) + { + s = fbCombineMask (src, msk); + if (a != 0xff) + { + m = FbIn(s,0,a,t); + n = FbIn(s,8,a,t); + o = FbIn(s,16,a,t); + p = FbIn(s,24,a,t); + s = m|n|o|p; + } + } + (*dst->store) (dst->line, dst->offset, s); +} + +void +fbCombineInReverse (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + CARD32 s, d; + CARD16 a; + CARD16 t; + CARD32 m,n,o,p; + + s = fbCombineMaskAlpha (src, msk); + a = s >> 24; + if (a != 0xff) + { + d = 0; + if (a) + { + d = (*dst->fetch) (dst->line, dst->offset); + m = FbIn(d,0,a,t); + n = FbIn(d,8,a,t); + o = FbIn(d,16,a,t); + p = FbIn(d,24,a,t); + d = m|n|o|p; + } + (*dst->store) (dst->line, dst->offset, d); + } +} + +void +fbCombineOut (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + CARD32 s, d; + CARD16 a; + CARD16 t; + CARD32 m,n,o,p; + + d = (*dst->fetch) (dst->line, dst->offset); + a = ~d >> 24; + s = 0; + if (a) + { + s = fbCombineMask (src, msk); + if (a != 0xff) + { + m = FbIn(s,0,a,t); + n = FbIn(s,8,a,t); + o = FbIn(s,16,a,t); + p = FbIn(s,24,a,t); + s = m|n|o|p; + } + } + (*dst->store) (dst->line, dst->offset, s); +} + +void +fbCombineOutReverse (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + CARD32 s, d; + CARD16 a; + CARD16 t; + CARD32 m,n,o,p; + + s = fbCombineMaskAlpha (src, msk); + a = ~s >> 24; + if (a != 0xff) + { + d = 0; + if (a) + { + d = (*dst->fetch) (dst->line, dst->offset); + m = FbIn(d,0,a,t); + n = FbIn(d,8,a,t); + o = FbIn(d,16,a,t); + p = FbIn(d,24,a,t); + d = m|n|o|p; + } + (*dst->store) (dst->line, dst->offset, d); + } +} + +void +fbCombineAtop (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + CARD32 s, d; + CARD16 ad, as; + CARD16 t; + CARD32 m,n,o,p; + + s = fbCombineMask (src, msk); + d = (*dst->fetch) (dst->line, dst->offset); + ad = ~s >> 24; + as = d >> 24; + m = FbGen(s,d,0,as,ad,t); + n = FbGen(s,d,8,as,ad,t); + o = FbGen(s,d,16,as,ad,t); + p = FbGen(s,d,24,as,ad,t); + (*dst->store) (dst->line, dst->offset, m|n|o|p); +} + +void +fbCombineAtopReverse (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + CARD32 s, d; + CARD16 ad, as; + CARD16 t; + CARD32 m,n,o,p; + + s = fbCombineMask (src, msk); + d = (*dst->fetch) (dst->line, dst->offset); + ad = s >> 24; + as = ~d >> 24; + m = FbGen(s,d,0,as,ad,t); + n = FbGen(s,d,8,as,ad,t); + o = FbGen(s,d,16,as,ad,t); + p = FbGen(s,d,24,as,ad,t); + (*dst->store) (dst->line, dst->offset, m|n|o|p); +} + +void +fbCombineXor (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + CARD32 s, d; + CARD16 ad, as; + CARD16 t; + CARD32 m,n,o,p; + + s = fbCombineMask (src, msk); + d = (*dst->fetch) (dst->line, dst->offset); + ad = ~s >> 24; + as = ~d >> 24; + m = FbGen(s,d,0,as,ad,t); + n = FbGen(s,d,8,as,ad,t); + o = FbGen(s,d,16,as,ad,t); + p = FbGen(s,d,24,as,ad,t); + (*dst->store) (dst->line, dst->offset, m|n|o|p); +} + +void +fbCombineAdd (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + CARD32 s, d; + CARD16 t; + CARD32 m,n,o,p; + + s = fbCombineMask (src, msk); + if (s == ~0) + (*dst->store) (dst->line, dst->offset, s); + else + { + d = (*dst->fetch) (dst->line, dst->offset); + if (s && d != ~0) + { + m = FbAdd(s,d,0,t); + n = FbAdd(s,d,8,t); + o = FbAdd(s,d,16,t); + p = FbAdd(s,d,24,t); + (*dst->store) (dst->line, dst->offset, m|n|o|p); + } + } +} + +void +fbCombineSaturate (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst) +{ + CARD32 s, d; + CARD16 sa, da; + CARD16 ad, as; + CARD16 t; + CARD32 m,n,o,p; + + s = fbCombineMask (src, msk); + d = (*dst->fetch) (dst->line, dst->offset); + sa = s >> 24; + da = ~d >> 24; + if (sa <= da) + { + m = FbAdd(s,d,0,t); + n = FbAdd(s,d,8,t); + o = FbAdd(s,d,16,t); + p = FbAdd(s,d,24,t); + } + else + { + as = (da << 8) / sa; + ad = 0xff; + m = FbGen(s,d,0,as,ad,t); + n = FbGen(s,d,8,as,ad,t); + o = FbGen(s,d,16,as,ad,t); + p = FbGen(s,d,24,as,ad,t); + } + (*dst->store) (dst->line, dst->offset, m|n|o|p); +} + +FbCombineFunc fbCombineFunc[] = { + fbCombineClear, + fbCombineSrc, + fbCombineDst, + fbCombineOver, + fbCombineOverReverse, + fbCombineIn, + fbCombineInReverse, + fbCombineOut, + fbCombineOutReverse, + fbCombineAtop, + fbCombineAtopReverse, + fbCombineXor, + fbCombineAdd, + fbCombineSaturate, +}; + +/* + * All of the fetch functions + */ + +CARD32 +fbFetch_a8r8g8b8 (FbBits *line, CARD32 offset) +{ + return ((CARD32 *)line)[offset >> 5]; +} + +CARD32 +fbFetch_x8r8g8b8 (FbBits *line, CARD32 offset) +{ + return ((CARD32 *)line)[offset >> 5] | 0xff000000; +} + +CARD32 +fbFetch_a8b8g8r8 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD32 *)line)[offset >> 5]; + + return ((pixel & 0xff000000) | + ((pixel >> 16) & 0xff) | + (pixel & 0x0000ff00) | + ((pixel & 0xff) << 16)); +} + +CARD32 +fbFetch_x8b8g8r8 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD32 *)line)[offset >> 5]; + + return ((0xff000000) | + ((pixel >> 16) & 0xff) | + (pixel & 0x0000ff00) | + ((pixel & 0xff) << 16)); +} + +CARD32 +fbFetch_r8g8b8 (FbBits *line, CARD32 offset) +{ + CARD8 *pixel = ((CARD8 *) line) + (offset >> 3); +#if IMAGE_BYTE_ORDER == MSBFirst + return (0xff000000 | + (pixel[0] << 16) | + (pixel[1] << 8) | + (pixel[2])); +#else + return (0xff000000 | + (pixel[2] << 16) | + (pixel[1] << 8) | + (pixel[0])); +#endif +} + +CARD32 +fbFetch_b8g8r8 (FbBits *line, CARD32 offset) +{ + CARD8 *pixel = ((CARD8 *) line) + (offset >> 3); +#if IMAGE_BYTE_ORDER == MSBFirst + return (0xff000000 | + (pixel[2] << 16) | + (pixel[1] << 8) | + (pixel[0])); +#else + return (0xff000000 | + (pixel[0] << 16) | + (pixel[1] << 8) | + (pixel[2])); +#endif +} + +CARD32 +fbFetch_r5g6b5 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD16 *) line)[offset >> 4]; + CARD32 r,g,b; + + r = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) << 8; + g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5; + b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; + return (0xff000000 | r | g | b); +} + +CARD32 +fbFetch_b5g6r5 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD16 *) line)[offset >> 4]; + CARD32 r,g,b; + + b = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) >> 8; + g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5; + r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; + return (0xff000000 | r | g | b); +} + +CARD32 +fbFetch_a1r5g5b5 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD16 *) line)[offset >> 4]; + CARD32 a,r,g,b; + + a = (CARD32) ((CARD8) (0 - ((pixel & 0x8000) >> 15))) << 24; + r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9; + g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; + b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; + return (a | r | g | b); +} + +CARD32 +fbFetch_x1r5g5b5 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD16 *) line)[offset >> 4]; + CARD32 r,g,b; + + r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9; + g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; + b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; + return (0xff000000 | r | g | b); +} + +CARD32 +fbFetch_a1b5g5r5 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD16 *) line)[offset >> 4]; + CARD32 a,r,g,b; + + a = (CARD32) ((CARD8) (0 - ((pixel & 0x8000) >> 15))) << 24; + b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7; + g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; + r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; + return (a | r | g | b); +} + +CARD32 +fbFetch_x1b5g5r5 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD16 *) line)[offset >> 4]; + CARD32 r,g,b; + + b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7; + g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; + r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; + return (0xff000000 | r | g | b); +} + +CARD32 +fbFetch_a8 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD8 *) line)[offset>>3]; + + return pixel << 24; +} + +CARD32 +fbFetch_r3g3b2 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD8 *) line)[offset>>3]; + CARD32 r,g,b; + + r = ((pixel & 0xe0) | ((pixel & 0xe0) >> 3) | ((pixel & 0xc0) >> 6)) << 16; + g = ((pixel & 0x1c) | ((pixel & 0x18) >> 3) | ((pixel & 0x1c) << 3)) << 8; + b = (((pixel & 0x03) ) | + ((pixel & 0x03) << 2) | + ((pixel & 0x03) << 4) | + ((pixel & 0x03) << 6)); + return (0xff000000 | r | g | b); +} + +CARD32 +fbFetch_b2g3r3 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD8 *) line)[offset>>3]; + CARD32 r,g,b; + + b = (((pixel & 0xc0) ) | + ((pixel & 0xc0) >> 2) | + ((pixel & 0xc0) >> 4) | + ((pixel & 0xc0) >> 6)); + g = ((pixel & 0x38) | ((pixel & 0x38) >> 3) | ((pixel & 0x30) << 2)) << 8; + r = (((pixel & 0x07) ) | + ((pixel & 0x07) << 3) | + ((pixel & 0x06) << 6)) << 16; + return (0xff000000 | r | g | b); +} + +CARD32 +fbFetch_a2r2g2b2 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD8 *) line)[offset>>3]; + CARD32 a,r,g,b; + + a = ((pixel & 0xc0) * 0x55) << 18; + r = ((pixel & 0x30) * 0x55) << 12; + g = ((pixel & 0x0c) * 0x55) << 6; + b = ((pixel & 0x03) * 0x55); + return a|r|g|b; +} + +CARD32 +fbFetch_a2b2g2r2 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD8 *) line)[offset>>3]; + CARD32 a,r,g,b; + + a = ((pixel & 0xc0) * 0x55) << 18; + b = ((pixel & 0x30) * 0x55) >> 6; + g = ((pixel & 0x0c) * 0x55) << 6; + r = ((pixel & 0x03) * 0x55) << 16; + return a|r|g|b; +} + +#define Fetch8(l,o) (((CARD8 *) (l))[(o) >> 3]) +#if IMAGE_BYTE_ORDER == MSBFirst +#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4) +#else +#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) >> 4 : Fetch8(l,o) & 0xf) +#endif + +CARD32 +fbFetch_a4 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = Fetch4(line, offset); + return (pixel | pixel << 4) << 24; +} + +CARD32 +fbFetch_r1g2b1 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = Fetch4(line, offset); + CARD32 r,g,b; + + r = ((pixel & 0x8) * 0xff) << 13; + g = ((pixel & 0x6) * 0x55) << 7; + b = ((pixel & 0x1) * 0xff); + return 0xff000000|r|g|b; +} + +CARD32 +fbFetch_b1g2r1 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = Fetch4(line, offset); + CARD32 r,g,b; + + b = ((pixel & 0x8) * 0xff) >> 3; + g = ((pixel & 0x6) * 0x55) << 7; + r = ((pixel & 0x1) * 0xff) << 16; + return 0xff000000|r|g|b; +} + +CARD32 +fbFetch_a1r1g1b1 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = Fetch4(line, offset); + CARD32 a,r,g,b; + + a = ((pixel & 0x8) * 0xff) << 21; + r = ((pixel & 0x4) * 0xff) << 14; + g = ((pixel & 0x2) * 0xff) << 7; + b = ((pixel & 0x1) * 0xff); + return a|r|g|b; +} + +CARD32 +fbFetch_a1b1g1r1 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = Fetch4(line, offset); + CARD32 a,r,g,b; + + a = ((pixel & 0x8) * 0xff) << 21; + r = ((pixel & 0x4) * 0xff) >> 3; + g = ((pixel & 0x2) * 0xff) << 7; + b = ((pixel & 0x1) * 0xff) << 16; + return a|r|g|b; +} + +CARD32 +fbFetch_a1 (FbBits *line, CARD32 offset) +{ + CARD32 pixel = ((CARD32 *)line)[offset >> 5]; + CARD32 a; +#if BITMAP_BIT_ORDER == MSBFirst + a = pixel >> (0x1f - offset & 0x1f); +#else + a = pixel >> (offset & 0x1f); +#endif + a = ((a & 0x1) & 0xff) << 24; + return a; +} + +/* + * All the store functions + */ + +#define Splita(v) CARD32 a = ((v) >> 24), r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff +#define Split(v) CARD32 r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff + +void +fbStore_a8r8g8b8 (FbBits *line, CARD32 offset, CARD32 value) +{ + ((CARD32 *)line)[offset >> 5] = value; +} + +void +fbStore_x8r8g8b8 (FbBits *line, CARD32 offset, CARD32 value) +{ + ((CARD32 *)line)[offset >> 5] = value & 0xffffff; +} + +void +fbStore_a8b8g8r8 (FbBits *line, CARD32 offset, CARD32 value) +{ + Splita(value); + ((CARD32 *)line)[offset >> 5] = a << 24 | b << 16 | g << 8 | r; +} + +void +fbStore_x8b8g8r8 (FbBits *line, CARD32 offset, CARD32 value) +{ + Split(value); + ((CARD32 *)line)[offset >> 5] = b << 16 | g << 8 | r; +} + +void +fbStore_r8g8b8 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD8 *pixel = ((CARD8 *) line) + (offset >> 3); + Split(value); +#if IMAGE_BYTE_ORDER == MSBFirst + pixel[0] = r; + pixel[1] = g; + pixel[2] = b; +#else + pixel[0] = b; + pixel[1] = g; + pixel[2] = r; +#endif +} + +void +fbStore_b8g8r8 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD8 *pixel = ((CARD8 *) line) + (offset >> 3); + Split(value); +#if IMAGE_BYTE_ORDER == MSBFirst + pixel[0] = b; + pixel[1] = g; + pixel[2] = r; +#else + pixel[0] = r; + pixel[1] = g; + pixel[2] = b; +#endif +} + +void +fbStore_r5g6b5 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD16 *pixel = ((CARD16 *) line) + (offset >> 4); + Split(value); + *pixel = (((r << 8) & 0xf800) | + ((g << 3) & 0x07e0) | + ((b >> 3) )); +} + +void +fbStore_b5g6r5 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD16 *pixel = ((CARD16 *) line) + (offset >> 4); + Split(value); + *pixel = (((b << 8) & 0xf800) | + ((g << 3) & 0x07e0) | + ((r >> 3) )); +} + +void +fbStore_a1r5g5b5 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD16 *pixel = ((CARD16 *) line) + (offset >> 4); + Splita(value); + *pixel = (((a << 8) & 0x8000) | + ((r << 7) & 0x7c00) | + ((g << 2) & 0x03e0) | + ((b >> 3) )); +} + +void +fbStore_x1r5g5b5 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD16 *pixel = ((CARD16 *) line) + (offset >> 4); + Split(value); + *pixel = (((r << 7) & 0x7c00) | + ((g << 2) & 0x03e0) | + ((b >> 3) )); +} + +void +fbStore_a1b5g5r5 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD16 *pixel = ((CARD16 *) line) + (offset >> 4); + Splita(value); + *pixel = (((a << 8) & 0x8000) | + ((b << 7) & 0x7c00) | + ((g << 2) & 0x03e0) | + ((r >> 3) )); +} + +void +fbStore_x1b5g5r5 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD16 *pixel = ((CARD16 *) line) + (offset >> 4); + Split(value); + *pixel = (((b << 7) & 0x7c00) | + ((g << 2) & 0x03e0) | + ((r >> 3) )); +} + +void +fbStore_a8 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD8 *pixel = ((CARD8 *) line) + (offset >> 3); + *pixel = value >> 24; +} + +void +fbStore_r3g3b2 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD8 *pixel = ((CARD8 *) line) + (offset >> 3); + Split(value); + *pixel = (((r ) & 0xe0) | + ((g >> 3) & 0x1c) | + ((b >> 6) )); +} + +void +fbStore_b2g3r3 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD8 *pixel = ((CARD8 *) line) + (offset >> 3); + Split(value); + *pixel = (((b ) & 0xe0) | + ((g >> 3) & 0x1c) | + ((r >> 6) )); +} + +void +fbStore_a2r2g2b2 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD8 *pixel = ((CARD8 *) line) + (offset >> 3); + Splita(value); + *pixel = (((a ) & 0xc0) | + ((r >> 2) & 0x30) | + ((g >> 4) & 0x0c) | + ((b >> 6) )); +} + +#define Store8(l,o,v) (((CARD8 *) l)[(o) >> 3] = (v)) +#if IMAGE_BYTE_ORDER == MSBFirst +#define Store4(l,o,v) Store8(l,o,((o) & 2 ? \ + Fetch8(l,o) & 0xf0 | (v) : \ + Fetch8(l,o) & 0x0f | ((v) << 4))) +#else +#define Store4(l,o,v) Store8(l,o,((o) & 2 ? \ + Fetch8(l,o) & 0x0f | ((v) << 4) : \ + Fetch8(l,o) & 0xf0 | (v))) +#endif + +void +fbStore_a4 (FbBits *line, CARD32 offset, CARD32 value) +{ + Store4(line,offset,value>>28); +} + +void +fbStore_r1g2b1 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD32 pixel; + + Split(value); + pixel = (((r >> 4) & 0x8) | + ((g >> 5) & 0x6) | + ((b >> 7) )); + Store4(line,offset,pixel); +} + +void +fbStore_b1g2r1 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD32 pixel; + + Split(value); + pixel = (((b >> 4) & 0x8) | + ((g >> 5) & 0x6) | + ((r >> 7) )); + Store4(line,offset,pixel); +} + +void +fbStore_a1r1g1b1 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD32 pixel; + Splita(value); + pixel = (((a >> 4) & 0x8) | + ((r >> 5) & 0x4) | + ((g >> 6) & 0x2) | + ((b >> 7) )); + Store4(line,offset,pixel); +} + +void +fbStore_a1b1g1r1 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD32 pixel; + Splita(value); + pixel = (((a >> 4) & 0x8) | + ((b >> 5) & 0x4) | + ((g >> 6) & 0x2) | + ((r >> 7) )); + Store4(line,offset,pixel); +} + +void +fbStore_a1 (FbBits *line, CARD32 offset, CARD32 value) +{ + CARD32 *pixel = ((CARD32 *) line) + (offset >> 5); + CARD32 mask = FbStipMask(offset & 0x1f, 1); + + value = value & 0x80000000 ? mask : 0; + *pixel = *pixel & ~mask | value; +} + +FbAccessMap fbAccessMap[] = { + /* 32bpp formats */ + PICT_a8r8g8b8, fbFetch_a8r8g8b8, fbStore_a8r8g8b8, + PICT_x8r8g8b8, fbFetch_x8r8g8b8, fbStore_x8r8g8b8, + PICT_a8b8g8r8, fbFetch_a8b8g8r8, fbStore_a8b8g8r8, + PICT_x8b8g8r8, fbFetch_x8b8g8r8, fbStore_x8b8g8r8, + + /* 24bpp formats */ + PICT_r8g8b8, fbFetch_r8g8b8, fbStore_r8g8b8, + PICT_b8g8r8, fbFetch_b8g8r8, fbStore_b8g8r8, + + /* 16bpp formats */ + PICT_r5g6b5, fbFetch_r5g6b5, fbStore_r5g6b5, + PICT_b5g6r5, fbFetch_b5g6r5, fbStore_b5g6r5, + + PICT_a1r5g5b5, fbFetch_a1r5g5b5, fbStore_a1r5g5b5, + PICT_x1r5g5b5, fbFetch_x1r5g5b5, fbStore_x1r5g5b5, + PICT_a1b5g5r5, fbFetch_a1b5g5r5, fbStore_a1b5g5r5, + PICT_x1b5g5r5, fbFetch_x1b5g5r5, fbStore_x1b5g5r5, + + /* 8bpp formats */ + PICT_a8, fbFetch_a8, fbStore_a8, + PICT_r3g3b2, fbFetch_r3g3b2, fbStore_r3g3b2, + PICT_b2g3r3, fbFetch_b2g3r3, fbStore_b2g3r3, + PICT_a2r2g2b2, fbFetch_a2r2g2b2, fbStore_a2r2g2b2, + + /* 4bpp formats */ + PICT_a4, fbFetch_a4, fbStore_a4, + PICT_r1g2b1, fbFetch_r1g2b1, fbStore_r1g2b1, + PICT_b1g2r1, fbFetch_b1g2r1, fbStore_b1g2r1, + PICT_a1r1g1b1, fbFetch_a1r1g1b1, fbStore_a1r1g1b1, + PICT_a1b1g1r1, fbFetch_a1b1g1r1, fbStore_a1b1g1r1, + + /* 1bpp formats */ + PICT_a1, fbFetch_a1, fbStore_a1, +}; +#define NumAccessMap (sizeof fbAccessMap / sizeof fbAccessMap[0]) + +Bool +fbBuildCompositeOperand (PicturePtr pPict, + FbCompositeOperand *op, + INT16 x, + INT16 y) +{ + int i; + + for (i = 0; i < NumAccessMap; i++) + if (fbAccessMap[i].format == pPict->format) + { + op->fetch = fbAccessMap[i].fetch; + op->store = fbAccessMap[i].store; + fbGetDrawable (pPict->pDrawable, op->line, op->stride, op->bpp); + op->line = op->line + y * op->stride; + op->offset = 0; + return TRUE; + } + return FALSE; +} + +void +fbCompositeGeneral (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) +{ + FbCompositeOperand src,msk,dst,*pmsk; + FbCombineFunc f; + int w; + + if (!fbBuildCompositeOperand (pSrc, &src, xSrc, ySrc)) + return; + if (!fbBuildCompositeOperand (pDst, &dst, xDst, yDst)) + return; + if (pMask) + { + if (!fbBuildCompositeOperand (pMask, &msk, xMask, yMask)) + return; + pmsk = &msk; + } + else + pmsk = 0; + f = fbCombineFunc[op]; + while (height--) + { + w = width; + src.offset = xSrc * src.bpp; + dst.offset = xDst * dst.bpp; + if (pmsk) + msk.offset = xMask * msk.bpp; + while (w--) + { + (*f) (&src, pmsk, &dst); + src.offset += src.bpp; + dst.offset += dst.bpp; + if (pmsk) + msk.offset += msk.bpp; + } + src.line += src.stride; + dst.line += dst.stride; + if (pmsk) + msk.line += msk.stride; + } + +} diff --git a/xc/programs/Xserver/fb/fbpict.h b/xc/programs/Xserver/fb/fbpict.h new file mode 100644 index 000000000..00b2dacee --- /dev/null +++ b/xc/programs/Xserver/fb/fbpict.h @@ -0,0 +1,447 @@ +/* + * $XFree86: xc/programs/Xserver/fb/fbpict.h,v 1.1 2000/10/02 05:25:46 keithp 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. + */ + +#ifndef _FBPICT_H_ +#define _FBPICT_H_ + +#define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) ) +#define FbGet8(v,i) ((CARD16) (CARD8) ((v) >> i)) +#define FbOver(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),(a),(t)) + FbGet8(x,i),\ + (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i)) +#define FbIn(x,i,a,t) ((CARD32) FbIntMult(FbGet8(x,i),(a),(t)) << (i)) +#define FbGen(x,y,i,ax,ay,t) ((t) = (FbIntMult(FbGet8(y,i),(ay),(t)) + \ + FbIntMult(FbGet8(x,i),(ax),(t))),\ + (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i)) +#define FbAdd(x,y,i,t) ((t) = FbGet8(x,i) + FbGet8(y,i), \ + (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i)) + + +typedef void (*CompositeFunc) (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height); + +typedef CARD32 (*FbCompositeFetch)(FbBits *line, CARD32 offset); +typedef void (*FbCompositeStore) (FbBits *line, CARD32 offset, CARD32 value); + +typedef struct _FbCompositeOperand { + FbBits *line; + CARD32 offset; + FbStride stride; + int bpp; + FbCompositeFetch fetch; + FbCompositeStore store; +} FbCompositeOperand; + +typedef void (*FbCombineFunc) (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +/* + * indexed by op + */ +extern FbCombineFunc fbCombineFunc[]; + +typedef struct _FbAccessMap { + CARD32 format; + FbCompositeFetch fetch; + FbCompositeStore store; +} FbAccessMap; + +/* + * search on format + */ +extern FbAccessMap fbAccessMap[]; + +/* fbcompose.c */ + +/* + * All compositing operators * + */ + +CARD32 +FbCombineMask (FbCompositeOperand *src, + FbCompositeOperand *msk); + +void +FbCombineClear (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +void +FbCombineSrc (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +void +FbCombineDst (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +void +FbCombineOver (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +void +FbCombineOverReverse (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +void +FbCombineIn (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +void +FbCombineInReverse (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +void +FbCombineOut (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +void +FbCombineOutReverse (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +void +FbCombineAtop (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +void +FbCombineAtopReverse (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +void +FbCombineXor (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +void +FbCombineAdd (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + +void +FbCombineSaturate (FbCompositeOperand *src, + FbCompositeOperand *msk, + FbCompositeOperand *dst); + + +/* + * All fetch functions + */ + +CARD32 +fbFetch_a8r8g8b8 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_x8r8g8b8 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_a8b8g8r8 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_x8b8g8r8 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_r8g8b8 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_b8g8r8 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_r5g6b5 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_b5g6r5 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_a1r5g5b5 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_x1r5g5b5 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_a1b5g5r5 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_x1b5g5r5 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_a8 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_r3g3b2 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_b2g3r3 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_a2r2g2b2 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_a2b2g2r2 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_a4 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_r1g2b1 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_b1g2r1 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_a1r1g1b1 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_a1b1g1r1 (FbBits *line, CARD32 offset); + +CARD32 +fbFetch_a1 (FbBits *line, CARD32 offset); + +void +fbStore_a8r8g8b8 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_x8r8g8b8 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_a8b8g8r8 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_x8b8g8r8 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_r8g8b8 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_b8g8r8 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_r5g6b5 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_b5g6r5 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_a1r5g5b5 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_x1r5g5b5 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_a1b5g5r5 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_x1b5g5r5 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_a8 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_r3g3b2 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_b2g3r3 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_a2r2g2b2 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_a4 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_r1g2b1 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_b1g2r1 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_a1r1g1b1 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_a1b1g1r1 (FbBits *line, CARD32 offset, CARD32 value); + +void +fbStore_a1 (FbBits *line, CARD32 offset, CARD32 value); + +Bool +fbBuildCompositeOperand (PicturePtr pPict, + FbCompositeOperand *op, + INT16 x, + INT16 y); +void +fbCompositeGeneral (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height); + + +/* fbpict.c */ +CARD32 +fbOver (CARD32 x, CARD32 y); + +CARD32 +fbIn (CARD32 x, CARD8 y); + +void +fbCompositeSolidMask_nx8x8888 (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 +fbCompositeSolidMask_nx8x0888 (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 +fbCompositeSolidMask_nx8x0565 (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 +fbCompositeSrc_8888x8888 (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 +fbCompositeSrc_8888x0888 (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 +fbCompositeSrc_8888x0565 (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 +fbCompositeSrc_0565x0565 (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 +fbComposite (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 +fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats); + +#endif /* _FBPICT_H_ */ diff --git a/xc/programs/Xserver/hw/kdrive/linux/ts.c b/xc/programs/Xserver/hw/kdrive/linux/ts.c new file mode 100644 index 000000000..3d7254534 --- /dev/null +++ b/xc/programs/Xserver/hw/kdrive/linux/ts.c @@ -0,0 +1,104 @@ +/* + * $XFree86: xc/programs/Xserver/hw/kdrive/linux/ts.c,v 1.2 2000/09/26 15:57:04 tsi Exp $ + * + * Derived from ps2.c by Jim Gettys + * + * Copyright © 1999 Keith Packard + * Copyright © 2000 Compaq Computer Corporation + * + * 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 or Compaq not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard and Compaq makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD AND COMPAQ DISCLAIM 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. + */ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "scrnintstr.h" +#include "kdrive.h" +#include "Xpoll.h" +#include <sys/ioctl.h> +#include <linux/h3600_ts.h> /* touch screen events */ + +void +TsRead (int tsPort) +{ + TS_EVENT event; + long buf[3]; + int n; + long pressure; + long x, y; + unsigned long flags; + unsigned long buttons; + + n = Ps2ReadBytes (tsPort, (char *) &event, + sizeof (event), sizeof (event)); + if (n == sizeof (event)) + { + if (event.pressure) + { + flags = KD_BUTTON_1; + x = event.x; + y = event.y; + } + else { + flags = KD_MOUSE_DELTA; + x = 0; + y = 0; + } + KdEnqueueMouseEvent (flags, x, y); + } +} + + +char *TsNames[] = { + "/dev/ts", + "/dev/h3600_ts" /* temporary name; note this code can try + to open more than one device */ +}; + +#define NUM_TS_NAMES (sizeof (TsNames) / sizeof (TsNames[0])) + +int +TsInit (void) +{ + int i; + int TsPort; + + for (i = 0; i < NUM_TS_NAMES; i++) + { + TsPort = open (TsNames[i], 0); + if (TsPort >= 0) + return TsPort; + } + perror("Touch screen not found.\n"); + exit (1); +} + +void +TsFini (int tsPort) +{ + if (tsPort >= 0) + close (tsPort); +} + +KdTsFuncs TsFuncs = { + TsInit, + TsRead, + TsFini +}; diff --git a/xc/programs/Xserver/hw/kdrive/vesa/vga.c b/xc/programs/Xserver/hw/kdrive/vesa/vga.c new file mode 100644 index 000000000..3d06e35ec --- /dev/null +++ b/xc/programs/Xserver/hw/kdrive/vesa/vga.c @@ -0,0 +1,240 @@ +/* + * $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vga.c,v 1.1 2000/10/20 00:19:51 keithp 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 "vesa.h" + +static const VesaModeRec vgaModes[] = { + { + 6, 0, + MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_LINEAR, + 1, 1, MEMORY_PLANAR, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 640, 200, 80, + }, + { + 0xd, 0, + MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR, + 4, 4, MEMORY_PLANAR, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 320, 200, 40, + }, + { + 0xe, 0, + MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR, + 4, 4, MEMORY_PLANAR, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 640, 200, 80, + }, + { + 0x10, 0, + MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR, + 4, 4, MEMORY_PLANAR, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 640, 350, 80, + }, + { + 0x11, 0, + MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_LINEAR, + 1, 1, MEMORY_PLANAR, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 640, 480, 80, + }, + { + 0x12, 0, + MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR, + 4, 4, MEMORY_PLANAR, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 640, 480, 80, + }, + { + 0x13, 0, + MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR | MODE_LINEAR, + 8, 8, MEMORY_PSEUDO, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 320, 200, 320, + }, +}; + +#define NUM_VGA_MODE (sizeof vgaModes / sizeof vgaModes[0]) + +int +VgaGetNmode (Vm86InfoPtr vi) +{ + return NUM_VGA_MODE; +} + +int +VgaGetModes (Vm86InfoPtr vi, VesaModePtr mode, int nmode) +{ + if (nmode > NUM_VGA_MODE) + nmode = NUM_VGA_MODE; + memcpy (mode, vgaModes, nmode * sizeof (VesaModeRec)); + return nmode; +} + +int +VgaSetMode(Vm86InfoPtr vi, int mode) +{ + int code; + + vi->vms.regs.eax = mode & 0x7f; + code = Vm86DoInterrupt (vi, 0x10); + if(code < 0) + return -1; + return 0; +} + +int +VgaGetMode (Vm86InfoPtr vi, int *mode) +{ + *mode = Vm86Memory (vi, 0x449); + return 0; +} + +int +VgaSetWritePlaneMask(Vm86InfoPtr vi, int mask) +{ + asm volatile ("outb %b0,%w1" : : "a" (2), "d" (0x3c4)); + asm volatile ("outb %b0,%w1" : : "a" (mask), "d" (0x3c5)); +} + +int +VgaSetReadPlaneMap(Vm86InfoPtr vi, int map) +{ + asm volatile ("outb %b0,%w1" : : "a" (4), "d" (0x3ce)); + asm volatile ("outb %b0,%w1" : : "a" (map), "d" (0x3cf)); +} + +int +VgaSetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries) +{ + U8 *palette_scratch; + int mark; + int palette_base; + int i, j, code; + + if(number == 0) + return 0; + + if(first < 0 || number < 0 || first + number > 256) { + ErrorF("Cannot set %d, %d palette entries\n", first, number); + return -1; + } + + mark = Vm86MarkMemory (vi); + palette_base = Vm86AllocateMemory (vi, 3 * 256); + + palette_scratch = &LM(vi, palette_base); + + vi->vms.regs.eax = 0x1012; + vi->vms.regs.ebx = first; + vi->vms.regs.ecx = number; + vi->vms.regs.es = POINTER_SEGMENT(palette_base); + vi->vms.regs.edx = POINTER_OFFSET(palette_base); + j = 0; + i = 0; + while (number--) + { + palette_scratch[j++] = entries[i++] >> 2; + palette_scratch[j++] = entries[i++] >> 2; + palette_scratch[j++] = entries[i++] >> 2; + i++; + } + code = Vm86DoInterrupt(vi, 0x10); + Vm86ReleaseMemory (vi, mark); + + if(code < 0) + return -1; + return 0; +} + +int +VgaGetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries) +{ + U8 *palette_scratch; + int mark; + int palette_base; + int i, j, code; + + if(number == 0) + return 0; + + if(first < 0 || number < 0 || first + number > 256) { + ErrorF("Cannot get %d, %d palette entries\n", first, number); + return -1; + } + + mark = Vm86MarkMemory (vi); + palette_base = Vm86AllocateMemory (vi, 3 * 256); + + palette_scratch = &LM(vi, palette_base); + + vi->vms.regs.eax = 0x1017; + vi->vms.regs.ebx = first; + vi->vms.regs.ecx = number; + vi->vms.regs.es = POINTER_SEGMENT(palette_base); + vi->vms.regs.edx = POINTER_OFFSET(palette_base); + + code = VbeDoInterrupt10(vi); + if(code < 0) + return -1; + + j = 0; + i = 0; + while (number--) + { + entries[i++] = palette_scratch[j++] << 2; + entries[i++] = palette_scratch[j++] << 2; + entries[i++] = palette_scratch[j++] << 2; + entries[i++] = 0; + } + + Vm86ReleaseMemory (vi, mark); + + return 0; +} + +#define VGA_FB(vm) ((vm) < 8 ? 0xb8000 : 0xa0000) + +void * +VgaSetWindow (Vm86InfoPtr vi, int vmode, int bytes, int mode, int *size) +{ + *size = 0x10000 - bytes; + return &LM(vi,VGA_FB(vmode) + bytes); +} + +void * +VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size) +{ + if (VGA_FB(vmode) == 0xa0000) + *size = 0x10000; + else + *size = 0x4000; + return &LM(vi,VGA_FB(vmode)); +} + +void +VgaUnmapFramebuffer (Vm86InfoPtr vi) +{ +} diff --git a/xc/programs/Xserver/hw/kdrive/vesa/vga.h b/xc/programs/Xserver/hw/kdrive/vesa/vga.h new file mode 100644 index 000000000..e11034172 --- /dev/null +++ b/xc/programs/Xserver/hw/kdrive/vesa/vga.h @@ -0,0 +1,61 @@ +/* + * $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vga.h,v 1.1 2000/10/20 00:19:51 keithp 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. + */ + +#ifndef _VGA_H_ +#define _VGA_H_ + +int +VgaGetNmode (Vm86InfoPtr vi); + +int +VgaGetModes (Vm86InfoPtr vi, VesaModePtr mode, int nmode); + +int +VgaSetMode(Vm86InfoPtr vi, int mode); + +int +VgaGetMode (Vm86InfoPtr vi, int *mode); + +int +VgaSetWritePlaneMask(Vm86InfoPtr vi, int mask); + +int +VgaSetReadPlaneMap(Vm86InfoPtr vi, int map); + +int +VgaSetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries); + +int +VgaGetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries); + +void * +VgaSetWindow (Vm86InfoPtr vi, int vmode, int bytes, int mode, int *size); + +void * +VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size); + +void +VgaUnmapFramebuffer (Vm86InfoPtr vi); + +#endif /* _VGA_H_ */ diff --git a/xc/programs/Xserver/hw/kdrive/vesa/vm86.c b/xc/programs/Xserver/hw/kdrive/vesa/vm86.c new file mode 100644 index 000000000..ff5c4b852 --- /dev/null +++ b/xc/programs/Xserver/hw/kdrive/vesa/vm86.c @@ -0,0 +1,697 @@ +/* + * $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vm86.c,v 1.1 2000/10/20 00:19:51 keithp 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. + */ +/* +Copyright (c) 2000 by Juliusz Chroboczek + +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 +AUTHORS OR COPYRIGHT HOLDERS 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 "vm86.h" + +#define PUSHW(vi, i) \ +{ vi->vms.regs.esp -= 2;\ + LMW(vi,MAKE_POINTER(vi->vms.regs.ss, vi->vms.regs.esp)) = i;} + +static int vm86old(struct vm86_struct *vms); +static int vm86_loop(Vm86InfoPtr vi); + +static const U8 rev_ints[32] = +{ 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0x80, +}; + +static const U8 retcode_data[2] = +{ 0xCD, 0xFF }; + +Vm86InfoPtr +Vm86Setup(void) +{ + int devmem = -1, devzero = -1; + void *magicMem, *loMem, *hiMem; + U32 stack_base, ret_code; + Vm86InfoPtr vi = NULL; + + devmem = open("/dev/mem", O_RDWR); + if(devmem < 0) { + perror("open /dev/mem"); + goto fail; + } + + devzero = open("/dev/zero", O_RDWR); + if(devmem < 0) { + perror("open /dev/zero"); + goto fail; + } + + + magicMem = mmap((void*)MAGICMEM_BASE, MAGICMEM_SIZE, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_FIXED, devmem, MAGICMEM_BASE); + + if(magicMem == MAP_FAILED) { + ErrorF("Couldn't map magic memory\n"); + goto fail; + } + + loMem = mmap((void*)LOMEM_BASE, LOMEM_SIZE, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_FIXED, devzero, LOMEM_BASE); + if(loMem == MAP_FAILED) { + ErrorF("Couldn't map low memory\n"); + munmap(magicMem, MAGICMEM_SIZE); + goto fail; + } + + hiMem = mmap((void*)HIMEM_BASE, HIMEM_SIZE, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_SHARED | MAP_FIXED, + devmem, HIMEM_BASE); + if(hiMem == MAP_FAILED) { + ErrorF("Couldn't map high memory\n"); + munmap(magicMem, MAGICMEM_SIZE); + munmap(loMem, LOMEM_SIZE); + goto fail; + } + + vi = xalloc(sizeof(Vm86InfoRec)); + if (!vi) + goto unmapfail; + + vi->magicMem = magicMem; + vi->loMem = loMem; + vi->hiMem = hiMem; + vi->brk = LOMEM_BASE; + + stack_base = Vm86AllocateMemory(vi, STACK_SIZE); + if(stack_base == ALLOC_FAIL) + goto unmapfail; + ret_code = Vm86AllocateMemory(vi, sizeof(retcode_data)); + if(ret_code == ALLOC_FAIL) + goto unmapfail; + + vi->stack_base = stack_base; + vi->ret_code = ret_code; + + memset(&vi->vms, 0, sizeof(struct vm86_struct)); + vi->vms.flags = 0; + vi->vms.screen_bitmap = 0; + vi->vms.cpu_type = CPU_586; + memcpy(&vi->vms.int_revectored, rev_ints, sizeof(rev_ints)); + + iopl(3); + + if(devmem >= 0) + close(devmem); + if(devzero >= 0) + close(devzero); + + return vi; + +unmapfail: + munmap(magicMem, MAGICMEM_SIZE); + munmap(loMem, LOMEM_SIZE); + munmap(hiMem, HIMEM_SIZE); +fail: + if(devmem >= 0) + close(devmem); + if(devzero >= 0) + close(devzero); + if(vi) + xfree(vi); + return NULL; +} + +void +Vm86Cleanup(Vm86InfoPtr vi) +{ + munmap(vi->magicMem, MAGICMEM_SIZE); + munmap(vi->loMem, LOMEM_SIZE); + munmap(vi->hiMem, HIMEM_SIZE); + xfree(vi); +} + +int +Vm86DoInterrupt(Vm86InfoPtr vi, int num) +{ + U16 seg, off; + int code; + + if(num < 0 || num>256) { + ErrorF("Interrupt %d doesn't exist\n"); + return -1; + } + seg = MMW(vi,num * 4 + 2); + off = MMW(vi,num * 4); + if(MAKE_POINTER(seg, off) < ROM_BASE || + MAKE_POINTER(seg, off) >= ROM_BASE + ROM_SIZE) { + ErrorF("Interrupt pointer doesn't point at ROM\n"); + return -1; + } + memcpy(&(LM(vi,vi->ret_code)), retcode_data, sizeof(retcode_data)); + vi->vms.regs.eflags = IF_MASK | IOPL_MASK; + vi->vms.regs.ss = POINTER_SEGMENT(vi->stack_base); + vi->vms.regs.esp = STACK_SIZE; + PUSHW(vi, IF_MASK | IOPL_MASK); + PUSHW(vi, POINTER_SEGMENT(vi->ret_code)); + PUSHW(vi, POINTER_OFFSET(vi->ret_code)); + vi->vms.regs.cs = seg; + vi->vms.regs.eip = off; + OsBlockSignals (); + code = vm86_loop(vi); + OsReleaseSignals (); + if(code < 0) { + perror("vm86 failed"); + return -1; + } else if(code != 0) { + ErrorF("vm86 returned 0x%04X\n", code); + return -1; + } else + return 0; +} + +#define DEBUG_VBE 0 +#if DEBUG_VBE +#define DBG(x) ErrorF x; usleep(10*1000) +#else +#define DBG(x) +#endif + +static inline U8 +vm86_inb(U16 port) +{ + U8 value; + + if (port != 0x3da) + { + DBG(("inb 0x%04x", port)); + } + asm volatile ("inb %w1,%b0" : "=a" (value) : "d" (port)); + if (port != 0x3da) + { + DBG((" = 0x%02x\n", value)); + } + return value; +} + +static inline U16 +vm86_inw(U16 port) +{ + U16 value; + DBG(("inw 0x%04x", port)); + asm volatile ("inw %w1,%w0" : "=a" (value) : "d" (port)); + DBG((" = 0x%04x\n", value)); + return value; +} + +static inline U32 +vm86_inl(U16 port) +{ + U32 value; + DBG(("inl 0x%04x", port)); + asm volatile ("inl %w1,%0" : "=a" (value) : "d" (port)); + DBG((" = 0x%08x\n", value)); + return value; +} + +static inline void +vm86_outb(U16 port, U8 value) +{ +#if 0 + static U8 CR; + + if (port == 0x3d4) + CR = value; + if (port == 0x3d5 && CR == 0xa4) + { + DBG(("outb 0x%04x = 0x%02x (skipped)\n", port, value)); + return; + } +#endif + DBG(("outb 0x%04x = 0x%02x\n", port, value)); + asm volatile ("outb %b0,%w1" : : "a" (value), "d" (port)); +} + +static inline void +vm86_outw(U16 port, U16 value) +{ + DBG(("outw 0x%04x = 0x%04x\n", port, value)); + asm volatile ("outw %w0,%w1" : : "a" (value), "d" (port)); +} + +static inline void +vm86_outl(U16 port, U32 value) +{ + DBG(("outl 0x%04x = 0x%08x\n", port, value)); + asm volatile ("outl %0,%w1" : : "a" (value), "d" (port)); +} + +#define SEG_CS 1 +#define SEG_DS 2 +#define SEG_ES 3 +#define SEG_SS 4 +#define SEG_GS 5 +#define SEG_FS 6 +#define REP 1 +#define REPNZ 2 +#define SET_8(_x, _y) (_x) = (_x & ~0xFF) | (_y & 0xFF); +#define SET_16(_x, _y) (_x) = (_x & ~0xFFFF) | (_y & 0xFFFF); +#define INC_IP(_i) SET_16(regs->eip, (regs->eip + _i)) +#define AGAIN INC_IP(1); goto again; + +static int +vm86_emulate(Vm86InfoPtr vi) +{ + struct vm86_regs *regs = &vi->vms.regs; + U8 opcode; + int size; + int pref_seg = 0, pref_rep = 0, pref_66 = 0, pref_67 = 0; + U32 count; + int code; + + again: + if(!Vm86IsMemory(vi, MAKE_POINTER(regs->cs, regs->eip))) { + ErrorF("Trying to execute unmapped memory\n"); + return -1; + } + opcode = Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip)); + switch(opcode) { + case 0x2E: pref_seg = SEG_CS; AGAIN; + case 0x3E: pref_seg = SEG_DS; AGAIN; + case 0x26: pref_seg = SEG_ES; AGAIN; + case 0x36: pref_seg = SEG_SS; AGAIN; + case 0x65: pref_seg = SEG_GS; AGAIN; + case 0x64: pref_seg = SEG_FS; AGAIN; + case 0x66: pref_66 = 1; AGAIN; + case 0x67: pref_67 = 1; AGAIN; + case 0xF2: pref_rep = REPNZ; AGAIN; + case 0xF3: pref_rep = REP; AGAIN; + + case 0xEC: /* IN AL, DX */ + SET_8(regs->eax, vm86_inb(regs->edx & 0xFFFF)); + INC_IP(1); + break; + case 0xED: /* IN AX, DX */ + if(pref_66) + regs->eax = vm86_inl(regs->edx & 0xFFFF); + else + SET_16(regs->eax, vm86_inw(regs->edx & 0xFFFF)); + INC_IP(1); + break; + case 0xE4: /* IN AL, imm8 */ + SET_8(regs->eax, + vm86_inb(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)))); + INC_IP(2); + break; + case 0xE5: /* IN AX, imm8 */ + if(pref_66) + regs->eax = + vm86_inl(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1))); + else + SET_16(regs->eax, + vm86_inw(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)))); + INC_IP(2); + break; + case 0x6C: /* INSB */ + case 0x6D: /* INSW */ + if(opcode == 0x6C) { + Vm86WriteMemory(vi, MAKE_POINTER(regs->es, regs->edi), + vm86_inb(regs->edx & 0xFFFF)); + size = 1; + } else if(pref_66) { + Vm86WriteMemoryL(vi, MAKE_POINTER(regs->es, regs->edi), + vm86_inl(regs->edx & 0xFFFF)); + size = 4; + } else { + Vm86WriteMemoryW(vi, MAKE_POINTER(regs->es, regs->edi), + vm86_inw(regs->edx & 0xFFFF)); + size = 2; + } + if(regs->eflags & (1<<10)) + regs->edi -= size; + else + regs->edi += size; + if(pref_rep) { + if(pref_66) { + regs->ecx--; + if(regs->ecx != 0) { + goto again; + } else { + SET_16(regs->ecx, regs->ecx - 1); + if(regs->ecx & 0xFFFF != 0) + goto again; + } + } + } + INC_IP(1); + break; + + case 0xEE: /* OUT DX, AL */ + vm86_outb(regs->edx & 0xFFFF, regs->eax & 0xFF); + INC_IP(1); + break; + case 0xEF: /* OUT DX, AX */ + if(pref_66) + vm86_outl(regs->edx & 0xFFFF, regs->eax); + else + vm86_outw(regs->edx & 0xFFFF, regs->eax & 0xFFFF); + INC_IP(1); + break; + case 0xE6: /* OUT imm8, AL */ + vm86_outb(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)), + regs->eax & 0xFF); + INC_IP(2); + break; + case 0xE7: /* OUT imm8, AX */ + if(pref_66) + vm86_outl(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)), + regs->eax); + else + vm86_outw(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)), + regs->eax & 0xFFFF); + INC_IP(2); + break; + case 0x6E: /* OUTSB */ + case 0x6F: /* OUTSW */ + if(opcode == 0x6E) { + vm86_outb(regs->edx & 0xFFFF, + Vm86Memory(vi, MAKE_POINTER(regs->es, regs->edi))); + size = 1; + } else if(pref_66) { + vm86_outl(regs->edx & 0xFFFF, + Vm86Memory(vi, MAKE_POINTER(regs->es, regs->edi))); + size = 4; + } else { + vm86_outw(regs->edx & 0xFFFF, + Vm86Memory(vi, MAKE_POINTER(regs->es, regs->edi))); + size = 2; + } + if(regs->eflags & (1<<10)) + regs->edi -= size; + else + regs->edi += size; + if(pref_rep) { + if(pref_66) { + regs->ecx--; + if(regs->ecx != 0) { + goto again; + } else { + SET_16(regs->ecx, regs->ecx - 1); + if(regs->ecx & 0xFFFF != 0) + goto again; + } + } + } + INC_IP(1); + break; + + case 0x0F: + ErrorF("Hit 0F trap in VM86 code\n"); + return -1; + case 0xF0: + ErrorF("Hit lock prefix in VM86 code\n"); + return -1; + case 0xF4: + ErrorF("Hit HLT in VM86 code\n"); + return -1; + + default: + ErrorF("Unhandled GP fault in VM86 code (opcode = 0x%02X)\n", + opcode); + return -1; + } + return 0; +} +#undef SEG_CS +#undef SEG_DS +#undef SEG_ES +#undef SEG_SS +#undef SEG_GS +#undef SEG_FS +#undef REP +#undef REPNZ +#undef SET_8 +#undef SET_16 +#undef INC_IP +#undef AGAIN + +static int +vm86_loop(Vm86InfoPtr vi) +{ + int code; + + while(1) { + code = vm86old(&vi->vms); + switch(VM86_TYPE(code)) { + case VM86_SIGNAL: + continue; + case VM86_UNKNOWN: + code = vm86_emulate(vi); + if(code < 0) { + Vm86Debug(vi); + return -1; + } + break; + case VM86_INTx: + if(VM86_ARG(code) == 0xFF) + return 0; + else { + PUSHW(vi, vi->vms.regs.eflags) + PUSHW(vi, vi->vms.regs.cs); + PUSHW(vi, vi->vms.regs.eip); + vi->vms.regs.cs = MMW(vi,VM86_ARG(code) * 4 + 2); + vi->vms.regs.eip = MMW(vi,VM86_ARG(code) * 4); + } + break; + case VM86_STI: + ErrorF("VM86 code enabled interrupts\n"); + Vm86Debug(vi); + return -1; + default: + ErrorF("Unexpected result code 0x%X from vm86\n", code); + Vm86Debug(vi); + return -1; + } + } +} + +int +Vm86IsMemory(Vm86InfoPtr vi, U32 i) +{ + if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) + return 1; + else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) + return 1; + else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) + return 1; + else + return 0; +} + +U8 +Vm86Memory(Vm86InfoPtr vi, U32 i) +{ + if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) + return MM(vi, i); + else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) + return LM(vi, i); + else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) + return HM(vi, i); + else { + ErrorF("Reading unmapped memory at 0x%08X\n", i); + } +} + +U16 +Vm86MemoryW(Vm86InfoPtr vi, U32 i) +{ + if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) + return MMW(vi, i); + else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) + return LMW(vi, i); + else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) + return HMW(vi, i); + else { + ErrorF("Reading unmapped memory at 0x%08X\n", i); + return 0; + } +} + +U32 +Vm86MemoryL(Vm86InfoPtr vi, U32 i) +{ + if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) + return MML(vi, i); + else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) + return LML(vi, i); + else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) + return HML(vi, i); + else { + ErrorF("Reading unmapped memory at 0x%08X\n", i); + return 0; + } +} + +void +Vm86WriteMemory(Vm86InfoPtr vi, U32 i, U8 val) +{ + if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) + MM(vi, i) = val; + else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) + LM(vi, i) = val; + else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) + HM(vi, i) = val; + else { + ErrorF("Writing unmapped memory at 0x%08X\n", i); + } +} + +void +Vm86WriteMemoryW(Vm86InfoPtr vi, U32 i, U16 val) +{ + if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) + MMW(vi, i) = val; + else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) + LMW(vi, i) = val; + else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) + HMW(vi, i) = val; + else { + ErrorF("Writing unmapped memory at 0x%08X\n", i); + } +} + +void +Vm86WriteMemoryL(Vm86InfoPtr vi, U32 i, U32 val) +{ + if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE) + MML(vi, i) = val; + else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE) + LML(vi, i) = val; + else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE) + HML(vi, i) = val; + else { + ErrorF("Writing unmapped memory at 0x%08X\n", i); + } +} + +int +Vm86AllocateMemory(Vm86InfoPtr vi, int n) +{ + int ret; + if(n<0) { + ErrorF("Asked to allocate negative amount of memory\n"); + return vi->brk; + } + + n = (n + 15) & ~15; + if(vi->brk + n > LOMEM_BASE + LOMEM_SIZE) { + ErrorF("Out of low memory\n"); + exit(2); + } + ret = vi->brk; + vi->brk += n; + return ret; +} + +int +Vm86MarkMemory (Vm86InfoPtr vi) +{ + return vi->brk; +} + +void +Vm86ReleaseMemory (Vm86InfoPtr vi, int mark) +{ + vi->brk = mark; +} + +static int +vm86old(struct vm86_struct *vm) +{ + int res; + + asm volatile ( + "pushl %%ebx\n\t" + "movl %2, %%ebx\n\t" + "movl %1,%%eax\n\t" + "int $0x80\n\t" + "popl %%ebx" + : "=a" (res) : "n" (113), "r" (vm)); + if(res < 0) { + errno = -res; + res = -1; + } else + errno = 0; + return res; +} + +void +Vm86Debug(Vm86InfoPtr vi) +{ + struct vm86_regs *regs = &vi->vms.regs; + int i; + + ErrorF("eax=0x%08lX ebx=0x%08lX ecx=0x%08lX edx=0x%08lX\n", + regs->eax, regs->ebx, regs->ecx, regs->edx); + ErrorF("esi=0x%08lX edi=0x%08lX ebp=0x%08lX\n", + regs->esi, regs->edi, regs->ebp); + ErrorF("eip=0x%08lX esp=0x%08lX eflags=0x%08lX\n", + regs->eip, regs->esp, regs->eflags); + ErrorF("cs=0x%04lX ds=0x%04lX es=0x%04lX fs=0x%04lX gs=0x%04lX\n", + regs->cs, regs->ds, regs->es, regs->fs, regs->gs); + for(i=-7; i<8; i++) { + ErrorF(" %s%02X", + i==0?"->":"", + Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip + i))); + } + ErrorF("\n"); +} + +#ifdef NOT_IN_X_SERVER +static void +ErrorF(char *f, ...) +{ + va_list args; + va_start(args, f); + vfprintf(stderr, f, args); + va_end(args); +} +#endif diff --git a/xc/programs/Xserver/hw/kdrive/vesa/vm86.h b/xc/programs/Xserver/hw/kdrive/vesa/vm86.h new file mode 100644 index 000000000..1cc202e47 --- /dev/null +++ b/xc/programs/Xserver/hw/kdrive/vesa/vm86.h @@ -0,0 +1,165 @@ +/* + * $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vm86.h,v 1.1 2000/10/20 00:19:51 keithp 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. + */ +/* +Copyright (c) 2000 by Juliusz Chroboczek + +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 +AUTHORS OR COPYRIGHT HOLDERS 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 _VM86_H_ +#define _VM86_H_ + +#include <stdlib.h> +#include <errno.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/mman.h> +#include <sys/vm86.h> +#include <sys/io.h> + +#ifdef NOT_IN_X_SERVER +#include <stdio.h> +#include <stdarg.h> +#include <malloc.h> +static void ErrorF(char*, ...); +#define xalloc(a) malloc(a) +#define xcalloc(a,b) calloc(a,b) +#define xfree(a) free(a) +#else +#include "X.h" +#include "Xproto.h" +#include "Xos.h" +#include "os.h" +#endif + +typedef unsigned char U8; +typedef unsigned short U16; +typedef unsigned int U32; + +/* The whole addressable memory */ +#define SYSMEM_BASE 0x00000 +#define SYSMEM_SIZE 0x100000 + +/* Interrupt vectors and BIOS data area */ +/* This is allocated privately from /dev/mem */ +#define MAGICMEM_BASE 0x00000 +#define MAGICMEM_SIZE 0x01000 + +/* The low memory, allocated privately from /dev/zero */ +/* 64KB should be enough for anyone, as they used to say */ +#define LOMEM_BASE 0x10000 +#define LOMEM_SIZE 0x10000 + +/* The video memory and BIOS ROM, allocated shared from /dev/mem */ +#define HIMEM_BASE 0xA0000 +#define HIMEM_SIZE (SYSMEM_BASE + SYSMEM_SIZE - HIMEM_BASE) + +/* The BIOS ROM */ +#define ROM_BASE 0xC0000 +#define ROM_SIZE 0x30000 + +#define STACK_SIZE 0x1000 + +#define POINTER_SEGMENT(ptr) (((unsigned int)ptr)>>4) +#define POINTER_OFFSET(ptr) (((unsigned int)ptr)&0x000F) +#define MAKE_POINTER(seg, off) (((((unsigned int)(seg))<<4) + (unsigned int)(off))) +#define MAKE_POINTER_1(lw) MAKE_POINTER(((lw)&0xFFFF0000)/0x10000, (lw)&0xFFFF) +#define ALLOC_FAIL ((U32)-1) + +typedef struct _Vm86InfoRec { + void *magicMem, *loMem, *hiMem; + U32 brk; + struct vm86_struct vms; + U32 ret_code, stack_base; +} Vm86InfoRec, *Vm86InfoPtr; + +#define LM(vi,i) (((char*)vi->loMem)[i-LOMEM_BASE]) +#define LMW(vi,i) (*(U16*)(&LM(vi,i))) +#define LML(vi,i) (*(U32*)(&LM(vi,i))) +#define MM(vi,i) (((char*)vi->magicMem)[i-MAGICMEM_BASE]) +#define MMW(vi,i) (*(U16*)(&MM(vi,i))) +#define MML(vi,i) (*(U32*)(&MM(vi,i))) +#define HM(vi,i) (((char*)vi->hiMem)[i-HIMEM_BASE]) +#define HMW(vi,i) (*(U16*)(&MM(vi,i))) +#define HML(vi,i) (*(U32*)(&MM(vi,i))) + +Vm86InfoPtr +Vm86Setup(void); + +void +Vm86Cleanup(Vm86InfoPtr vi); + +int +Vm86DoInterrupt(Vm86InfoPtr vi, int num); + +int +Vm86IsMemory(Vm86InfoPtr vi, U32 i); + +U8 +Vm86Memory(Vm86InfoPtr, U32); + +U16 +Vm86MemoryW(Vm86InfoPtr, U32); + +U32 +Vm86MemoryL(Vm86InfoPtr, U32); + +void +Vm86WriteMemory(Vm86InfoPtr, U32, U8); + +void +Vm86WriteMemoryW(Vm86InfoPtr, U32, U16); + +void +Vm86WriteMemoryL(Vm86InfoPtr, U32, U32); + +int +Vm86AllocateMemory(Vm86InfoPtr, int); + +int +Vm86MarkMemory (Vm86InfoPtr vi); + +void +Vm86ReleaseMemory (Vm86InfoPtr vi, int mark); + +void +Vm86Debug(Vm86InfoPtr vi); + +#endif /* _VM86_H_ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.c new file mode 100644 index 000000000..0480c7356 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.c @@ -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; + } +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.h new file mode 100644 index 000000000..e9e5f8db7 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.h @@ -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___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.c new file mode 100644 index 000000000..16133b2f6 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.c @@ -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 */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.h new file mode 100644 index 000000000..f70ed396a --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.h @@ -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___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.c new file mode 100644 index 000000000..50f371cf0 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.c @@ -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; +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.h new file mode 100644 index 000000000..a01aee882 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.h @@ -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___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.c new file mode 100644 index 000000000..974cb0cbc --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.c @@ -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 */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.h new file mode 100644 index 000000000..f61ad7b42 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.h @@ -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___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.c new file mode 100644 index 000000000..e10d206af --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.c @@ -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 */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.h new file mode 100644 index 000000000..5c2727227 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.h @@ -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___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i128/IBMRGB.h b/xc/programs/Xserver/hw/xfree86/drivers/i128/IBMRGB.h new file mode 100644 index 000000000..9a3656585 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/i128/IBMRGB.h @@ -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 + + diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i128/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/i128/Imakefile new file mode 100644 index 000000000..d441441e9 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/i128/Imakefile @@ -0,0 +1,56 @@ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/Imakefile,v 1.2 2000/10/05 11:33:15 alanh 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 +OBJS = i128_driver.o i128init.o i128IBMDAC.o i128accel.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) + +InstallDriverSDKObjectModule(i128,$(DRIVERSDKMODULEDIR),drivers) + diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i128/Ti302X.h b/xc/programs/Xserver/hw/xfree86/drivers/i128/Ti302X.h new file mode 100644 index 000000000..7a57c0496 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/i128/Ti302X.h @@ -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 diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i128/i128.cpp b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128.cpp new file mode 100644 index 000000000..b71467143 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128.cpp @@ -0,0 +1,70 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128.cpp,v 1.1 2000/10/04 23:34:58 robin Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH I128 __drivermansuffix__ "Version 4.0.1" "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). diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i128/i128.h b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128.h new file mode 100644 index 000000000..589b02094 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128.h @@ -0,0 +1,136 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128.h,v 1.2 2000/10/23 14:11:39 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; + unsigned char *vgamem; + + /* 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 (*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); + +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 diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i128/i128IBMDAC.c b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128IBMDAC.c new file mode 100644 index 000000000..385bb766b --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128IBMDAC.c @@ -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); +} + + diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i128/i128_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128_driver.c new file mode 100644 index 000000000..10f2a7c13 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128_driver.c @@ -0,0 +1,2330 @@ +/* + * 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.9 2000/10/27 22:30:29 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" + +/* 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 *fbSymbols[] = { + "fbScreenInit", + 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, + 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); + devSections = NULL; + + if (numUsed <= 0) + return FALSE; + + if (flags & PROBE_DETECT) { + if (usedChips) + 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; + } + + if (usedChips) + 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); + + /* 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_T2R) || + (pI128->Chipset == PCI_CHIP_I128_T2R4)) { + 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->virtualX, + pScrn->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); + + /* 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; + + 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) +{ + I128SaveState(pScrn); +} + +/* + * Restore the initial (text) mode. + */ +static void +I128Restore(ScrnInfoPtr pScrn) +{ + I128RestoreState(pScrn); +} + +/* 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; + + + /* + * 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; + + 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) + 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); + 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. + */ + 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); +} + diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c new file mode 100644 index 000000000..27ad796cc --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c @@ -0,0 +1,504 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c,v 1.4 2000/10/24 02:00:06 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\n", x1, y1, x2, y2, w, h); +#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 = 0; + if (pI128->Chipset == PCI_CHIP_I128_T2R) + infoPtr->ScreenToScreenCopyFlags |= ONLY_LEFT_TO_RIGHT_BITBLT; + + infoPtr->SetupForScreenToScreenCopy = I128SetupForScreenToScreenCopy; + infoPtr->SubsequentScreenToScreenCopy = + I128SubsequentScreenToScreenCopy; + + /* 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)); +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c new file mode 100644 index 000000000..f8c8a804e --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c @@ -0,0 +1,594 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c,v 1.4 2000/10/25 00:09:17 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); + +#define VGA_SAVE_COUNT 4096*1024 + + +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)) { + int i; + unsigned char *vidmem = (unsigned char *)pI128->mem.mw0_ad; + + if (pI128->Primary) + for (i=0; i<VGA_SAVE_COUNT; i++) + vidmem[i] = pI128->vgamem[i]; + 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); + } + + if (!pI128->FontsSaved && pI128->Primary) { + int i; + unsigned char *vidmem = + (unsigned char *)pI128->mem.mw0_ad; + + pI128->vgamem = xnfalloc(VGA_SAVE_COUNT); + for (i=0; i<VGA_SAVE_COUNT; i++) + pI128->vgamem[i] = vidmem[i]; + pI128->FontsSaved = TRUE; + } + + } + + 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++; + } +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i128/i128reg.h b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128reg.h new file mode 100644 index 000000000..ee1894d02 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/i128/i128reg.h @@ -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 diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/README_HALLIB b/xc/programs/Xserver/hw/xfree86/drivers/mga/README_HALLIB new file mode 100644 index 000000000..432e42ecf --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/README_HALLIB @@ -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 diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_video.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_video.c new file mode 100644 index 000000000..1152a4253 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_video.c @@ -0,0 +1,802 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_video.c,v 1.3 2000/10/23 21:16:49 tsi Exp $ */ +/************************************************************************** + +Copyright 2000 Stuart R. Anderson and Metro Link, 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 +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: + * Stuart R. Anderson <anderson@metrolink.com> + * + * Credits: + * + * This code is derived primarily from the GATOS Project run by Stea Greene. + * The initial version of this code was done by Vladimir Dergacheb. + * + * This code was simplified from the GATOS code primarily because I didn't + * have the right hardware handy to test anything beyond simple overlays, + * and because I wanted to complete it in a short time frame that I had + * available. + * + * My apologies to Vladimir as there is more good work in his code that + * should be brought forward. + */ +#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 "xf86xv.h" +#include "xf86Cursor.h" +#include "Xv.h" +#include "xaalocal.h" +#include "dixstruct.h" +#include "fourcc.h" +#ifdef XF86DRI +#include "r128_dri.h" +#endif + +#include "r128.h" +#include "r128_reg.h" + +/* + * For Debug +#define OUTREG(addr, val) { xf86DrvMsgVerb(pScrn->scrnIndex,X_INFO,1,"OUTREG(%s,%x)\n",#addr,val) ;MMIO_OUT32(R128MMIO, addr, val);} +*/ + +#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 +void R128InitVideo(ScreenPtr); +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 *); + +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) + +#define IMAGE_MAX_WIDTH 2048 +#define IMAGE_MAX_HEIGHT 2048 +#define Y_BUF_SIZE (IMAGE_MAX_WIDTH * IMAGE_MAX_HEIGHT) + +static Atom xvColorKey; + +typedef struct { + int videoStatus; + unsigned char brightness; + unsigned char contrast; + + RegionRec clip; + CARD32 colorKey; + CARD8 overlay_pixel_size; + CARD8 current_buffer; + int overlay_pad; + CARD32 overlay_id; + CARD32 overlay_width; + + CARD32 scale_cntl; + CARD32 video_format; + FBLinearPtr linear; + } R128PortPrivRec, *R128PortPrivPtr; + +void R128InitVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL; + int num_adaptors; + + R128TRACE(("R128InitVideo called\n")); + + /* Determine if the card supports this */ + if (pScrn->bitsPerPixel != 8) + { + 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[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}, + {32, TrueColor} +}; + +#define NUM_ATTRIBUTES 1 + +static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = +{ + {XvSettable | XvGettable, 0, (1<<24)-1, "XV_COLORKEY"}, +}; + +#define NUM_IMAGES 3 + +static XF86ImageRec Images[NUM_IMAGES] = +{ + XVIMAGE_YUY2, + XVIMAGE_YV12, + XVIMAGE_UYVY +}; + +static void +R128ResetVideo(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128PortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; + + R128TRACE(("R128ResetVideo called\n")); + + /* Initialize some of the HW here */ + OUTREG(R128_OV0_EXCLUSIVE_HORZ,0); /* disable exclusive mode */ + OUTREG(R128_OV0_VIDEO_KEY_MSK,0xffff); + OUTREG(R128_OV0_KEY_CNTL, R128_GRAPHIC_KEY_FN_NE); + OUTREG(R128_OV0_GRAPHICS_KEY_CLR,pPriv->colorKey); + /* Only using one buffer for now + OUTREG(R128_OV0_AUTO_FLIP_CNTL,pAPriv->Port[0].auto_flip_cntl); + */ + switch(pScrn->depth){ + case 8: + OUTREG(R128_OV0_GRAPHICS_KEY_MSK,0xff); + break; + case 15: + OUTREG(R128_OV0_GRAPHICS_KEY_MSK,0x7fff); + break; + case 16: + OUTREG(R128_OV0_GRAPHICS_KEY_MSK,0xffff); + break; + case 24: + OUTREG(R128_OV0_GRAPHICS_KEY_MSK,0xffffff); + break; + case 32: + OUTREG(R128_OV0_GRAPHICS_KEY_MSK,0xffffffff); + break; + } + + OUTREG(R128_OV0_REG_LOAD_CNTL,0x0); + OUTREG(R128_OV0_DEINTERLACE_PATTERN,0xAAAAA); + OUTREG(R128_OV0_P1_V_ACCUM_INIT,(2<<20)|1); + OUTREG(R128_OV0_P23_V_ACCUM_INIT,(2<<20)|1); + OUTREG(R128_OV0_P1_H_ACCUM_INIT,(3<<28)); + OUTREG(R128_OV0_P23_H_ACCUM_INIT,(2<<28)); + OUTREG(R128_OV0_STEP_BY,1|(1<<8)); + OUTREG(R128_OV0_FILTER_CNTL,0xf); /* use hardcoded coeff's */ + OUTREG(R128_OV0_FILTER_CNTL,0x0); /* use programmable coeff's */ + OUTREG(R128_OV0_FOUR_TAP_COEF_0 , 0x00002000); + OUTREG(R128_OV0_FOUR_TAP_COEF_1 , 0x0D06200D); + OUTREG(R128_OV0_FOUR_TAP_COEF_2 , 0x0D0A1C0D); + OUTREG(R128_OV0_FOUR_TAP_COEF_3 , 0x0C0E1A0C); + OUTREG(R128_OV0_FOUR_TAP_COEF_4 , 0x0C14140C); + OUTREG(R128_OV0_COLOUR_CNTL,(1<<12)|(1<<20)); + OUTREG(R128_OV0_TEST,0); + OUTREG(R128_OV0_SCALE_CNTL,pPriv->scale_cntl|pPriv->video_format); + OUTREG(R128_CAP0_TRIG_CNTL,0); +} + +static XF86VideoAdaptorPtr +R128SetupImageVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + XF86VideoAdaptorPtr adapt; + R128PortPrivPtr pPriv; + + R128TRACE(("R128SetupImageVideo called\n")); + + if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + + sizeof(R128PortPrivRec) + + sizeof(DevUnion)))) + return NULL; + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "R128 Video Overlay"; + adapt->nEncodings = 1; + adapt->pEncodings = DummyEncoding; + adapt->nFormats = NUM_FORMATS; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->pPortPrivates = (DevUnion*)(&adapt[1]); + + pPriv = (R128PortPrivPtr)(&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 = R128StopVideo; + adapt->SetPortAttribute = R128SetPortAttribute; + adapt->GetPortAttribute = R128GetPortAttribute; + adapt->QueryBestSize = R128QueryBestSize; + adapt->PutImage = R128PutImage; + adapt->QueryImageAttributes = R128QueryImageAttributes; + + /* gotta uninit this someplace */ + REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); + + info->adaptor = adapt; + + pPriv->colorKey = 0x01; /* a touch of blue */ + pPriv->video_format = R128_SCALER_SOURCE_VYUY422; + pPriv->scale_cntl = R128_SCALER_PRG_LOAD_START|R128_SCALER_DOUBLE_BUFFER; + pPriv->scale_cntl|= R128_SCALER_SMART_SWITCH|R128_SCALER_PIX_EXPAND; + pPriv->scale_cntl|= R128_SCALER_SMART_SWITCH; + + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + + R128ResetVideo(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 void +R128StopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128PortPrivPtr pPriv = (R128PortPrivPtr) data; + + R128TRACE(("R128StopVideo called\n")); + + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + + if(exit) { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + OUTREG(R128_OV0_SCALE_CNTL,pPriv->scale_cntl|pPriv->video_format); + } + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; + } + pPriv->videoStatus = 0; + } else { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + } + } +} + +static int +R128SetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 value, + pointer data +) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128PortPrivPtr pPriv = (R128PortPrivPtr) data; + + R128TRACE(("R128SetPortAttribute called\n")); + + if (attribute == xvColorKey) { + pPriv->colorKey = value; + OUTREG(R128_OV0_GRAPHICS_KEY_CLR,pPriv->colorKey); + R128TRACE(("Setting ColorKey to %d\n", pPriv->colorKey)); + return Success; + } + + return Success; +} + +static int +R128GetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 *value, + pointer data +) +{ + R128PortPrivPtr pPriv = (R128PortPrivPtr) data; + + R128TRACE(("R128GetPortAttribute called\n")); + + if (attribute == xvColorKey) { + R128TRACE(("Getting ColorKey %d\n", pPriv->colorKey)); + *value = pPriv->colorKey; + return Success; + } + + 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 +) +{ + R128TRACE(("R128QueryBestSize called\n")); + *p_w = drw_w; + *p_h = drw_h; +} + +static void +R128DisplayVideo( + 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, + int fboffset +) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128PortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; + int step_by, vert_inc, horz_inc; + + R128TRACE(("R128DisplayVideo called\n")); + + /* calculate step_by factor */ + step_by=src_w/(drw_w*2); + switch(step_by){ + case 0: + OUTREG(R128_OV0_STEP_BY,0x101); + step_by=1; + break; + case 1: + OUTREG(R128_OV0_STEP_BY,0x202); + step_by=2; + break; + case 2: + case 3: + OUTREG(R128_OV0_STEP_BY,0x303); + step_by=4; + break; + default: + OUTREG(R128_OV0_STEP_BY,0x404); + step_by=8; + break; + } + + vert_inc=(src_h<<12)/(drw_h); + horz_inc=(src_w<<12)/(drw_w*step_by); + + OUTREG(R128_OV0_Y_X_START,((x1))|(y1<<16)|(1<<31)); + OUTREG(R128_OV0_Y_X_END,((x2))|((y2)<<16)); + OUTREG(R128_OV0_H_INC,(horz_inc)|((horz_inc<<15))); + OUTREG(R128_OV0_V_INC,(vert_inc<<8)); + OUTREG(R128_OV0_P1_BLANK_LINES_AT_TOP,0xfff|((src_h-1)<<16)); + OUTREG(R128_OV0_P23_BLANK_LINES_AT_TOP,0xfff|((src_h-1)<<16)); + OUTREG(R128_OV0_VID_BUF_PITCH0_VALUE,width<<1); + OUTREG(R128_OV0_VID_BUF_PITCH1_VALUE,width<<1); + OUTREG(R128_OV0_P1_X_START_END,(src_w-1)|((x1&0xf)<<16)); + OUTREG(R128_OV0_P2_X_START_END,(src_w-1)|((x1&0xf)<<16)); + OUTREG(R128_OV0_P3_X_START_END,(src_w-1)|((x1&0xf)<<16)); + + OUTREG(R128_OV0_VID_BUF0_BASE_ADRS,(fboffset)&(~0xf)); + OUTREG(R128_OV0_VID_BUF1_BASE_ADRS,(fboffset)&(~0xf)); + OUTREG(R128_OV0_VID_BUF2_BASE_ADRS,(fboffset)&(~0xf)); + +#if 0 + /* Enable this when double buffering is implemented */ + OUTREG(R128_OV0_VID_BUF3_BASE_ADRS,(fboffset2)&(~0xf)); + OUTREG(R128_OV0_VID_BUF4_BASE_ADRS,(fboffset2)&(~0xf)); + OUTREG(R128_OV0_VID_BUF5_BASE_ADRS,(fboffset2)&(~0xf)); +#endif + + OUTREG(R128_OV0_SCALE_CNTL,pPriv->scale_cntl|R128_SCALER_ENABLE|pPriv->video_format); +} + +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 = (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 +R128AllocateMemory( + ScrnInfoPtr pScrn, + FBLinearPtr linear, + int size +) +{ + ScreenPtr pScreen; + FBLinearPtr new_linear; + + R128TRACE(("R128AllocateMemory(%x,%d) called\n",linear,size)); + + 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); + } + + R128TRACE(("returning %x(%x)\n",new_linear,new_linear->offset)); + + return new_linear; +} + +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); + unsigned char *R128MMIO = info->MMIO; + R128PortPrivPtr pPriv = (R128PortPrivPtr)data; + INT32 x1, x2, y1, y2; + INT32 d_x,d_y,d_width,d_height; + int srcPitch = 0, srcPitch2 = 0; + int dstPitch = 0; + int offset,offset2 = 0,offset3 = 0,fboffset; + int top, left, npixels, nlines, size; + BoxRec dstBox; + CARD32 video_format; + + R128TRACE(("R128PutImage called\n")); + + switch(id) { + case FOURCC_YV12: + case FOURCC_UYVY: + video_format=R128_SCALER_SOURCE_VYUY422; + break; + case FOURCC_YUY2: + video_format=R128_SCALER_SOURCE_YVYU422; + break; + default: + return BadValue; + } + + /* Clip */ + d_x=drw_x; + d_y=drw_y; + d_width=drw_w; + d_height=drw_h; + if(drw_x<0){ + drw_w+=drw_x; + drw_x=0; + } + if(drw_y<0){ + drw_h+=drw_y; + drw_y=0; + } + if(drw_x+drw_w>pScrn->pScreen->width){ + drw_w=pScrn->pScreen->width-drw_x; + } + if(drw_y+drw_h>pScrn->pScreen->height){ + drw_h=pScrn->pScreen->height-drw_y; + } + if((drw_w<=0)||(drw_h<=0)){ + /* this should not happen, + since we are outside of visible screen, + but just in case */ + return Success; + } + + x1 = src_x; + x2 = src_x + src_w; + y1 = src_y; + y2 = src_y + src_h; + + dstPitch = width*info->CurrentLayout.pixel_bytes; + srcPitch=width; + + switch(id) { + case FOURCC_YV12: + size = width * height * 2; /* 16bpp */ + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + size = width * height * 1.5; + break; + } + + if(!(pPriv->linear = R128AllocateMemory(pScrn, pPriv->linear,size))) + return BadAlloc; + + /* copy data */ + top = y1 >> 16; + left = (x1 >> 16) & ~1; + npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left; + + switch(id) { + case FOURCC_YV12: + srcPitch = (width + 3) & ~3; + offset2 = srcPitch * height; + srcPitch2 = ((width >> 1) + 3) & ~3; + offset3 = (srcPitch2 * (height >> 1)) + offset2; + nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + buf += (top * srcPitch) + left; + nlines = ((y2 + 0xffff) >> 16) - top; + srcPitch = (width << 1); + break; + } + nlines=src_h; + npixels=src_w; + if(npixels>width) npixels=width; + if(nlines>height) nlines=height; + + /* adjust source rectangle */ + src_x+=((drw_x-d_x)*src_w)/d_width; + src_y+=((drw_y-d_y)*src_h)/d_height; + + src_w=(src_w * drw_w)/d_width; + src_h=(src_h * drw_h)/d_height; + + offset=(src_x+src_y*width)*info->CurrentLayout.pixel_bytes; + fboffset=pPriv->linear->offset*info->CurrentLayout.pixel_bytes; + + if(!(INREG(R128_CRTC_STATUS)&2)){ + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"too fast"); + return Success; + } + + R128DisplayVideo(pScrn, id, width, height, dstPitch, + drw_x, drw_y, drw_x+drw_w, drw_y+drw_h, + &dstBox, src_w, src_h, drw_w, drw_h,fboffset); + + /* 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)); + } + + + switch(id) { + case FOURCC_YV12: + R128CopyMungedData(buf + (top * srcPitch) + (left >> 1), + buf + offset2, buf + offset3, info->FB+fboffset, + srcPitch, srcPitch2, dstPitch, nlines, npixels); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + R128CopyData(buf,info->FB+fboffset,srcPitch,dstPitch, + nlines,npixels); + break; + } + + pPriv->videoStatus = CLIENT_VIDEO_ON; + return Success; +} + +static int +R128QueryImageAttributes( + ScrnInfoPtr pScrn, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets +) +{ + int size, tmp; + R128TRACE(("R128QueryImageAtrributes called\n")); + + if(*w > IMAGE_MAX_WIDTH) *w = IMAGE_MAX_WIDTH; + if(*h > IMAGE_MAX_HEIGHT) *h = IMAGE_MAX_HEIGHT; + + *w = (*w + 1) & ~1; + if(offsets) offsets[0] = 0; + + switch(id) { + case FOURCC_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; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + size = *w << 1; + if(pitches) pitches[0] = size; + size *= *h; + break; + } + + return size; +} +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_video.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_video.c new file mode 100644 index 000000000..4a453abdc --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_video.c @@ -0,0 +1,803 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_video.c,v 1.3 2000/10/23 21:16:49 tsi Exp $ */ +/************************************************************************** + +Copyright 2000 Stuart R. Anderson and Metro Link, 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 +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: + * Stuart R. Anderson <anderson@metrolink.com> + * + * Credits: + * + * This code is derived primarily from the GATOS Project run by Stea Greene. + * The initial version of this code was done by Vladimir Dergacheb. + * + * This code was simplified from the GATOS code primarily because I didn't + * have the right hardware handy to test anything beyond simple overlays, + * and because I wanted to complete it in a short time frame that I had + * available. + * + * My apologies to Vladimir as there is more good work in his code that + * should be brought forward. + * + * RADEON ALERT ! + * This is an extremely quick port to the Radeon, it hasn't been tested + * thoroughly, although it appears to work. + */ +#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 "xf86xv.h" +#include "xf86Cursor.h" +#include "Xv.h" +#include "xaalocal.h" +#include "dixstruct.h" +#include "fourcc.h" + +#include "radeon.h" +#include "radeon_reg.h" + +/* + * For Debug +#define OUTREG(addr, val) { xf86DrvMsgVerb(pScrn->scrnIndex,X_INFO,1,"OUTREG(%s,%x)\n",#addr,val) ;MMIO_OUT32(RADEONMMIO, addr, val);} +*/ + +#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 +void RADEONInitVideo(ScreenPtr); +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 *); + +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) + +#define IMAGE_MAX_WIDTH 2048 +#define IMAGE_MAX_HEIGHT 2048 +#define Y_BUF_SIZE (IMAGE_MAX_WIDTH * IMAGE_MAX_HEIGHT) + +static Atom xvColorKey; + +typedef struct { + int videoStatus; + unsigned char brightness; + unsigned char contrast; + + RegionRec clip; + CARD32 colorKey; + CARD8 overlay_pixel_size; + CARD8 current_buffer; + int overlay_pad; + CARD32 overlay_id; + CARD32 overlay_width; + + CARD32 scale_cntl; + CARD32 video_format; + FBLinearPtr linear; + } RADEONPortPrivRec, *RADEONPortPrivPtr; + +void RADEONInitVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL; + int num_adaptors; + + RADEONTRACE(("RADEONInitVideo called\n")); + + /* Determine if the card supports this */ + if (pScrn->bitsPerPixel != 8) + { + 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[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}, + {32, TrueColor} +}; + +#define NUM_ATTRIBUTES 1 + +static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = +{ + {XvSettable | XvGettable, 0, (1<<24)-1, "XV_COLORKEY"}, +}; + +#define NUM_IMAGES 3 + +static XF86ImageRec Images[NUM_IMAGES] = +{ + XVIMAGE_YUY2, + XVIMAGE_YV12, + XVIMAGE_UYVY +}; + +static void +RADEONResetVideo(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONPortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; + + RADEONTRACE(("RADEONResetVideo called\n")); + + /* Initialize some of the HW here */ + OUTREG(RADEON_OV0_EXCLUSIVE_HORZ,0); /* disable exclusive mode */ + OUTREG(RADEON_OV0_VIDEO_KEY_MSK,0xffff); + OUTREG(RADEON_OV0_KEY_CNTL, RADEON_GRAPHIC_KEY_FN_NE); + OUTREG(RADEON_OV0_GRAPHICS_KEY_CLR,pPriv->colorKey); + /* Only using one buffer for now + OUTREG(RADEON_OV0_AUTO_FLIP_CNTL,pAPriv->Port[0].auto_flip_cntl); + */ + switch(pScrn->depth){ + case 8: + OUTREG(RADEON_OV0_GRAPHICS_KEY_MSK,0xff); + break; + case 15: + OUTREG(RADEON_OV0_GRAPHICS_KEY_MSK,0x7fff); + break; + case 16: + OUTREG(RADEON_OV0_GRAPHICS_KEY_MSK,0xffff); + break; + case 24: + OUTREG(RADEON_OV0_GRAPHICS_KEY_MSK,0xffffff); + break; + case 32: + OUTREG(RADEON_OV0_GRAPHICS_KEY_MSK,0xffffffff); + break; + } + + OUTREG(RADEON_OV0_REG_LOAD_CNTL,0x0); + OUTREG(RADEON_OV0_DEINTERLACE_PATTERN,0xAAAAA); + OUTREG(RADEON_OV0_P1_V_ACCUM_INIT,(2<<20)|1); + OUTREG(RADEON_OV0_P23_V_ACCUM_INIT,(2<<20)|1); + OUTREG(RADEON_OV0_P1_H_ACCUM_INIT,(3<<28)); + OUTREG(RADEON_OV0_P23_H_ACCUM_INIT,(2<<28)); + OUTREG(RADEON_OV0_STEP_BY,1|(1<<8)); + OUTREG(RADEON_OV0_FILTER_CNTL,0xf); /* use hardcoded coeff's */ + OUTREG(RADEON_OV0_FILTER_CNTL,0x0); /* use programmable coeff's */ + OUTREG(RADEON_OV0_FOUR_TAP_COEF_0 , 0x00002000); + OUTREG(RADEON_OV0_FOUR_TAP_COEF_1 , 0x0D06200D); + OUTREG(RADEON_OV0_FOUR_TAP_COEF_2 , 0x0D0A1C0D); + OUTREG(RADEON_OV0_FOUR_TAP_COEF_3 , 0x0C0E1A0C); + OUTREG(RADEON_OV0_FOUR_TAP_COEF_4 , 0x0C14140C); + OUTREG(RADEON_OV0_COLOUR_CNTL,(1<<12)|(1<<20)); + OUTREG(RADEON_OV0_TEST,0); + OUTREG(RADEON_OV0_SCALE_CNTL,pPriv->scale_cntl|pPriv->video_format); + OUTREG(RADEON_CAP0_TRIG_CNTL,0); +} + +static XF86VideoAdaptorPtr +RADEONSetupImageVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + XF86VideoAdaptorPtr adapt; + RADEONPortPrivPtr pPriv; + + RADEONTRACE(("RADEONSetupImageVideo called\n")); + + if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + + sizeof(RADEONPortPrivRec) + + sizeof(DevUnion)))) + return NULL; + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "RADEON Video Overlay"; + adapt->nEncodings = 1; + adapt->pEncodings = DummyEncoding; + adapt->nFormats = NUM_FORMATS; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->pPortPrivates = (DevUnion*)(&adapt[1]); + + pPriv = (RADEONPortPrivPtr)(&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 = RADEONStopVideo; + adapt->SetPortAttribute = RADEONSetPortAttribute; + adapt->GetPortAttribute = RADEONGetPortAttribute; + adapt->QueryBestSize = RADEONQueryBestSize; + adapt->PutImage = RADEONPutImage; + adapt->QueryImageAttributes = RADEONQueryImageAttributes; + + /* gotta uninit this someplace */ + REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); + + info->adaptor = adapt; + + pPriv->colorKey = 0x01; /* a touch of blue */ + pPriv->video_format = RADEON_SCALER_SOURCE_VYUY422; + pPriv->scale_cntl = RADEON_SCALER_PRG_LOAD_START|RADEON_SCALER_DOUBLE_BUFFER; + pPriv->scale_cntl|= RADEON_SCALER_SMART_SWITCH|RADEON_SCALER_PIX_EXPAND; + pPriv->scale_cntl|= RADEON_SCALER_SMART_SWITCH; + + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + + RADEONResetVideo(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 void +RADEONStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr) data; + + RADEONTRACE(("RADEONStopVideo called\n")); + + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + + if(exit) { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + OUTREG(RADEON_OV0_SCALE_CNTL,pPriv->scale_cntl|pPriv->video_format); + } + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; + } + pPriv->videoStatus = 0; + } else { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + } + } +} + +static int +RADEONSetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 value, + pointer data +) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr) data; + + RADEONTRACE(("RADEONSetPortAttribute called\n")); + + if (attribute == xvColorKey) { + pPriv->colorKey = value; + OUTREG(RADEON_OV0_GRAPHICS_KEY_CLR,pPriv->colorKey); + RADEONTRACE(("Setting ColorKey to %d\n", pPriv->colorKey)); + return Success; + } + + return Success; +} + +static int +RADEONGetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 *value, + pointer data +) +{ + RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr) data; + + RADEONTRACE(("RADEONGetPortAttribute called\n")); + + if (attribute == xvColorKey) { + RADEONTRACE(("Getting ColorKey %d\n", pPriv->colorKey)); + *value = pPriv->colorKey; + return Success; + } + + 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 +) +{ + RADEONTRACE(("RADEONQueryBestSize called\n")); + *p_w = drw_w; + *p_h = drw_h; +} + +static void +RADEONDisplayVideo( + 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, + int fboffset +) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONPortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; + int step_by, vert_inc, horz_inc; + + RADEONTRACE(("RADEONDisplayVideo called\n")); + + /* calculate step_by factor */ + step_by=src_w/(drw_w*2); + switch(step_by){ + case 0: + OUTREG(RADEON_OV0_STEP_BY,0x101); + step_by=1; + break; + case 1: + OUTREG(RADEON_OV0_STEP_BY,0x202); + step_by=2; + break; + case 2: + case 3: + OUTREG(RADEON_OV0_STEP_BY,0x303); + step_by=4; + break; + default: + OUTREG(RADEON_OV0_STEP_BY,0x404); + step_by=8; + break; + } + + vert_inc=(src_h<<12)/(drw_h); + horz_inc=(src_w<<12)/(drw_w*step_by); + + OUTREG(RADEON_OV0_Y_X_START,((x1))|(y1<<16)|(1<<31)); + OUTREG(RADEON_OV0_Y_X_END,((x2))|((y2)<<16)); + OUTREG(RADEON_OV0_H_INC,(horz_inc)|((horz_inc<<15))); + OUTREG(RADEON_OV0_V_INC,(vert_inc<<8)); + OUTREG(RADEON_OV0_P1_BLANK_LINES_AT_TOP,0xfff|((src_h-1)<<16)); + OUTREG(RADEON_OV0_P23_BLANK_LINES_AT_TOP,0xfff|((src_h-1)<<16)); + OUTREG(RADEON_OV0_VID_BUF_PITCH0_VALUE,width<<1); + OUTREG(RADEON_OV0_VID_BUF_PITCH1_VALUE,width<<1); + OUTREG(RADEON_OV0_P1_X_START_END,(src_w-1)|((x1&0xf)<<16)); + OUTREG(RADEON_OV0_P2_X_START_END,(src_w-1)|((x1&0xf)<<16)); + OUTREG(RADEON_OV0_P3_X_START_END,(src_w-1)|((x1&0xf)<<16)); + + OUTREG(RADEON_OV0_VID_BUF0_BASE_ADRS,(fboffset)&(~0xf)); + OUTREG(RADEON_OV0_VID_BUF1_BASE_ADRS,(fboffset)&(~0xf)); + OUTREG(RADEON_OV0_VID_BUF2_BASE_ADRS,(fboffset)&(~0xf)); + +#if 0 + /* Enable this when double buffering is implemented */ + OUTREG(RADEON_OV0_VID_BUF3_BASE_ADRS,(fboffset2)&(~0xf)); + OUTREG(RADEON_OV0_VID_BUF4_BASE_ADRS,(fboffset2)&(~0xf)); + OUTREG(RADEON_OV0_VID_BUF5_BASE_ADRS,(fboffset2)&(~0xf)); +#endif + + OUTREG(RADEON_OV0_SCALE_CNTL,pPriv->scale_cntl|RADEON_SCALER_ENABLE|pPriv->video_format); +} + +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 = (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 +RADEONAllocateMemory( + ScrnInfoPtr pScrn, + FBLinearPtr linear, + int size +) +{ + ScreenPtr pScreen; + FBLinearPtr new_linear; + + RADEONTRACE(("RADEONAllocateMemory(%x,%d) called\n",linear,size)); + + 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); + } + + RADEONTRACE(("returning %x(%x)\n",new_linear,new_linear->offset)); + + return new_linear; +} + +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); + unsigned char *RADEONMMIO = info->MMIO; + RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr)data; + INT32 x1, x2, y1, y2; + INT32 d_x,d_y,d_width,d_height; + int srcPitch = 0, srcPitch2 = 0; + int dstPitch = 0; + int offset,offset2 = 0,offset3 = 0,fboffset; + int top, left, npixels, nlines, size; + BoxRec dstBox; + CARD32 video_format; + + RADEONTRACE(("RADEONPutImage called\n")); + + switch(id) { + case FOURCC_YV12: + case FOURCC_UYVY: + video_format=RADEON_SCALER_SOURCE_VYUY422; + break; + case FOURCC_YUY2: + video_format=RADEON_SCALER_SOURCE_YVYU422; + break; + default: + return BadValue; + } + + /* Clip */ + d_x=drw_x; + d_y=drw_y; + d_width=drw_w; + d_height=drw_h; + if(drw_x<0){ + drw_w+=drw_x; + drw_x=0; + } + if(drw_y<0){ + drw_h+=drw_y; + drw_y=0; + } + if(drw_x+drw_w>pScrn->pScreen->width){ + drw_w=pScrn->pScreen->width-drw_x; + } + if(drw_y+drw_h>pScrn->pScreen->height){ + drw_h=pScrn->pScreen->height-drw_y; + } + if((drw_w<=0)||(drw_h<=0)){ + /* this should not happen, + since we are outside of visible screen, + but just in case */ + return Success; + } + + x1 = src_x; + x2 = src_x + src_w; + y1 = src_y; + y2 = src_y + src_h; + + dstPitch = width*info->CurrentLayout.pixel_bytes; + srcPitch=width; + + switch(id) { + case FOURCC_YV12: + size = width * height * 2; /* 16bpp */ + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + size = width * height * 1.5; + break; + } + + if(!(pPriv->linear = RADEONAllocateMemory(pScrn, pPriv->linear,size))) + return BadAlloc; + + /* copy data */ + top = y1 >> 16; + left = (x1 >> 16) & ~1; + npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left; + + switch(id) { + case FOURCC_YV12: + srcPitch = (width + 3) & ~3; + offset2 = srcPitch * height; + srcPitch2 = ((width >> 1) + 3) & ~3; + offset3 = (srcPitch2 * (height >> 1)) + offset2; + nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + buf += (top * srcPitch) + left; + nlines = ((y2 + 0xffff) >> 16) - top; + srcPitch = (width << 1); + break; + } + nlines=src_h; + npixels=src_w; + if(npixels>width) npixels=width; + if(nlines>height) nlines=height; + + /* adjust source rectangle */ + src_x+=((drw_x-d_x)*src_w)/d_width; + src_y+=((drw_y-d_y)*src_h)/d_height; + + src_w=(src_w * drw_w)/d_width; + src_h=(src_h * drw_h)/d_height; + + offset=(src_x+src_y*width)*info->CurrentLayout.pixel_bytes; + fboffset=pPriv->linear->offset*info->CurrentLayout.pixel_bytes; + + if(!(INREG(RADEON_CRTC_STATUS)&2)){ + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"too fast"); + return Success; + } + + RADEONDisplayVideo(pScrn, id, width, height, dstPitch, + drw_x, drw_y, drw_x+drw_w, drw_y+drw_h, + &dstBox, src_w, src_h, drw_w, drw_h,fboffset); + + /* 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)); + } + + + switch(id) { + case FOURCC_YV12: + RADEONCopyMungedData(buf + (top * srcPitch) + (left >> 1), + buf + offset2, buf + offset3, info->FB+fboffset, + srcPitch, srcPitch2, dstPitch, nlines, npixels); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + RADEONCopyData(buf,info->FB+fboffset,srcPitch,dstPitch, + nlines,npixels); + break; + } + + pPriv->videoStatus = CLIENT_VIDEO_ON; + return Success; +} + +static int +RADEONQueryImageAttributes( + ScrnInfoPtr pScrn, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets +) +{ + int size, tmp; + RADEONTRACE(("RADEONQueryImageAtrributes called\n")); + + if(*w > IMAGE_MAX_WIDTH) *w = IMAGE_MAX_WIDTH; + if(*h > IMAGE_MAX_HEIGHT) *h = IMAGE_MAX_HEIGHT; + + *w = (*w + 1) & ~1; + if(offsets) offsets[0] = 0; + + switch(id) { + case FOURCC_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; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + size = *w << 1; + if(pitches) pitches[0] = size; + size *= *h; + break; + } + + return size; +} +#endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_xv.c b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_xv.c new file mode 100755 index 000000000..8fd912834 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_xv.c @@ -0,0 +1,1096 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_xv.c,v 1.1 2000/10/23 14:54:45 alanh 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) || + (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; +} + + + +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) +{ + S3VPtr ps3v = S3VPTR(pScrn); + S3VPortPrivPtr pPriv = ps3v->portPrivate; + + /* empty for ViRGE at the moment... */ +#if 0 + 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 = /*pMga->videoKey;*/ + /*cep*/ + (1 << pScrn->offset.red) | + (1 << pScrn->offset.green) | + (((pScrn->mask.blue >> pScrn->offset.blue) - 1) << pScrn->offset.blue); + +#if 0 + pScrn->mask.red | pScrn->mask.green | pScrn->mask.blue; + (1 << (pScrn->offset.red+4)) | + (1 << (pScrn->offset.green+5)) | + (((pScrn->mask.blue >> pScrn->offset.blue) - 1) << pScrn->offset.blue); +#endif + + +#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; + +#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) + { + /*OUTREG(MGAREG_BESCTL, 0);*/ + /*OUTREG(SSTREAM_CONTROL_REG, 0x02000000);*/ + /* 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 +){ +#if 0 + MGAPtr pMga = MGAPTR(pScrn); +#endif + int tmp; + int flag; + +#if 0 + CHECK_DMA_QUIESCENT(pMga, pScrn); +#endif + S3VPtr ps3v = S3VPTR(pScrn); + S3VPortPrivPtr pPriv = ps3v->portPrivate; + +#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. */ + + 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 tmp =2; + /*tmp &= 3;*/ + /* YCbCr-16 */ + if( drw_w == src_w ) flag = 1; else flag = 0; + OUTREG(SSTREAM_CONTROL_REG, + tmp << 28 | 0x01000000 | + ((((src_w-1)<<1)-(drw_w-1)) & 0xfff) + ); + break; + } + + OUTREG(SSTREAM_STRETCH_REG, + ((src_w - 1) & 0x7ff) | (((src_w-drw_w) & 0x7ff) << 16) + ); +#if 0 + /* Opaque overlay secondary stream */ + OUTREG(BLEND_CONTROL_REG, 0x00000000); +#else + /* Color key on primary */ + OUTREG(BLEND_CONTROL_REG, 0x05000000); +#endif + + OUTREG(SSTREAM_FBADDR0_REG, offset & 0x3fffff ); + OUTREG(SSTREAM_STRIDE_REG, (pitch /*>> 1*/) & 0xfff ); + + OUTREG(K1_VSCALE_REG, src_h-1 ); + OUTREG(K2_VSCALE_REG, (src_h - drw_h) & 0x7ff ); + 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 + ); + +#if 0 + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Weights r:%X g:%X b:%X " + "ck:%X mb:%X or:%X ob:%X ckc:%X\n" , + pScrn->weight.red, + pScrn->weight.green, + pScrn->weight.blue, + pPriv->colorKey, + pScrn->mask.blue, + pScrn->offset.red, + pScrn->offset.blue, + /*0x17000000*/ 0x10000000 | ((pScrn->weight.red-1) << 24) | + ((pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red)<<16<<3 | + ((pPriv->colorKey & pScrn->mask.green) >> pScrn->offset.green)<<8<<2 | + ((pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset.blue)<<3 + + ); +#endif + + /*cep*/ + 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 0 + OUTREG(MGAREG_BESA1ORG, offset); + + if(y1 & 0x00010000) + OUTREG(MGAREG_BESCTL, 0x00050c41); + else + OUTREG(MGAREG_BESCTL, 0x00050c01); + + OUTREG(MGAREG_BESHCOORD, (dstBox->x1 << 16) | (dstBox->x2 - 1)); + OUTREG(MGAREG_BESVCOORD, (dstBox->y1 << 16) | (dstBox->y2 - 1)); + + OUTREG(MGAREG_BESHSRCST, x1 & 0x03fffffc); + OUTREG(MGAREG_BESHSRCEND, (x2 - 0x00010000) & 0x03fffffc); + OUTREG(MGAREG_BESHSRCLST, (width - 1) << 16); + + OUTREG(MGAREG_BESPITCH, pitch >> 1); + + OUTREG(MGAREG_BESV1WGHT, y1 & 0x0000fffc); + OUTREG(MGAREG_BESV1SRCLST, height - 1 - (y1 >> 16)); + + tmp = ((src_h - 1) << 16)/drw_h; + if(tmp >= (32 << 16)) + tmp = (32 << 16) - 1; + OUTREG(MGAREG_BESVISCAL, tmp & 0x001ffffc); + + tmp = (((src_w - 1) << 16)/drw_w) << 1; + if(tmp >= (32 << 16)) + tmp = (32 << 16) - 1; + OUTREG(MGAREG_BESHISCAL, tmp & 0x001ffffc); +#endif /*0*/ + +} + + +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, offset3; + int srcPitch, srcPitch2, 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 += 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 */ + diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tga/IBM561ramdac.c b/xc/programs/Xserver/hw/xfree86/drivers/tga/IBM561ramdac.c new file mode 100644 index 000000000..1443fb8f4 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/tga/IBM561ramdac.c @@ -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]); +*/ + +} + diff --git a/xc/programs/Xserver/hw/xfree86/drivers/vesa/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/vesa/Imakefile new file mode 100644 index 000000000..42840ea4f --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/vesa/Imakefile @@ -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) + diff --git a/xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c b/xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c new file mode 100644 index 000000000..558652a18 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c @@ -0,0 +1,2429 @@ +/* + * 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.4 2000/10/27 18:31:04 dawes 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" +#define DEBUG +/* 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 = NULL; + 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) + return (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) + return (TRUE); + 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); + } + } + + if (devSections) + 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)) { + ErrorF("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 { + ErrorF("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); +#ifdef DEBUG + ErrorF("virtual address = %p - physical address = %p - size = %d\n", + pVesa->base, pScrn->memPhysBase, pVesa->mapSize); +#endif + +#if 0 + pVesa->base = xf86int10Addr(pVesa->pInt, 0xa0000); +#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); + 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; + + if (pVesa->fonts != NULL) + return; + + pVesa->fonts = xalloc(16384); + + /* If in graphics mode, don't save anything */ + attr10 = ReadAttr(0x10); + if (attr10 & 0x01) + return; + + /* 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); + + 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->base, 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->base, pVesa->fonts + 8192, 8192); + + /* 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; + + if (pVesa->fonts == NULL) + return; + + /* 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); + + 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->base, 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->base, 8192); + + /* 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); + unsigned char scrn = ReadSeq(0x01); + + if (on) + SetTimeSinceLastInputEvent(); + + if (pScrn->vtSema) { + 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); + + 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; + + 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 (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)); +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.cpp b/xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.cpp new file mode 100644 index 000000000..c56806118 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.cpp @@ -0,0 +1,53 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.cpp,v 1.1 2000/10/20 14:59:01 alanh Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH VESA __drivermansuffix__ "Version 4.0.1" "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. diff --git a/xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.h b/xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.h new file mode 100644 index 000000000..86cab01ae --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.h @@ -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.4 2000/10/27 18:31:05 dawes 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; + 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_ */ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSiS.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSiS.c new file mode 100644 index 000000000..d626f57c5 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSiS.c @@ -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; +} diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c new file mode 100644 index 000000000..6d836644c --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c @@ -0,0 +1,347 @@ +/* + * 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.1 2000/10/20 14:59:05 alanh 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); + +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) +#ifdef __alpha__ + SYMFUNC(_bus_base) +#endif + + SYMFUNC(xf86AddDriver) + {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; +} +#endif diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h new file mode 100644 index 000000000..5d7b69863 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h @@ -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 */ diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.c new file mode 100644 index 000000000..75c956bdd --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.c @@ -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) */ diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.h new file mode 100644 index 000000000..42d802307 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.h @@ -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 */ diff --git a/xc/programs/Xserver/mi/micoord.h b/xc/programs/Xserver/mi/micoord.h new file mode 100644 index 000000000..c80ba0b7f --- /dev/null +++ b/xc/programs/Xserver/mi/micoord.h @@ -0,0 +1,67 @@ +/* $XFree86: xc/programs/Xserver/mi/micoord.h,v 1.1 2000/10/23 21:16:52 tsi 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, + * 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. + * + */ + +#ifndef _MICOORD_H_ +#define _MICOORD_H_ 1 + +/* Macros which handle a coordinate in a single register */ + +/* + * Most compilers will convert divisions by 65536 into shifts, if signed + * shifts exist. If your machine does arithmetic shifts and your compiler + * can't get it right, add to this line. + */ + +/* + * mips compiler - what a joke - it CSEs the 65536 constant into a reg + * forcing as to use div instead of shift. Let's be explicit. + */ + +#if defined(mips) || \ + defined(sparc) || \ + defined(__alpha) || defined(__alpha__) || \ + defined(__i386__) || defined(i386) || \ + defined(__ia64__) || defined(ia64) +#define GetHighWord(x) (((int) (x)) >> 16) +#else +#define GetHighWord(x) (((int) (x)) / 65536) +#endif + +#if IMAGE_BYTE_ORDER == MSBFirst +#define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int) ((short) (i)))) +#define coordToInt(x,y) (((x) << 16) | ((y) & 0xffff)) +#define intToX(i) (GetHighWord(i)) +#define intToY(i) ((int) ((short) i)) +#else +#define intToCoord(i,x,y) (((x) = (int) ((short) (i))), ((y) = GetHighWord(i))) +#define coordToInt(x,y) (((y) << 16) | ((x) & 0xffff)) +#define intToX(i) ((int) ((short) (i))) +#define intToY(i) (GetHighWord(i)) +#endif + +#endif /* _MICOORD_H_ */ |