summaryrefslogtreecommitdiff
path: root/hw/kdrive/trio
diff options
context:
space:
mode:
Diffstat (limited to 'hw/kdrive/trio')
-rw-r--r--hw/kdrive/trio/s3.c500
-rw-r--r--hw/kdrive/trio/s3.h76
-rw-r--r--hw/kdrive/trio/s3clock.c8
-rw-r--r--hw/kdrive/trio/s3curs.c79
-rw-r--r--hw/kdrive/trio/s3stub.c8
5 files changed, 160 insertions, 511 deletions
diff --git a/hw/kdrive/trio/s3.c b/hw/kdrive/trio/s3.c
index 3233173cb..182c59b17 100644
--- a/hw/kdrive/trio/s3.c
+++ b/hw/kdrive/trio/s3.c
@@ -21,139 +21,13 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3.c,v 1.1 1999/11/19 13:54:02 hohndel Exp $ */
#include "s3.h"
#define REGISTERS_OFFSET (0x1000000)
#define PACKED_OFFSET (0x8100)
-/*
- * Clock synthesis:
- *
- * f_out = f_ref * ((M + 2) / ((N + 2) * (1 << R)))
- *
- * Constraints:
- *
- * 1. 135MHz <= f_ref * ((M + 2) / (N + 2)) <= 270 MHz
- * 2. N >= 1
- *
- * Vertical refresh rate = clock / ((hsize + hblank) * (vsize + vblank))
- * Horizontal refresh rate = clock / (hsize + hblank)
- */
-
-#define DEFAULT_S3_TIMING 1
-
-S3Timing s3Timings[] = {
- /* FP BP BLANK */
- /* M N R blank bios5 */
- { 640, 480, 60,
- 16, 48, 160, /* horizontal 31.321 KHz */
- 10, 33, 45, /* vertical 59.568 Hz */
- 26, 0, 3, /* pixel 25.057 MHz */
- },
-
- { 800, 600, 85,
- 32, 152, 248, /* horizontal 53.673 KHz */
- 1, 27, 31, /* vertical 85.060 Hz */
- 108, 5, 2, /* pixel 56.249 MHz */
- },
- { 800, 600, 75,
- 16, 160, 256, /* horizontal 46.891 KHz */
- 1, 21, 25, /* vertical 75.025 Hz */
- 81, 4, 2, /* pixel 49.516 MHz */
- },
- { 800, 600, 72,
- 56, 64, 240, /* horizontal 48.186 KHz */
- 37, 23, 66, /* vertical 72.351 Hz */
- 26, 0, 2, /* pixel 50.113 MHz */
- },
-
- { 1024, 768, 85,
- 48, 208, 352, /* horizontal 68.676 KHz */
- 1, 36, 40, /* vertical 84.996 Hz */
- 64, 3, 1, /* pixel 94.499 MHz */
- },
- { 1024, 768, 75,
- 16, 176, 288, /* horizontal 60.022 KHz */
- 1, 28, 32, /* vertical 75.028 Hz */
- 20, 0, 1, /* pixel 78.749 MHz */
- },
- { 1024, 768, 70,
- 24, 144, 304, /* horizontal 56.604 KHz */
- 3, 29, 38, /* vertical 70.227 Hz */
- 40, 2, 1, /* pixel 75.170 MHz */
- },
- { 1024, 768, 66,
- 24, 144, 304, /* horizontal 53.234 KHz */
- 3, 29, 38, /* vertical 66.047 Hz */
- 77, 6, 1, /* pixel 70.695 MHz */
- },
-
- { 1152, 900, 85,
- 48, 208, 384, /* horizontal 79.900 KHz */
- 1, 32, 38, /* vertical 85.181 Hz */
- 118, 5, 1, /* pixel 122.726 MHz */
- },
- { 1152, 900, 75,
- 32, 208, 384, /* horizontal 70.495 Khz */
- 1, 32, 38, /* vertical 75.154 Hz */
- 119, 6, 1, /* pixel 108.280 MHz */
- },
- { 1152, 900, 70,
- 32, 208, 384, /* horizontal 65.251 KHz */
- 2, 32, 38, /* vertical 69.564 Hz */
- 12, 0, 0, /* pixel 100.226 MHz */
- },
- { 1152, 900, 66,
- 32, 208, 384, /* horizontal 61.817 KHz */
- 1, 32, 38, /* vertical 65.903 Hz */
- 124, 17, 0, /* pixel 94.951 MHz */
- },
- { 1280, 1024, 85,
- 16, 248, 416, /* horizontal 90.561 KHz */
- 1, 40, 45, /* vertical 84.717 Hz */
- 116, 9, 0, /* pixel 153.593 MHz */
- },
- { 1280, 1024, 75,
- 16, 248, 408, /* horizontal 80.255 KHz */
- 1, 38, 42, /* vertical 75.285 Hz */
- 111, 4, 1, /* pixel 134.828 MHz */
- },
- { 1280, 1024, 70,
- 32, 248, 400, /* horizontal 74.573 KHz */
- 0, 36, 39, /* vertical 70.153 Hz */
- 68, 2, 1, /* pixel 125.283 MHz */
- },
- { 1280, 1024, 66,
- 32, 248, 400, /* horizontal 70.007 KHz */
- 0, 36, 39, /* vertical 65.858 Hz */
- 113, 5, 1, /* pixel 117.612 MHz */
- },
-
- { 1600, 1200, 85,
- 64, 304, 560, /* horizontal 106.059 KHz */
- 1, 46, 50, /* vertical 84.847 Hz */
- 126, 6, 0, /* pixel 229.088 MHz */
- },
- { 1600, 1200, 75,
- 64, 304, 560, /* horizontal 93.748 KHz */
- 1, 46, 50, /* vertical 74.999 Hz */
- 97, 5, 0, /* pixel 202.497 MHz */
- },
- { 1600, 1200, 70,
- 56, 304, 588, /* horizontal 87.524 KHz */
- 1, 46, 50, /* vertical 70.019 Hz */
- 105, 6, 0, /* pixel 191.503 MHz */
- },
- { 1600, 1200, 65,
- 56, 308, 524, /* horizontal 80.050 KHz */
- 1, 38, 42, /* vertical 64.453 Hz */
- 93, 6, 0, /* pixel 170.026 MHz */
- },
-};
-
-#define NUM_S3_TIMINGS (sizeof (s3Timings) / sizeof (s3Timings[0]))
CARD8
_s3ReadIndexRegister (volatile CARD8 *base, CARD8 index)
@@ -245,20 +119,7 @@ _s3LoadCrtc (S3Ptr s3, S3Crtc *crtc)
crtc->dclk_value_high = GetSrtc (s3, 0x13);
crtc->control_2 = GetSrtc (s3, 0x15);
crtc->ramdac_control = GetSrtc (s3, 0x18);
-
- crtc->dclk_value_low_savage = GetSrtc (s3, 0x36);
- crtc->dclk_pll_m0_savage_0_7 = GetSrtc (s3, 0x37);
- crtc->dclk_pll_m1_savage_0_7 = GetSrtc (s3, 0x38);
- crtc->extended_seq_39 = GetSrtc (s3, 0x39);
-
- fprintf (stderr, "SR1A 0x%x SR1B 0x%x\n",
- GetSrtc (s3, 0x1a),
- GetSrtc (s3, 0x1b));
- fprintf (stderr, "SR36 0x%x SR37 0x%x SR38 0x%x SR39 0x%x\n",
- GetSrtc (s3, 0x36),
- GetSrtc (s3, 0x37),
- GetSrtc (s3, 0x38),
- GetSrtc (s3, 0x39));
+
/* combine values */
switch (crtc_ge_screen_width(crtc)) {
@@ -391,12 +252,8 @@ _s3SetDepth (S3Ptr s3, S3Crtc *crtc)
*/
save_3c2 = s3->crt_vga_3cc;
DRAW_DEBUG ((DEBUG_S3INIT, "save_3c2 0x%x", save_3c2));
- s3->crt_vga_3c2 = 0x0f;
+ s3->crt_vga_3c2 = save_3c2 | 0x0c;
- PutSrtc (s3, 0x36, crtc->dclk_value_low_savage);
- PutSrtc (s3, 0x37, crtc->dclk_pll_m0_savage_0_7);
- PutSrtc (s3, 0x38, crtc->dclk_pll_m1_savage_0_7);
- PutSrtc (s3, 0x39, crtc->extended_seq_39);
PutSrtc(s3, 0x12, crtc->dclk_value_low);
PutSrtc(s3, 0x13, crtc->dclk_value_high);
@@ -453,7 +310,6 @@ s3Reset (S3CardInfo *s3c)
s3->scissors_br = 0x0fff0fff;
_s3WriteIndexRegister (&s3->crt_vga_3c4, 0x01, save->clock_mode);
- PutSrtc(s3, 0x08, save->locksrtc);
PutCrtc(s3, 0x39, save->lock2);
PutCrtc(s3, 0x38, save->lock1);
@@ -478,11 +334,6 @@ s3Save (S3CardInfo *s3c)
save->lock1 = GetCrtc(s3, 0x38);
save->lock2 = GetCrtc(s3, 0x39);
- save->locksrtc = GetSrtc (s3, 0x08);
-
- /* unlock srtc registers to read them */
- PutSrtc (s3, 0x08, 0x06);
-
save->clock_mode = _s3ReadIndexRegister (&s3->crt_vga_3c4, 0x01);
_s3UnlockExt (s3);
@@ -502,10 +353,8 @@ s3CardInit (KdCardInfo *card)
S3Ptr s3;
int size;
CARD8 *registers;
- CARD32 s3FrameBuffer;
- CARD32 s3Registers;
+ CARD32 s3Address = card->attr.address[0];
CARD8 *temp_buffer;
- CARD32 max_memory;
DRAW_DEBUG ((DEBUG_S3INIT, "s3CardInit"));
s3c = (S3CardInfo *) xalloc (sizeof (S3CardInfo));
@@ -519,23 +368,8 @@ s3CardInit (KdCardInfo *card)
card->driver = s3c;
- if (card->attr.naddr > 1)
- {
- s3FrameBuffer = card->attr.address[1];
- s3Registers = card->attr.address[0];
- max_memory = 32 * 1024 * 1024;
- s3c->savage = TRUE;
- }
- else
- {
- s3FrameBuffer = card->attr.address[0];
- s3Registers = s3FrameBuffer + REGISTERS_OFFSET;
- max_memory = 4 * 1024 * 1024;
- s3c->savage = FALSE;
- }
-
- fprintf (stderr, "S3 at 0x%x/0x%x\n", s3Registers, s3FrameBuffer);
- registers = KdMapDevice (s3Registers,
+ fprintf (stderr, "S3 at 0x%x\n", s3Address);
+ registers = KdMapDevice (s3Address + REGISTERS_OFFSET,
sizeof (S3) + PACKED_OFFSET);
if (!registers)
{
@@ -546,34 +380,30 @@ s3CardInit (KdCardInfo *card)
s3c->registers = registers;
s3c->s3 = s3;
-#if 0
s3->crt_vga_3c3 = 1; /* wake up part from deep sleep */
s3->crt_vga_3c2 = 0x01 | 0x02 | 0x0c;
s3->crt_vga_3c4 = 0x58;
s3->crt_vga_3c5 = 0x10 | 0x3;
-#endif
/*
* Can't trust S3 register value for frame buffer amount, must compute
*/
- temp_buffer = KdMapDevice (s3FrameBuffer, max_memory);
+ temp_buffer = KdMapDevice (s3Address, 4096 * 1024);
- s3c->memory = KdFrameBufferSize (temp_buffer, max_memory);
+ s3c->memory = KdFrameBufferSize (temp_buffer, 4096 * 1024);
- fprintf (stderr, "Frame buffer 0x%x\n", s3c->memory);
-
DRAW_DEBUG ((DEBUG_S3INIT, "Detected frame buffer %d", s3c->memory));
KdUnmapDevice (temp_buffer, 4096 * 1024);
if (!s3c->memory)
{
- ErrorF ("Can't detect s3 frame buffer at 0x%x\n", s3FrameBuffer);
+ ErrorF ("Can't detect s3 frame buffer\n");
goto bail3;
}
- s3c->frameBuffer = KdMapDevice (s3FrameBuffer, s3c->memory);
+ s3c->frameBuffer = KdMapDevice (s3Address, s3c->memory);
if (!s3c->frameBuffer)
{
ErrorF ("Can't map s3 frame buffer\n");
@@ -593,6 +423,60 @@ bail0:
}
Bool
+s3ModeSupported (KdScreenInfo *screen,
+ const KdMonitorTiming *t)
+{
+ if (t->horizontal != 1600 &&
+ t->horizontal != 1280 &&
+ t->horizontal != 1152 &&
+ t->horizontal != 800 &&
+ t->horizontal != 640)
+ return FALSE;
+ if (t->clock > S3_MAX_CLOCK * 2)
+ return FALSE;
+}
+
+Bool
+s3ModeUsable (KdScreenInfo *screen)
+{
+ KdCardInfo *card = screen->card;
+ S3CardInfo *s3c = (S3CardInfo *) card->driver;
+ int screen_size;
+ int pixel_width;
+ int byte_width;
+
+ if (screen->depth >= 24)
+ {
+ screen->depth = 24;
+ screen->bitsPerPixel = 32;
+ }
+ else if (screen->depth >= 16)
+ {
+ screen->depth = 16;
+ screen->bitsPerPixel = 16;
+ }
+ else if (screen->depth >= 15)
+ {
+ screen->depth = 15;
+ screen->bitsPerPixel = 16;
+ }
+ else
+ {
+ screen->depth = 8;
+ screen->bitsPerPixel = 8;
+ }
+
+ byte_width = screen->width * (screen->bitsPerPixel >> 3);
+ pixel_width = screen->width;
+ screen->pixelStride = pixel_width;
+ screen->byteStride = byte_width;
+
+ screen_size = byte_width * screen->height;
+
+ return screen_size <= s3c->memory;
+}
+
+Bool
s3ScreenInit (KdScreenInfo *screen)
{
KdCardInfo *card = screen->card;
@@ -606,7 +490,7 @@ s3ScreenInit (KdScreenInfo *screen)
int pixel_width;
int m, n, r;
int i;
- S3Timing *t;
+ const KdMonitorTiming *t;
DRAW_DEBUG ((DEBUG_S3INIT, "s3ScreenInit"));
s3s = (S3ScreenInfo *) xalloc (sizeof (S3ScreenInfo));
@@ -626,29 +510,12 @@ s3ScreenInit (KdScreenInfo *screen)
DRAW_DEBUG ((DEBUG_S3INIT, "Requested parameters %dx%dx%d",
screen->width, screen->height, screen->rate));
- for (i = 0, t = s3Timings; i < NUM_S3_TIMINGS; i++, t++)
- {
- DRAW_DEBUG ((DEBUG_S3INIT, "Available parameters %dx%dx%d",
- t->horizontal, t->vertical, t->rate));
- if (t->horizontal >= screen->width &&
- t->vertical >= screen->height &&
- (!screen->rate || t->rate <= screen->rate))
- break;
- }
- if (i == NUM_S3_TIMINGS)
- t = &s3Timings[DEFAULT_S3_TIMING];
+ t = KdFindMode (screen, s3ModeSupported);
screen->rate = t->rate;
screen->width = t->horizontal;
screen->height = t->vertical;
+ s3GetClock (t->clock, &m, &n, &r, 127, 31, 3);
#if 0
- s3GetClock (t, &m, &n, &r,
- s3c->savage ? 511 : 127,
- s3c->savage ? 127 : 31,
- s3c->savage ? 4 : 3);
-#else
- s3GetClock (t, &m, &n, &r, 127, 31, 3);
-#endif
-#if 1
fprintf (stderr, "computed %d,%d,%d (%d) provided %d,%d,%d (%d)\n",
m, n, r, S3_CLOCK(m,n,r),
t->dac_m, t->dac_n, t->dac_r,
@@ -657,97 +524,13 @@ s3ScreenInit (KdScreenInfo *screen)
/*
* Can only operate in pixel-doubled mode at 8 bits per pixel
*/
- if (s3c->savage)
- {
- if (screen->depth > 16 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
- screen->depth = 16;
- }
- else
- {
- if (screen->depth > 8 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
- screen->depth = 8;
- }
+ if (screen->depth > 8 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
+ screen->depth = 8;
- for (;;)
+ if (!KdTuneMode (screen, s3ModeUsable, s3ModeSupported))
{
- if (screen->depth >= 24)
- {
- screen->depth = 24;
- screen->bitsPerPixel = 32;
- }
- else if (screen->depth >= 16)
- {
- screen->depth = 16;
- screen->bitsPerPixel = 16;
- }
- else if (screen->depth >= 15)
- {
- screen->depth = 15;
- screen->bitsPerPixel = 16;
- }
- else
- {
- screen->depth = 8;
- screen->bitsPerPixel = 8;
- }
-
- /* Normalize width to supported values */
-
- if (screen->width >= 1600)
- screen->width = 1600;
- else if (screen->width >= 1280)
- screen->width = 1280;
- else if (screen->width >= 1152)
- screen->width = 1152;
- else if (screen->width >= 1024)
- screen->width = 1024;
- else if (screen->width >= 800)
- screen->width = 800;
- else
- screen->width = 640;
-
- byte_width = screen->width * (screen->bitsPerPixel >> 3);
- pixel_width = screen->width;
- screen->pixelStride = pixel_width;
- screen->byteStride = byte_width;
-
- screen_size = byte_width * screen->height;
-
- if (screen_size <= s3c->memory)
- break;
-
- /*
- * Fix requested depth and geometry until it works
- */
- if (screen->depth > 16)
- screen->depth = 16;
- else if (screen->depth > 8)
- screen->depth = 8;
- else if (screen->width > 1152)
- {
- screen->width = 1152;
- screen->height = 900;
- }
- else if (screen->width > 1024)
- {
- screen->width = 1024;
- screen->height = 768;
- }
- else if (screen->width > 800)
- {
- screen->width = 800;
- screen->height = 600;
- }
- else if (screen->width > 640)
- {
- screen->width = 640;
- screen->height = 480;
- }
- else
- {
- xfree (s3s);
- return FALSE;
- }
+ xfree (s3s);
+ return FALSE;
}
memory = s3c->memory - screen_size;
@@ -886,7 +669,7 @@ s3Enable (ScreenPtr pScreen)
int h_blank_extend_;
int i;
CARD16 cursor_address;
- S3Timing *t;
+ const KdMonitorTiming *t;
int m, n, r;
DRAW_DEBUG ((DEBUG_S3INIT, "s3Enable"));
@@ -894,17 +677,7 @@ s3Enable (ScreenPtr pScreen)
DRAW_DEBUG ((DEBUG_S3INIT, "requested bpp %d current %d",
pScreenPriv->bitsPerPixel, s3c->save.crtc.bits_per_pixel));
- for (i = 0; i < NUM_S3_TIMINGS; i++)
- {
- t = &s3Timings[i];
-
- if (t->horizontal == screen->width &&
- t->vertical == screen->height &&
- t->rate <= screen->rate)
- break;
- }
- if (i == NUM_S3_TIMINGS)
- t = &s3Timings[DEFAULT_S3_TIMING];
+ t = KdFindMode (screen, s3ModeSupported);
hfp = t->hfp;
hbp = t->hbp;
@@ -919,58 +692,23 @@ s3Enable (ScreenPtr pScreen)
crtcR = s3c->save.crtc;
crtc = &crtcR;
-#if 0
- if (s3c->savage)
- {
- m = ((int) crtc->dclk_pll_m_savage_8 << 8) | crtc->dclk_pll_m0_savage_0_7;
- n = (crtc->dclk_pll_n_savage_6 << 6) | crtc->dclk_pll_n_savage_0_5;
- r = (crtc->dclk_pll_r_savage_2 << 2) | crtc->dclk_pll_r_savage_0_1;
- fprintf (stderr, "old clock %d, %d, %d\n", m, n, r);
- s3GetClock (t, &m, &n, &r, 127, 31, 3);
-#if 0
- s3GetClock (t, &m, &n, &r, 511, 127, 4);
- crtc->dclk_pll_m0_savage_0_7 = m;
- crtc->dclk_pll_m1_savage_0_7 = m;
- crtc->dclk_pll_m_savage_8 = m >> 8;
- crtc->dclk_pll_n_savage_0_5 = n;
- crtc->dclk_pll_n_savage_6 = n >> 6;
- crtc->dclk_pll_r_savage_0_1 = r;
- crtc->dclk_pll_r_savage_2 = r >> 2;
- crtc->dclk_pll_select_savage = 1;
-#endif
- fprintf (stderr, "new clock %d, %d, %d\n", m, n, r);
- }
- else
- {
- s3GetClock (t, &m, &n, &r, 127, 31, 3);
- crtc->dclk_pll_m_trio = m;
- crtc->dclk_pll_n_trio = n;
- crtc->dclk_pll_r_trio = r;
- }
+ s3GetClock (t->clock, &m, &n, &r, 127, 31, 3);
+ crtc->dclk_pll_m_trio = m;
+ crtc->dclk_pll_n_trio = n;
+ crtc->dclk_pll_r_trio = r;
- if (!s3c->savage)
- {
- crtc->alt_refresh_count = 0x02;
- crtc->enable_alt_refresh = 1;
- }
- else
- {
- crtc->alt_refresh_count = 1;
- crtc->enable_alt_refresh = 0;
- }
+ crtc->alt_refresh_count = 0x02;
+ crtc->enable_alt_refresh = 1;
crtc->enable_256_or_more = 1;
DRAW_DEBUG ((DEBUG_S3INIT, "memory_bus_size %d\n", crtc->memory_bus_size));
- if (!s3c->savage)
- crtc->memory_bus_size = 1;
+ crtc->memory_bus_size = 1;
- if (!s3c->savage)
- crtc->dclk_over_2 = 0;
+ crtc->dclk_over_2 = 0;
crtc->dclk_invert = 0;
crtc->enable_clock_double = 0;
crtc->delay_blank = 0;
- if (!s3c->savage)
- crtc->extended_bios_5 = 0;
+ crtc->extended_bios_5 = 0;
/*
* Compute character lengths for horizontal timing values
*/
@@ -987,11 +725,12 @@ s3Enable (ScreenPtr pScreen)
* Set up for double-pixel mode, switch color modes,
* divide the dclk and delay h blank by 2 dclks
*/
- if (S3_CLOCK(m, n, r) > S3_MAX_CLOCK)
+ if (S3_CLOCK(crtc->dclk_pll_m_trio, crtc->dclk_pll_n_trio,
+ crtc->dclk_pll_r_trio) > S3_MAX_CLOCK)
{
DRAW_DEBUG ((DEBUG_S3INIT, "S3 clock %g > 80MHz, using pixel double mode",
- S3_CLOCK(crtc->dclk_pll_m, crtc->dclk_pll_n,
- crtc->dclk_pll_r)));
+ S3_CLOCK(crtc->dclk_pll_m_trio, crtc->dclk_pll_n_trio,
+ crtc->dclk_pll_r_trio)));
crtc->color_mode = 1;
crtc->dclk_over_2 = 1;
crtc->enable_clock_double = 1;
@@ -1001,50 +740,18 @@ s3Enable (ScreenPtr pScreen)
h_adjust = 1;
break;
case 16:
- if (s3c->savage)
- {
- hactive = screen->width / 4;
- hblank /= 4;
- hfp /= 4;
- hbp /= 4;
- h_screen_off = hactive * 2;
- crtc->pixel_length = 1;
- if (S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
- {
- if (crtc->depth == 15)
- crtc->color_mode = 3;
- else
- crtc->color_mode = 5;
- crtc->dclk_over_2 = 1;
- crtc->enable_clock_double = 1;
- crtc->delay_blank = 2;
- }
- else
- {
- if (crtc->depth == 15)
- crtc->color_mode = 2;
- else
- crtc->color_mode = 4;
- crtc->dclk_over_2 = 0;
- crtc->enable_clock_double = 0;
- }
- h_adjust = 1;
- }
+ hactive = screen->width / 4;
+ hblank /= 4;
+ hfp /= 4;
+ hbp /= 4;
+ h_screen_off = hactive;
+ crtc->pixel_length = 1;
+ crtc->extended_bios_5 = 2;
+ if (crtc->depth == 15)
+ crtc->color_mode = 3;
else
- {
- hactive = screen->width / 4;
- hblank /= 4;
- hfp /= 4;
- hbp /= 4;
- h_screen_off = hactive;
- crtc->pixel_length = 1;
- crtc->extended_bios_5 = 2;
- if (crtc->depth == 15)
- crtc->color_mode = 3;
- else
- crtc->color_mode = 5;
- h_adjust = 2;
- }
+ crtc->color_mode = 5;
+ h_adjust = 2;
break;
case 32:
hactive = screen->width / 8;
@@ -1057,7 +764,6 @@ s3Enable (ScreenPtr pScreen)
h_adjust = 1;
break;
}
-#endif
/*
* X server starts frame buffer at top of memory
@@ -1066,7 +772,6 @@ s3Enable (ScreenPtr pScreen)
crtc_start_address (crtc)));
crtc_set_start_address (crtc, 0);
-#if 0
/*
* Compute horizontal register values from timings
*/
@@ -1119,7 +824,6 @@ s3Enable (ScreenPtr pScreen)
crtc_set_v_display_end (crtc, v_display_end);
crtc_set_v_blank_start (crtc, v_blank_start);
crtc->v_blank_end_0_7 = v_blank_end;
-#endif
/*
* Set cursor
@@ -1277,6 +981,7 @@ s3CardFini (KdCardInfo *card)
KdCardFuncs s3Funcs = {
s3CardInit,
s3ScreenInit,
+ 0,
s3Preserve,
s3Enable,
s3DPMS,
@@ -1291,8 +996,15 @@ KdCardFuncs s3Funcs = {
s3RecolorCursor,
s3DrawInit,
s3DrawEnable,
+ s3DrawSync,
s3DrawDisable,
s3DrawFini,
s3GetColors,
s3PutColors,
};
+
+void
+S3InitCard (KdCardAttr *attr)
+{
+ KdCardInfoAdd (&s3Funcs, attr, 0);
+}
diff --git a/hw/kdrive/trio/s3.h b/hw/kdrive/trio/s3.h
index 97374045f..578690558 100644
--- a/hw/kdrive/trio/s3.h
+++ b/hw/kdrive/trio/s3.h
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3.h,v 1.1 1999/11/19 13:54:03 hohndel Exp $ */
#ifndef _S3_H_
#define _S3_H_
@@ -87,8 +87,7 @@ typedef volatile struct _s3 {
VOL32 alt_mix; /* 8134 */
VOL32 scissors_tl; /* 8138 */
VOL32 scissors_br; /* 813c */
- VOL16 pix_cntl; /* 8140 */
- VOL16 mult_misc2; /* 8142 */
+ VOL32 pix_cntl_mult_misc2; /* 8140 */
VOL32 mult_misc_read_sel; /* 8144 */
VOL32 alt_pcnt; /* 8148 min_axis_pcnt, maj_axis_pcnt */
VOL8 _pad3[0x19c]; /* 814c */
@@ -231,6 +230,7 @@ typedef volatile struct _s3 {
#define PATTERN_L 0x8000
#define PATTERN_H 0x9000
#define PIX_CNTL 0xa000
+#define CONTROL_MISC2 0xd000
#define PIX_TRANS 0xe2e8
/* Advanced Function Control Regsiter */
@@ -347,13 +347,19 @@ typedef volatile struct _s3 {
#define FIFO_SLOTS 13
+#define GPSLOT(n) (1 << ((n) > 8 ? (15 - ((n) - 9)) : (8 - (n))))
+
+/* Wait for n slots to become available */
#if 0
-/* Wait for one slot to become available */
-#define _s3WaitSlot(s3) { \
- DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitSlot 0x%x", (s3)->cmd_gp_stat)); \
- while ((s3)->cmd_gp_stat & GPBUSY_1) ; \
- DRAW_DEBUG ((DEBUG_CRTC, " s3 slot available")); \
+#define _s3WaitSlots(s3,n) { \
+ DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitSlots 0x%x %d", (s3)->cmd_gp_stat, n)); \
+ while (((s3)->cmd_gp_stat & GPSLOT(n)) != 0); \
+ DRAW_DEBUG ((DEBUG_CRTC, " s3 0x%x %d slots ready", (s3)->cmd_gp_stat, n)); \
}
+#else
+/* let PCI retries solve this problem */
+#define _s3WaitSlots(s3,n)
+#endif
/* Wait until queue is empty */
#define _s3WaitEmpty(s3) { \
@@ -375,11 +381,6 @@ typedef volatile struct _s3 {
while ((s3)->cmd_gp_stat & GPBUSY) ; \
DRAW_DEBUG ((DEBUG_CRTC, " s3 idle")); \
}
-#endif
-#define _s3WaitSlot(s3)
-#define _s3WaitEmpty(s3)
-#define _s3WaitIdleEmpty(s3)
-#define _s3WaitIdle(s3)
typedef struct _s3Cursor {
int width, height;
@@ -1072,25 +1073,6 @@ typedef struct _crtc {
#define S3_MAX_CLOCK 135000 /* KHz */
#endif
-typedef struct _s3Timing {
- /* label */
- int horizontal;
- int vertical;
- int rate;
- /* horizontal timing */
- int hfp; /* front porch */
- int hbp; /* back porch */
- int hblank; /* blanking */
- /* vertical timing */
- int vfp; /* front porch */
- int vbp; /* back porch */
- int vblank; /* blanking */
- /* clock values */
- int dac_m;
- int dac_n;
- int dac_r;
-} S3Timing;
-
typedef struct _s3Save {
CARD8 cursor_fg;
CARD8 cursor_bg;
@@ -1112,6 +1094,7 @@ typedef struct _s3CardInfo {
CARD8 *registers; /* pointer to register map */
S3Save save;
Bool savage;
+ Bool need_sync;
} S3CardInfo;
typedef struct _s3ScreenInfo {
@@ -1148,6 +1131,7 @@ void s3RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
Bool s3DrawInit (ScreenPtr pScreen);
void s3DrawEnable (ScreenPtr pScreen);
+void s3DrawSync (ScreenPtr pScreen);
void s3DrawDisable (ScreenPtr pScreen);
void s3DrawFini (ScreenPtr pScreen);
@@ -1156,7 +1140,7 @@ void s3PutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
void S3InitCard (KdCardAttr *attr);
-void s3GetClock (S3Timing *t, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR);
+void s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR);
CARD8 _s3ReadIndexRegister (VOL8 *base, CARD8 index);
void _s3WriteIndexRegister (VOL8 *base, CARD8 index, CARD8 value);
@@ -1209,30 +1193,4 @@ extern KdCardFuncs s3Funcs;
#define S3_TILE_SIZE 8
-/*
- * Ok, so the S3 is broken -- it expects bitmaps to come MSB bit order,
- * but it's willing to take them in LSB byte order. These macros
- * flip bits around without flipping bytes. Instead of using a table
- * and burning memory bandwidth, do them in place with the CPU.
- */
-
-/* The MIPS compiler automatically places these constants in registers */
-#define S3InvertBits32(v) { \
- v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
- v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
- v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
-}
-
-#define S3InvertBits16(v) { \
- v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \
- v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \
- v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \
-}
-
-#define S3InvertBits8(v) { \
- v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \
- v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \
- v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \
-}
-
#endif /* _S3_H_ */
diff --git a/hw/kdrive/trio/s3clock.c b/hw/kdrive/trio/s3clock.c
index 1c4f893dd..15a9b3069 100644
--- a/hw/kdrive/trio/s3clock.c
+++ b/hw/kdrive/trio/s3clock.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3clock.c,v 1.1 1999/11/19 13:54:03 hohndel Exp $ */
#include "s3.h"
@@ -44,16 +44,12 @@
#define MAX_VCO 360000.0
void
-s3GetClock (S3Timing *t, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR)
+s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR)
{
int M, N, R, bestM, bestN;
int f_vco, f_out;
- int target;
int err, abserr, besterr;
- target = ((t->horizontal + t->hblank) *
- (t->vertical + t->vblank) *
- t->rate) / 1000;
/*
* Compute correct R value to keep VCO in range
*/
diff --git a/hw/kdrive/trio/s3curs.c b/hw/kdrive/trio/s3curs.c
index 6cbdd4f7a..79ec038c6 100644
--- a/hw/kdrive/trio/s3curs.c
+++ b/hw/kdrive/trio/s3curs.c
@@ -21,9 +21,10 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3curs.c,v 1.1 1999/11/19 13:54:06 hohndel Exp $ */
#include "s3.h"
+#include "s3draw.h"
#include "cursorstr.h"
#define SetupCursor(s) KdScreenPriv(s); \
@@ -94,31 +95,8 @@ s3AllocCursorColors (ScreenPtr pScreen)
CursorPtr pCursor = pCurPriv->pCursor;
xColorItem sourceColor, maskColor;
- /*
- * Set these to an invalid pixel value so that
- * when the store colors comes through, the cursor
- * won't get recolored
- */
- pCurPriv->source = ~0;
- pCurPriv->mask = ~0;
- /*
- * XXX S3 bug workaround; s3 chip doesn't use RGB values from
- * the cursor color registers as documented, rather it uses
- * them to index the DAC. This is in the errata though.
- */
- sourceColor.red = pCursor->foreRed;
- sourceColor.green = pCursor->foreGreen;
- sourceColor.blue = pCursor->foreBlue;
- FakeAllocColor(pScreenPriv->pInstalledmap, &sourceColor);
- maskColor.red = pCursor->backRed;
- maskColor.green = pCursor->backGreen;
- maskColor.blue = pCursor->backBlue;
- FakeAllocColor(pScreenPriv->pInstalledmap, &maskColor);
- FakeFreeColor(pScreenPriv->pInstalledmap, sourceColor.pixel);
- FakeFreeColor(pScreenPriv->pInstalledmap, maskColor.pixel);
-
- pCurPriv->source = sourceColor.pixel;
- pCurPriv->mask = maskColor.pixel;
+ KdAllocateCursorPixels (pScreen, pCursor,
+ &pCurPriv->source, &pCurPriv->mask);
switch (pScreenPriv->screen->bitsPerPixel) {
case 4:
pCurPriv->source |= pCurPriv->source << 4;
@@ -192,8 +170,9 @@ s3LoadCursor (ScreenPtr pScreen, int x, int y)
CursorBitsPtr bits = pCursor->bits;
int w, h;
unsigned char r[2], g[2], b[2];
- unsigned short *ram, *msk, *mskLine, *src, *srcLine;
- unsigned short and, xor;
+ unsigned long *ram;
+ unsigned long *msk, *mskLine, *src, *srcLine;
+ unsigned long and, xor;
int i, j;
int cursor_address;
int wsrc;
@@ -204,11 +183,6 @@ s3LoadCursor (ScreenPtr pScreen, int x, int y)
*/
s3AllocCursorColors (pScreen);
- /*
- * Lock S3 so the cursor doesn't move while we're setting it
- */
- LockS3(s3c);
-
pCurPriv->pCursor = pCursor;
pCurPriv->xhot = pCursor->bits->xhot;
pCurPriv->yhot = pCursor->bits->yhot;
@@ -216,24 +190,25 @@ s3LoadCursor (ScreenPtr pScreen, int x, int y)
/*
* Stick new image into cursor memory
*/
- ram = (unsigned short *) s3s->cursor_base;
- mskLine = (unsigned short *) bits->mask;
- srcLine = (unsigned short *) bits->source;
+ ram = (unsigned long *) s3s->cursor_base;
+ mskLine = (unsigned long *) bits->mask;
+ srcLine = (unsigned long *) bits->source;
h = bits->height;
if (h > S3_CURSOR_HEIGHT)
h = S3_CURSOR_HEIGHT;
- wsrc = BitmapBytePad(bits->width) / 2; /* words per line */
+ wsrc = BitmapBytePad(bits->width) / 4; /* ulongs per line */
- for (i = 0; i < S3_CURSOR_HEIGHT; i++) {
+ for (i = 0; i < S3_CURSOR_HEIGHT; i++)
+ {
msk = mskLine;
src = srcLine;
mskLine += wsrc;
srcLine += wsrc;
- for (j = 0; j < S3_CURSOR_WIDTH / 16; j++) {
+ for (j = 0; j < S3_CURSOR_WIDTH / 32; j++) {
- unsigned short m, s;
+ unsigned long m, s;
if (i < h && j < wsrc)
{
@@ -244,14 +219,14 @@ s3LoadCursor (ScreenPtr pScreen, int x, int y)
}
else
{
- and = 0xffff;
- xor = 0x0000;
+ and = 0xffffffff;
+ xor = 0x00000000;
}
- S3InvertBits16(and);
- *ram++ = and;
- S3InvertBits16(xor);
- *ram++ = xor;
+ S3AdjustBits32(and);
+ S3AdjustBits32(xor);
+ *ram++ = (and & 0xffff) | (xor << 16);
+ *ram++ = (and >> 16) | (xor & 0xffff0000);
}
}
@@ -302,7 +277,11 @@ s3RealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
{
if (pCursor)
{
- int x, y;
+#ifdef FB_OLD_SCREEN
+ short x, y;
+#else
+ int x, y;
+#endif
miPointerPosition (&x, &y);
s3LoadCursor (pScreen, x, y);
@@ -397,7 +376,11 @@ s3CursorEnable (ScreenPtr pScreen)
{
if (pCurPriv->pCursor)
{
- int x, y;
+#ifdef FB_OLD_SCREEN
+ short x, y;
+#else
+ int x, y;
+#endif
miPointerPosition (&x, &y);
s3LoadCursor (pScreen, x, y);
diff --git a/hw/kdrive/trio/s3stub.c b/hw/kdrive/trio/s3stub.c
index 59773f725..597294e6e 100644
--- a/hw/kdrive/trio/s3stub.c
+++ b/hw/kdrive/trio/s3stub.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3stub.c,v 1.1 1999/11/19 13:54:06 hohndel Exp $ */
#include "s3.h"
@@ -52,8 +52,8 @@ InitInput (int argc, char **argv)
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
}
-void
-OsVendorInit (void)
+int
+ddxProcessArgument (int argc, char **argv, int i)
{
- KdOsInit (&LinuxFuncs);
+ return KdProcessArgument (argc, argv, i);
}