diff options
Diffstat (limited to 'hw/kdrive/mach64')
-rw-r--r-- | hw/kdrive/mach64/Makefile.am | 37 | ||||
-rw-r--r-- | hw/kdrive/mach64/mach64.c | 434 | ||||
-rw-r--r-- | hw/kdrive/mach64/mach64.h | 658 | ||||
-rw-r--r-- | hw/kdrive/mach64/mach64curs.c | 392 | ||||
-rw-r--r-- | hw/kdrive/mach64/mach64draw.c | 593 | ||||
-rw-r--r-- | hw/kdrive/mach64/mach64draw.h | 72 | ||||
-rw-r--r-- | hw/kdrive/mach64/mach64stub.c | 73 | ||||
-rw-r--r-- | hw/kdrive/mach64/mach64video.c | 1037 |
8 files changed, 0 insertions, 3296 deletions
diff --git a/hw/kdrive/mach64/Makefile.am b/hw/kdrive/mach64/Makefile.am deleted file mode 100644 index 9a9b46469..000000000 --- a/hw/kdrive/mach64/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -INCLUDES = \ - @KDRIVE_INCS@ \ - -I$(top_srcdir)/hw/kdrive/vesa \ - @XSERVER_CFLAGS@ - -bin_PROGRAMS = Xmach64 - -if TSLIB -TSLIB_FLAG = -lts -endif - - -noinst_LIBRARIES = libmach64.a - -libmach64_a_SOURCES = \ - mach64.c \ - mach64draw.c \ - mach64video.c \ - mach64.h \ - mach64draw.h - -Xmach64_SOURCES = \ - mach64stub.c - -MACH64_LIBS = \ - libmach64.a \ - $(top_builddir)/hw/kdrive/vesa/libvesa.a - - -Xmach64_LDADD = \ - $(MACH64_LIBS) \ - @KDRIVE_LIBS@ \ - @XSERVER_LIBS@ \ - $(TSLIB_FLAG) - - -Xmach64_DEPENDENCIES = $(MACH64_LIBS) @KDRIVE_LIBS@ diff --git a/hw/kdrive/mach64/mach64.c b/hw/kdrive/mach64/mach64.c deleted file mode 100644 index c093ef83c..000000000 --- a/hw/kdrive/mach64/mach64.c +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Copyright © 2001 Keith Packard - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/mach64/mach64.c,v 1.10 2002/10/14 18:01:41 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "mach64.h" - -static Bool -mach64CardInit (KdCardInfo *card) -{ - Mach64CardInfo *mach64c; - - mach64c = (Mach64CardInfo *) xalloc (sizeof (Mach64CardInfo)); - if (!mach64c) - return FALSE; - - (void) mach64MapReg (card, mach64c); - mach64c->lcdEnabled = FALSE; - - if (!vesaInitialize (card, &mach64c->vesa)) - { - xfree (mach64c); - return FALSE; - } - - card->driver = mach64c; - - return TRUE; -} - -static Bool -mach64ScreenInit (KdScreenInfo *screen) -{ - Mach64CardInfo *mach64c = screen->card->driver; - Mach64ScreenInfo *mach64s; - - mach64s = (Mach64ScreenInfo *) xalloc (sizeof (Mach64ScreenInfo)); - if (!mach64s) - return FALSE; - memset (mach64s, '\0', sizeof (Mach64ScreenInfo)); - if (!vesaScreenInitialize (screen, &mach64s->vesa)) - { - xfree (mach64s); - return FALSE; - } - if (!mach64c->reg) - screen->dumb = TRUE; - if (mach64s->vesa.mapping != VESA_LINEAR) - screen->dumb = TRUE; - switch (screen->fb[0].depth) { - case 8: - mach64s->colorKey = 0xff; - break; - case 15: - case 16: - mach64s->colorKey = 0x001e; - break; - case 24: - mach64s->colorKey = 0x0000fe; - break; - default: - mach64s->colorKey = 1; - break; - } - screen->driver = mach64s; - return TRUE; -} - -static Bool -mach64InitScreen (ScreenPtr pScreen) -{ -#ifdef XV - mach64InitVideo(pScreen); -#endif - return vesaInitScreen (pScreen); -} - -#ifdef RANDR -static Bool -mach64RandRSetConfig (ScreenPtr pScreen, - Rotation rotation, - int rate, - RRScreenSizePtr pSize) -{ - KdCheckSync (pScreen); - - if (!vesaRandRSetConfig (pScreen, rotation, rate, pSize)) - return FALSE; - - return TRUE; -} - -static void -mach64RandRInit (ScreenPtr pScreen) -{ - rrScrPriv(pScreen); - - pScrPriv->rrSetConfig = mach64RandRSetConfig; -} -#endif - -static Bool -mach64FinishInitScreen (ScreenPtr pScreen) -{ - Bool ret; - ret = vesaFinishInitScreen (pScreen); -#ifdef RANDR - mach64RandRInit (pScreen); -#endif - return ret; -} - -static Bool -mach64CreateResources (ScreenPtr pScreen) -{ - return vesaCreateResources (pScreen); -} - -CARD32 -mach64ReadLCD (Reg *reg, int id) -{ - CARD32 LCD_INDEX; - - LCD_INDEX = reg->LCD_INDEX & ~(0x3f); - reg->LCD_INDEX = (LCD_INDEX | id); - return reg->LCD_DATA; -} - -void -mach64WriteLCD (Reg *reg, int id, CARD32 data) -{ - CARD32 LCD_INDEX; - - LCD_INDEX = reg->LCD_INDEX & ~(0x3f); - reg->LCD_INDEX = (LCD_INDEX | id); - reg->LCD_DATA = data; -} - -void -mach64Preserve (KdCardInfo *card) -{ - Mach64CardInfo *mach64c = card->driver; - Reg *reg = mach64c->reg; - - vesaPreserve(card); - if (reg) - { - mach64c->save.LCD_GEN_CTRL = mach64ReadLCD (reg, 1); - } -} - -Bool -mach64MapReg (KdCardInfo *card, Mach64CardInfo *mach64c) -{ - mach64c->reg_base = (CARD8 *) KdMapDevice (MACH64_REG_BASE(card), - MACH64_REG_SIZE(card)); - - if (!mach64c->reg_base) - { - mach64c->reg = 0; - mach64c->media_reg = 0; - return FALSE; - } - - KdSetMappedMode (MACH64_REG_BASE(card), - MACH64_REG_SIZE(card), - KD_MAPPED_MODE_REGISTERS); - mach64c->reg = (Reg *) (mach64c->reg_base + MACH64_REG_OFF(card)); - mach64c->media_reg = (MediaReg *) (mach64c->reg_base + MACH64_MEDIA_REG_OFF(card)); - return TRUE; -} - -void -mach64UnmapReg (KdCardInfo *card, Mach64CardInfo *mach64c) -{ - if (mach64c->reg_base) - { - KdResetMappedMode (MACH64_REG_BASE(card), - MACH64_REG_SIZE(card), - KD_MAPPED_MODE_REGISTERS); - KdUnmapDevice ((void *) mach64c->reg_base, MACH64_REG_SIZE(card)); - mach64c->reg_base = 0; - mach64c->reg = 0; - mach64c->media_reg = 0; - } -} - -void -mach64SetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c) -{ - if (!mach64c->reg_base) - mach64MapReg (card, mach64c); - if (mach64c->reg) - { - if (mach64c->reg->GUI_STAT == 0xffffffff) - FatalError ("Mach64 REG not visible\n"); - } -} - -void -mach64ResetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c) -{ - mach64UnmapReg (card, mach64c); -} - -Bool -mach64Enable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - Mach64CardInfo *mach64c = pScreenPriv->card->driver; - - if (!vesaEnable (pScreen)) - return FALSE; - - mach64SetMMIO (pScreenPriv->card, mach64c); - mach64DPMS (pScreen, KD_DPMS_NORMAL); -#ifdef XV - KdXVEnable (pScreen); -#endif - return TRUE; -} - -void -mach64Disable (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - Mach64CardInfo *mach64c = pScreenPriv->card->driver; - -#ifdef XV - KdXVDisable (pScreen); -#endif - mach64ResetMMIO (pScreenPriv->card, mach64c); - vesaDisable (pScreen); -} - -const CARD8 mach64DPMSModes[4] = { - 0x80, /* KD_DPMS_NORMAL */ - 0x8c, /* KD_DPMS_STANDBY */ - 0x8c, /* KD_DPMS_STANDBY */ - 0x8c, /* KD_DPMS_STANDBY */ -/* 0xb0, KD_DPMS_SUSPEND */ -/* 0xbc, KD_DPMS_POWERDOWN */ -}; - -#define PWR_MGT_ON (1 << 0) -#define PWR_MGT_MODE (3 << 1) -#define PWR_MGT_MODE_PIN (0 << 1) -#define PWR_MGT_MODE_REG (1 << 1) -#define PWR_MGT_MODE_TIMER (2 << 1) -#define PWR_MGR_MODE_PCI (3 << 1) -#define AUTO_PWRUP_EN (1 << 3) -#define ACTIVITY_PIN_ON (1 << 4) -#define STANDBY_POL (1 << 5) -#define SUSPEND_POL (1 << 6) -#define SELF_REFRESH (1 << 7) -#define ACTIVITY_PIN_EN (1 << 8) -#define KEYBD_SNOOP (1 << 9) -#define DONT_USE_F32KHZ (1 << 10) -#define TRISTATE_MEM_EN (1 << 11) -#define LCDENG_TEST_MODE (0xf << 12) -#define STANDBY_COUNT (0xf << 16) -#define SUSPEND_COUNT (0xf << 20) -#define BIASON (1 << 24) -#define BLON (1 << 25) -#define DIGON (1 << 26) -#define PM_D3_RST_ENB (1 << 27) -#define STANDBY_NOW (1 << 28) -#define SUSPEND_NOW (1 << 29) -#define PWR_MGT_STATUS (3 << 30) -#define PWR_MGT_STATUS_ON (0 << 30) -#define PWR_MGT_STATUS_STANDBY (1 << 30) -#define PWR_MGT_STATUS_SUSPEND (2 << 30) -#define PWR_MGT_STATUS_TRANSITION (3 << 30) - -Bool -mach64DPMS (ScreenPtr pScreen, int mode) -{ - KdScreenPriv(pScreen); - Mach64CardInfo *mach64c = pScreenPriv->card->driver; - int hsync_off = 0, vsync_off = 0, blank = 0; - CARD32 CRTC_GEN_CNTL; - CARD32 LCD_GEN_CTRL; - Reg *reg = mach64c->reg; - - if (!reg) - return FALSE; - - CRTC_GEN_CNTL = reg->CRTC_GEN_CNTL; - LCD_GEN_CTRL = mach64ReadLCD (reg, 1); - - switch (mode) { - case KD_DPMS_NORMAL: - hsync_off = 0; - vsync_off = 0; - blank = 0; - break; - case KD_DPMS_STANDBY: - hsync_off = 1; - vsync_off = 0; - blank = 1; - break; - case KD_DPMS_SUSPEND: - hsync_off = 0; - vsync_off = 1; - blank = 1; - break; - case KD_DPMS_POWERDOWN: - hsync_off = 1; - vsync_off = 1; - blank = 1; - } - - if (hsync_off) - CRTC_GEN_CNTL |= (1 << 2); - else - CRTC_GEN_CNTL &= ~(1 << 2); - if (vsync_off) - CRTC_GEN_CNTL |= (1 << 3); - else - CRTC_GEN_CNTL &= ~(1 << 3); - if (blank) - { - mach64c->lcdEnabled = (LCD_GEN_CTRL & (1 << 1)) != 0; - LCD_GEN_CTRL &= ~(1 << 1); - CRTC_GEN_CNTL |= (1 << 6); - - } - else - { - if (!(LCD_GEN_CTRL & 3) || mach64c->lcdEnabled) - LCD_GEN_CTRL |= (1 << 1); - CRTC_GEN_CNTL &= ~(1 << 6); - } - - KdCheckSync (pScreen); - - mach64WriteLCD (reg, 1, LCD_GEN_CTRL); - - reg->CRTC_GEN_CNTL = CRTC_GEN_CNTL; - return TRUE; -} - -static void -mach64Restore (KdCardInfo *card) -{ - Mach64CardInfo *mach64c = card->driver; - Reg *reg = mach64c->reg; - - if (reg) - { - mach64WriteLCD (reg, 1, mach64c->save.LCD_GEN_CTRL); - } - mach64ResetMMIO (card, mach64c); - vesaRestore (card); -} - -static void -mach64ScreenFini (KdScreenInfo *screen) -{ - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; -#ifdef XV - mach64FiniVideo(screen->pScreen); -#endif - vesaScreenFini (screen); - xfree (mach64s); - screen->driver = 0; -} - -static void -mach64CardFini (KdCardInfo *card) -{ - Mach64CardInfo *mach64c = card->driver; - - mach64UnmapReg (card, mach64c); - vesaCardFini (card); - xfree (mach64c); -} - -#define mach64CursorInit 0 /* initCursor */ -#define mach64CursorEnable 0 /* enableCursor */ -#define mach64CursorDisable 0 /* disableCursor */ -#define mach64CursorFini 0 /* finiCursor */ -#define mach64RecolorCursor 0 /* recolorCursor */ - -KdCardFuncs mach64Funcs = { - mach64CardInit, /* cardinit */ - mach64ScreenInit, /* scrinit */ - mach64InitScreen, /* initScreen */ - mach64FinishInitScreen, /* finishInitScreen */ - mach64CreateResources, /* createRes */ - mach64Preserve, /* preserve */ - mach64Enable, /* enable */ - mach64DPMS, /* dpms */ - mach64Disable, /* disable */ - mach64Restore, /* restore */ - mach64ScreenFini, /* scrfini */ - mach64CardFini, /* cardfini */ - - mach64CursorInit, /* initCursor */ - mach64CursorEnable, /* enableCursor */ - mach64CursorDisable, /* disableCursor */ - mach64CursorFini, /* finiCursor */ - mach64RecolorCursor, /* recolorCursor */ - - mach64DrawInit, /* initAccel */ - mach64DrawEnable, /* enableAccel */ - mach64DrawSync, /* syncAccel */ - mach64DrawDisable, /* disableAccel */ - mach64DrawFini, /* finiAccel */ - - vesaGetColors, /* getColors */ - vesaPutColors, /* putColors */ -}; diff --git a/hw/kdrive/mach64/mach64.h b/hw/kdrive/mach64/mach64.h deleted file mode 100644 index ca042c282..000000000 --- a/hw/kdrive/mach64/mach64.h +++ /dev/null @@ -1,658 +0,0 @@ -/* - * Id: mach64.h,v 1.2 1999/11/02 08:17:24 keithp Exp $ - * - * Copyright © 2001 Keith Packard - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/mach64/mach64.h,v 1.5 2001/06/23 03:41:24 keithp Exp $ */ - -#ifndef _MACH64_H_ -#define _MACH64_H_ -#include <vesa.h> -#include "kxv.h" - -/* - * offset from ioport beginning - */ - -#define MACH64_REG_BASE(c) ((c)->attr.address[1]) -#define MACH64_REG_SIZE(c) (4096) - -#define MACH64_REG_OFF(c) (1024) -#define MACH64_MEDIA_REG_OFF(c) (0) - -typedef volatile CARD8 VOL8; -typedef volatile CARD16 VOL16; -typedef volatile CARD32 VOL32; - -typedef struct _Reg { - VOL32 CRTC_H_TOTAL_DISP; /* 0x00 */ - VOL32 CRTC_H_SYNC_STRT_WID; /* 0x01 */ - VOL32 CRTC_V_TOTAL_DISP; /* 0x02 */ - VOL32 CRTC_V_SYNC_STRT_WID; /* 0x03 */ - VOL32 CRTC_VLINE_CRNT_VLINE; /* 0x04 */ - VOL32 CRTC_OFF_PITCH; /* 0x05 */ - VOL32 CRTC_INT_CNTL; /* 0x06 */ - VOL32 CRTC_GEN_CNTL; /* 0x07 */ - VOL32 DSP_CONFIG; /* 0x08 */ - VOL32 DSP_ON_OFF; /* 0x09 */ - VOL32 TIMER_CONFIG; /* 0x0a */ - VOL32 MEM_BUF_CNTL; /* 0x0b */ - VOL32 unused0; /* 0x0c */ - VOL32 MEM_ADDR_CONFIG; /* 0x0d */ - VOL32 CRT_TRAP; /* 0x0e */ - VOL32 I2C_CNTL_0; /* 0x0f */ - VOL32 OVR_CLR; /* 0x10 */ - VOL32 OVR_WID_LEFT_RIGHT; /* 0x11 */ - VOL32 OVR_WID_TOP_BOTTOM; /* 0x12 */ - VOL32 VGA_DSP_CONFIG; /* 0x13 */ - VOL32 VGA_DSP_ON_OFF; /* 0x14 */ - VOL32 DSP2_CONFIG; /* 0x15 */ - VOL32 DSP2_ON_OFF; /* 0x16 */ - VOL32 CRTC2_OFF_PITCH; /* 0x17 */ - VOL32 CUR_CLR0; /* 0x18 */ - VOL32 CUR_CLR1; /* 0x19 */ - VOL32 CUR_OFFSET; /* 0x1a */ - VOL32 CUR_HORZ_VERT_POSN; /* 0x1b */ - VOL32 CUR_HORZ_VERT_OFF; /* 0x1c */ - VOL32 TV_OUT_INDEX; /* 0x1d */ - VOL32 GP_IO; /* 0x1e */ - VOL32 HW_DEBUG; /* 0x1f */ - VOL32 SCRATCH_REG0; /* 0x20 */ - VOL32 SCRATCH_REG1; - VOL32 SCRATCH_REG2; - VOL32 SCRATCH_REG3; - VOL32 CLOCK_CNTL; - VOL32 CONFIG_STAT1; - VOL32 CONFIG_STAT2; - VOL32 TV_OUT_DATA; - VOL32 BUS_CNTL; /* 0x28 */ - VOL32 LCD_INDEX; /* 0x29 */ - VOL32 LCD_DATA; /* 0x2a */ - VOL32 EXT_MEM_CNTL; - VOL32 MEM_CNTL; - VOL32 MEM_VGA_WP_SEL; - VOL32 MEM_VGA_RP_SEL; - VOL32 I2C_CNTL_1; - VOL32 DAC_REGS; /* 0x30 */ - VOL32 DAC_CNTL; /* 0x31 */ - VOL32 unused_32; - VOL32 unused_33; - VOL32 GEN_TEST_CNTL; /* 0x34 */ - VOL32 CUSTOM_MACRO_CNTL; - VOL32 unused36; - VOL32 CONFIG_CNTL; - VOL32 CONFIG_CHIP_ID; - VOL32 CONFIG_STAT0; - VOL32 CRC_SIG; - VOL32 unused_3b; - VOL32 unused_3c; - VOL32 unused_3d; - VOL32 unused_3e; - VOL32 unused_3f; - VOL32 DST_OFF_PITCH; /* 0x40 */ - VOL32 DST_X; - VOL32 DST_Y; - VOL32 DST_Y_X; - VOL32 DST_WIDTH; - VOL32 DST_HEIGHT; - VOL32 DST_HEIGHT_WIDTH; - VOL32 DST_X_WIDTH; - VOL32 DST_BRES_LNTH; - VOL32 DST_BRES_ERR; - VOL32 DST_BRES_INC; - VOL32 DST_BRES_DEC; - VOL32 DST_CNTL; - VOL32 DST_Y_X_ALIAS; - VOL32 TRAIL_BRES_ERR; - VOL32 TRAIL_BRES_INC; - VOL32 TRAIL_BRES_DEC; - VOL32 LEAD_BRES_LNTH; - VOL32 Z_OFF_PITCH; - VOL32 Z_CNTL; - VOL32 ALPHA_TST_CNTL; - VOL32 unused55; - VOL32 SECONDARY_STW_EXP; - VOL32 SECONDARY_S_X_INC; - VOL32 SECONDARY_S_Y_INC; - VOL32 SECONDARY_S_START; - VOL32 SECONDARY_W_X_INC; - VOL32 SECONDARY_W_Y_INC; - VOL32 SECONDARY_W_START; - VOL32 SECONDARY_T_X_INC; - VOL32 SECONDARY_T_Y_INC; - VOL32 SECONDARY_T_START; - VOL32 SRC_OFF_PITCH; - VOL32 SRC_X; - VOL32 SRC_Y; - VOL32 SRC_Y_X; - VOL32 SRC_WIDTH1; - VOL32 SRC_HEIGHT1; - VOL32 SRC_HEIGHT1_WIDTH1; - VOL32 SRC_X_START; - VOL32 SRC_Y_START; - VOL32 SRC_Y_X_START; - VOL32 SRC_WIDTH2; - VOL32 SRC_HEIGHT2; - VOL32 SRC_HEIGHT2_WIDTH2; - VOL32 SRC_CNTL; - VOL32 unused6e; - VOL32 unused6f; - union { - struct { - VOL32 SCALE_OFF; /* 0x70 */ - VOL32 unused71; - VOL32 unused72; - VOL32 unused73; - VOL32 unused74; - VOL32 unused75; - VOL32 unused76; - VOL32 SCALE_WIDTH; - VOL32 SCALE_HEIGHT; - VOL32 unused79; - VOL32 unused7a; - VOL32 SCALE_PITCH; - VOL32 SCALE_X_INC; - VOL32 SCALE_Y_INC; - VOL32 SCALE_VACC; - VOL32 SCALE_3D_CNTL; /* 0x7f */ - } scaler; - struct { - VOL32 TEX_0_OFF; /* 0x70 */ - VOL32 TEX_1_OFF; - VOL32 TEX_2_OFF; - VOL32 TEX_3_OFF; - VOL32 TEX_4_OFF; - VOL32 TEX_5_OFF; - VOL32 TEX_6_OFF; - VOL32 TEX_7_OFF; - VOL32 TEX_8_OFF; - VOL32 TEX_9_OFF; - VOL32 TEX_10_OFF; - VOL32 S_Y_INC; - VOL32 RED_X_INC; - VOL32 GREEN_X_INC; /* 0x7d */ - VOL32 unused7e; - VOL32 unused7f; - } texture; - } u; - VOL32 HOST_DATA[16]; /* 0x80 */ - VOL32 HOST_CNTL; /* 0x90 */ - VOL32 BM_HOSTDATA; /* 0x91 */ - VOL32 BM_ADDR; /* 0x92 */ - VOL32 BM_GUI_TABLE_CMD; /* 0x93 */ - VOL32 unused94; /* 0x94 */ - VOL32 unused95; /* 0x95 */ - VOL32 unused96; /* 0x96 */ - VOL32 FOG_TABLE_INDEX; /* 0x97 */ - VOL32 FOG_TABLE_DATA[8]; /* 0x98 */ - VOL32 PAT_REG0; /* 0xa0 */ - VOL32 PAT_REG1; - VOL32 PAT_CNTL; - VOL32 unused_0a3; - VOL32 unused_0a4; - VOL32 unused_0a5; - VOL32 unused_0a6; - VOL32 unused_0a7; - VOL32 SC_LEFT; - VOL32 SC_RIGHT; - VOL32 SC_LEFT_RIGHT; - VOL32 SC_TOP; - VOL32 SC_BOTTOM; - VOL32 SC_TOP_BOTTOM; - VOL32 USR1_DST_OFF_PITCH; - VOL32 USR2_DST_OFF_PITCH; - VOL32 DP_BKGD_CLR; /* 0xb0 */ - VOL32 DP_FRGD_CLR; - VOL32 DP_WRITE_MSK; - VOL32 unused_0b3; - VOL32 DP_PIX_WIDTH; - VOL32 DP_MIX; - VOL32 DP_SRC; - VOL32 DP_FRGD_CLR_MIX; - VOL32 DP_FRGD_BKGD_CLR; - VOL32 unused_0b9; - VOL32 DST_X_Y; - VOL32 DST_WIDTH_HEIGHT; - VOL32 USR_DST_PITCH; - VOL32 unused_0bd; - VOL32 DP_SET_GUI_ENGINE2; - VOL32 DP_SET_GUI_ENGINE; - VOL32 CLR_CMP_CLR; /* 0xc0 */ - VOL32 CLR_CMP_MSK; - VOL32 CLR_CMP_CNTL; - VOL32 unused_0c3; - VOL32 FIFO_STAT; - VOL32 unused_0c5; - VOL32 unused_0c6; - VOL32 unused_0c7; - VOL32 unused_0c8; - VOL32 unused_0c9; - VOL32 unused_0ca; - VOL32 unused_0cb; - VOL32 GUI_TRAJ_CNTL; - VOL32 unused_0cd; - VOL32 GUI_STAT; - VOL32 unused_0cf; - VOL32 TEX_PALETTE_INDEX; - VOL32 STW_EXP; - VOL32 LOG_MAX_INC; - VOL32 S_X_INC; - VOL32 S_Y_INC_2_SCALE_PITCH; - VOL32 S_START; - VOL32 W_X_INC; - VOL32 W_Y_INC; - VOL32 W_START; - VOL32 T_X_INC; - VOL32 T_Y_INC_SECONDARY_SCALE_PITCH; - VOL32 T_START; - VOL32 TEX_SIZE_PITCH; - VOL32 TEX_CNTL; - VOL32 SECONDARY_TEX_OFFSET_SECONDARY_SCALE_OFF; - VOL32 TEX_PALETTE; - VOL32 SCALE_PITCH_BOTH; /* 0xe0 */ - VOL32 SECONDARY_SCALE_OFF_ACC; - VOL32 SCALE_OFF_ACC; - VOL32 SCALE_DST_Y_X; - VOL32 unused_0e4; - VOL32 unused_0e5; - VOL32 COMPOSITE_SHADOW_ID; - VOL32 SECONDARY_SCALE_X_INC_SPECULAR_RED_X_INC; - VOL32 SPECULAR_RED_Y_INC; - VOL32 SPECULAR_RED_START_SECONDARY_SCALE_HACC;; - VOL32 SPECULAR_GREEN_X_INC; - VOL32 SPECULAR_GREEN_Y_INC; - VOL32 SPECULAR_GREEN_START; - VOL32 SPECULAR_BLUE_X_INC; - VOL32 SPECULAR_BLUE_Y_INC; - VOL32 SPECULAR_BLUE_START; - VOL32 RED_X_INC_SCALE_X_INC; - VOL32 RED_Y_INC; - VOL32 RED_START_SCALE_HACC; - VOL32 GREEN_X_INC_SCALE_Y_INC; - VOL32 GREEN_Y_INC_SECONDARY_SCALE_Y_INC; - VOL32 GREEN_START_SECONDARY_SCALE_VACC; - VOL32 BLUE_X_INC; - VOL32 BLUE_Y_INC; - VOL32 BLUE_START; - VOL32 Z_X_INC; - VOL32 Z_Y_INC; - VOL32 Z_START; - VOL32 ALPHA_X_INC; - VOL32 FOG_X_INC; - VOL32 ALPHA_Y_INC; - VOL32 FOG_Y_INC; - VOL32 ALPHA_START; - VOL32 FOG_START; - VOL32 unused_0ff; -} Reg; /* 0x100 */ - -#define DST_X_DIR (1 << 0) -#define DST_Y_DIR (1 << 1) -#define DST_Y_MAJOR (1 << 2) -#define DST_X_TILE (1 << 3) -#define DST_Y_TILE (1 << 4) -#define DST_LAST_PEL (1 << 5) -#define DST_POLYGON_EN (1 << 6) -#define DST_24_ROT_EN (1 << 7) -#define DST_24_ROT(n) ((n) << 8) -#define DST_BRES_ZERO (1 << 11) -#define DST_POLYGON_RTEDGE_DIS (1 << 12) -#define TRAIL_X_DIR (1 << 13) -#define TRAP_FILL_DIR (1 << 14) -#define TRAIL_BRES_SIGN (1 << 15) -#define SRC_PATT_EN (1 << 16) -#define SRC_PATT_ROT_EN (1 << 17) -#define SRC_LINEAR_EN (1 << 18) -#define SRC_BYTE_ALIGN (1 << 19) -#define SRC_LINE_X_DIR (1 << 20) -#define SRC_8x8x8_BRUSH (1 << 21) -#define FAST_FILL_EN (1 << 22) -#define SRC_TRACK_DST (1 << 23) -#define PAT_MONO_EN (1 << 24) -#define PAT_CLR_4x2_EN (1 << 25) -#define PAT_CLR_8x1_EN (1 << 26) -#define HOST_BYTE_ALIGN (1 << 28) -#define HOST_BIG_ENDIAN_EN (1 << 29) - -/* BUS_CNTL bits */ -#define BUS_DBL_RESYNC (1 << 0) -#define BUS_MSTR_RESET (1 << 1) -#define BUS_FLUSH_BUF (1 << 2) -#define BUS_STOP_REQ_DIS (1 << 3) -#define BUS_APER_REG_DIS (1 << 4) -#define BUS_EXTRA_PIPE_DIS (1 << 5) -#define BUS_MASTER_DIS (1 << 6) -#define ROM_WRT_EN (1 << 7) -#define CHIP_HIDDEN_REV (3 << 8) -#define BUS_PCI_READ_RETRY_EN (1 << 13) -#define BUS_PCI_WRT_RETRY_EN (1 << 15) -#define BUS_RETRY_WS (0xf << 16) -#define BUS_MSTR_RD_MULT (1 << 20) -#define BUS_MSTR_RD_LINE (1 << 21) -#define BUS_SUSPEND (1 << 22) -#define LAT16X (1 << 23) -#define BUS_RD_DISCARD_EN (1 << 24) -#define BUS_RD_ABORT_EN (1 << 25) -#define BUS_MSTR_WS (1 << 26) -#define BUS_EXT_REG_EN (1 << 27) -#define BUS_MSTR_DISCONNECT_EN (1 << 28) -#define BUS_WRT_BURST (1 << 29) -#define BUS_READ_BURST (1 << 30) -#define BUS_RDY_READ_DLY (1 << 31) - -#define SCALE_PIX_EXPAND (1 << 0) -#define SCALE_Y2R_TEMP (1 << 1) -#define SCALE_HORZ_MODE (1 << 2) -#define SCALE_VERT_MODE (1 << 3) -#define SCALE_SIGNED_UV (1 << 4) -#define SCALE_GAMMA_SEL (3 << 5) -#define SCALE_GAMMA_BRIGHT (0 << 5) -#define SCALE_GAMMA_22 (1 << 5) -#define SCALE_GAMMA_18 (2 << 5) -#define SCALE_GAMMA_14 (3 << 5) -#define SCALE_DISP_SEL (1 << 7) -#define SCALE_BANDWIDTH (1 << 26) -#define SCALE_DIS_LIMIT (1 << 27) -#define SCALE_CLK_FORCE_ON (1 << 29) -#define SCALE_OVERLAY_EN (1 << 30) -#define SCALE_EN (1 << 31) - -#define VIDEO_IN_VYUY422 (0xb) -#define VIDEO_IN_YVYU422 (0xc) -#define SCALER_IN_15bpp (0x3 << 16) -#define SCALER_IN_16bpp (0x4 << 16) -#define SCALER_IN_32bpp (0x6 << 16) -#define SCALER_IN_YUV_9 (0x9 << 16) -#define SCALER_IN_YUV_12 (0xa << 16) -#define SCALER_IN_VYUY422 (0xb << 16) -#define SCALER_IN_YVYU422 (0xc << 16) - -#define CAP_INPUT_MODE (1 << 0) -#define CAP_BUF_MODE (1 << 2) -#define CAP_START_BUF (1 << 3) -#define CAP_BUF_TYPE_FIELD (0 << 4) -#define CAP_BUF_TYPE_ALTERNATING (1 << 4) -#define CAP_BUF_TYPE_FRAME (2 << 4) - -#define OVL_BUF_MODE (1 << 28) -#define OVL_BUF_NEXT (1 << 29) - -#define CAP_TRIGGER (3 << 0) -#define OVL_CUR_BUF (1 << 5) -#define OVL_BUF_STATUS (1 << 6) -#define CAP_BUF_STATUS (1 << 7) -#define CAPTURE_EN (1 << 31) - -typedef struct _MediaReg { - VOL32 OVERLAY_Y_X_START; /* 0x100 */ - VOL32 OVERLAY_Y_X_END; - VOL32 OVERLAY_VIDEO_KEY_CLR; - VOL32 OVERLAY_VIDEO_KEY_MSK; - VOL32 OVERLAY_GRAPHICS_KEY_CLR; - VOL32 OVERLAY_GRAPHICS_KEY_MSK; - VOL32 OVERLAY_KEY_CNTL; - VOL32 unused_107; - VOL32 OVERLAY_SCALE_INC; - VOL32 OVERLAY_SCALE_CNTL; - VOL32 SCALER_HEIGHT_WIDTH; - VOL32 SCALER_TEST; - VOL32 unused_10c; - VOL32 SCALER_BUF0_OFFSET; - VOL32 SCALER_BUF1_OFFSET; - VOL32 SCALER_BUF_PITCH; - VOL32 CAPTURE_START_END; /* 0x110 */ - VOL32 CAPTURE_X_WIDTH; - VOL32 VIDEO_FORMAT; - VOL32 VBI_START_END; - VOL32 CAPTURE_CONFIG; - VOL32 TRIG_CNTL; - VOL32 OVERLAY_EXCLUSIVE_HORZ; - VOL32 OVERLAY_EXCLUSIVE_VERT; - VOL32 VBI_WIDTH; - VOL32 CAPTURE_DEBUG; - VOL32 VIDEO_SYNC_TEST; - VOL32 unused_11b; - VOL32 SNAPSHOT_VH_COUNTS; - VOL32 SNAPSHOT_F_COUNT; - VOL32 N_VIF_COUNT; - VOL32 SNAPSHOT_VIF_COUNT; - VOL32 CAPTURE_BUF0_OFFSET; /* 0x120 */ - VOL32 CAPTURE_BUF1_OFFSET; - VOL32 ONESHOT_BUF_OFFSET; - VOL32 unused_123; - VOL32 unused_124; - VOL32 unused_125; - VOL32 unused_126; - VOL32 unused_127; - VOL32 unused_128; - VOL32 unused_129; - VOL32 unused_12a; - VOL32 unused_12b; - VOL32 SNAPSHOT2_VH_COUNTS; - VOL32 SNAPSHOT2_F_COUNT; - VOL32 N_VIF2_COUNT; - VOL32 SNAPSHOT2_VIF_COUNT; - VOL32 MPP_CONFIG; /* 0x130 */ - VOL32 MPP_STROBE_SEQ; - VOL32 MPP_ADDR; - VOL32 MPP_DATA; - VOL32 unused_134; - VOL32 unused_135; - VOL32 unused_136; - VOL32 unused_137; - VOL32 unused_138; - VOL32 unused_139; - VOL32 unused_13a; - VOL32 unused_13b; - VOL32 unused_13c; - VOL32 unused_13d; - VOL32 unused_13e; - VOL32 unused_13f; - VOL32 TVO_CNTL; /* 0x140 */ - VOL32 unused_141[15]; - VOL32 unused_150; /* 0x150 */ - VOL32 CRT_HORZ_VERT_LOAD; /* 0x151 */ - VOL32 AGP_BASE; /* 0x152 */ - VOL32 AGP_CNTL; /* 0x153 */ - VOL32 SCALER_COLOUR_CNTL; /* 0x154 */ - VOL32 SCALER_H_COEFF0; /* 0x155 */ - VOL32 SCALER_H_COEFF1; /* 0x156 */ - VOL32 SCALER_H_COEFF2; /* 0x157 */ - VOL32 SCALER_H_COEFF3; /* 0x158 */ - VOL32 SCALER_H_COEFF4; /* 0x159 */ - VOL32 unused_15a; - VOL32 unused_15b; - VOL32 GUI_CMDFIFO_DEBUG; - VOL32 GUI_CMDFIFO_DATA; - VOL32 GUI_CNTL; - VOL32 unused_15f; - VOL32 BM_FRAME_BUF_OFFSET; /* 0x160 */ - VOL32 BM_SYSTEM_MEM_ADDR; - VOL32 BM_COMMAND; - VOL32 BM_STATUS; - VOL32 unused_164[10]; - VOL32 BM_GUI_TABLE; - VOL32 BM_SYSTEM_TABLE; - VOL32 unused_170[5]; /* 0x170 */ - VOL32 SCALER_BUF0_OFFSET_U; - VOL32 SCALER_BUF0_OFFSET_V; - VOL32 SCALER_BUF1_OFFSET_U; - VOL32 SCALER_BUF1_OFFSET_V; - VOL32 unused_179[7]; - VOL32 unused_180[16]; /* 0x180 */ - VOL32 setup_engine[0x40]; /* 0x190 */ - VOL32 dvd_subpicture[0x30]; /* 0x1d0 */ -} MediaReg; - -#define MACH64_XY(x,y) (((x) & 0x7fff) | (((y) & 0x7fff) << 16)) -#define MACH64_YX(x,y) (((y) & 0x7fff) | (((x) & 0x7fff) << 16)) - -typedef struct _mach64Save { - CARD32 LCD_GEN_CTRL; -} Mach64Save; - -typedef struct _mach64CardInfo { - VesaCardPrivRec vesa; - CARD8 *reg_base; - Reg *reg; - MediaReg *media_reg; - Mach64Save save; - Bool lcdEnabled; -} Mach64CardInfo; - -#define getMach64CardInfo(kd) ((Mach64CardInfo *) ((kd)->card->driver)) -#define mach64CardInfo(kd) Mach64CardInfo *mach64c = getMach64CardInfo(kd) - -typedef struct _mach64Cursor { - int width, height; - int xhot, yhot; - Bool has_cursor; - CursorPtr pCursor; - Pixel source, mask; -} Mach64Cursor; - -#define MACH64_CURSOR_WIDTH 64 -#define MACH64_CURSOR_HEIGHT 64 - -/* - * Xv information, optional - */ -typedef struct _mach64PortPriv { - CARD32 YBuf0Offset; - - CARD32 YBuf1Offset; - - CARD8 currentBuf; - - int brightness; - int saturation; - - RegionRec clip; - CARD32 colorKey; - - Bool videoOn; - Time offTime; - Time freeTime; - CARD32 size; - CARD32 offset; - KdOffscreenArea *off_screen; -} Mach64PortPrivRec, *Mach64PortPrivPtr; - -Bool mach64InitVideo(ScreenPtr pScreen); -void mach64FiniVideo(ScreenPtr pScreen); - -/* - * These values are per-format, which is essentially per-depth/per-bpp. - * Because bpp is fixed for the screen by depth, they're computed - * per-screen per-depth. - */ - -typedef struct _mach64ScreenInfo { - VesaScreenPrivRec vesa; - Mach64Cursor cursor; - CARD32 colorKey; - KdVideoAdaptorPtr pAdaptor; -} Mach64ScreenInfo; - -#define getMach64ScreenInfo(kd) ((Mach64ScreenInfo *) ((kd)->screen->driver)) -#define mach64ScreenInfo(kd) Mach64ScreenInfo *mach64s = getMach64ScreenInfo(kd) - -CARD32 -mach64ReadLCD (Reg *reg, int id); - -void -mach64WriteLCD (Reg *reg, int id, CARD32 data); - -void -mach64Preserve (KdCardInfo *card); - -Bool -mach64MapReg (KdCardInfo *card, Mach64CardInfo *mach64c); - -void -mach64UnmapReg (KdCardInfo *card, Mach64CardInfo *mach64c); - -void -mach64SetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c); - -void -mach64ResetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c); - -Bool -mach64Enable (ScreenPtr pScreen); - -void -mach64Disable (ScreenPtr pScreen); - -Bool -mach64DPMS (ScreenPtr pScreen, int mode); - -void -mach64WaitAvail(Reg *reg, int n); - -void -mach64WaitIdle (Reg *reg); - -Bool -mach64DrawSetup (ScreenPtr pScreen); - -Bool -mach64DrawInit (ScreenPtr pScreen); - -void -mach64DrawReinit (ScreenPtr pScreen); - -void -mach64DrawEnable (ScreenPtr pScreen); - -void -mach64DrawSync (ScreenPtr pScreen); - -void -mach64DrawDisable (ScreenPtr pScreen); - -void -mach64DrawFini (ScreenPtr pScreen); - -CARD8 -mach64ReadIndex (Mach64CardInfo *mach64c, CARD16 port, CARD8 index); - -void -mach64WriteIndex (Mach64CardInfo *mach64c, CARD16 port, CARD8 index, CARD8 value); - -Bool -mach64CursorInit (ScreenPtr pScreen); - -void -mach64CursorEnable (ScreenPtr pScreen); - -void -mach64CursorDisable (ScreenPtr pScreen); - -void -mach64CursorFini (ScreenPtr pScreen); - -void -mach64RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef); - -extern KdCardFuncs mach64Funcs; - -#endif /* _MACH64_H_ */ diff --git a/hw/kdrive/mach64/mach64curs.c b/hw/kdrive/mach64/mach64curs.c deleted file mode 100644 index b5d7cd16c..000000000 --- a/hw/kdrive/mach64/mach64curs.c +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Id: tridentcurs.c,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * Copyright © 1999 Keith Packard - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c,v 1.6 2000/09/03 05:11:20 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "trident.h" -#include "cursorstr.h" - -#define SetupCursor(s) KdScreenPriv(s); \ - tridentCardInfo(pScreenPriv); \ - tridentScreenInfo(pScreenPriv); \ - TridentCursor *pCurPriv = &tridents->cursor - -static void -_tridentMoveCursor (ScreenPtr pScreen, int x, int y) -{ - SetupCursor(pScreen); - CARD8 xlow, xhigh, ylow, yhigh; - CARD8 xoff, yoff; - - x -= pCurPriv->xhot; - xoff = 0; - if (x < 0) - { - xoff = -x; - x = 0; - } - y -= pCurPriv->yhot; - yoff = 0; - if (y < 0) - { - yoff = -y; - y = 0; - } - xlow = (CARD8) x; - xhigh = (CARD8) (x >> 8); - ylow = (CARD8) y; - yhigh = (CARD8) (y >> 8); - - - /* This is the recommended order to move the cursor */ - - tridentWriteIndex (tridentc, 0x3d4, 0x41, xhigh); - tridentWriteIndex (tridentc, 0x3d4, 0x40, xlow); - tridentWriteIndex (tridentc, 0x3d4, 0x42, ylow); - tridentWriteIndex (tridentc, 0x3d4, 0x46, xoff); - tridentWriteIndex (tridentc, 0x3d4, 0x47, yoff); - tridentWriteIndex (tridentc, 0x3d4, 0x43, yhigh); -} - -static void -tridentMoveCursor (ScreenPtr pScreen, int x, int y) -{ - SetupCursor (pScreen); - - if (!pCurPriv->has_cursor) - return; - - if (!pScreenPriv->enabled) - return; - - _tridentMoveCursor (pScreen, x, y); -} - -static void -tridentAllocCursorColors (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - CursorPtr pCursor = pCurPriv->pCursor; - - KdAllocateCursorPixels (pScreen, 0, pCursor, - &pCurPriv->source, &pCurPriv->mask); - switch (pScreenPriv->screen->fb[0].bitsPerPixel) { - case 4: - pCurPriv->source |= pCurPriv->source << 4; - pCurPriv->mask |= pCurPriv->mask << 4; - case 8: - pCurPriv->source |= pCurPriv->source << 8; - pCurPriv->mask |= pCurPriv->mask << 8; - case 16: - pCurPriv->source |= pCurPriv->source << 16; - pCurPriv->mask |= pCurPriv->mask << 16; - } -} - -static void -tridentSetCursorColors (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - CursorPtr pCursor = pCurPriv->pCursor; - CARD32 fg, bg; - - fg = pCurPriv->source; - bg = pCurPriv->mask; - tridentWriteIndex (tridentc, 0x3d4, 0x48, fg); - tridentWriteIndex (tridentc, 0x3d4, 0x49, fg >> 8); - tridentWriteIndex (tridentc, 0x3d4, 0x4a, fg >> 16); - - tridentWriteIndex (tridentc, 0x3d4, 0x4c, bg); - tridentWriteIndex (tridentc, 0x3d4, 0x4d, bg >> 8); - tridentWriteIndex (tridentc, 0x3d4, 0x4e, bg >> 16); -} - -void -tridentRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef) -{ - SetupCursor (pScreen); - CursorPtr pCursor = pCurPriv->pCursor; - xColorItem sourceColor, maskColor; - - if (!pCurPriv->has_cursor || !pCursor) - return; - - if (!pScreenPriv->enabled) - return; - - if (pdef) - { - while (ndef) - { - if (pdef->pixel == pCurPriv->source || - pdef->pixel == pCurPriv->mask) - break; - ndef--; - } - if (!ndef) - return; - } - tridentAllocCursorColors (pScreen); - tridentSetCursorColors (pScreen); -} - -#define InvertBits32(v) { \ - v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ - v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ - v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ -} - -static void -tridentLoadCursor (ScreenPtr pScreen, int x, int y) -{ - SetupCursor(pScreen); - CursorPtr pCursor = pCurPriv->pCursor; - CursorBitsPtr bits = pCursor->bits; - int w, h; - CARD32 *ram, *msk, *mskLine, *src, *srcLine; - int i, j; - int cursor_address; - int lwsrc; - unsigned char ramdac_control_; - CARD32 offset; - - /* - * Allocate new colors - */ - tridentAllocCursorColors (pScreen); - - pCurPriv->pCursor = pCursor; - pCurPriv->xhot = pCursor->bits->xhot; - pCurPriv->yhot = pCursor->bits->yhot; - - /* - * Stick new image into cursor memory - */ - ram = (CARD32 *) tridents->cursor_base; - mskLine = (CARD32 *) bits->mask; - srcLine = (CARD32 *) bits->source; - - h = bits->height; - if (h > TRIDENT_CURSOR_HEIGHT) - h = TRIDENT_CURSOR_HEIGHT; - - lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */ - - for (i = 0; i < TRIDENT_CURSOR_HEIGHT; i++) { - msk = mskLine; - src = srcLine; - mskLine += lwsrc; - srcLine += lwsrc; - for (j = 0; j < TRIDENT_CURSOR_WIDTH / 32; j++) { - - CARD32 m, s; - -#if 1 - if (i < h && j < lwsrc) - { - m = *msk++; - s = *src++; - InvertBits32(m); - InvertBits32(s); - } - else - { - m = 0; - s = 0; - } -#endif - *ram++ = m; - *ram++ = s; - } - } - - /* Set address for cursor bits */ - offset = tridents->cursor_base - (CARD8 *) tridents->screen; - offset >>= 10; - tridentWriteIndex (tridentc, 0x3d4, 0x44, (CARD8) (offset & 0xff)); - tridentWriteIndex (tridentc, 0x3d4, 0x45, (CARD8) (offset >> 8)); - - /* Set new color */ - tridentSetCursorColors (pScreen); - - /* Enable the cursor */ - tridentWriteIndex (tridentc, 0x3d4, 0x50, 0xc1); - - /* Move to new position */ - tridentMoveCursor (pScreen, x, y); -} - -static void -tridentUnloadCursor (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - /* Disable cursor */ - tridentWriteIndex (tridentc, 0x3d4, 0x50, 0); -} - -static Bool -tridentRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) -{ - SetupCursor(pScreen); - - if (!pScreenPriv->enabled) - return TRUE; - - /* miRecolorCursor does this */ - if (pCurPriv->pCursor == pCursor) - { - if (pCursor) - { - int x, y; - - miPointerPosition (&x, &y); - tridentLoadCursor (pScreen, x, y); - } - } - return TRUE; -} - -static Bool -tridentUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) -{ - return TRUE; -} - -static void -tridentSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) -{ - SetupCursor(pScreen); - - pCurPriv->pCursor = pCursor; - - if (!pScreenPriv->enabled) - return; - - if (pCursor) - tridentLoadCursor (pScreen, x, y); - else - tridentUnloadCursor (pScreen); -} - -miPointerSpriteFuncRec tridentPointerSpriteFuncs = { - tridentRealizeCursor, - tridentUnrealizeCursor, - tridentSetCursor, - tridentMoveCursor, -}; - -static void -tridentQueryBestSize (int class, - unsigned short *pwidth, unsigned short *pheight, - ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - switch (class) - { - case CursorShape: - if (*pwidth > pCurPriv->width) - *pwidth = pCurPriv->width; - if (*pheight > pCurPriv->height) - *pheight = pCurPriv->height; - if (*pwidth > pScreen->width) - *pwidth = pScreen->width; - if (*pheight > pScreen->height) - *pheight = pScreen->height; - break; - default: - fbQueryBestSize (class, pwidth, pheight, pScreen); - break; - } -} - -Bool -tridentCursorInit (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - if (!tridents->cursor_base) - { - pCurPriv->has_cursor = FALSE; - return FALSE; - } - - pCurPriv->width = TRIDENT_CURSOR_WIDTH; - pCurPriv->height= TRIDENT_CURSOR_HEIGHT; - pScreen->QueryBestSize = tridentQueryBestSize; - miPointerInitialize (pScreen, - &tridentPointerSpriteFuncs, - &kdPointerScreenFuncs, - FALSE); - pCurPriv->has_cursor = TRUE; - pCurPriv->pCursor = NULL; - return TRUE; -} - -void -tridentCursorEnable (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - if (pCurPriv->has_cursor) - { - if (pCurPriv->pCursor) - { - int x, y; - - miPointerPosition (&x, &y); - tridentLoadCursor (pScreen, x, y); - } - else - tridentUnloadCursor (pScreen); - } -} - -void -tridentCursorDisable (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - if (!pScreenPriv->enabled) - return; - - if (pCurPriv->has_cursor) - { - if (pCurPriv->pCursor) - { - tridentUnloadCursor (pScreen); - } - } -} - -void -tridentCursorFini (ScreenPtr pScreen) -{ - SetupCursor (pScreen); - - pCurPriv->pCursor = NULL; -} diff --git a/hw/kdrive/mach64/mach64draw.c b/hw/kdrive/mach64/mach64draw.c deleted file mode 100644 index df53f3fad..000000000 --- a/hw/kdrive/mach64/mach64draw.c +++ /dev/null @@ -1,593 +0,0 @@ -/* - * Id: mach64draw.c,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * Copyright © 1999 Keith Packard - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/mach64/mach64draw.c,v 1.6 2001/07/23 03:44:17 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "mach64.h" -#include "mach64draw.h" - -#include <X11/Xmd.h> -#include "gcstruct.h" -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "regionstr.h" -#include "mistruct.h" -#include "fontstruct.h" -#include "dixfontstr.h" -#include "fb.h" -#include "migc.h" -#include "miline.h" -#include "picturestr.h" - -CARD8 mach64Rop[16] = { - /* GXclear */ 0x01, /* 0 */ - /* GXand */ 0x0c, /* src AND dst */ - /* GXandReverse */ 0x0d, /* src AND NOT dst */ - /* GXcopy */ 0x07, /* src */ - /* GXandInverted*/ 0x0e, /* NOT src AND dst */ - /* GXnoop */ 0x03, /* dst */ - /* GXxor */ 0x05, /* src XOR dst */ - /* GXor */ 0x0b, /* src OR dst */ - /* GXnor */ 0x0f, /* NOT src AND NOT dst */ - /* GXequiv */ 0x06, /* NOT src XOR dst */ - /* GXinvert */ 0x00, /* NOT dst */ - /* GXorReverse */ 0x0a, /* src OR NOT dst */ - /* GXcopyInverted*/ 0x04, /* NOT src */ - /* GXorInverted */ 0x09, /* NOT src OR dst */ - /* GXnand */ 0x08, /* NOT src OR NOT dst */ - /* GXset */ 0x02, /* 1 */ -}; - -#define MACH64_DRAW_COMBO_SOLID 0x1 -#define MACH64_DRAW_COMBO_COPY 0x8 - -#define SYNC_ALWAYS 0 -static Reg *reg; -static CARD32 avail; -static CARD32 triple; - -#define IDX(reg,n) (&(reg)->n - &(reg)->CRTC_H_TOTAL_DISP) - -void -mach64WaitAvail(Reg *reg, int n) -{ - if (avail < n) - { - while ((avail = ((reg->GUI_STAT) >> 16) & 0x3ff) < n) - ; - } - avail -= n; -} - -void -mach64WaitIdle (Reg *reg) -{ - while (reg->GUI_STAT & 1) - ; -} - -#define PIX_FORMAT_MONO 0 -#define PIX_FORMAT_PSEUDO_8 2 -#define PIX_FORMAT_TRUE_1555 3 -#define PIX_FORMAT_TRUE_565 4 -#define PIX_FORMAT_TRUE_8888 6 -#define PIX_FORMAT_TRUE_332 7 -#define PIX_FORMAT_GRAY_8 8 -#define PIX_FORMAT_YUV_422 0xb -#define PIX_FORMAT_YUV_444 0xe -#define PIX_FORMAT_TRUE_4444 0xf - -typedef struct _mach64AccelReg { - int depth; - int bitsPerPixel; - CARD32 DP_PIX_WIDTH; - CARD32 DP_SET_GUI_ENGINE; -} Mach64AccelReg; - -static const Mach64AccelReg mach64AccelReg[] = { - { 1, 1, - /* DP_PIX_WIDTH */ - ((PIX_FORMAT_MONO << 0) | /* DP_DST_PIX_WIDTH */ - (PIX_FORMAT_MONO << 4) | /* COMPOSITE_PIX_WIDTH */ - (PIX_FORMAT_MONO << 8) | /* DP_SRC_PIX_WIDTH */ - (0 << 13) | /* DP_HOST_TRIPLE_EN */ - (0 << 14) | /* DP_PALETTE_TYPE */ - (PIX_FORMAT_MONO << 16) | /* DP_HOST_PIX_WIDTH */ - (0 << 20) | /* DP_C14_RGB_INDEX */ - (0 << 24) | /* DP_BYTE_PIX_ORDER */ - (0 << 25) | /* DP_CONVERSION_TEMP */ - (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */ - (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */ - (PIX_FORMAT_MONO << 28) | /* DP_SCALE_PIX_WIDTH */ - 0), - /* DP_SET_GUI_ENGINE */ - ((PIX_FORMAT_MONO << 3) | - (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */ - (6 << 7) | /* SET_DST_OFFSET */ - (0 << 10) | /* SET_DST_PITCH */ - (0 << 14) | /* SET_DST_PITCH_BY_2 */ - (0 << 15) | /* SET_SRC_OFFPITCH_COPY */ - (0 << 16) | /* SET_SRC_HGTWID1_2 */ - (0 << 20) | /* SET_DRAWING_COMBO */ - (1 << 24) | /* SET_BUS_MASTER_OP */ - (0 << 26) | /* SET_BUS_MASTER_EN */ - (0 << 27) | /* SET_BUS_MASTER_SYNC */ - (0 << 28) | /* DP_HOST_TRIPLE_EN */ - (0 << 29) | /* FAST_FILL_EN */ - (0 << 30) | /* BLOCK_WRITE_EN */ - 0) - }, - { 8, 8, - /* DP_PIX_WIDTH */ - ((PIX_FORMAT_PSEUDO_8 << 0) | /* DP_DST_PIX_WIDTH */ - (PIX_FORMAT_PSEUDO_8 << 4) | /* COMPOSITE_PIX_WIDTH */ - (PIX_FORMAT_PSEUDO_8 << 8) | /* DP_SRC_PIX_WIDTH */ - (0 << 13) | /* DP_HOST_TRIPLE_EN */ - (0 << 14) | /* DP_PALETTE_TYPE */ - (PIX_FORMAT_PSEUDO_8 << 16) | /* DP_HOST_PIX_WIDTH */ - (0 << 20) | /* DP_C14_RGB_INDEX */ - (0 << 24) | /* DP_BYTE_PIX_ORDER */ - (0 << 25) | /* DP_CONVERSION_TEMP */ - (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */ - (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */ - (PIX_FORMAT_PSEUDO_8 << 28) | /* DP_SCALE_PIX_WIDTH */ - 0), - /* DP_SET_GUI_ENGINE */ - ((PIX_FORMAT_PSEUDO_8 << 3) | - (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */ - (6 << 7) | /* SET_DST_OFFSET */ - (0 << 10) | /* SET_DST_PITCH */ - (0 << 14) | /* SET_DST_PITCH_BY_2 */ - (0 << 15) | /* SET_SRC_OFFPITCH_COPY */ - (0 << 16) | /* SET_SRC_HGTWID1_2 */ - (0 << 20) | /* SET_DRAWING_COMBO */ - (1 << 24) | /* SET_BUS_MASTER_OP */ - (0 << 26) | /* SET_BUS_MASTER_EN */ - (0 << 27) | /* SET_BUS_MASTER_SYNC */ - (0 << 28) | /* DP_HOST_TRIPLE_EN */ - (0 << 29) | /* FAST_FILL_EN */ - (0 << 30) | /* BLOCK_WRITE_EN */ - 0) - }, - { 15, 16, - /* DP_PIX_WIDTH */ - ((PIX_FORMAT_TRUE_1555 << 0) | /* DP_DST_PIX_WIDTH */ - (PIX_FORMAT_TRUE_1555 << 4) | /* COMPOSITE_PIX_WIDTH */ - (PIX_FORMAT_TRUE_1555 << 8) | /* DP_SRC_PIX_WIDTH */ - (0 << 13) | /* DP_HOST_TRIPLE_EN */ - (0 << 14) | /* DP_PALETTE_TYPE */ - (PIX_FORMAT_TRUE_1555 << 16) | /* DP_HOST_PIX_WIDTH */ - (0 << 20) | /* DP_C14_RGB_INDEX */ - (0 << 24) | /* DP_BYTE_PIX_ORDER */ - (0 << 25) | /* DP_CONVERSION_TEMP */ - (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */ - (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */ - (PIX_FORMAT_TRUE_1555 << 28) | /* DP_SCALE_PIX_WIDTH */ - 0), - /* DP_SET_GUI_ENGINE */ - ((PIX_FORMAT_TRUE_1555 << 3) | - (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */ - (6 << 7) | /* SET_DST_OFFSET */ - (0 << 10) | /* SET_DST_PITCH */ - (0 << 14) | /* SET_DST_PITCH_BY_2 */ - (0 << 15) | /* SET_SRC_OFFPITCH_COPY */ - (0 << 16) | /* SET_SRC_HGTWID1_2 */ - (0 << 20) | /* SET_DRAWING_COMBO */ - (1 << 24) | /* SET_BUS_MASTER_OP */ - (0 << 26) | /* SET_BUS_MASTER_EN */ - (0 << 27) | /* SET_BUS_MASTER_SYNC */ - (0 << 28) | /* DP_HOST_TRIPLE_EN */ - (0 << 29) | /* FAST_FILL_EN */ - (0 << 30) | /* BLOCK_WRITE_EN */ - 0) - }, - { 16, 16, - /* DP_PIX_WIDTH */ - ((PIX_FORMAT_TRUE_565 << 0) | /* DP_DST_PIX_WIDTH */ - (PIX_FORMAT_TRUE_565 << 4) | /* COMPOSITE_PIX_WIDTH */ - (PIX_FORMAT_TRUE_565 << 8) | /* DP_SRC_PIX_WIDTH */ - (0 << 13) | /* DP_HOST_TRIPLE_EN */ - (0 << 14) | /* DP_PALETTE_TYPE */ - (PIX_FORMAT_TRUE_565 << 16) | /* DP_HOST_PIX_WIDTH */ - (0 << 20) | /* DP_C14_RGB_INDEX */ - (0 << 24) | /* DP_BYTE_PIX_ORDER */ - (0 << 25) | /* DP_CONVERSION_TEMP */ - (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */ - (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */ - (PIX_FORMAT_TRUE_565 << 28) | /* DP_SCALE_PIX_WIDTH */ - 0), - /* DP_SET_GUI_ENGINE */ - ((PIX_FORMAT_TRUE_565 << 3) | - (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */ - (6 << 7) | /* SET_DST_OFFSET */ - (0 << 10) | /* SET_DST_PITCH */ - (0 << 14) | /* SET_DST_PITCH_BY_2 */ - (0 << 15) | /* SET_SRC_OFFPITCH_COPY */ - (0 << 16) | /* SET_SRC_HGTWID1_2 */ - (0 << 20) | /* SET_DRAWING_COMBO */ - (1 << 24) | /* SET_BUS_MASTER_OP */ - (0 << 26) | /* SET_BUS_MASTER_EN */ - (0 << 27) | /* SET_BUS_MASTER_SYNC */ - (0 << 28) | /* DP_HOST_TRIPLE_EN */ - (0 << 29) | /* FAST_FILL_EN */ - (0 << 30) | /* BLOCK_WRITE_EN */ - 0) - }, - { 24, 24, - /* DP_PIX_WIDTH */ - ((PIX_FORMAT_PSEUDO_8 << 0) | /* DP_DST_PIX_WIDTH */ - (PIX_FORMAT_PSEUDO_8 << 4) | /* COMPOSITE_PIX_WIDTH */ - (PIX_FORMAT_PSEUDO_8 << 8) | /* DP_SRC_PIX_WIDTH */ - (0 << 13) | /* DP_HOST_TRIPLE_EN */ - (0 << 14) | /* DP_PALETTE_TYPE */ - (PIX_FORMAT_PSEUDO_8 << 16) | /* DP_HOST_PIX_WIDTH */ - (0 << 20) | /* DP_C14_RGB_INDEX */ - (0 << 24) | /* DP_BYTE_PIX_ORDER */ - (0 << 25) | /* DP_CONVERSION_TEMP */ - (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */ - (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */ - (PIX_FORMAT_PSEUDO_8 << 28) | /* DP_SCALE_PIX_WIDTH */ - 0), - /* DP_SET_GUI_ENGINE */ - ((PIX_FORMAT_PSEUDO_8 << 3) | - (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */ - (6 << 7) | /* SET_DST_OFFSET */ - (0 << 10) | /* SET_DST_PITCH */ - (0 << 14) | /* SET_DST_PITCH_BY_2 */ - (0 << 15) | /* SET_SRC_OFFPITCH_COPY */ - (0 << 16) | /* SET_SRC_HGTWID1_2 */ - (0 << 20) | /* SET_DRAWING_COMBO */ - (1 << 24) | /* SET_BUS_MASTER_OP */ - (0 << 26) | /* SET_BUS_MASTER_EN */ - (0 << 27) | /* SET_BUS_MASTER_SYNC */ - (0 << 28) | /* DP_HOST_TRIPLE_EN */ - (0 << 29) | /* FAST_FILL_EN */ - (0 << 30) | /* BLOCK_WRITE_EN */ - 0) - }, - { 24, 32, - /* DP_PIX_WIDTH */ - ((PIX_FORMAT_TRUE_8888 << 0) | /* DP_DST_PIX_WIDTH */ - (PIX_FORMAT_TRUE_8888 << 4) | /* COMPOSITE_PIX_WIDTH */ - (PIX_FORMAT_TRUE_8888 << 8) | /* DP_SRC_PIX_WIDTH */ - (0 << 13) | /* DP_HOST_TRIPLE_EN */ - (0 << 14) | /* DP_PALETTE_TYPE */ - (PIX_FORMAT_TRUE_8888 << 16) | /* DP_HOST_PIX_WIDTH */ - (0 << 20) | /* DP_C14_RGB_INDEX */ - (0 << 24) | /* DP_BYTE_PIX_ORDER */ - (0 << 25) | /* DP_CONVERSION_TEMP */ - (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */ - (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */ - (PIX_FORMAT_TRUE_8888 << 28) | /* DP_SCALE_PIX_WIDTH */ - 0), - /* DP_SET_GUI_ENGINE */ - ((PIX_FORMAT_TRUE_8888 << 3) | - (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */ - (6 << 7) | /* SET_DST_OFFSET */ - (0 << 10) | /* SET_DST_PITCH */ - (0 << 14) | /* SET_DST_PITCH_BY_2 */ - (0 << 15) | /* SET_SRC_OFFPITCH_COPY */ - (0 << 16) | /* SET_SRC_HGTWID1_2 */ - (0 << 20) | /* SET_DRAWING_COMBO */ - (1 << 24) | /* SET_BUS_MASTER_OP */ - (0 << 26) | /* SET_BUS_MASTER_EN */ - (0 << 27) | /* SET_BUS_MASTER_SYNC */ - (0 << 28) | /* DP_HOST_TRIPLE_EN */ - (0 << 29) | /* FAST_FILL_EN */ - (0 << 30) | /* BLOCK_WRITE_EN */ - 0) - }, - { 32, 32, - /* DP_PIX_WIDTH */ - ((PIX_FORMAT_TRUE_8888 << 0) | /* DP_DST_PIX_WIDTH */ - (PIX_FORMAT_TRUE_8888 << 4) | /* COMPOSITE_PIX_WIDTH */ - (PIX_FORMAT_TRUE_8888 << 8) | /* DP_SRC_PIX_WIDTH */ - (0 << 13) | /* DP_HOST_TRIPLE_EN */ - (0 << 14) | /* DP_PALETTE_TYPE */ - (PIX_FORMAT_TRUE_8888 << 16) | /* DP_HOST_PIX_WIDTH */ - (0 << 20) | /* DP_C14_RGB_INDEX */ - (0 << 24) | /* DP_BYTE_PIX_ORDER */ - (0 << 25) | /* DP_CONVERSION_TEMP */ - (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */ - (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */ - (PIX_FORMAT_TRUE_8888 << 28) | /* DP_SCALE_PIX_WIDTH */ - 0), - /* DP_SET_GUI_ENGINE */ - ((PIX_FORMAT_TRUE_8888 << 3) | - (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */ - (6 << 7) | /* SET_DST_OFFSET */ - (0 << 10) | /* SET_DST_PITCH */ - (0 << 14) | /* SET_DST_PITCH_BY_2 */ - (0 << 15) | /* SET_SRC_OFFPITCH_COPY */ - (0 << 16) | /* SET_SRC_HGTWID1_2 */ - (0 << 20) | /* SET_DRAWING_COMBO */ - (1 << 24) | /* SET_BUS_MASTER_OP */ - (0 << 26) | /* SET_BUS_MASTER_EN */ - (0 << 27) | /* SET_BUS_MASTER_SYNC */ - (0 << 28) | /* DP_HOST_TRIPLE_EN */ - (0 << 29) | /* FAST_FILL_EN */ - (0 << 30) | /* BLOCK_WRITE_EN */ - 0) - } -}; - -#define NACCELREG (sizeof mach64AccelReg / sizeof mach64AccelReg[0]) - -static Bool -mach64Setup (PixmapPtr pDst, PixmapPtr pSrc, CARD32 combo, int wait) -{ - ScreenPtr pScreen = pDst->drawable.pScreen; - KdScreenPriv(pScreen); - mach64CardInfo(pScreenPriv); - CARD32 DST_PITCH; - CARD32 DST_OFFSET; - CARD32 SRC_PITCH; - CARD32 SRC_OFFSET; - CARD32 DP_PIX_WIDTH; - CARD32 DP_SET_GUI_ENGINE; - int i; - - for (i = 0; i < NACCELREG; i++) - if (mach64AccelReg[i].depth == pDst->drawable.depth && - mach64AccelReg[i].bitsPerPixel == pDst->drawable.bitsPerPixel) - break; - if (i == NACCELREG) - return FALSE; - DP_PIX_WIDTH = mach64AccelReg[i].DP_PIX_WIDTH; - DP_SET_GUI_ENGINE = mach64AccelReg[i].DP_SET_GUI_ENGINE; - - reg = mach64c->reg; - if (!reg) - return FALSE; - - triple = (pDst->drawable.bitsPerPixel == 24); - - if (triple) - { - /* bytes / 8 = bytes >> 3 */ - DST_PITCH = pDst->devKind >> 3; - } - else - { - /* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */ - DST_PITCH = pDst->devKind / pDst->drawable.bitsPerPixel; - } - - /* bytes / 8 */ - DST_OFFSET = ((CARD8 *) pDst->devPrivate.ptr - pScreenPriv->screen->memory_base) >> 3; - - mach64WaitAvail(reg, wait + (pSrc ? 5 : 4)); - reg->DP_SET_GUI_ENGINE = DP_SET_GUI_ENGINE | (combo << 20); - reg->DP_PIX_WIDTH = DP_PIX_WIDTH; - reg->DST_OFF_PITCH = ((DST_OFFSET << 0) | /* USR1_DST_OFFSET */ - (DST_PITCH << 22) | /* USR1_DST_PITCH */ - 0); - if (pSrc) - { - if (triple) - { - SRC_PITCH = pSrc->devKind >> 3; - } - else - { - /* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */ - SRC_PITCH = pSrc->devKind / pSrc->drawable.bitsPerPixel; - } - /* bytes / 8 */ - SRC_OFFSET = ((CARD8 *) pSrc->devPrivate.ptr - pScreenPriv->screen->memory_base) >> 3; - - reg->SRC_OFF_PITCH = ((SRC_OFFSET << 0) | - (SRC_PITCH << 22) | - 0); - } - return TRUE; -} - -static Bool -mach64PrepareSolid (PixmapPtr pPixmap, - int alu, - Pixel pm, - Pixel fg) -{ - if (!mach64Setup (pPixmap, 0, 1, 3)) - return FALSE; - reg->DP_MIX = (mach64Rop[alu] << 16) | 0; - reg->DP_WRITE_MSK = pm; - reg->DP_FRGD_CLR = fg; - return TRUE; -} - -static void -mach64Solid (int x1, int y1, int x2, int y2) -{ - if (triple) - { - CARD32 traj; - - x1 *= 3; - x2 *= 3; - - traj = (DST_X_DIR | - DST_Y_DIR | - DST_24_ROT_EN | - DST_24_ROT((x1 / 4) % 6)); - mach64WaitAvail (reg, 1); - reg->GUI_TRAJ_CNTL = traj; - } - mach64WaitAvail(reg,2); - reg->DST_X_Y = MACH64_XY(x1,y1); - reg->DST_WIDTH_HEIGHT = MACH64_XY(x2-x1,y2-y1); -} - -static void -mach64DoneSolid (void) -{ -#if SYNC_ALWAYS - mach64WaitIdle (reg); -#endif -} - -static int copyDx; -static int copyDy; -static CARD32 copyCombo; - -static Bool -mach64PrepareCopy (PixmapPtr pSrcPixmap, - PixmapPtr pDstPixmap, - int dx, - int dy, - int alu, - Pixel pm) -{ - copyCombo = 8 | 2 | 1; - copyDx = dx; - copyDy = dy; - - /* - * Avoid going backwards when copying pixmaps to the screen. - * This should reduce tearing somewhat - */ - if (pSrcPixmap == pDstPixmap) - { - if (dx <= 0) - copyCombo &= ~1; - if (dy <= 0) - copyCombo &= ~2; - } - - if (!mach64Setup (pDstPixmap, pSrcPixmap, copyCombo, 2)) - return FALSE; - - reg->DP_MIX = (mach64Rop[alu] << 16) | 0; - reg->DP_WRITE_MSK = pm; - return TRUE; -} - -static void -mach64Copy (int srcX, - int srcY, - int dstX, - int dstY, - int w, - int h) -{ - if (triple) - { - CARD32 traj; - - srcX *= 3; - dstX *= 3; - w *= 3; - - traj = DST_24_ROT_EN | DST_24_ROT((dstX / 4) % 6); - - if (copyCombo & 1) - traj |= 1; - if (copyCombo & 2) - traj |= 2; - - mach64WaitAvail (reg, 1); - reg->GUI_TRAJ_CNTL = traj; - } - if ((copyCombo & 1) == 0) - { - srcX += w - 1; - dstX += w - 1; - } - if ((copyCombo & 2) == 0) - { - srcY += h - 1; - dstY += h - 1; - } - mach64WaitAvail (reg, 4); - reg->SRC_Y_X = MACH64_YX(srcX, srcY); - reg->SRC_WIDTH1 = w; - reg->DST_Y_X = MACH64_YX(dstX, dstY); - reg->DST_HEIGHT_WIDTH = MACH64_YX(w,h); -} - -static void -mach64DoneCopy (void) -{ -#if SYNC_ALWAYS - mach64WaitIdle (reg); -#endif -} - -KaaScreenInfoRec mach64Kaa = { - mach64PrepareSolid, - mach64Solid, - mach64DoneSolid, - - mach64PrepareCopy, - mach64Copy, - mach64DoneCopy, - - 64, /* Offscreen byte alignment */ - 64, /* Offscreen pitch */ - KAA_OFFSCREEN_PIXMAPS, /* Flags */ -}; - -Bool -mach64DrawInit (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - - if (pScreenPriv->screen->fb[0].depth == 4) - return FALSE; - - if (!kaaDrawInit (pScreen, &mach64Kaa)) - return FALSE; - - return TRUE; -} - -void -mach64DrawEnable (ScreenPtr pScreen) -{ - KdMarkSync (pScreen); -} - -void -mach64DrawDisable (ScreenPtr pScreen) -{ -} - -void -mach64DrawFini (ScreenPtr pScreen) -{ - kaaDrawFini (pScreen); -} - -void -mach64DrawSync (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - mach64CardInfo(pScreenPriv); - reg = mach64c->reg; - - mach64WaitIdle (reg); -} diff --git a/hw/kdrive/mach64/mach64draw.h b/hw/kdrive/mach64/mach64draw.h deleted file mode 100644 index b7053ae49..000000000 --- a/hw/kdrive/mach64/mach64draw.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Id: tridentdraw.h,v 1.1 1999/11/02 03:54:47 keithp Exp $ - * - * Copyright © 1999 Keith Packard - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.h,v 1.4 2000/10/11 06:04:40 keithp Exp $ */ - -#ifndef _TRIDENTDRAW_H_ -#define _TRIDENTDRAW_H_ - -#define SetupTrident(s) KdScreenPriv(s); \ - tridentCardInfo(pScreenPriv); \ - Cop *cop = tridentc->cop - -#define TridentAlpha (COP_MULTI_ALPHA|COP_ALPHA_WRITE_ENABLE) - -#define _tridentInit(cop,tridentc) { \ - if ((cop)->status == 0xffffffff) tridentSetMMIO(tridentc); \ - (cop)->multi = (tridentc)->cop_depth; \ - (cop)->multi = (tridentc)->cop_stride; \ - (cop)->multi = TridentAlpha; \ -} \ - -#define _tridentSetSolidRect(cop,pix,alu,cmd) {\ - cop->multi = COP_MULTI_PATTERN; \ - cop->multi = COP_MULTI_ROP | tridentRop[alu]; \ - cop->fg = (pix); \ - cmd = COP_OP_BLT | COP_SCL_OPAQUE | COP_OP_ROP | COP_OP_FG; \ -} - -#define _tridentRect(cop,x1,y1,x2,y2,cmd) { \ - (cop)->dst_start_xy = TRI_XY (x1,y1); \ - (cop)->dst_end_xy = TRI_XY(x2,y2); \ - _tridentWaitDone(cop); \ - (cop)->command = (cmd); \ -} - -#define COP_STATUS_BUSY (COP_STATUS_BE_BUSY | \ - COP_STATUS_DPE_BUSY | \ - COP_STATUS_MI_BUSY) - -#define _tridentWaitDone(cop) { \ - int __q__ = 500000; \ - while (__q__-- && (cop)->status & COP_STATUS_BUSY) \ - ; \ - if (!__q__) \ - (cop)->status = 0; \ -} - -#define _tridentWaitIdleEmpty(cop) _tridentWaitDone(cop) - -#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3)) - -#endif diff --git a/hw/kdrive/mach64/mach64stub.c b/hw/kdrive/mach64/mach64stub.c deleted file mode 100644 index 03d47608d..000000000 --- a/hw/kdrive/mach64/mach64stub.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Id: mach64stub.c,v 1.1 1999/11/02 08:19:15 keithp Exp $ - * - * Copyright 1999 SuSE, 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 SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Keith Packard, SuSE, Inc. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/mach64/mach64stub.c,v 1.2 2001/10/12 06:33:10 keithp Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "mach64.h" -#include <klinux.h> - -void -InitCard (char *name) -{ - KdCardAttr attr; - - if (LinuxFindPci (0x1002, 0x4c4d, 0, &attr)) - KdCardInfoAdd (&mach64Funcs, &attr, 0); - else if (LinuxFindPci (0x1002, 0x4c49, 0, &attr)) - KdCardInfoAdd (&mach64Funcs, &attr, 0); - else if (LinuxFindPci (0x1002, 0x4c46, 0, &attr)) - KdCardInfoAdd (&mach64Funcs, &attr, 0); -} - -void -InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) -{ - KdInitOutput (pScreenInfo, argc, argv); -} - -void -InitInput (int argc, char **argv) -{ - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -} - -void -ddxUseMsg (void) -{ - KdUseMsg(); - vesaUseMsg(); -} - -int -ddxProcessArgument (int argc, char **argv, int i) -{ - int ret; - - if (!(ret = vesaProcessArgument (argc, argv, i))) - ret = KdProcessArgument(argc, argv, i); - return ret; -} diff --git a/hw/kdrive/mach64/mach64video.c b/hw/kdrive/mach64/mach64video.c deleted file mode 100644 index 1f945db3c..000000000 --- a/hw/kdrive/mach64/mach64video.c +++ /dev/null @@ -1,1037 +0,0 @@ -/* - * Copyright © 2001 Keith Packard - * - * 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. - */ -/* $RCSId: xc/programs/Xserver/hw/kdrive/mach64/mach64video.c,v 1.9tsi Exp $ */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "mach64.h" - -#include <X11/extensions/Xv.h> -#include "fourcc.h" - -#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) - -static Atom xvBrightness, xvSaturation, xvColorKey; - -#define IMAGE_MAX_WIDTH 720 -#define IMAGE_MAX_HEIGHT 576 - -static void -mach64StopVideo(KdScreenInfo *screen, pointer data, Bool exit) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - Reg *reg = mach64c->reg; - MediaReg *media = mach64c->media_reg; - - REGION_EMPTY(screen->pScreen, &pPortPriv->clip); - - if (!media) - return; - - if(pPortPriv->videoOn) - { - mach64WaitIdle (reg); - /* wait for buffer to be displayed */ - while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf) - ; - /* wait for buffer to be finished */ - while (((media->TRIG_CNTL >> 6) & 1) != 0) - ; - mach64WaitAvail (reg, 1); - media->OVERLAY_SCALE_CNTL = 0; - pPortPriv->videoOn = FALSE; - mach64WaitIdle (reg); - } - if (pPortPriv->off_screen) - { - KdOffscreenFree (pScreen, pPortPriv->off_screen); - pPortPriv->off_screen = 0; - } -} - -static int -mach64SetPortAttribute(KdScreenInfo *screen, - Atom attribute, - int value, - pointer data) -{ - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - - if(attribute == xvBrightness) - { - if(value < -1000) - value = -1000; - if (value > 1000) - value = 1000; - pPortPriv->brightness = value; - } - else if(attribute == xvSaturation) - { - if (value < -1000) - value = -1000; - if (value > 1000) - value = 1000; - pPortPriv->saturation = value; - } - else if(attribute == xvColorKey) - { - if (pPortPriv->colorKey != value) - { - pPortPriv->colorKey = value; - REGION_EMPTY(screen->pScreen, &pPortPriv->clip); - } - } - else - return BadMatch; - - return Success; -} - -static int -mach64GetPortAttribute(KdScreenInfo *screen, - Atom attribute, - int *value, - pointer data) -{ - Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data; - - if(attribute == xvBrightness) - *value = pPortPriv->brightness; - else if(attribute == xvSaturation) - *value = pPortPriv->saturation; - else if(attribute == xvColorKey) - *value = pPortPriv->colorKey; - else - return BadMatch; - - return Success; -} - -static void -mach64QueryBestSize(KdScreenInfo *screen, - 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 -mach64CopyPackedData(KdScreenInfo *screen, - unsigned char *buf, - int randr, - int srcPitch, - int dstPitch, - int srcW, - int srcH, - int top, - int left, - int h, - int w) -{ - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - CARD8 *src = buf, *dst; - int srcDown = srcPitch, srcRight = 2, srcNext; - int p; - - switch (randr & RR_Rotate_All) { - case RR_Rotate_0: - src = buf; - srcDown = srcPitch; - srcRight = 2; - break; - case RR_Rotate_90: - src = buf + (srcH - 1) * 2; - srcDown = -2; - srcRight = srcPitch; - break; - case RR_Rotate_180: - src = buf + srcPitch * (srcH - 1) + (srcW - 1) * 2; - srcDown = -srcPitch; - srcRight = -2; - break; - case RR_Rotate_270: - src = buf + srcPitch * (srcW - 1); - srcDown = 2; - srcRight = -srcPitch; - break; - } - - src = src + top*srcDown + left*srcRight; - - if (pPortPriv->currentBuf == 0) - dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset; - else - dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset; - - w >>= 1; - srcRight >>= 1; - srcNext = srcRight >> 1; - while(h--) - { - CARD16 *s = (CARD16 *) src; - CARD32 *d = (CARD32 *) dst; - p = w; - while (p--) - { - *d++ = s[0] | (s[srcNext] << 16); - s += srcRight; - } - src += srcPitch; - dst += dstPitch; - } -} - -static void -mach64CopyPlanarData(KdScreenInfo *screen, - unsigned char *buf, - int randr, - int srcPitch, - int srcPitch2, - int dstPitch, /* of chroma */ - int srcW, - int srcH, - int height, - int top, - int left, - int h, - int w, - int id) -{ - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - int i, j; - CARD8 *src1, *src2, *src3, *dst1; - int srcDown = srcPitch, srcDown2 = srcPitch2; - int srcRight = 2, srcRight2 = 1, srcNext = 1; - - /* compute source data pointers */ - src1 = buf; - src2 = src1 + height * srcPitch; - src3 = src2 + (height >> 1) * srcPitch2; - switch (randr & RR_Rotate_All) { - case RR_Rotate_0: - srcDown = srcPitch; - srcDown2 = srcPitch2; - srcRight = 2; - srcRight2 = 1; - srcNext = 1; - break; - case RR_Rotate_90: - src1 = src1 + srcH - 1; - src2 = src2 + (srcH >> 1) - 1; - src3 = src3 + (srcH >> 1) - 1; - srcDown = -1; - srcDown2 = -1; - srcRight = srcPitch * 2; - srcRight2 = srcPitch2; - srcNext = srcPitch; - break; - case RR_Rotate_180: - src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1); - src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1); - src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1); - srcDown = -srcPitch; - srcDown2 = -srcPitch2; - srcRight = -2; - srcRight2 = -1; - srcNext = -1; - break; - case RR_Rotate_270: - src1 = src1 + srcPitch * (srcW - 1); - src2 = src2 + srcPitch2 * ((srcW >> 1) - 1); - src3 = src3 + srcPitch2 * ((srcW >> 1) - 1); - srcDown = 1; - srcDown2 = 1; - srcRight = -srcPitch * 2; - srcRight2 = -srcPitch2; - srcNext = -srcPitch; - break; - } - - /* adjust for origin */ - src1 += top * srcDown + left * srcNext; - src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2; - src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2; - - if (id == FOURCC_I420) - { - CARD8 *srct = src2; - src2 = src3; - src3 = srct; - } - - if (pPortPriv->currentBuf == 0) - dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset; - else - dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset; - - w >>= 1; - for (j = 0; j < h; j++) - { - CARD32 *dst = (CARD32 *) dst1; - CARD8 *s1l = src1; - CARD8 *s1r = src1 + srcNext; - CARD8 *s2 = src2; - CARD8 *s3 = src3; - - for (i = 0; i < w; i++) - { - *dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24); - s1l += srcRight; - s1r += srcRight; - s2 += srcRight2; - s3 += srcRight2; - } - src1 += srcDown; - dst1 += dstPitch; - if (j & 1) - { - src2 += srcDown2; - src3 += srcDown2; - } - } -} - -static void -mach64PaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg) -{ - GCPtr pGC; - CARD32 val[2]; - xRectangle *rects, *r; - BoxPtr pBox = REGION_RECTS (pRgn); - int nBox = REGION_NUM_RECTS (pRgn); - - rects = ALLOCATE_LOCAL (nBox * sizeof (xRectangle)); - if (!rects) - goto bail0; - r = rects; - while (nBox--) - { - r->x = pBox->x1 - pDraw->x; - r->y = pBox->y1 - pDraw->y; - r->width = pBox->x2 - pBox->x1; - r->height = pBox->y2 - pBox->y1; - r++; - pBox++; - } - - pGC = GetScratchGC (pDraw->depth, pDraw->pScreen); - if (!pGC) - goto bail1; - - val[0] = fg; - val[1] = IncludeInferiors; - ChangeGC (pGC, GCForeground|GCSubwindowMode, val); - - ValidateGC (pDraw, pGC); - - (*pGC->ops->PolyFillRect) (pDraw, pGC, - REGION_NUM_RECTS (pRgn), rects); - - FreeScratchGC (pGC); -bail1: - DEALLOCATE_LOCAL (rects); -bail0: - ; -} - -/* Mach64ClipVideo - - - Takes the dst box in standard X BoxRec form (top and left - edges inclusive, bottom and right exclusive). The new dst - box is returned. The source boundaries are given (x1, y1 - inclusive, x2, y2 exclusive) and returned are the new source - boundaries in 16.16 fixed point. -*/ - -static void -Mach64ClipVideo(BoxPtr dst, - INT32 *x1, - INT32 *x2, - INT32 *y1, - INT32 *y2, - BoxPtr extents, /* extents of the clip region */ - INT32 width, - INT32 height) -{ - INT32 vscale, hscale, delta; - int diff; - - hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1); - vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1); - - *x1 <<= 16; *x2 <<= 16; - *y1 <<= 16; *y2 <<= 16; - - diff = extents->x1 - dst->x1; - if(diff > 0) { - dst->x1 = extents->x1; - *x1 += diff * hscale; - } - diff = dst->x2 - extents->x2; - if(diff > 0) { - dst->x2 = extents->x2; - *x2 -= diff * hscale; - } - diff = extents->y1 - dst->y1; - if(diff > 0) { - dst->y1 = extents->y1; - *y1 += diff * vscale; - } - diff = dst->y2 - extents->y2; - if(diff > 0) { - dst->y2 = extents->y2; - *y2 -= diff * vscale; - } - - if(*x1 < 0) { - diff = (- *x1 + hscale - 1)/ hscale; - dst->x1 += diff; - *x1 += diff * hscale; - } - delta = *x2 - (width << 16); - if(delta > 0) { - diff = (delta + hscale - 1)/ hscale; - dst->x2 -= diff; - *x2 -= diff * hscale; - } - if(*y1 < 0) { - diff = (- *y1 + vscale - 1)/ vscale; - dst->y1 += diff; - *y1 += diff * vscale; - } - delta = *y2 - (height << 16); - if(delta > 0) { - diff = (delta + vscale - 1)/ vscale; - dst->y2 -= diff; - *y2 -= diff * vscale; - } -} - -static void -mach64DisplayVideo(KdScreenInfo *screen, - int id, - int dstPitch, /* of chroma for 4:2:0 */ - int x1, - int y1, - int x2, - int y2, - int dst_x1, - int dst_y1, - int dst_x2, - int dst_y2, - short src_w, - short src_h, - short drw_w, - short drw_h) -{ - ScreenPtr pScreen = screen->pScreen; - KdScreenPriv(pScreen); - KdCardInfo *card = pScreenPriv->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - Reg *reg = mach64c->reg; - MediaReg *media = mach64c->media_reg; - int HORZ_INC, VERT_INC; - CARD32 SCALER_IN; - int bright; - int sat; - - if (id == FOURCC_UYVY) - SCALER_IN = SCALER_IN_YVYU422; - else - SCALER_IN = SCALER_IN_VYUY422; - - mach64WaitAvail (reg, 4); - - media->VIDEO_FORMAT = SCALER_IN | VIDEO_IN_VYUY422; - - /* color key */ - media->OVERLAY_GRAPHICS_KEY_MSK = (1 << screen->fb[0].depth) - 1; - media->OVERLAY_GRAPHICS_KEY_CLR = pPortPriv->colorKey; - /* set key control to obey only graphics color key */ - media->OVERLAY_KEY_CNTL = 0x50; - - mach64WaitAvail (reg, 9); - media->CAPTURE_DEBUG = 0; - /* no exclusive video region */ - media->OVERLAY_EXCLUSIVE_HORZ = 0; - media->OVERLAY_EXCLUSIVE_VERT = 0; - /* scaling coefficients */ - media->SCALER_H_COEFF0 = 0x00002000; - media->SCALER_H_COEFF1 = 0x0D06200D; - media->SCALER_H_COEFF2 = 0x0D0A1C0D; - media->SCALER_H_COEFF3 = 0x0C0E1A0C; - media->SCALER_H_COEFF4 = 0x0C14140C; - media->SCALER_TEST = 0; - - mach64WaitAvail (reg, 2); - media->OVERLAY_SCALE_CNTL = (SCALE_PIX_EXPAND | - SCALE_GAMMA_BRIGHT | - SCALE_BANDWIDTH | - SCALE_OVERLAY_EN | - SCALE_EN); - - bright = (pPortPriv->brightness * 64 / 1000); - if (bright < -0x40) - bright = -0x40; - if (bright > 0x3f) - bright = 0x3f; - bright = bright & 0x7f; - sat = ((pPortPriv->saturation * 31 + 31000) / 2000); - if (sat > 0x1f) - sat = 0x1f; - if (sat < 0) - sat = 0; - - media->SCALER_COLOUR_CNTL = ((bright << 0) | /* BRIGHTNESS */ - (sat << 8) | /* SATURATION_U */ - (sat << 16) | /* SATURATION_V */ - (0 << 21) | /* SCALER_VERT_ADJ_UV */ - (0 << 28)); /* SCALER_HORZ_ADJ_UV */ - - VERT_INC = (src_h << 12) / drw_h; - HORZ_INC = (src_w << 12) / drw_w; - - mach64WaitAvail (reg, 13); - - /* lock registers to prevent non-atomic update */ - media->OVERLAY_Y_X_START = 0x80000000 | MACH64_YX (dst_x1, dst_y1); - /* ending screen coordinate */ - media->OVERLAY_Y_X_END = 0x80000000 | MACH64_YX (dst_x2, dst_y2); - - media->OVERLAY_SCALE_INC = MACH64_YX(HORZ_INC, VERT_INC); - - media->SCALER_BUF0_OFFSET = pPortPriv->YBuf0Offset; - media->SCALER_BUF1_OFFSET = pPortPriv->YBuf1Offset; - - media->SCALER_BUF0_OFFSET_U = pPortPriv->YBuf0Offset; - media->SCALER_BUF1_OFFSET_U = pPortPriv->YBuf1Offset; - - media->SCALER_BUF0_OFFSET_V = pPortPriv->YBuf0Offset; - media->SCALER_BUF1_OFFSET_V = pPortPriv->YBuf1Offset; - - media->SCALER_BUF_PITCH = dstPitch >> 1; - media->SCALER_HEIGHT_WIDTH = MACH64_YX(src_w - (x1 >> 16), src_h - (y1 >> 16)); - - media->CAPTURE_CONFIG = pPortPriv->currentBuf << 28; - - /* set XY location and unlock */ - media->OVERLAY_Y_X_START = MACH64_YX (dst_x1, dst_y1); -} - -static void -mach64VideoSave (ScreenPtr pScreen, KdOffscreenArea *area) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; - - if (pPortPriv->off_screen == area) - pPortPriv->off_screen = 0; -} - -static int -mach64PutImage(KdScreenInfo *screen, - DrawablePtr pDraw, - 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) -{ - KdCardInfo *card = screen->card; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data; - MediaReg *media = mach64c->media_reg; - INT32 x1, x2, y1, y2; - int randr = mach64s->vesa.randr; - int srcPitch, srcPitch2, dstPitch; - int top, left, npixels, nlines, size; - BoxRec dstBox; - int dst_width = width, dst_height = height; - int rot_x1, rot_y1, rot_x2, rot_y2; - int dst_x1, dst_y1, dst_x2, dst_y2; - int rot_src_w, rot_src_h, rot_drw_w, rot_drw_h; - - /* 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; - - Mach64ClipVideo(&dstBox, &x1, &x2, &y1, &y2, - REGION_EXTENTS(pScreen, clipBoxes), width, height); - - if((x1 >= x2) || (y1 >= y2)) - return Success; - - if (!media) - return BadAlloc; - - if (randr & (RR_Rotate_0|RR_Rotate_180)) - { - dst_width = width; - dst_height = height; - rot_src_w = src_w; - rot_src_h = src_h; - rot_drw_w = drw_w; - rot_drw_h = drw_h; - } - else - { - dst_width = height; - dst_height = width; - rot_src_w = src_h; - rot_src_h = src_w; - rot_drw_w = drw_h; - rot_drw_h = drw_w; - } - - switch (randr & RR_Rotate_All) { - case RR_Rotate_0: - default: - dst_x1 = dstBox.x1; - dst_y1 = dstBox.y1; - dst_x2 = dstBox.x2; - dst_y2 = dstBox.y2; - rot_x1 = x1; - rot_y1 = y1; - rot_x2 = x2; - rot_y2 = y2; - break; - case RR_Rotate_90: - dst_x1 = dstBox.y1; - dst_y1 = screen->height - dstBox.x2; - dst_x2 = dstBox.y2; - dst_y2 = screen->height - dstBox.x1; - - rot_x1 = y1; - rot_y1 = (src_w << 16) - x2; - rot_x2 = y2; - rot_y2 = (src_w << 16) - x1; - break; - case RR_Rotate_180: - dst_x1 = screen->width - dstBox.x2; - dst_y1 = screen->height - dstBox.y2; - dst_x2 = screen->width - dstBox.x1; - dst_y2 = screen->height - dstBox.y1; - rot_x1 = (src_w << 16) - x2; - rot_y1 = (src_h << 16) - y2; - rot_x2 = (src_w << 16) - x1; - rot_y2 = (src_h << 16) - y1; - break; - case RR_Rotate_270: - dst_x1 = screen->width - dstBox.y2; - dst_y1 = dstBox.x1; - dst_x2 = screen->width - dstBox.y1; - dst_y2 = dstBox.x2; - rot_x1 = (src_h << 16) - y2; - rot_y1 = x1; - rot_x2 = (src_h << 16) - y1; - rot_y2 = x2; - break; - } - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - dstPitch = ((dst_width << 1) + 15) & ~15; - srcPitch = (width + 3) & ~3; - srcPitch2 = ((width >> 1) + 3) & ~3; - size = dstPitch * (int) dst_height; - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - dstPitch = ((dst_width << 1) + 15) & ~15; - srcPitch = (width << 1); - srcPitch2 = 0; - size = dstPitch * (int) dst_height; - break; - } - - if (pPortPriv->off_screen && size != pPortPriv->size) - { - KdOffscreenFree (screen->pScreen, pPortPriv->off_screen); - pPortPriv->off_screen = 0; - } - - if (!pPortPriv->off_screen) - { - pPortPriv->off_screen = KdOffscreenAlloc (screen->pScreen, size * 2, 64, - TRUE, mach64VideoSave, - pPortPriv); - if (!pPortPriv->off_screen) - return BadAlloc; - } - - pPortPriv->offset = pPortPriv->off_screen->offset; - pPortPriv->size = size; - /* fixup pointers */ - - pPortPriv->YBuf0Offset = pPortPriv->offset; - pPortPriv->YBuf1Offset = pPortPriv->offset + size; - -#if 0 - mach64WaitIdle (reg); - - if (pPortPriv->videoOn) - { - /* wait for buffer to be displayed */ - while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf) - ; - } -#endif - /* - * Use the other buffer - */ - pPortPriv->currentBuf = 1 - pPortPriv->currentBuf; - - /* copy data */ - top = rot_y1 >> 16; - left = (rot_x1 >> 16) & ~1; - npixels = ((((rot_x2 + 0xffff) >> 16) + 1) & ~1) - left; - - switch(id) { - case FOURCC_YV12: - case FOURCC_I420: - top &= ~1; - nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top; - mach64CopyPlanarData(screen, buf, randr, - srcPitch, srcPitch2, dstPitch, - rot_src_w, rot_src_h, height, - top, left, nlines, npixels, id); - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - nlines = ((rot_y2 + 0xffff) >> 16) - top; - mach64CopyPackedData(screen, buf, randr, - srcPitch, dstPitch, - rot_src_w, rot_src_h, - top, left, nlines, - npixels); - break; - } - - mach64DisplayVideo(screen, id, dstPitch, - rot_x1, rot_y1, rot_x2, rot_y2, - dst_x1, dst_y1, - dst_x2, dst_y2, - rot_src_w, rot_src_h, rot_drw_w, rot_drw_h); - - /* update cliplist */ - if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes)) - { - REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes); - mach64PaintRegion (pDraw, &pPortPriv->clip, pPortPriv->colorKey); - } - - pPortPriv->videoOn = TRUE; - - return Success; -} - -static int -mach64QueryImageAttributes(KdScreenInfo *screen, - int id, - unsigned short *w, - unsigned short *h, - int *pitches, - int *offsets) -{ - int size, tmp; - - 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: - 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; -} - - -/* client libraries expect an encoding */ -static KdVideoEncodingRec DummyEncoding[1] = -{ - { - 0, - "XV_IMAGE", - IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, - {1, 1} - } -}; - -#define NUM_FORMATS 3 - -static KdVideoFormatRec Formats[NUM_FORMATS] = -{ - {15, TrueColor}, {16, TrueColor}, {24, TrueColor} -}; - -#define NUM_ATTRIBUTES 3 - -static KdAttributeRec Attributes[NUM_ATTRIBUTES] = -{ - {XvSettable | XvGettable, 0, ~0, "XV_COLORKEY"}, - {XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"}, - {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"} -}; - -#define NUM_IMAGES 4 - -static KdImageRec Images[NUM_IMAGES] = -{ - XVIMAGE_YUY2, - XVIMAGE_YV12, - XVIMAGE_I420, - XVIMAGE_UYVY -}; - -static void mach64ResetVideo(KdScreenInfo *screen) -{ -} - -static int -mach64ReputImage (KdScreenInfo *screen, - DrawablePtr pDraw, - short drw_x, - short drw_y, - RegionPtr clipBoxes, - pointer data) -{ - Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data; - BoxPtr pOldExtents = REGION_EXTENTS (screen->pScreen, &pPortPriv->clip); - BoxPtr pNewExtents = REGION_EXTENTS (screen->pScreen, clipBoxes); - - if (pOldExtents->x1 == pNewExtents->x1 && - pOldExtents->x2 == pNewExtents->x2 && - pOldExtents->y1 == pNewExtents->y1 && - pOldExtents->y2 == pNewExtents->y2) - { - /* update cliplist */ - if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes)) - { - REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes); - mach64PaintRegion (pDraw, &pPortPriv->clip, pPortPriv->colorKey); - } - return Success; - } - return BadMatch; -} - -static KdVideoAdaptorPtr -mach64SetupImageVideo(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - mach64ScreenInfo(pScreenPriv); - KdScreenInfo *screen = pScreenPriv->screen; - KdVideoAdaptorPtr adapt; - Mach64PortPrivPtr pPortPriv; - - if(!(adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) + - sizeof(Mach64PortPrivRec) + - sizeof(DevUnion)))) - return NULL; - - adapt->type = XvWindowMask | XvInputMask | XvImageMask; - adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - adapt->name = "Mach64 Video Overlay"; - adapt->nEncodings = 1; - adapt->pEncodings = DummyEncoding; - adapt->nFormats = NUM_FORMATS; - adapt->pFormats = Formats; - adapt->nPorts = 1; - adapt->pPortPrivates = (DevUnion*)(&adapt[1]); - - pPortPriv = (Mach64PortPrivPtr)(&adapt->pPortPrivates[1]); - - adapt->pPortPrivates[0].ptr = (pointer)(pPortPriv); - 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 = mach64StopVideo; - adapt->SetPortAttribute = mach64SetPortAttribute; - adapt->GetPortAttribute = mach64GetPortAttribute; - adapt->QueryBestSize = mach64QueryBestSize; - adapt->PutImage = mach64PutImage; - adapt->ReputImage = mach64ReputImage; - adapt->QueryImageAttributes = mach64QueryImageAttributes; - - pPortPriv->colorKey = mach64s->colorKey; - pPortPriv->videoOn = FALSE; - pPortPriv->brightness = 0; - pPortPriv->saturation = 0; - pPortPriv->currentBuf = 0; - pPortPriv->off_screen = 0; - pPortPriv->size = 0; - pPortPriv->offset = 0; - - /* gotta uninit this someplace */ - REGION_INIT(pScreen, &pPortPriv->clip, NullBox, 0); - - mach64s->pAdaptor = adapt; - - xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); - xvSaturation = MAKE_ATOM("XV_SATURATION"); - xvColorKey = MAKE_ATOM("XV_COLORKEY"); - - mach64ResetVideo(screen); - - return adapt; -} - -Bool mach64InitVideo(ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL; - KdVideoAdaptorPtr newAdaptor = NULL; - int num_adaptors; - KdCardInfo *card = pScreenPriv->card; - Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; - Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; - - mach64s->pAdaptor = NULL; - - if (!mach64c->media_reg) - return FALSE; - - newAdaptor = mach64SetupImageVideo(pScreen); - - num_adaptors = KdXVListGenericAdaptors(screen, &adaptors); - - if(newAdaptor) - { - if(!num_adaptors) - { - num_adaptors = 1; - adaptors = &newAdaptor; - } - else - { - newAdaptors = xalloc((num_adaptors + 1) * - sizeof(KdVideoAdaptorPtr*)); - if(newAdaptors) - { - memcpy(newAdaptors, adaptors, - num_adaptors * sizeof(KdVideoAdaptorPtr)); - newAdaptors[num_adaptors] = newAdaptor; - adaptors = newAdaptors; - num_adaptors++; - } - } - } - - if(num_adaptors) - KdXVScreenInit(pScreen, adaptors, num_adaptors); - - if(newAdaptors) - xfree(newAdaptors); - return TRUE; -} - -void -mach64FiniVideo (ScreenPtr pScreen) -{ - KdScreenPriv(pScreen); - mach64ScreenInfo(pScreenPriv); - KdVideoAdaptorPtr adapt = mach64s->pAdaptor; - - if (adapt) - { - Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)(&adapt->pPortPrivates[1]); - REGION_UNINIT (pScreen, &pPortPriv->clip); - xfree (adapt); - } -} |