? smi_501.c ? smi_501.h ? xorg-sm501-2005-01-28.patch Index: Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/Imakefile,v retrieving revision 1.3 diff -u -p -r1.3 Imakefile --- Imakefile 17 Sep 2004 03:04:54 -0000 1.3 +++ Imakefile 28 Jan 2005 15:59:29 -0000 @@ -5,10 +5,10 @@ XCOMM $XFree86: xc/programs/Xserver/hw/x #include SRCS = smi_driver.c smi_accel.c smi_dac.c smi_hwcurs.c smi_dga.c smi_i2c.c \ - smi_shadow.c smi_video.c + smi_shadow.c smi_video.c smi_501.c OBJS = smi_driver.o smi_accel.o smi_dac.o smi_hwcurs.o smi_dga.o smi_i2c.o \ - smi_shadow.o smi_video.o + smi_shadow.o smi_video.o smi_501.o DEFINES = -DPSZ=8 @@ -20,7 +20,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86O -I$(XF86SRC)/xaa -I$(XF86SRC)/rac \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/fbdevhw \ -I$(XF86SRC)/ramdac -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ - -I$(SERVERSRC)/Xext -I$(XF86SRC)/int10 \ + -I$(SERVERSRC)/Xext -I$(XF86SRC)/int10 \ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ -I$(XF86SRC)/shadowfb -I$(EXTINCSRC) -I$(SERVERSRC)/fb \ -I$(SERVERSRC)/render -I$(XF86SRC)/vbe @@ -52,8 +52,10 @@ InstallDriverSDKNonExecFile(smi_hwcurs.c InstallDriverSDKNonExecFile(smi_i2c.c,$(DRIVERSDKDIR)/drivers/siliconmotion) InstallDriverSDKNonExecFile(smi_shadow.c,$(DRIVERSDKDIR)/drivers/siliconmotion) InstallDriverSDKNonExecFile(smi_video.c,$(DRIVERSDKDIR)/drivers/siliconmotion) +InstallDriverSDKNonExecFile(smi_501.c,$(DRIVERSDKDIR)/drivers/siliconmotion) InstallDriverSDKNonExecFile(regsmi.h,$(DRIVERSDKDIR)/drivers/siliconmotion) InstallDriverSDKNonExecFile(smi.h,$(DRIVERSDKDIR)/drivers/siliconmotion) InstallDriverSDKNonExecFile(smi_video.h,$(DRIVERSDKDIR)/drivers/siliconmotion) +InstallDriverSDKNonExecFile(smi_501.h,$(DRIVERSDKDIR)/drivers/siliconmotion) InstallDriverSDKObjectModule(siliconmotion,$(DRIVERSDKMODULEDIR),drivers) Index: regsmi.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/regsmi.h,v retrieving revision 1.2 diff -u -p -r1.2 regsmi.h --- regsmi.h 23 Apr 2004 19:45:06 -0000 1.2 +++ regsmi.h 28 Jan 2005 15:59:29 -0000 @@ -36,6 +36,7 @@ authorization from the XFree86 Project a #define SMI_COUGAR_SERIES(chip) ((chip & 0xF0F0) == 0x0030) #define SMI_LYNXEM_SERIES(chip) ((chip & 0xFFF0) == 0x0710) #define SMI_LYNXM_SERIES(chip) ((chip & 0xFF00) == 0x0700) +#define SMI_MSOC_SERIES(chip) ((chip & 0xFF00) == 0x0500) /* Chip tags */ #define PCI_SMI_VENDOR_ID PCI_VENDOR_SMI @@ -47,6 +48,7 @@ authorization from the XFree86 Project a #define SMI_LYNXEMplus PCI_CHIP_SMI712 #define SMI_LYNX3DM PCI_CHIP_SMI720 #define SMI_COUGAR3DR PCI_CHIP_SMI731 +#define SMI_MSOC PCI_CHIP_SMI501 /* I/O Functions */ static __inline__ CARD8 @@ -118,6 +120,10 @@ VGAOUT8(SMIPtr pSmi, int port, CARD8 dat #define READ_CPR(pSmi, cpr) MMIO_IN32(pSmi->CPRBase, cpr) #define WRITE_FPR(pSmi, fpr, data) MMIO_OUT32(pSmi->FPRBase, fpr, data); DEBUG((VERBLEV, "FPR%02X = %08X\n", fpr, data)) #define READ_FPR(pSmi, fpr) MMIO_IN32(pSmi->FPRBase, fpr) +#define WRITE_DCR(pSmi, dcr, data) MMIO_OUT32(pSmi->DCRBase, dcr, data); DEBUG((VERBLEV, "DCR%02X = %08X\n", dcr, data)) +#define READ_DCR(pSmi, dcr) MMIO_IN32(pSmi->DCRBase, dcr) +#define WRITE_SCR(pSmi, scr, data) MMIO_OUT32(pSmi->SCRBase, scr, data); DEBUG((VERBLEV, "SCR%02X = %08X\n", scr, data)) +#define READ_SCR(pSmi, scr) MMIO_IN32(pSmi->SCRBase, scr) /* 2D Engine commands */ #define SMI_TRANSPARENT_SRC 0x00000100 @@ -165,10 +171,16 @@ VGAOUT8(SMIPtr pSmi, int port, CARD8 dat #define MAXLOOP 0x100000 /* timeout value for engine waits */ -#define ENGINE_IDLE() \ - ((VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x16) & 0x08) == 0) -#define FIFO_EMPTY() \ - ((VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x16) & 0x10) != 0) +#define ENGINE_IDLE() \ + ((pSmi->Chipset != SMI_MSOC) ? \ + ((VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x16) & 0x08) == 0) : \ + ((READ_SCR(pSmi, SCR00) & 0x00080000) == 0) ) + +#define FIFO_EMPTY() \ + ((pSmi->Chipset != SMI_MSOC) ? \ + ((VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x16) & 0x10) != 0) : \ + ((READ_SCR(pSmi, SCR00) & 0x00100000) != 0) ) + /* Wait until "v" queue entries are free */ #define WaitQueue(v) \ @@ -268,5 +280,126 @@ VGAOUT8(SMIPtr pSmi, int port, CARD8 dat #define PANEL_1600x1200 0x04 #define PANEL_1400x1050 0x0A +/* SM501 System Configuration Registers */ +#define SCR00 0x0000 +#define SCR04 0x0004 +#define SCR08 0x0008 +#define SCR0C 0x000C +#define SCR10 0x0010 +#define SCR10_LOCAL_MEM_SIZE 0x0000E000 +#define SCR10_LOCAL_MEM_SIZE_SHIFT 13 +#define SCR14 0x0014 +#define SCR18 0x0018 +#define SCR1C 0x001C +#define SCR20 0x0020 +#define SCR24 0x0024 +#define SCR28 0x0028 +#define SCR2C 0x002C +#define SCR30 0x0030 +#define SCR34 0x0034 +#define SCR38 0x0038 +#define SCR3C 0x003C +#define SCR40 0x0040 +#define SCR44 0x0044 +#define SCR48 0x0048 +#define SCR4C 0x004C +#define SCR50 0x0050 +#define SCR54 0x0054 +#define SCR58 0x0058 +#define SCR5C 0x005C +#define SCR60 0x0060 +#define SCR64 0x0064 +#define SCR68 0x0068 +#define SCR6C 0x006C + +/* SM501 Panel Graphics Control */ +#define DCR00 0x0000 +#define DCR04 0x0004 +#define DCR08 0x0008 +#define DCR0C 0x000C +#define DCR10 0x0010 +#define DCR14 0x0014 +#define DCR18 0x0018 +#define DCR1C 0x001C +#define DCR20 0x0020 +#define DCR24 0x0024 +#define DCR28 0x0028 +#define DCR2c 0x002c +#define DCR30 0x0030 +#define DCR34 0x0034 + +/* SM 501 Video Control */ +#define DCR40 0x0040 +#define DCR44 0x0044 +#define DCR48 0x0048 +#define DCR4C 0x004C +#define DCR50 0x0050 +#define DCR54 0x0054 +#define DCR58 0x0058 +#define DCR5C 0x005C +#define DCR60 0x0060 +#define DCR64 0x0064 +#define DCR68 0x0068 + +/* SM501 Video Alpha Control */ +#define DCR80 0x0080 +#define DCR84 0x0084 +#define DCR88 0x0088 +#define DCR8C 0x008C +#define DCR90 0x0090 +#define DCR94 0x0094 +#define DCR98 0x0098 +#define DCR9C 0x009C +#define DCRA0 0x00A0 +#define DCRA4 0x00A4 + +/* SM501 Panel Cursor Control */ +#define DCRF0 0x00F0 +#define DCRF4 0x00F4 +#define DCRF8 0x00F8 +#define DCRFC 0x00FC + +/* SM 501 Alpha Control */ +#define DCR100 0x0100 +#define DCR104 0x0104 +#define DCR108 0x0108 +#define DCR10C 0x010C +#define DCR110 0x0110 +#define DCR114 0x0114 +#define DCR118 0x0118 + +/* SM 501 CRT Graphics Control */ +#define DCR200 0x0200 +#define DCR200_CRT_BLANK 0x00000400 +#define DCR200_CRT_GRAPHICS_PLN_FMT 0x00000003 +#define CRT_GRAPHICS_PLN_FMT_8 0x00 +#define CRT_GRAPHICS_PLN_FMT_16 0x01 +#define CRT_GRAPHICS_PLN_FMT_32 0x10 +#define DCR204 0x0204 +#define DCR208 0x0208 +#define DCR20C 0x020C +#define DCR210 0x0210 +#define DCR214 0x0214 +#define DCR218 0x0218 +#define DCR21C 0x021C +#define DCR220 0x0220 +#define DCR224 0x0224 + +/* SM 501 CRT Cursor Control */ +#define DCR230 0x0230 +#define DCR234 0x0234 +#define DCR238 0x0238 +#define DCR23C 0x023C + +/* SM 501 Palette Ram */ +#define DCR400 0x0400 /* Panel */ +#define DCR800 0x0800 /* Video */ +#define DCRC00 0x0C00 /* CRT */ + +/* HWCursor definitons for Panel AND CRT */ +#define SMI501_MASK_HWCENABLE 0x80000000 +#define SMI501_MASK_MAXBITS 0x000007FF +#define SMI501_MASK_BOUNDARY 0x00000800 +#define SMI501_HWCFBADDR_MASK 0x0CFFFFFF #endif /* _REGSMI_H */ Index: siliconmotion.man =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/siliconmotion.man,v retrieving revision 1.2 diff -u -p -r1.2 siliconmotion.man --- siliconmotion.man 23 Apr 2004 19:45:06 -0000 1.2 +++ siliconmotion.man 28 Jan 2005 15:59:29 -0000 @@ -51,6 +51,9 @@ SM720 .TP 12 .B Cougar3DR SM730 +.TP 12 +.B Voyager +SM510 .SH CONFIGURATION DETAILS Please refer to __xconfigfile__(__filemansuffix__) for general configuration details. This section only covers configuration details specific to this @@ -64,7 +67,7 @@ names may optionally be specified in the section, and will override the auto-detection: .PP .RS 4 -"lynx", "lynxe", "lynx3d", "lynxem", "lynxem+", "lynx3dm", "cougar3dr". +"lynx", "lynxe", "lynx3d", "lynxem", "lynxem+", "lynx3dm", "cougar3dr", "voyager". .RE .PP Index: smi.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi.h,v retrieving revision 1.4 diff -u -p -r1.4 smi.h --- smi.h 17 Sep 2004 03:04:54 -0000 1.4 +++ smi.h 28 Jan 2005 15:59:29 -0000 @@ -135,7 +135,9 @@ typedef struct CARD8 * DPRBase; /* Base of DPR registers */ CARD8 * VPRBase; /* Base of VPR registers */ CARD8 * CPRBase; /* Base of CPR registers */ - CARD8 * FPRBase; /* Base of FPR registers - for 0730 chipset */ + CARD8 * FPRBase; /* Base of FPR registers - for 0730 chipset */ + CARD8 * DCRBase; /* Base of DCR registers - for 0501 chipset */ + CARD8 * SCRBase; /* Base of SCR registers - for 0501 chipset */ CARD8 * DataPortBase; /* Base of data port */ int DataPortSize; /* Size of data port */ CARD8 * IOBase; /* Base of MMIO VGA ports */ @@ -216,7 +218,7 @@ typedef struct pixels */ CARD32 saveBufferSize; /* #670 - FB save buffer size */ void * pSaveBuffer; /* #670 - FB save buffer */ - CARD32 fbMapOffset; /* offset for fb mapping */ + CARD32 fbMapOffset; /* offset for fb mapping */ CARD32 savedFBOffset; /* #670 - Saved FBOffset value */ CARD32 savedFBReserved; /* #670 - Saved FBReserved value */ Index: smi_accel.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_accel.c,v retrieving revision 1.3 diff -u -p -r1.3 smi_accel.c --- smi_accel.c 30 Jul 2004 20:30:54 -0000 1.3 +++ smi_accel.c 28 Jan 2005 15:59:29 -0000 @@ -117,11 +117,11 @@ SMI_AccelInit(ScreenPtr pScreen) /* Color Expansion Fills */ infoPtr->CPUToScreenColorExpandFillFlags = ROP_NEEDS_SOURCE - | NO_PLANEMASK - | BIT_ORDER_IN_BYTE_MSBFIRST - | LEFT_EDGE_CLIPPING - | CPU_TRANSFER_PAD_DWORD - | SCANLINE_PAD_DWORD; + | NO_PLANEMASK + | BIT_ORDER_IN_BYTE_MSBFIRST + | LEFT_EDGE_CLIPPING + | CPU_TRANSFER_PAD_DWORD + | SCANLINE_PAD_DWORD; infoPtr->ColorExpandBase = pSmi->DataPortBase; infoPtr->ColorExpandRange = pSmi->DataPortSize; infoPtr->SetupForCPUToScreenColorExpandFill = @@ -242,6 +242,7 @@ SMI_GEReset(ScrnInfoPtr pScrn, int from_ { SMIPtr pSmi = SMIPTR(pScrn); CARD8 tmp; + unsigned int iTempVal; ENTER_PROC("SMI_GEReset"); @@ -257,12 +258,26 @@ SMI_GEReset(ScrnInfoPtr pScrn, int from_ WaitIdleEmpty(); } - tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x15); - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x15, tmp | 0x30); + if (pSmi->Chipset == SMI_MSOC) + { + ErrorF("Resetting Graphics Engine!!!\n"); + iTempVal = READ_SCR(pSmi, SCR00) & ~0x00003000; + WRITE_SCR(pSmi, SCR00, (iTempVal | 0x00003000)); + WRITE_SCR(pSmi, SCR00, iTempVal); + } + else + { + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x15); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x15, tmp | 0x30); + } WaitIdleEmpty(); - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x15, tmp); + if (pSmi->Chipset != SMI_MSOC) + { + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x15, tmp); + } + SMI_EngineReset(pScrn); LEAVE_PROC("SMI_GEReset"); @@ -343,7 +358,7 @@ SMI_EngineReset(ScrnInfoPtr pScrn) WRITE_DPR(pSmi, 0x44, 0); SMI_DisableClipping(pScrn); - + LEAVE_PROC("SMI_EngineReset"); } @@ -459,11 +474,11 @@ SMI_SetupForSolidFill(ScrnInfoPtr pScrn, else { WaitQueue(3); - } - WRITE_DPR(pSmi, 0x14, color); + } + WRITE_DPR(pSmi, 0x14, color); WRITE_DPR(pSmi, 0x34, 0xFFFFFFFF); WRITE_DPR(pSmi, 0x38, 0xFFFFFFFF); - + LEAVE_PROC("SMI_SetupForSolidFill"); } @@ -486,6 +501,16 @@ SMI_SubsequentSolidFillRect(ScrnInfoPtr } } + if (pSmi->Chipset == SMI_MSOC) + { + /* Clip to prevent negative screen coordinates */ + if (x < 0) + x = 0; + + if (y < 0) + y = 0; + } + WaitQueue(3); WRITE_DPR(pSmi, 0x04, (x << 16) | (y & 0xFFFF)); WRITE_DPR(pSmi, 0x08, (w << 16) | (h & 0xFFFF)); @@ -908,7 +933,15 @@ SMI_SetClippingRectangle(ScrnInfoPtr pSc WaitQueue(2); WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); - WRITE_DPR(pSmi, 0x30, pSmi->ScissorsRight); + + if (pSmi->Chipset == SMI_MSOC) + { + WRITE_DPR(pSmi, 0x30, pSmi->ScissorsRight); + } + else + { + WRITE_DPR(pSmi, 0x30, (((bottom + 1) << 16) | ((right + 1) & 0xFFFF))); + } LEAVE_PROC("SMI_SetClippingRectangle"); } Index: smi_driver.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_driver.c,v retrieving revision 1.7 diff -u -p -r1.7 smi_driver.c --- smi_driver.c 17 Sep 2004 03:04:54 -0000 1.7 +++ smi_driver.c 28 Jan 2005 15:59:29 -0000 @@ -41,6 +41,10 @@ authorization from The XFree86 Project o #define DPMS_SERVER #include "extensions/dpms.h" +void crtSetMode(SMIPtr pSmi, int nWidth, int nHeight, unsigned int fMode, int nHertz, int fbPitch, int bpp); +void panelSetMode(SMIPtr pSmi, int nWidth, int nHeight, unsigned int fMode, int nHertz, int fbPitch, int bpp); +void panelUseCRT(SMIPtr pSmi, BOOL bEnable); + /* * Internals */ @@ -81,6 +85,8 @@ static unsigned int SMI_ddc1Read(ScrnInf static void SMI_FreeScreen(int ScrnIndex, int flags); static void SMI_ProbeDDC(ScrnInfoPtr pScrn, int index); +static Bool SMI_MSOCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode); + #define SILICONMOTION_NAME "Silicon Motion" #define SILICONMOTION_DRIVER_NAME "siliconmotion" @@ -121,6 +127,7 @@ static SymTabRec SMIChipsets[] = { PCI_CHIP_SMI712, "LynxEM+" }, { PCI_CHIP_SMI720, "Lynx3DM" }, { PCI_CHIP_SMI731, "Cougar3DR" }, + { PCI_CHIP_SMI501, "MSOC" }, { -1, NULL } }; @@ -134,6 +141,7 @@ static PciChipsets SMIPciChipsets[] = { PCI_CHIP_SMI712, PCI_CHIP_SMI712, RES_SHARED_VGA }, { PCI_CHIP_SMI720, PCI_CHIP_SMI720, RES_SHARED_VGA }, { PCI_CHIP_SMI731, PCI_CHIP_SMI731, RES_SHARED_VGA }, + { PCI_CHIP_SMI501, PCI_CHIP_SMI501, RES_SHARED_VGA }, { -1, -1, RES_UNDEFINED } }; @@ -158,6 +166,8 @@ typedef enum /* end CZ */ OPTION_USEBIOS, OPTION_ZOOMONLCD, +/* OPTION_PANELWIDTH, + OPTION_PANELHEIGHT, */ NUMBER_OF_OPTIONS } SMIOpts; @@ -499,8 +509,9 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags unsigned char config, m, n, shift; int mclk; vgaHWPtr hwp; - int vgaCRIndex, vgaIOBase; + int vgaCRIndex, vgaCRReg, vgaIOBase; vbeInfoPtr pVbe = NULL; + int chipType; ENTER_PROC("SMI_PreInit"); @@ -510,7 +521,11 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags LEAVE_PROC("SMI_PreInit"); return(TRUE); } - +/* + pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + pSmi->PciInfo = xf86GetPciInfoForEntity(pEnt->index); + chipType = pSmi->PciInfo->chipType; +*/ /* Ignoring the Type list for now. It might be needed when multiple cards * are supported. */ @@ -553,28 +568,58 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags * The first thing we should figure out is the depth, bpp, etc. * We support only 24bpp layouts, so indicate that. */ - if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb)) + + if (chipType == SMI_MSOC) { - LEAVE_PROC("SMI_PreInit"); - return(FALSE); - } + if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support32bppFb | SupportConvert24to32 | PreferConvert24to32)) + { + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } - /* Check that the returned depth is one we support */ - switch (pScrn->depth) - { - case 8: - case 16: - case 24: - /* OK */ - break; + /* Check that the returned depth is one we support */ + switch (pScrn->depth) + { + case 8: + case 16: + case 24: + case 32: + /* OK */ + break; - default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Given depth (%d) is not supported by this driver\n", - pScrn->depth); + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by this driver\n", + pScrn->depth); + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + } + else + { + if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb)) + { LEAVE_PROC("SMI_PreInit"); return(FALSE); - } + } + + /* Check that the returned depth is one we support */ + switch (pScrn->depth) + { + case 8: + case 16: + case 24: + /* OK */ + break; + + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by this driver\n", + pScrn->depth); + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + } xf86PrintDepthBpp(pScrn); /* @@ -585,7 +630,7 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags { /* The defaults are OK for us */ rgb zeros = {0, 0, 0}; - + if (!xf86SetWeight(pScrn, zeros, zeros)) { LEAVE_PROC("SMI_PreInit"); @@ -618,7 +663,7 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags /* Set the bits per RGB for 8bpp mode */ if (pScrn->depth == 8) { - pScrn->rgbBits = 6; + pScrn->rgbBits = (chipType == SMI_MSOC ? 8 : 6); } /* Process the options */ @@ -846,17 +891,20 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags return(FALSE); } - if (xf86LoadSubModule(pScrn,"int10")) { - xf86LoaderReqSymLists(int10Symbols,NULL); - pSmi->pInt10 = xf86InitInt10(pEnt->index); - } - - if (pSmi->pInt10 && xf86LoadSubModule(pScrn, "vbe")) + if (chipType != SMI_MSOC) /* NO vga on 501 */ { - xf86LoaderReqSymLists(vbeSymbols, NULL); - pVbe = VBEInit(pSmi->pInt10, pEnt->index); + if (xf86LoadSubModule(pScrn,"int10")) { + xf86LoaderReqSymLists(int10Symbols,NULL); + pSmi->pInt10 = xf86InitInt10(pEnt->index); + } + + if (pSmi->pInt10 && xf86LoadSubModule(pScrn, "vbe")) + { + xf86LoaderReqSymLists(vbeSymbols, NULL); + pVbe = VBEInit(pSmi->pInt10, pEnt->index); + } } - + pSmi->PciInfo = xf86GetPciInfoForEntity(pEnt->index); xf86RegisterResources(pEnt->index, NULL, ResExclusive); /* xf86SetOperatingState(resVgaIo, pEnt->index, ResUnusedOpr); */ @@ -883,7 +931,7 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags else { from = X_PROBED; - pSmi->Chipset = pSmi->PciInfo->chipType; + pSmi->Chipset = pSmi->PciInfo->chipType; pScrn->chipset = (char *) xf86TokenToString(SMIChipsets, pSmi->Chipset); } @@ -924,74 +972,79 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags pSmi->PciInfo->func); SMI_MapMem(pScrn); - SMI_DisableVideo(pScrn); - hwp = VGAHWPTR(pScrn); - vgaIOBase = hwp->IOBase; - vgaCRIndex = vgaIOBase + VGA_CRTC_INDEX_OFFSET; - pSmi->PIOBase = hwp->PIOOffset; + if (chipType != SMI_MSOC) + { + SMI_DisableVideo(pScrn); - xf86ErrorFVerb(VERBLEV, "\tSMI_PreInit vgaCRIndex=%x, vgaIOBase=%x, " - "MMIOBase=%p\n", vgaCRIndex, vgaIOBase, hwp->MMIOBase); + hwp = VGAHWPTR(pScrn); + vgaIOBase = hwp->IOBase; + vgaCRIndex = vgaIOBase + VGA_CRTC_INDEX_OFFSET; + pSmi->PIOBase = hwp->PIOOffset; - /* Next go on to detect amount of installed ram */ - config = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x71); + xf86ErrorFVerb(VERBLEV, "\tSMI_PreInit vgaCRIndex=%x, vgaIOBase=%x, " + "MMIOBase=%p\n", vgaCRIndex, vgaIOBase, hwp->MMIOBase); - if (xf86LoadSubModule(pScrn, "i2c")) - { - xf86LoaderReqSymLists(i2cSymbols, NULL); - SMI_I2CInit(pScrn); - } - if (xf86LoadSubModule(pScrn, "ddc")) - { - xf86MonPtr pMon = NULL; + /* Next go on to detect amount of installed ram */ + config = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x71); - xf86LoaderReqSymLists(ddcSymbols, NULL); -#if 1 /* PDR#579 */ - if (pVbe) + if (xf86LoadSubModule(pScrn, "i2c")) + { + xf86LoaderReqSymLists(i2cSymbols, NULL); + SMI_I2CInit(pScrn); + } + if (xf86LoadSubModule(pScrn, "ddc")) { - pMon = vbeDoEDID(pVbe, NULL); - if (pMon != NULL) + xf86MonPtr pMon = NULL; + + xf86LoaderReqSymLists(ddcSymbols, NULL); +#if 1 /* PDR#579 */ + if (pVbe) { - if ( (pMon->rawData[0] == 0x00) - && (pMon->rawData[1] == 0xFF) - && (pMon->rawData[2] == 0xFF) - && (pMon->rawData[3] == 0xFF) - && (pMon->rawData[4] == 0xFF) - && (pMon->rawData[5] == 0xFF) - && (pMon->rawData[6] == 0xFF) - && (pMon->rawData[7] == 0x00) - ) + pMon = vbeDoEDID(pVbe, NULL); + if (pMon != NULL) { - pMon = xf86PrintEDID(pMon); - if (pMon != NULL) + if ( (pMon->rawData[0] == 0x00) + && (pMon->rawData[1] == 0xFF) + && (pMon->rawData[2] == 0xFF) + && (pMon->rawData[3] == 0xFF) + && (pMon->rawData[4] == 0xFF) + && (pMon->rawData[5] == 0xFF) + && (pMon->rawData[6] == 0xFF) + && (pMon->rawData[7] == 0x00) + ) { - xf86SetDDCproperties(pScrn, pMon); + pMon = xf86PrintEDID(pMon); + if (pMon != NULL) + { + xf86SetDDCproperties(pScrn, pMon); + } } } } - } #else - if ( (pVbe) - && ((pMon = xf86PrintEDID(vbeDoEDID(pVbe, NULL))) != NULL) - ) - { - xf86SetDDCproperties(pScrn, pMon); - } + if ( (pVbe) + && ((pMon = xf86PrintEDID(vbeDoEDID(pVbe, NULL))) != NULL) + ) + { + xf86SetDDCproperties(pScrn, pMon); + } #endif - else if (!SMI_ddc1(pScrn->scrnIndex)) - { - if (pSmi->I2C) + else if (!SMI_ddc1(pScrn->scrnIndex)) { - xf86SetDDCproperties(pScrn, - xf86PrintEDID(xf86DoEDID_DDC2(pScrn->scrnIndex, - pSmi->I2C))); + if (pSmi->I2C) + { + xf86SetDDCproperties(pScrn, + xf86PrintEDID(xf86DoEDID_DDC2(pScrn->scrnIndex, + pSmi->I2C))); + } } } - } - vbeFree(pVbe); - xf86FreeInt10(pSmi->pInt10); + vbeFree(pVbe); + xf86FreeInt10(pSmi->pInt10); + } /* End !SMI_MSOC */ + pSmi->pInt10 = NULL; /* @@ -1045,10 +1098,24 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags /* per instructions from Silicon Motion engineers */ pSmi->videoRAMKBytes = 16 * 1024; break; - } + + } + case SMI_MSOC: + { + int mem_table[6] = { 4, 8, 16, 32, 64, 2 }; + int memval = READ_SCR(pSmi, SCR10); + memval = (memval & SCR10_LOCAL_MEM_SIZE) >> SCR10_LOCAL_MEM_SIZE_SHIFT; + pSmi->videoRAMKBytes = mem_table[memval] * 1024; + break; + } } pSmi->videoRAMBytes = pSmi->videoRAMKBytes * 1024; pScrn->videoRam = pSmi->videoRAMKBytes; + + if (pSmi->Chipset == SMI_MSOC) + { + pSmi->FBReserved = pSmi->videoRAMBytes - 4096; + } xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "videoram: %dkB\n", pSmi->videoRAMKBytes); @@ -1070,7 +1137,9 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags pScrn->clock[3] = pScrn->clock[2]; } - if ((pSmi->Chipset == SMI_LYNX3DM) || (pSmi->Chipset == SMI_COUGAR3DR)) + if ((pSmi->Chipset == SMI_LYNX3DM) || + (pSmi->Chipset == SMI_COUGAR3DR) || + (pSmi->Chipset == SMI_MSOC)) { if (pScrn->clock[0] <= 0) pScrn->clock[0] = 200000; if (pScrn->clock[1] <= 0) pScrn->clock[1] = 200000; @@ -1089,35 +1158,38 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags switch (pSmi->Chipset) { default: - pSmi->minClock = 20000; - pSmi->maxClock = 135000; + pSmi->minClock = 12000; + pSmi->maxClock = 270000; break; } xf86ErrorFVerb(VERBLEV, "\tSMI_PreInit minClock=%d, maxClock=%d\n", pSmi->minClock, pSmi->maxClock); - /* Detect current MCLK and print it for user */ - m = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6A); - n = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6B); - switch (n >> 6) + if (pSmi->Chipset != SMI_MSOC) { - default: - shift = 1; - break; + /* Detect current MCLK and print it for user */ + m = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6A); + n = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6B); + switch (n >> 6) + { + default: + shift = 1; + break; - case 1: - shift = 4; - break; + case 1: + shift = 4; + break; - case 2: - shift = 2; - break; + case 2: + shift = 2; + break; + } + n &= 0x3F; + mclk = ((1431818 * m) / n / shift + 50) / 100; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected current MCLK value of " + "%1.3f MHz\n", mclk / 1000.0); } - n &= 0x3F; - mclk = ((1431818 * m) / n / shift + 50) / 100; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected current MCLK value of " - "%1.3f MHz\n", mclk / 1000.0); - + SMI_EnableVideo(pScrn); SMI_UnmapMem(pScrn); @@ -1134,7 +1206,7 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags clockRanges->clockIndex = -1; clockRanges->interlaceAllowed = FALSE; clockRanges->doubleScanAllowed = FALSE; - + i = xf86ValidateModes( pScrn, /* Screen pointer */ pScrn->monitor->Modes, /* Available monitor modes */ @@ -1170,11 +1242,15 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags LEAVE_PROC("SMI_PreInit"); return(FALSE); } - xf86SetCrtcForModes(pScrn, 0); + + if (pSmi->Chipset != SMI_MSOC) + { + xf86SetCrtcForModes(pScrn, 0); + } /* Set the current mode to the first in the list */ pScrn->currentMode = pScrn->modes; - + /* Print the list of modes being used */ xf86PrintModes(pScrn); @@ -1379,84 +1455,87 @@ SMI_Save(ScrnInfoPtr pScrn) ENTER_PROC("SMI_Save"); - /* Save the standard VGA registers */ - vgaHWSave(pScrn, vgaSavePtr, VGA_SR_ALL); - save->smiDACMask = VGAIN8(pSmi, VGA_DAC_MASK); - VGAOUT8(pSmi, VGA_DAC_READ_ADDR, 0); - for (i = 0; i < 256; i++) - { - save->smiDacRegs[i][0] = VGAIN8(pSmi, VGA_DAC_DATA); - save->smiDacRegs[i][1] = VGAIN8(pSmi, VGA_DAC_DATA); - save->smiDacRegs[i][2] = VGAIN8(pSmi, VGA_DAC_DATA); - } - for (i = 0, offset = 2; i < 8192; i++, offset += 8) - { - save->smiFont[i] = *(pSmi->FBBase + offset); - } - - /* Now we save all the extended registers we need. */ - save->SR17 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x17); - save->SR18 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x18); - save->SR21 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21); - save->SR31 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31); - save->SR32 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x32); - save->SR6A = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6A); - save->SR6B = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6B); - save->SR81 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81); - save->SRA0 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0xA0); - - if (SMI_LYNXM_SERIES(pSmi->Chipset)) + if (pSmi->Chipset != SMI_MSOC) { - /* Save primary registers */ - save->CR90[14] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E); - VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, - save->CR90[14] & ~0x20); - - for (i = 0; i < 16; i++) + /* Save the standard VGA registers */ + vgaHWSave(pScrn, vgaSavePtr, VGA_SR_ALL); + save->smiDACMask = VGAIN8(pSmi, VGA_DAC_MASK); + VGAOUT8(pSmi, VGA_DAC_READ_ADDR, 0); + for (i = 0; i < 256; i++) { - save->CR90[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x90 + i); + save->smiDacRegs[i][0] = VGAIN8(pSmi, VGA_DAC_DATA); + save->smiDacRegs[i][1] = VGAIN8(pSmi, VGA_DAC_DATA); + save->smiDacRegs[i][2] = VGAIN8(pSmi, VGA_DAC_DATA); } - save->CR33 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33); - save->CR3A = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x3A); - for (i = 0; i < 14; i++) + for (i = 0, offset = 2; i < 8192; i++, offset += 8) { - save->CR40[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i); + save->smiFont[i] = *(pSmi->FBBase + offset); } - /* Save secondary registers */ - VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, save->CR90[14] | 0x20); - save->CR33_2 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33); - for (i = 0; i < 14; i++) - { - save->CR40_2[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, - 0x40 + i); - } - save->CR9F_2 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9F); + /* Now we save all the extended registers we need. */ + save->SR17 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x17); + save->SR18 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x18); + save->SR21 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21); + save->SR31 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31); + save->SR32 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x32); + save->SR6A = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6A); + save->SR6B = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6B); + save->SR81 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81); + save->SRA0 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0xA0); - /* Save common registers */ - for (i = 0; i < 14; i++) + if (SMI_LYNXM_SERIES(pSmi->Chipset)) { - save->CRA0[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0xA0 + i); - } + /* Save primary registers */ + save->CR90[14] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E); + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, + save->CR90[14] & ~0x20); - /* PDR#1069 */ - VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, save->CR90[14]); - } - else - { - save->CR33 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33); - save->CR3A = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x3A); - for (i = 0; i < 14; i++) + for (i = 0; i < 16; i++) + { + save->CR90[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x90 + i); + } + save->CR33 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33); + save->CR3A = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x3A); + for (i = 0; i < 14; i++) + { + save->CR40[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i); + } + + /* Save secondary registers */ + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, save->CR90[14] | 0x20); + save->CR33_2 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33); + for (i = 0; i < 14; i++) + { + save->CR40_2[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, + 0x40 + i); + } + save->CR9F_2 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9F); + + /* Save common registers */ + for (i = 0; i < 14; i++) + { + save->CRA0[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0xA0 + i); + } + + /* PDR#1069 */ + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, save->CR90[14]); + } + else { - save->CR40[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i); + save->CR33 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33); + save->CR3A = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x3A); + for (i = 0; i < 14; i++) + { + save->CR40[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i); + } } - } - /* CZ 2.11.2001: for gamma correction (TODO: other chipsets?) */ - if ((pSmi->Chipset == SMI_LYNX3DM) || (pSmi->Chipset == SMI_COUGAR3DR)) { - save->CCR66 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x66); + /* CZ 2.11.2001: for gamma correction (TODO: other chipsets?) */ + if ((pSmi->Chipset == SMI_LYNX3DM) || (pSmi->Chipset == SMI_COUGAR3DR)) { + save->CCR66 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x66); + } + /* end CZ */ } - /* end CZ */ save->DPR10 = READ_DPR(pSmi, 0x10); save->DPR1C = READ_DPR(pSmi, 0x1C); @@ -1482,22 +1561,25 @@ SMI_Save(ScrnInfoPtr pScrn) save->CPR00 = READ_CPR(pSmi, 0x00); - if (!pSmi->ModeStructInit) + if (pSmi->Chipset != SMI_MSOC) { - /* XXX Should check the return value of vgaHWCopyReg() */ - vgaHWCopyReg(&hwp->ModeReg, vgaSavePtr); - memcpy(&pSmi->ModeReg, save, sizeof(SMIRegRec)); - pSmi->ModeStructInit = TRUE; - } + if (!pSmi->ModeStructInit) + { + /* XXX Should check the return value of vgaHWCopyReg() */ + vgaHWCopyReg(&hwp->ModeReg, vgaSavePtr); + memcpy(&pSmi->ModeReg, save, sizeof(SMIRegRec)); + pSmi->ModeStructInit = TRUE; + } - if (pSmi->useBIOS && (pSmi->pInt10 != NULL)) - { - pSmi->pInt10->num = 0x10; - pSmi->pInt10->ax = 0x0F00; - xf86ExecX86int10(pSmi->pInt10); - save->mode = pSmi->pInt10->ax & 0x007F; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Current mode 0x%02X.\n", - save->mode); + if (pSmi->useBIOS && (pSmi->pInt10 != NULL)) + { + pSmi->pInt10->num = 0x10; + pSmi->pInt10->ax = 0x0F00; + xf86ExecX86int10(pSmi->pInt10); + save->mode = pSmi->pInt10->ax & 0x007F; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Current mode 0x%02X.\n", + save->mode); + } } if (xf86GetVerbosity() > 1) @@ -1744,6 +1826,12 @@ SMI_MapMem(ScrnInfoPtr pScrn) memBase = pSmi->PciInfo->memBase[0]; pSmi->MapSize = 0x200000; break; + + case SMI_MSOC: + memBase = pSmi->PciInfo->memBase[1]; + pSmi->MapSize = 0x200000; + break; + } pSmi->MapBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pSmi->PciTag, memBase, pSmi->MapSize); @@ -1804,6 +1892,17 @@ SMI_MapMem(ScrnInfoPtr pScrn) pSmi->DataPortBase = pSmi->MapBase + 0x100000; pSmi->DataPortSize = 0x100000; break; + + case SMI_MSOC: + pSmi->DPRBase = pSmi->MapBase + 0x100000; + pSmi->VPRBase = pSmi->MapBase + 0x000000; + pSmi->CPRBase = pSmi->MapBase + 0x090000; + pSmi->DCRBase = pSmi->MapBase + 0x080000; + pSmi->SCRBase = pSmi->MapBase + 0x000000; + pSmi->IOBase = 0; + pSmi->DataPortBase = pSmi->MapBase + 0x110000; + pSmi->DataPortSize = 0x10000; + break; } xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, "Physical MMIO at 0x%08lX\n", (unsigned long)memBase); @@ -1824,7 +1923,7 @@ SMI_MapMem(ScrnInfoPtr pScrn) pSmi->fbMapOffset = 0x200000; else pSmi->fbMapOffset = 0x0; - + if (pSmi->videoRAMBytes) { pSmi->FBBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, @@ -1855,8 +1954,18 @@ SMI_MapMem(ScrnInfoPtr pScrn) /* Set up offset to hwcursor memory area. It's a 1K chunk at the end of * the frame buffer. Also set up the reserved memory space. */ - pSmi->FBCursorOffset = pSmi->videoRAMBytes - 1024; - if (VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x30) & 0x01)/* #1074 */ + if (pSmi->Chipset != SMI_MSOC) + { + pSmi->FBCursorOffset = pSmi->videoRAMBytes - 1024; + } + else /* SMI 501 is a 2K chunk at the end of the FB... */ + { + /* Due to a HW issue with an early rev of Voyager, need 2048 bytes */ + pSmi->FBCursorOffset = pSmi->videoRAMBytes - 2048; + } + + if ((SMI_MSOC != pSmi->Chipset) && + (VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x30) & 0x01))/* #1074 */ { CARD32 fifoOffset = 0; fifoOffset |= VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x46) @@ -1867,10 +1976,15 @@ SMI_MapMem(ScrnInfoPtr pScrn) & 0x1C) << 17; pSmi->FBReserved = fifoOffset; /* PDR#1074 */ } - else + else if (SMI_MSOC != pSmi->Chipset) { pSmi->FBReserved = pSmi->videoRAMBytes - 2048; } + else /* SMI_501 Chipset */ + { + pSmi->FBReserved = pSmi->videoRAMBytes - 4096; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Cursor Offset: %08lX Reserved: %08lX\n", (unsigned long)pSmi->FBCursorOffset, @@ -1947,7 +2061,15 @@ SMI_MapMem(ScrnInfoPtr pScrn) /* Set this to indicate that we've done the detection */ pSmi->lcd = 1; } - else /* panel size detection for hardware other than 730 */ + else if (pSmi->Chipset == SMI_MSOC) /* 501 panel detection */ + { + pSmi->lcd = 1; + /* Hardcode panel size for now, we can add options for it later */ + /* Not that it seems to make any difference at all */ + pSmi->lcdWidth = 1024; + pSmi->lcdHeight = 768; + } + else /* panel size detection for hardware other than 730 and the 501 */ { pSmi->lcd = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31) & 0x01; @@ -1991,25 +2113,28 @@ SMI_MapMem(ScrnInfoPtr pScrn) (pSmi->lcd == 0) ? "OFF" : (pSmi->lcd == 1) ? "TFT" : "DSTN", pSmi->lcdWidth, pSmi->lcdHeight); - /* Assign hwp->MemBase & IOBase here */ - hwp = VGAHWPTR(pScrn); - if (pSmi->IOBase != NULL) + if (pSmi->Chipset != SMI_MSOC) /* 501? No VGA! */ { - vgaHWSetMmioFuncs(hwp, pSmi->MapBase, pSmi->IOBase - pSmi->MapBase); - } - vgaHWGetIOBase(hwp); + /* Assign hwp->MemBase & IOBase here */ + hwp = VGAHWPTR(pScrn); + if (pSmi->IOBase != NULL) + { + vgaHWSetMmioFuncs(hwp, pSmi->MapBase, pSmi->IOBase - pSmi->MapBase); + } + vgaHWGetIOBase(hwp); - /* Map the VGA memory when the primary video */ - if (xf86IsPrimaryPci(pSmi->PciInfo)) - { - hwp->MapSize = 0x10000; - if (!vgaHWMapMem(pScrn)) + /* Map the VGA memory when the primary video */ + if (xf86IsPrimaryPci(pSmi->PciInfo)) { - LEAVE_PROC("SMI_MapMem"); - return(FALSE); + hwp->MapSize = 0x10000; + if (!vgaHWMapMem(pScrn)) + { + LEAVE_PROC("SMI_MapMem"); + return(FALSE); + } + pSmi->PrimaryVidMapped = TRUE; } - pSmi->PrimaryVidMapped = TRUE; - } + } LEAVE_PROC("SMI_MapMem"); return(TRUE); @@ -2065,7 +2190,7 @@ SMI_ScreenInit(int scrnIndex, ScreenPtr pEnt = xf86GetEntityInfo(pScrn->entityList[0]); - if (!pSmi->pInt10) { + if (!pSmi->pInt10 && !(SMI_MSOC == pSmi->Chipset)) { pSmi->pInt10 = xf86InitInt10(pEnt->index); } @@ -2170,8 +2295,7 @@ SMI_ScreenInit(int scrnIndex, ScreenPtr xf86InitFBManager(pScreen, &AvailFBArea); } /* end CZ */ - - + /* Initialize acceleration layer */ if (!pSmi->NoAccel) { if (!SMI_AccelInit(pScreen)) { @@ -2183,7 +2307,7 @@ SMI_ScreenInit(int scrnIndex, ScreenPtr miInitializeBackingStore(pScreen); /* hardware cursor needs to wrap this layer */ - SMI_DGAInit(pScreen); + SMI_DGAInit(pScreen); /* Initialise cursor functions */ miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); @@ -2252,7 +2376,7 @@ SMI_ScreenInit(int scrnIndex, ScreenPtr xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "DPMS initialization failed!\n"); } - SMI_InitVideo(pScreen); + SMI_InitVideo(pScreen); /* Report any unused options (only for the first generation) */ if (serverGeneration == 1) @@ -2315,10 +2439,15 @@ SMI_InternalScreenInit(int scrnIndex, Sc pSmi->FBReserved -= pSmi->saveBufferSize; pSmi->FBReserved &= ~0x15; WRITE_VPR(pSmi, 0x0C, (pSmi->FBOffset = pSmi->FBReserved) >> 3); - if(pSmi->Chipset == SMI_COUGAR3DR) + if (pSmi->Chipset == SMI_COUGAR3DR) { WRITE_FPR(pSmi, FPR0C, (pSmi->FBOffset = pSmi->FBReserved) >> 3); } + if (pSmi->Chipset == SMI_MSOC) + { + WRITE_DCR(pSmi, DCR0C, pSmi->FBOffset); + WRITE_DCR(pSmi, DCR204, pSmi->FBOffset); + } pScrn->fbOffset = pSmi->FBOffset + pSmi->fbMapOffset; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Shadow: width=%d height=%d " @@ -2345,9 +2474,14 @@ SMI_InternalScreenInit(int scrnIndex, Sc case 8: case 16: case 24: - ret = fbScreenInit(pScreen, pSmi->FBBase, width, height, xDpi, - yDpi, displayWidth,pScrn->bitsPerPixel); - break; + case 32: + if ((SMI_MSOC == pSmi->Chipset && pScrn->bitsPerPixel != 24) || + (SMI_MSOC != pSmi->Chipset && pScrn->bitsPerPixel != 32)) + { + ret = fbScreenInit(pScreen, pSmi->FBBase, width, height, xDpi, + yDpi, displayWidth,pScrn->bitsPerPixel); + } + break; default: xf86DrvMsg(scrnIndex, X_ERROR, "Internal error: invalid bpp (%d) " "in SMI_InternalScreenInit\n", pScrn->bitsPerPixel); @@ -2355,6 +2489,15 @@ SMI_InternalScreenInit(int scrnIndex, Sc return(FALSE); } + if ((pSmi->Chipset == SMI_MSOC) && (pScrn->bitsPerPixel == 8)) + { + /* Initialize Palette entries 0 and 1, they don't seem to get hit */ + WRITE_DCR(pSmi, DCR400 + 0, 0x00000000); /* CRT Palette */ + WRITE_DCR(pSmi, DCR400 + 4, 0x00FFFFFF); /* CRT Palette */ + WRITE_DCR(pSmi, DCR800 + 0, 0x00000000); /* Panel Palette */ + WRITE_DCR(pSmi, DCR800 + 4, 0x00FFFFFF); /* Panel Palette */ + } + LEAVE_PROC("SMI_InternalScreenInit"); return(ret); } @@ -2377,7 +2520,7 @@ SMI_ValidMode(int scrnIndex, DisplayMode { int mem; - if (pScrn->bitsPerPixel == 24) + if (pScrn->bitsPerPixel > 16) { LEAVE_PROC("SMI_ValidMode"); return(MODE_BAD); @@ -2421,7 +2564,7 @@ SMI_ValidMode(int scrnIndex, DisplayMode } #if 1 /* PDR#944 */ - if (pSmi->rotate) + if ((pSmi->rotate) && (pSmi->Chipset != SMI_MSOC)) { if ( (mode->HDisplay != pSmi->lcdWidth) || (mode->VDisplay != pSmi->lcdHeight) @@ -2452,6 +2595,36 @@ SMI_ModeInit(ScrnInfoPtr pScrn, DisplayM vgaRegPtr vganew = &hwp->ModeReg; ENTER_PROC("SMI_ModeInit"); + + if (SMI_MSOC == pSmi->Chipset) + { + pSmi->Bpp = pScrn->bitsPerPixel / 8; + + + if (pSmi->rotate) + { + pSmi->width = pScrn->virtualY; + pSmi->height = pScrn->virtualX; + pSmi->Stride = (pSmi->height * pSmi->Bpp + 15) & ~15; + } + else + { + pSmi->width = pScrn->virtualX; + pSmi->height = pScrn->virtualY; + pSmi->Stride = (pSmi->width * pSmi->Bpp + 15) & ~15; + } + + /* Set mode on Voyager */ + SMI_MSOCSetMode(pScrn, mode); + + /* Adjust the viewport */ + SMI_AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + SMI_PrintRegs(pScrn); + + LEAVE_PROC("SMI_ModeInit"); + return(TRUE); + } if(!vgaHWInit(pScrn, mode)) { @@ -2741,7 +2914,7 @@ SMI_ModeInit(ScrnInfoPtr pScrn, DisplayM new->VPR0C = pSmi->FBOffset >> 3; if (pSmi->rotate) { - new->VPR10 = (((( pSmi->height * pSmi->Bpp) >> 3) + new->VPR10 = ((((pSmi->height * pSmi->Bpp) >> 3) + 2) << 16) | ((pSmi->height * pSmi->Bpp) >> 3); } else @@ -2926,7 +3099,7 @@ SMI_AdjustFrame(int scrnIndex, int x, in } #endif } - else + else if (pSmi->Chipset != SMI_MSOC) { Base = (Base + 7) & ~7; #if 1 /* PDR#1058 */ @@ -2937,7 +3110,17 @@ SMI_AdjustFrame(int scrnIndex, int x, in #endif } - WRITE_VPR(pSmi, 0x0C, Base >> 3); + if (pSmi->Chipset != SMI_MSOC) + { + WRITE_VPR(pSmi, 0x0C, Base >> 3); + } + else + { + ErrorF("Base = %8X\n", Base); + WRITE_DCR(pSmi, DCR0C, Base); + WRITE_DCR(pSmi, DCR204, Base); + } + if(pSmi->Chipset == SMI_COUGAR3DR) { WRITE_FPR(pSmi, FPR0C, Base >> 3); @@ -2965,11 +3148,12 @@ SMI_LoadPalette(ScrnInfoPtr pScrn, int n { SMIPtr pSmi = SMIPTR(pScrn); int i; + int iRGB; ENTER_PROC("SMI_LoadPalette"); /* Enable both the CRT and LCD DAC RAM paths, so both palettes are updated */ - if ((pSmi->Chipset == SMI_LYNX3DM) || (pSmi->Chipset == SMI_COUGAR3DR)) + if ((pSmi->Chipset == SMI_LYNX3DM) || (pSmi->Chipset == SMI_COUGAR3DR)) { CARD8 ccr66; @@ -2978,15 +3162,31 @@ SMI_LoadPalette(ScrnInfoPtr pScrn, int n VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x66, ccr66); } - for(i = 0; i < numColors; i++) + if (pSmi->Chipset != SMI_MSOC) { - DEBUG((VERBLEV, "pal[%d] = %d %d %d\n", indicies[i], - colors[indicies[i]].red, colors[indicies[i]].green, colors[indicies[i]].blue)); - VGAOUT8(pSmi, VGA_DAC_WRITE_ADDR, indicies[i]); - VGAOUT8(pSmi, VGA_DAC_DATA, colors[indicies[i]].red); - VGAOUT8(pSmi, VGA_DAC_DATA, colors[indicies[i]].green); - VGAOUT8(pSmi, VGA_DAC_DATA, colors[indicies[i]].blue); + for(i = 0; i < numColors; i++) + { + DEBUG((VERBLEV, "pal[%d] = %d %d %d\n", indicies[i], + colors[indicies[i]].red, colors[indicies[i]].green, colors[indicies[i]].blue)); + VGAOUT8(pSmi, VGA_DAC_WRITE_ADDR, indicies[i]); + VGAOUT8(pSmi, VGA_DAC_DATA, colors[indicies[i]].red); + VGAOUT8(pSmi, VGA_DAC_DATA, colors[indicies[i]].green); + VGAOUT8(pSmi, VGA_DAC_DATA, colors[indicies[i]].blue); + } } + else /* For SMI 501 Palette control */ + { + for(i = 0; i < numColors; i++) + { + DEBUG((VERBLEV, "pal[%d] = %d %d %d\n", indicies[i], + colors[indicies[i]].red, colors[indicies[i]].green, colors[indicies[i]].blue)); + iRGB = (colors[indicies[i]].red << 16) | + (colors[indicies[i]].green << 8 ) | + (colors[indicies[i]].blue ) ; + WRITE_DCR(pSmi, DCR400 + (4*(indicies[i])), iRGB); /* CRT */ + WRITE_DCR(pSmi, DCR800 + (4*(indicies[i])), iRGB); /* Panel */ + } + } LEAVE_PROC("SMI_LoadPalette"); } @@ -2996,19 +3196,39 @@ SMI_DisableVideo(ScrnInfoPtr pScrn) { SMIPtr pSmi = SMIPTR(pScrn); CARD8 tmp; + int rVal; - if (!(tmp = VGAIN8(pSmi, VGA_DAC_MASK))) - return; - pSmi->DACmask = tmp; - VGAOUT8(pSmi, VGA_DAC_MASK, 0); + if (SMI_MSOC != pSmi->Chipset) + { + if (!(tmp = VGAIN8(pSmi, VGA_DAC_MASK))) + return; + pSmi->DACmask = tmp; + VGAOUT8(pSmi, VGA_DAC_MASK, 0); + } + else + { + rVal = READ_DCR(pSmi, DCR200); + rVal |= DCR200_CRT_BLANK; + WRITE_DCR(pSmi, DCR200, rVal); + } } static void SMI_EnableVideo(ScrnInfoPtr pScrn) { SMIPtr pSmi = SMIPTR(pScrn); + int rVal; - VGAOUT8(pSmi, VGA_DAC_MASK, pSmi->DACmask); + if (SMI_MSOC != pSmi->Chipset) + { + VGAOUT8(pSmi, VGA_DAC_MASK, pSmi->DACmask); + } + else + { + rVal = READ_DCR(pSmi, DCR200); + rVal &= ~DCR200_CRT_BLANK; + WRITE_DCR(pSmi, DCR200, rVal); + } } @@ -3021,23 +3241,26 @@ SMI_EnableMmio(ScrnInfoPtr pScrn) ENTER_PROC("SMI_EnableMmio"); - /* - * Enable chipset (seen on uninitialized secondary cards) might not be - * needed once we use the VGA softbooter - */ - vgaHWSetStdFuncs(hwp); + if (pSmi->Chipset != SMI_MSOC) + { + /* + * Enable chipset (seen on uninitialized secondary cards) might not be + * needed once we use the VGA softbooter + */ + vgaHWSetStdFuncs(hwp); - /* Enable linear mode */ - outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x18); - tmp = inb(pSmi->PIOBase + VGA_SEQ_DATA); - pSmi->SR18Value = tmp; /* PDR#521 */ - outb(pSmi->PIOBase + VGA_SEQ_DATA, tmp | 0x11); + /* Enable linear mode */ + outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x18); + tmp = inb(pSmi->PIOBase + VGA_SEQ_DATA); + pSmi->SR18Value = tmp; /* PDR#521 */ + outb(pSmi->PIOBase + VGA_SEQ_DATA, tmp | 0x11); - /* Enable 2D/3D Engine and Video Processor */ - outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x21); - tmp = inb(pSmi->PIOBase + VGA_SEQ_DATA); - pSmi->SR21Value = tmp; /* PDR#521 */ - outb(pSmi->PIOBase + VGA_SEQ_DATA, tmp & ~0x03); + /* Enable 2D/3D Engine and Video Processor */ + outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x21); + tmp = inb(pSmi->PIOBase + VGA_SEQ_DATA); + pSmi->SR21Value = tmp; /* PDR#521 */ + outb(pSmi->PIOBase + VGA_SEQ_DATA, tmp & ~0x03); + } LEAVE_PROC("SMI_EnableMmio"); } @@ -3050,15 +3273,18 @@ SMI_DisableMmio(ScrnInfoPtr pScrn) ENTER_PROC("SMI_DisableMmio"); - vgaHWSetStdFuncs(hwp); + if (pSmi->Chipset != SMI_MSOC) + { + vgaHWSetStdFuncs(hwp); - /* Disable 2D/3D Engine and Video Processor */ - outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x21); - outb(pSmi->PIOBase + VGA_SEQ_DATA, pSmi->SR21Value); /* PDR#521 */ + /* Disable 2D/3D Engine and Video Processor */ + outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x21); + outb(pSmi->PIOBase + VGA_SEQ_DATA, pSmi->SR21Value); /* PDR#521 */ - /* Disable linear mode */ - outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x18); - outb(pSmi->PIOBase + VGA_SEQ_DATA, pSmi->SR18Value); /* PDR#521 */ + /* Disable linear mode */ + outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x18); + outb(pSmi->PIOBase + VGA_SEQ_DATA, pSmi->SR18Value); /* PDR#521 */ + } LEAVE_PROC("SMI_DisableMmio"); } @@ -3067,7 +3293,7 @@ SMI_DisableMmio(ScrnInfoPtr pScrn) static void SMI_PrintRegs(ScrnInfoPtr pScrn) { - unsigned char i; + unsigned int i; vgaHWPtr hwp = VGAHWPTR(pScrn); SMIPtr pSmi = SMIPTR(pScrn); int vgaCRIndex = hwp->IOBase + VGA_CRTC_INDEX_OFFSET; @@ -3077,53 +3303,56 @@ SMI_PrintRegs(ScrnInfoPtr pScrn) xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, "START register dump ------------------\n"); - xf86ErrorFVerb(VERBLEV, "MISCELLANEOUS OUTPUT\n %02X\n", - VGAIN8(pSmi, VGA_MISC_OUT_R)); - - xf86ErrorFVerb(VERBLEV, "\nSEQUENCER\n" - " x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF"); - for (i = 0x00; i <= 0xAF; i++) + if (pSmi->Chipset != SMI_MSOC) { - if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); - if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " "); - xf86ErrorFVerb(VERBLEV, "%02X ", - VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, i)); - } + xf86ErrorFVerb(VERBLEV, "MISCELLANEOUS OUTPUT\n %02X\n", + VGAIN8(pSmi, VGA_MISC_OUT_R)); - xf86ErrorFVerb(VERBLEV, "\n\nCRT CONTROLLER\n" - " x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF"); - for (i = 0x00; i <= 0xAD; i++) - { - if (i == 0x20) i = 0x30; - if (i == 0x50) i = 0x90; - if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); - if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " "); - xf86ErrorFVerb(VERBLEV, "%02X ", - VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRReg, i)); - } + xf86ErrorFVerb(VERBLEV, "\nSEQUENCER\n" + " x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF"); + for (i = 0x00; i <= 0xAF; i++) + { + if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); + if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " "); + xf86ErrorFVerb(VERBLEV, "%02X ", + VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, i)); + } - xf86ErrorFVerb(VERBLEV, "\n\nGRAPHICS CONTROLLER\n" - " x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF"); - for (i = 0x00; i <= 0x08; i++) - { - if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); - if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " "); - xf86ErrorFVerb(VERBLEV, "%02X ", - VGAIN8_INDEX(pSmi, VGA_GRAPH_INDEX, VGA_GRAPH_DATA, i)); - } + xf86ErrorFVerb(VERBLEV, "\n\nCRT CONTROLLER\n" + " x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF"); + for (i = 0x00; i <= 0xAD; i++) + { + if (i == 0x20) i = 0x30; + if (i == 0x50) i = 0x90; + if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); + if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " "); + xf86ErrorFVerb(VERBLEV, "%02X ", + VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRReg, i)); + } - xf86ErrorFVerb(VERBLEV, "\n\nATTRIBUTE 0CONTROLLER\n" - " x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF"); - for (i = 0x00; i <= 0x14; i++) - { + xf86ErrorFVerb(VERBLEV, "\n\nGRAPHICS CONTROLLER\n" + " x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF"); + for (i = 0x00; i <= 0x08; i++) + { + if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); + if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " "); + xf86ErrorFVerb(VERBLEV, "%02X ", + VGAIN8_INDEX(pSmi, VGA_GRAPH_INDEX, VGA_GRAPH_DATA, i)); + } + + xf86ErrorFVerb(VERBLEV, "\n\nATTRIBUTE 0CONTROLLER\n" + " x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF"); + for (i = 0x00; i <= 0x14; i++) + { + (void) VGAIN8(pSmi, vgaStatus); + if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); + if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " "); + xf86ErrorFVerb(VERBLEV, "%02X ", + VGAIN8_INDEX(pSmi, VGA_ATTR_INDEX, VGA_ATTR_DATA_R, i)); + } (void) VGAIN8(pSmi, vgaStatus); - if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); - if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " "); - xf86ErrorFVerb(VERBLEV, "%02X ", - VGAIN8_INDEX(pSmi, VGA_ATTR_INDEX, VGA_ATTR_DATA_R, i)); + VGAOUT8(pSmi, VGA_ATTR_INDEX, 0x20); } - (void) VGAIN8(pSmi, vgaStatus); - VGAOUT8(pSmi, VGA_ATTR_INDEX, 0x20); xf86ErrorFVerb(VERBLEV, "\n\nDPR x0 x4 x8 xC"); for (i = 0x00; i <= 0x44; i += 4) @@ -3146,6 +3375,22 @@ SMI_PrintRegs(ScrnInfoPtr pScrn) xf86ErrorFVerb(VERBLEV, " %08lX", (unsigned long)READ_CPR(pSmi, i)); } + if (SMI_MSOC == pSmi->Chipset) + { + xf86ErrorFVerb(VERBLEV, "\n\nSCR x0 x4 x8 xC"); + for (i = 0x00; i <= 0x6C; i += 4) + { + if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); + xf86ErrorFVerb(VERBLEV, " %08lX", (unsigned long)READ_SCR(pSmi, i)); + } + xf86ErrorFVerb(VERBLEV, "\n\nDCR x0 x4 x8 xC"); + for (i = 0x200; i <= 0x23C; i += 4) + { + if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); + xf86ErrorFVerb(VERBLEV, " %08lX", (unsigned long)READ_DCR(pSmi, i)); + } + } + xf86ErrorFVerb(VERBLEV, "\n\n"); xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, "END register dump --------------------\n"); @@ -3368,3 +3613,23 @@ SMI_ddc1(int scrnIndex) LEAVE_PROC("SMI_ddc1"); return(success); } + +static Bool +SMI_MSOCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_MSOCSetMode"); + + mode->VRefresh = 60; + + panelSetMode(pSmi, mode->HDisplay, mode->VDisplay, 0, mode->VRefresh, pSmi->Stride, pScrn->depth); + crtSetMode (pSmi, mode->HDisplay, mode->VDisplay, 0, mode->VRefresh, pSmi->Stride, pScrn->depth); + + panelUseCRT(pSmi, TRUE); /* Enable both outputs simultaneously */ + + LEAVE_PROC("SMI_MSOCSetMode"); + + return (TRUE); +} + Index: smi_hwcurs.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_hwcurs.c,v retrieving revision 1.2 diff -u -p -r1.2 smi_hwcurs.c --- smi_hwcurs.c 23 Apr 2004 19:45:06 -0000 1.2 +++ smi_hwcurs.c 28 Jan 2005 15:59:29 -0000 @@ -1,4 +1,4 @@ -/* Header: //Mercury/Projects/archives/XFree86/4.0/smi_hwcurs.c-arc 1.12 27 Nov 2000 15:47:48 Frido $ */ +/* Header: //Mercury/Projects/archives/XFree86/4.0/smi_hwcurs.c-arc 1.12 27 Nov 2000 15:47:48 Frido $ */ /* Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. @@ -16,7 +16,7 @@ copies or substantial portions of the So THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- -NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -32,6 +32,7 @@ authorization from the XFree86 Project a #include "smi.h" #define MAX_CURSOR 32 +#define MAX_CURSOR_501 64 static unsigned char * SMI_RealizeCursor(xf86CursorInfoPtr infoPtr, CursorPtr pCurs) @@ -196,6 +197,180 @@ SMI_RealizeCursor(xf86CursorInfoPtr info return(ram); } +static unsigned short +InterleaveBytes(source, mask) +{ + unsigned char ibit; + unsigned short usWord = 0; + unsigned char ucBitMask = 0x01; + + /* + * This function will interleave the bits in the source and mask bytes + * to create a word that looks like this: + * + * [M7 M6 M5 M4 M3 M2 M1 M0] [S7 S6 S5 S4 S3 S2 S1 S0] + * Results in: + * [M7 S7 M6 S6 M5 S5 M4 S4 M3 S3 M2 S2 M1 S1 M0 S0] + */ + + for (ibit = 0; ibit < 8; ibit++) + { + usWord |= (source & ucBitMask) << ibit; + usWord |= (mask & ucBitMask) << (ibit + 1); + ucBitMask <<= 1; + } + + return (usWord); +} + +void SMI501_RotateCursorShape(xf86CursorInfoPtr infoPtr, int angle, unsigned char *pByte) +{ + BYTE *pCursor; + unsigned long ulBase, ulIndex; + BYTE src[256], dst[256]; /* 128 = 8 x 32 */ + BYTE jMask, j, bitMask; + int x, y, cx = 32, cy = 32; + + pCursor = pByte; + + memset(src, 0x00, sizeof(src)); + memset(dst, 0x00, sizeof(dst)); + + /* Save the original pointer shape into local memory shapeRow[] */ + for (y=0; y>1)) + dst[ulIndex] |= (jMask >> 1); + } + } + break; + + + case SMI_ROTATE_CW: + + for (y = 0; y < cy; y++) + { + jMask = 0x80 >> ((y&3)*2); + + /* Write available bits into shapeRow */ + for (x = 0; x < cx; x++) + { + j = src[y*8 + x/4]; + bitMask = 0x02 << ((x&3)*2); + + ulBase = x * 8; + ulIndex = (ulBase + (31 - y) / 4); + + if (j & bitMask) + dst[ulIndex] |= jMask; + if (j & (bitMask>>1)) + dst[ulIndex] |= (jMask >> 1); + } + } + break; + + default: + return; + } + + for (y=0; ypScrn); + CursorBitsPtr bits = pCurs->bits; + unsigned char * ram; + unsigned short * usram; + unsigned char * psource = bits->source; + unsigned char * pmask = bits->mask; + int x, y, srcwidth, i; + unsigned int MaxCursor; + + ENTER_PROC("SMI_501_RealizeCursor"); + + /* Allocate memory */ + ram = (unsigned char *) xcalloc(1, 2048); + + usram = (unsigned short *)ram; + MaxCursor = MAX_CURSOR_501; + + if (ram == NULL) + { + LEAVE_PROC("SMI_501_RealizeCursor"); + return(NULL); + } + + /* Calculate cursor information */ + srcwidth = ((bits->width + 31) / 8) & ~3; + + i = 0; + + /* Copy cursor image */ + for (y = 0; y < min(MaxCursor, bits->height); y++) + { + for (x = 0; x < min(MaxCursor / 8, srcwidth); x++) + { + unsigned char mask = *pmask++; + unsigned char source = *psource++ & mask; + + usram[i++] = InterleaveBytes(source, mask); + } + + pmask += srcwidth - x; + psource += srcwidth - x; + + /* Fill remaining part of line with no shape */ + for (; x < MaxCursor / 8; x++) + { + usram[i++] = 0x0000; + } + } + + /* Fill remaining part of memory with no shape */ + for (; y < MaxCursor; y++) + { + for (x = 0; x < MaxCursor / 8; x++) + { + usram[i++] = 0x0000; + } + } + + SMI501_RotateCursorShape(infoPtr, pSmi->rotate ,ram); + + LEAVE_PROC("SMI_501_RealizeCursor"); + return(ram); +} + static void SMI_LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) { @@ -204,23 +379,32 @@ SMI_LoadCursorImage(ScrnInfoPtr pScrn, u ENTER_PROC("SMI_LoadCursorImage"); - /* Load storage location. */ - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x80, - pSmi->FBCursorOffset / 2048); - tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81) & 0x80; - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, - tmp | ((pSmi->FBCursorOffset / 2048) >> 8)); - - /* Program FPR copy when on the 730 */ - if (pSmi->Chipset == SMI_COUGAR3DR) - { - CARD32 fpr15c; - - /* put address in upper word, and disable the cursor */ - fpr15c = READ_FPR(pSmi, FPR15C) & FPR15C_MASK_HWCCOLORS; - fpr15c |= (pSmi->FBCursorOffset / 2048) << 16; - WRITE_FPR(pSmi, FPR15C, fpr15c); - } + /* Load storage location. */ + if (pSmi->Chipset != SMI_MSOC) + { + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x80, + pSmi->FBCursorOffset / 2048); + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81) & 0x80; + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, + tmp | ((pSmi->FBCursorOffset / 2048) >> 8)); + + /* Program FPR copy when on the 730 */ + if (pSmi->Chipset == SMI_COUGAR3DR) + { + CARD32 fpr15c; + + /* put address in upper word, and disable the cursor */ + fpr15c = READ_FPR(pSmi, FPR15C) & FPR15C_MASK_HWCCOLORS; + fpr15c |= (pSmi->FBCursorOffset / 2048) << 16; + WRITE_FPR(pSmi, FPR15C, fpr15c); + } + } + else /* SMI 501 family */ + { + /* Write address, disabling the HW cursor */ + WRITE_DCR(pSmi, DCRF0, pSmi->FBCursorOffset); /* Panel HWC Addr */ + WRITE_DCR(pSmi, DCR230, pSmi->FBCursorOffset); /* CRT HWC Addr */ + } /* Copy cursor image to framebuffer storage */ memcpy(pSmi->FBBase + pSmi->FBCursorOffset, src, 1024); @@ -237,19 +421,45 @@ SMI_ShowCursor(ScrnInfoPtr pScrn) ENTER_PROC("SMI_ShowCursor"); /* Show cursor */ - tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81); - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, tmp | 0x80); + if (pSmi->Chipset != SMI_MSOC) + { + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, tmp | 0x80); + + /* Program FPR copy when on the 730 */ + if (pSmi->Chipset == SMI_COUGAR3DR) + { + CARD32 fpr15c; + + /* turn on the top bit */ + fpr15c = READ_FPR(pSmi, FPR15C); + fpr15c |= FPR15C_MASK_HWCENABLE; + WRITE_FPR(pSmi, FPR15C, fpr15c); + } + } + else /* SMI 501 */ + { + CARD32 uiPanelTmp; + CARD32 uiCrtTmp; + + uiPanelTmp = READ_DCR(pSmi, DCRF0); + uiCrtTmp = READ_DCR(pSmi, DCR230); + uiPanelTmp |= SMI501_MASK_HWCENABLE; + uiCrtTmp |= SMI501_MASK_HWCENABLE; + WRITE_DCR(pSmi, DCRF0, uiPanelTmp); + WRITE_DCR(pSmi, DCR230, uiCrtTmp); + } + + /* Program FPR copy when on the 730 */ + if (pSmi->Chipset == SMI_COUGAR3DR) + { + CARD32 fpr15c; - /* Program FPR copy when on the 730 */ - if (pSmi->Chipset == SMI_COUGAR3DR) - { - CARD32 fpr15c; - - /* turn on the top bit */ - fpr15c = READ_FPR(pSmi, FPR15C); - fpr15c |= FPR15C_MASK_HWCENABLE; - WRITE_FPR(pSmi, FPR15C, fpr15c); - } + /* turn on the top bit */ + fpr15c = READ_FPR(pSmi, FPR15C); + fpr15c |= FPR15C_MASK_HWCENABLE; + WRITE_FPR(pSmi, FPR15C, fpr15c); + } LEAVE_PROC("SMI_ShowCursor"); } @@ -263,19 +473,45 @@ SMI_HideCursor(ScrnInfoPtr pScrn) ENTER_PROC("SMI_HideCursor"); /* Hide cursor */ - tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81); - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, tmp & ~0x80); + if (pSmi->Chipset != SMI_MSOC) + { + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, tmp & ~0x80); + + /* Program FPR copy when on the 730 */ + if (pSmi->Chipset == SMI_COUGAR3DR) + { + CARD32 fpr15c; + + /* turn off the top bit */ + fpr15c = READ_FPR(pSmi, FPR15C); + fpr15c &= ~FPR15C_MASK_HWCENABLE; + WRITE_FPR(pSmi, FPR15C, fpr15c); + } + } + else + { + CARD32 uiPanelTmp; + CARD32 uiCrtTmp; + + uiPanelTmp = READ_DCR(pSmi, DCRF0); + uiCrtTmp = READ_DCR(pSmi, DCR230); + uiPanelTmp &= ~SMI501_MASK_HWCENABLE; + uiCrtTmp &= ~SMI501_MASK_HWCENABLE; + WRITE_DCR(pSmi, DCRF0, uiPanelTmp); + WRITE_DCR(pSmi, DCR230, uiCrtTmp); + } + + /* Program FPR copy when on the 730 */ + if (pSmi->Chipset == SMI_COUGAR3DR) + { + CARD32 fpr15c; - /* Program FPR copy when on the 730 */ - if (pSmi->Chipset == SMI_COUGAR3DR) - { - CARD32 fpr15c; - - /* turn off the top bit */ - fpr15c = READ_FPR(pSmi, FPR15C); - fpr15c &= ~FPR15C_MASK_HWCENABLE; - WRITE_FPR(pSmi, FPR15C, fpr15c); - } + /* turn off the top bit */ + fpr15c = READ_FPR(pSmi, FPR15C); + fpr15c &= ~FPR15C_MASK_HWCENABLE; + WRITE_FPR(pSmi, FPR15C, fpr15c); + } LEAVE_PROC("SMI_HideCursor"); } @@ -308,59 +544,88 @@ SMI_SetCursorPosition(ScrnInfoPtr pScrn, } /* Program coordinates */ - if (xoff >= 0) + if (pSmi->Chipset != SMI_MSOC) { - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x88, xoff & 0xFF); - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x89, - (xoff >> 8) & 0x07); + if (xoff >= 0) + { + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x88, xoff & 0xFF); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x89, + (xoff >> 8) & 0x07); + } + else + { + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x88, + (-xoff) & (MAX_CURSOR - 1)); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x89, 0x08); + } + + if (yoff >= 0) + { + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8A, yoff & 0xFF); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8B, + (yoff >> 8) & 0x07); + } + else + { + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8A, + (-yoff) & (MAX_CURSOR - 1)); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8B, 0x08); + } + } - else + else /* SMI 501 Family */ { - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x88, - (-xoff) & (MAX_CURSOR - 1)); - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x89, 0x08); - } + CARD32 hwcLocVal; - if (yoff >= 0) - { - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8A, yoff & 0xFF); - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8B, - (yoff >> 8) & 0x07); + if (xoff >= 0) + { + hwcLocVal = (xoff & SMI501_MASK_MAXBITS); + } + else + { + hwcLocVal = (((-xoff) & SMI501_MASK_MAXBITS) | SMI501_MASK_BOUNDARY); + } + + if (yoff >= 0) + { + hwcLocVal |= (yoff & SMI501_MASK_MAXBITS)<<16; + } + else + { + hwcLocVal |= (((-yoff) & SMI501_MASK_MAXBITS) | SMI501_MASK_BOUNDARY)<<16; + } + + /* Program combined coordinates */ + WRITE_DCR(pSmi, DCRF4, hwcLocVal); /* Panel HWC Location */ + WRITE_DCR(pSmi, DCR234, hwcLocVal); /* CRT HWC Location */ } - else + + /* Program FPR copy when on the 730 */ + if (pSmi->Chipset == SMI_COUGAR3DR) { - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8A, - (-yoff) & (MAX_CURSOR - 1)); - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8B, 0x08); - } - - /* Program FPR copy when on the 730 */ - if (pSmi->Chipset == SMI_COUGAR3DR) - { - CARD32 fpr158; - - if (xoff >= 0) - { - fpr158 = (xoff & FPR158_MASK_MAXBITS)<<16; - } - else - { - fpr158 = (((-xoff) & FPR158_MASK_MAXBITS) | FPR158_MASK_BOUNDARY)<<16; - } - - if (yoff >= 0) - { - fpr158 |= (yoff & FPR158_MASK_MAXBITS); - } - else - { - fpr158 |= (((-yoff) & FPR158_MASK_MAXBITS) | FPR158_MASK_BOUNDARY); - } + CARD32 fpr158; - /* Program combined coordinates */ - WRITE_FPR(pSmi, FPR158, fpr158); + if (xoff >= 0) + { + fpr158 = (xoff & FPR158_MASK_MAXBITS)<<16; + } + else + { + fpr158 = (((-xoff) & FPR158_MASK_MAXBITS) | FPR158_MASK_BOUNDARY)<<16; + } + + if (yoff >= 0) + { + fpr158 |= (yoff & FPR158_MASK_MAXBITS); + } + else + { + fpr158 |= (((-yoff) & FPR158_MASK_MAXBITS) | FPR158_MASK_BOUNDARY); + } - } + /* Program combined coordinates */ + WRITE_FPR(pSmi, FPR158, fpr158); + } LEAVE_PROC("SMI_SetCursorPosition"); } @@ -373,30 +638,69 @@ SMI_SetCursorColors(ScrnInfoPtr pScrn, i ENTER_PROC("SMI_SetCursorColors"); - /* Pack the true color into 8 bit */ - packedFG = (fg & 0xE00000) >> 16 - | (fg & 0x00E000) >> 11 - | (fg & 0x0000C0) >> 6 - ; - packedBG = (bg & 0xE00000) >> 16 - | (bg & 0x00E000) >> 11 - | (bg & 0x0000C0) >> 6 - ; - - /* Program the colors */ - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8C, packedFG); - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8D, packedBG); - - /* Program FPR copy when on the 730 */ - if (pSmi->Chipset == SMI_COUGAR3DR) - { - CARD32 fpr15c; - - fpr15c = READ_FPR(pSmi, FPR15C) & FPR15C_MASK_HWCADDREN; - fpr15c |= packedFG; - fpr15c |= packedBG<<8; - WRITE_FPR(pSmi, FPR15C, fpr15c); - } + if (pSmi->Chipset != SMI_MSOC) + { + /* Pack the true color into 8 bit */ + packedFG = (fg & 0xE00000) >> 16 + | (fg & 0x00E000) >> 11 + | (fg & 0x0000C0) >> 6 + ; + packedBG = (bg & 0xE00000) >> 16 + | (bg & 0x00E000) >> 11 + | (bg & 0x0000C0) >> 6 + ; + + /* Program the colors */ + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8C, packedFG); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8D, packedBG); + } + else + { + /* for the SMI501 HWCursor, there are 4 possible colors, one of which + * is transparent: M,S: 0,0 = Transparent + * 0,1 = color 1 + * 1,0 = color 2 + * 1,1 = color 3 + * To simplify implementation, we use color2 == bg and + * color3 == fg + * Color 1 is don't care, so we set it to color 2's value + */ + unsigned int packedFGBG; + + /* Pack the true color components into 16 bit RGB -- 5:6:5 */ + packedFGBG = (bg & 0xF80000) >> 8 + | (bg & 0x00FC00) >> 5 + | (bg & 0x0000F8) >> 3 + ; + + packedFGBG |= (bg & 0xF80000) << 8 + | (bg & 0x00FC00) << 11 + | (bg & 0x0000F8) << 13 + ; + + WRITE_DCR(pSmi, DCRF8, packedFGBG); /* Panel HWC Color 1,2 */ + WRITE_DCR(pSmi, DCR238, packedFGBG); /* CRT HWC Color 1,2 */ + + packedFGBG = (fg & 0xF80000) >> 8 + | (fg & 0x00FC00) >> 5 + | (fg & 0x0000F8) >> 3 + ; + WRITE_DCR(pSmi, DCRFC, packedFGBG); /* Panel HWC Color 3 */ + WRITE_DCR(pSmi, DCR23C, packedFGBG); /* CRT HWC Color 3 */ + + + } + + /* Program FPR copy when on the 730 */ + if (pSmi->Chipset == SMI_COUGAR3DR) + { + CARD32 fpr15c; + + fpr15c = READ_FPR(pSmi, FPR15C) & FPR15C_MASK_HWCADDREN; + fpr15c |= packedFG; + fpr15c |= packedBG<<8; + WRITE_FPR(pSmi, FPR15C, fpr15c); + } LEAVE_PROC("SMI_SetCursorColors"); } @@ -419,28 +723,46 @@ SMI_HWCursorInit(ScreenPtr pScreen) return(FALSE); } - pSmi->CursorInfoRec = infoPtr; + pSmi->CursorInfoRec = infoPtr; /* Fill in the information */ - infoPtr->MaxWidth = MAX_CURSOR; - infoPtr->MaxHeight = MAX_CURSOR; - infoPtr->Flags = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 - | HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK - | HARDWARE_CURSOR_AND_SOURCE_WITH_MASK - | HARDWARE_CURSOR_BIT_ORDER_MSBFIRST - | HARDWARE_CURSOR_TRUECOLOR_AT_8BPP - | HARDWARE_CURSOR_INVERT_MASK; - - infoPtr->SetCursorColors = SMI_SetCursorColors; - infoPtr->SetCursorPosition = SMI_SetCursorPosition; - infoPtr->LoadCursorImage = SMI_LoadCursorImage; - infoPtr->HideCursor = SMI_HideCursor; - infoPtr->ShowCursor = SMI_ShowCursor; - infoPtr->RealizeCursor = SMI_RealizeCursor; - infoPtr->UseHWCursor = NULL; + if (pSmi->Chipset != SMI_MSOC) + { + infoPtr->MaxWidth = MAX_CURSOR; + infoPtr->MaxHeight = MAX_CURSOR; + } + else + { + infoPtr->MaxWidth = MAX_CURSOR_501; + infoPtr->MaxHeight = MAX_CURSOR_501; + } + + if (pSmi->Chipset != SMI_MSOC) + { + infoPtr->Flags = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 + | HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK + | HARDWARE_CURSOR_AND_SOURCE_WITH_MASK + | HARDWARE_CURSOR_BIT_ORDER_MSBFIRST + | HARDWARE_CURSOR_INVERT_MASK; + infoPtr->RealizeCursor = SMI_RealizeCursor; + } + else + { + infoPtr->Flags = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 + | HARDWARE_CURSOR_TRUECOLOR_AT_8BPP + | HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK; + infoPtr->RealizeCursor = SMI_501_RealizeCursor; + } + + infoPtr->SetCursorColors = SMI_SetCursorColors; + infoPtr->SetCursorPosition = SMI_SetCursorPosition; + infoPtr->LoadCursorImage = SMI_LoadCursorImage; + infoPtr->HideCursor = SMI_HideCursor; + infoPtr->ShowCursor = SMI_ShowCursor; + infoPtr->UseHWCursor = NULL; /* Proceed with cursor initialization */ - ret = xf86InitCursor(pScreen, infoPtr); + ret = xf86InitCursor(pScreen, infoPtr); LEAVE_PROC("SMI_HWCursorInit"); return(ret); Index: smi_shadow.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_shadow.c,v retrieving revision 1.2 diff -u -p -r1.2 smi_shadow.c --- smi_shadow.c 23 Apr 2004 19:45:06 -0000 1.2 +++ smi_shadow.c 28 Jan 2005 15:59:29 -0000 @@ -39,6 +39,9 @@ authorization from the XFree86 Project a #include "smi.h" +#define ROTBLTWIDTH 16 + + /******************************************************************************\ |* SMI_RefreshArea |*============================================================================= @@ -57,6 +60,7 @@ void SMI_RefreshArea(ScrnInfoPtr pScrn, { SMIPtr pSmi = SMIPTR(pScrn); int width, height, srcX, srcY, destX, destY; + int leftoverwidth; ENTER_PROC("SMI_RefreshArea"); @@ -73,7 +77,15 @@ void SMI_RefreshArea(ScrnInfoPtr pScrn, WaitIdleEmpty(); WRITE_DPR(pSmi, 0x10, pSmi->ShadowPitch); WRITE_DPR(pSmi, 0x3C, pSmi->ShadowPitch); - WRITE_DPR(pSmi, 0x44, pSmi->FBOffset >> 3); + + if (SMI_MSOC != pSmi->Chipset) + { + WRITE_DPR(pSmi, 0x44, pSmi->FBOffset >> 3); + } + else + { + WRITE_DPR(pSmi, 0x44, pSmi->FBOffset); + } } /* #672 */ @@ -94,6 +106,7 @@ void SMI_RefreshArea(ScrnInfoPtr pScrn, DEBUG((VERBLEV, "x=%d y=%d w=%d h=%d\n", srcX, srcY, width, height)); + if ((width > 0) && (height > 0)) { switch (pSmi->rotate) @@ -110,15 +123,88 @@ void SMI_RefreshArea(ScrnInfoPtr pScrn, | | +-----+ +---+ */ - destX = pSmi->ShadowHeight - srcY - 1; - destY = srcX; - - WaitQueue(4); - WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); - WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); - WRITE_DPR(pSmi, 0x08, (width << 16) + height); - WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | - SMI_ROTATE_CW | SMI_START_ENGINE); + if (SMI_MSOC == pSmi->Chipset) + { + if (srcX < 0 || srcY < 0) + { + if (srcX < 0) + { + width += srcX; + srcX = 0; + } + if (srcY < 0) + { + height += srcY; + srcY = 0; + } + + if (width < 0 || height < 0) + { + /* Perform no operation if width or height is negative */ + break; + } + } + + /* Adjust source coordinates to be 32-byte aligned for 501 HW */ + width += srcX % (32/(pScrn->bitsPerPixel/8)); + srcX -= srcX % (32/(pScrn->bitsPerPixel/8)); + + destX = pSmi->ShadowHeight - srcY - 1; + destY = srcX; + + /* 501 has some wierdness where it won't clip correctly + * at the bottom of the screen. Need to do this in SW. */ + if ((srcX + width) > pSmi->width) + { + width -= ((srcX+width) - pSmi->width); + if (width <= 0) + break; + } + if ((srcY + height) > pSmi->height) + { + height -= ((srcY + height) - pSmi->height); + if (height <= 0) + break; + } + + + leftoverwidth = width; + + /* 501 Hardware cannot handle rotblits > 32 bytes */ + while (leftoverwidth > ROTBLTWIDTH) + { + + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (ROTBLTWIDTH << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CW | SMI_START_ENGINE); + + leftoverwidth -= ROTBLTWIDTH; + srcX += ROTBLTWIDTH; + destY = srcX; + } + + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (leftoverwidth << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CW | SMI_START_ENGINE); + } + else /* NOT SMOC 501 chipset */ + { + destX = pSmi->ShadowHeight - srcY - 1; + destY = srcX; + + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CW | SMI_START_ENGINE); + } break; case SMI_ROTATE_CCW: @@ -133,15 +219,96 @@ void SMI_RefreshArea(ScrnInfoPtr pScrn, | | *-----+ +---+ */ - destX = srcY; - destY = pSmi->ShadowWidth - srcX - 1; - WaitQueue(4); - WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); - WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); - WRITE_DPR(pSmi, 0x08, (width << 16) + height); - WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | - SMI_ROTATE_CCW | SMI_START_ENGINE); + if (SMI_MSOC == pSmi->Chipset) + { + if (srcX < 0 || srcY < 0) + { + if (srcX < 0) + { + width += srcX; + srcX = 0; + } + if (srcY < 0) + { + height += srcY; + srcY = 0; + } + + if (width < 0 || height < 0) + { + /* Punt on blits with a negative width or height*/ + break; + } + } + + + /* Adjust source coordinates to be 32-byte aligned for 501 HW */ + width += srcX % (32/(pScrn->bitsPerPixel/8)); + srcX -= srcX % (32/(pScrn->bitsPerPixel/8)); + + destX = srcY; + destY = pSmi->ShadowWidth - srcX - 1; + + /* 501 has some wierdness where it won't clip correctly + * at the bottom of the screen. Need to do this in SW. */ + if ((srcX + width) > pSmi->width) + { + width -= ((srcX+width) - pSmi->width); + if (width <= 0) + break; + } + if ((srcY + height) > pSmi->height) + { + height -= ((srcY + height) - pSmi->height); + if (height <= 0) + break; + } + leftoverwidth = width; + + /* 501 Hardware cannot handle rotblits > 32 bytes */ + while (leftoverwidth > ROTBLTWIDTH) + { + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (ROTBLTWIDTH << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CCW | SMI_START_ENGINE); + + leftoverwidth -= ROTBLTWIDTH; + srcX += ROTBLTWIDTH; + destY = pSmi->ShadowWidth - srcX - 1; + + if (destY < 0) + { + destY = 0; + height-= 1; + } + } + + if (leftoverwidth > 0) + { + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (leftoverwidth << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CCW | SMI_START_ENGINE); + } + } + else + { + destX = srcY; + destY = pSmi->ShadowWidth - srcX - 1; + + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CCW | SMI_START_ENGINE); + } break; default: @@ -165,7 +332,6 @@ void SMI_RefreshArea(ScrnInfoPtr pScrn, break; } } - pbox++; } Index: smi_video.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.c,v retrieving revision 1.3 diff -u -p -r1.3 smi_video.c --- smi_video.c 31 Jul 2004 01:21:51 -0000 1.3 +++ smi_video.c 28 Jan 2005 15:59:30 -0000 @@ -1,4 +1,4 @@ -/* Header: //Mercury/Projects/archives/XFree86/4.0/smi_video.c.-arc 1.14 30 Nov 2000 16:51:40 Frido $ */ +/* Header: //Mercury/Projects/archives/XFree86/4.0/smi_video.c.-arc 1.14 30 Nov 2000 16:51:40 Frido $ */ /* Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. Copyright (C) 2000 Silicon Motion, Inc. All Rights Reserved. @@ -16,7 +16,7 @@ copies or substantial portions of the So THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- -NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -38,7 +38,7 @@ this is a heavy modified version of the - interlaced video for double vertical resolution Author of changes: Corvin Zahn -Date: 2.11.2001 +Date: 2.11.2001 */ /* $XdotOrg: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.c,v 1.3 2004/07/31 01:21:51 anholt Exp $ */ @@ -53,11 +53,11 @@ Date: 2.11.2001 new attribute: XV_INTERLACED = 0: only one field of an interlaced video signal is displayed: - -> half vertical resolution, but no comb like artifacts from - moving vertical edges + -> half vertical resolution, but no comb like artifacts from + moving vertical edges XV_INTERLACED = 1: both fields of an interlaced video signal are displayed: - -> full vertical resolution, but comb like artifacts from - moving vertical edges + -> full vertical resolution, but comb like artifacts from + moving vertical edges The default value can be set with the driver option Interlaced @@ -71,7 +71,7 @@ The default value can be set with the dr #undef CLAMP #undef ENTRIES -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define ABS(n) (((n) < 0) ? -(n) : (n)) #define CLAMP(v, min, max) (((v) < (min)) ? (min) : MIN(v, max)) @@ -120,6 +120,9 @@ static Bool SMI_ClipVideo(ScrnInfoPtr pS static void SMI_DisplayVideo(ScrnInfoPtr pScrn, int id, int offset, short width, short height, int pitch, int x1, int y1, int x2, int y2, BoxPtr dstBox, short vid_w, short vid_h, short drw_w, short drw_h); +static void SMI_DisplayVideo0501(ScrnInfoPtr pScrn, int id, int offset, + short width, short height, int pitch, int x1, int y1, int x2, int y2, + BoxPtr dstBox, short vid_w, short vid_h, short drw_w, short drw_h); static void SMI_DisplayVideo0730(ScrnInfoPtr pScrn, int id, int offset, short width, short height, int pitch, int x1, int y1, int x2, int y2, BoxPtr dstBox, short vid_w, short vid_h, short drw_w, short drw_h); @@ -129,7 +132,7 @@ static void SMI_BlockHandler(int i, poin static void SMI_WaitForSync(ScrnInfoPtr pScrn); #endif /*static int SMI_SendI2C(ScrnInfoPtr pScrn, CARD8 device, char *devName, - SMI_I2CDataPtr i2cData);*/ + SMI_I2CDataPtr i2cData);*/ static void SMI_InitOffscreenImages(ScreenPtr pScreen); static FBAreaPtr SMI_AllocateMemory(ScrnInfoPtr pScrn, FBAreaPtr area, @@ -167,7 +170,7 @@ static Atom xvInterlaced; /******************************************************************************\ ** ** -** C A P A B I L I T I E S ** +** C A P A B I L I T I E S ** ** ** \******************************************************************************/ @@ -186,12 +189,12 @@ typedef enum _VideoInput { VID_COMPOSITE /* video input formats */ typedef struct _VideoInputDataRec { - char* name; + char* name; } VideoInputDataRec; static VideoInputDataRec VideoInputs[] = { - { "composite" }, - { "svideo" } + { "composite" }, + { "svideo" } }; @@ -202,25 +205,25 @@ static VideoInputDataRec VideoInputs[] = typedef enum _VideoNorm { PAL, NTSC, SECAM } VideoNorm; typedef struct _VideoNormDataRec { - char* name; - unsigned long Wt; - unsigned long Wa; - unsigned long Ht; - unsigned long Ha; - unsigned long HStart; - unsigned long VStart; - XvRationalRec rate; + char* name; + unsigned long Wt; + unsigned long Wa; + unsigned long Ht; + unsigned long Ha; + unsigned long HStart; + unsigned long VStart; + XvRationalRec rate; } VideoNormDataRec; static VideoNormDataRec VideoNorms[] = { - /* PAL-BDGHI */ - {"pal", 864, 704, 625, 576, 16, 16, { 1, 50 }}, - /* NTSC */ - {"ntsc", 858, 704, 525, 480, 21, 8, { 1001, 60000 }}, - /* SECAM (not tested) */ - {"secam", 864, 7040, 625, 576, 31, 16, { 1, 50 }}, + /* PAL-BDGHI */ + {"pal", 864, 704, 625, 576, 16, 16, { 1, 50 }}, + /* NTSC */ + {"ntsc", 858, 704, 525, 480, 21, 8, { 1001, 60000 }}, + /* SECAM (not tested) */ + {"secam", 864, 7040, 625, 576, 31, 16, { 1, 50 }}, }; @@ -245,31 +248,31 @@ static XF86VideoFormatRec SMI_VideoForma * Attributes */ -#define XV_ENCODING_NAME "XV_ENCODING" -#define XV_BRIGHTNESS_NAME "XV_BRIGHTNESS" -#define XV_CAPTURE_BRIGHTNESS_NAME "XV_CAPTURE_BRIGHTNESS" -#define XV_CONTRAST_NAME "XV_CONTRAST" -#define XV_SATURATION_NAME "XV_SATURATION" -#define XV_HUE_NAME "XV_HUE" -#define XV_COLORKEY_NAME "XV_COLORKEY" -#define XV_INTERLACED_NAME "XV_INTERLACED" +#define XV_ENCODING_NAME "XV_ENCODING" +#define XV_BRIGHTNESS_NAME "XV_BRIGHTNESS" +#define XV_CAPTURE_BRIGHTNESS_NAME "XV_CAPTURE_BRIGHTNESS" +#define XV_CONTRAST_NAME "XV_CONTRAST" +#define XV_SATURATION_NAME "XV_SATURATION" +#define XV_HUE_NAME "XV_HUE" +#define XV_COLORKEY_NAME "XV_COLORKEY" +#define XV_INTERLACED_NAME "XV_INTERLACED" /* fixed order! */ static XF86AttributeRec SMI_VideoAttributesSAA711x[N_ATTRS] = { - {XvSettable | XvGettable, 0, N_ENCODINGS-1, XV_ENCODING_NAME}, - {XvSettable | XvGettable, 0, 255, XV_BRIGHTNESS_NAME}, - {XvSettable | XvGettable, 0, 255, XV_CAPTURE_BRIGHTNESS_NAME}, - {XvSettable | XvGettable, 0, 127, XV_CONTRAST_NAME}, - {XvSettable | XvGettable, 0, 127, XV_SATURATION_NAME}, - {XvSettable | XvGettable, -128, 127, XV_HUE_NAME}, - {XvSettable | XvGettable, 0x000000, 0xFFFFFF, XV_COLORKEY_NAME}, - {XvSettable | XvGettable, 0, 1, XV_INTERLACED_NAME}, + {XvSettable | XvGettable, 0, N_ENCODINGS-1, XV_ENCODING_NAME}, + {XvSettable | XvGettable, 0, 255, XV_BRIGHTNESS_NAME}, + {XvSettable | XvGettable, 0, 255, XV_CAPTURE_BRIGHTNESS_NAME}, + {XvSettable | XvGettable, 0, 127, XV_CONTRAST_NAME}, + {XvSettable | XvGettable, 0, 127, XV_SATURATION_NAME}, + {XvSettable | XvGettable, -128, 127, XV_HUE_NAME}, + {XvSettable | XvGettable, 0x000000, 0xFFFFFF, XV_COLORKEY_NAME}, + {XvSettable | XvGettable, 0, 1, XV_INTERLACED_NAME}, }; static XF86AttributeRec SMI_VideoAttributes[2] = { - {XvSettable | XvGettable, 0, 255, XV_BRIGHTNESS_NAME}, - {XvSettable | XvGettable, 0x000000, 0xFFFFFF, XV_COLORKEY_NAME}, + {XvSettable | XvGettable, 0, 255, XV_BRIGHTNESS_NAME}, + {XvSettable | XvGettable, 0x000000, 0xFFFFFF, XV_COLORKEY_NAME}, }; @@ -357,6 +360,55 @@ static XF86ImageRec SMI_VideoImages[] = }, }; +/**************************************************************************/ +static XF86ImageRec SMI501_VideoImages[] = +{ + XVIMAGE_YUY2, + XVIMAGE_YV12, + XVIMAGE_I420, + { + FOURCC_RV16, /* id */ + XvRGB, /* type */ + LSBFirst, /* byte_order */ + { 'R', 'V' ,'1', '6', + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, /* guid */ + 16, /* bits_per_pixel */ + XvPacked, /* format */ + 1, /* num_planes */ + 16, /* depth */ + 0x001F, 0x07E0, 0xF800, /* red_mask, green, blue */ + 0, 0, 0, /* y_sample_bits, u, v */ + 0, 0, 0, /* horz_y_period, u, v */ + 0, 0, 0, /* vert_y_period, u, v */ + { 'R', 'V', 'B' }, /* component_order */ + XvTopToBottom /* scaline_order */ + }, + { + FOURCC_RV32, /* id */ + XvRGB, /* type */ + LSBFirst, /* byte_order */ + { 'R', 'V' ,'3', '2', + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, /* guid */ + 32, /* bits_per_pixel */ + XvPacked, /* format */ + 1, /* num_planes */ + 24, /* depth */ + 0x0000FF, 0x00FF00, 0xFF0000, /* red_mask, green, blue */ + 0, 0, 0, /* y_sample_bits, u, v */ + 0, 0, 0, /* horz_y_period, u, v */ + 0, 0, 0, /* vert_y_period, u, v */ + { 'R', 'V', 'B' }, /* component_order */ + XvTopToBottom /* scaline_order */ + }, +}; + + + + /**************************************************************************/ @@ -366,29 +418,29 @@ static XF86ImageRec SMI_VideoImages[] = /** SAA7111 control sequences for selecting one out of four - composite input channels */ + composite input channels */ static I2CByte SAA7111CompositeChannelSelect[N_COMPOSITE_CHANNELS][4] = { - { 0x02, 0xC0, 0x09, 0x4A}, /* CVBS AI11 */ - { 0x02, 0xC1, 0x09, 0x4A}, /* CVBS AI12 */ - { 0x02, 0xC2, 0x09, 0x4A}, /* CVBS AI21 */ - { 0x02, 0xC3, 0x09, 0x4A}, /* CVBS AI22 */ + { 0x02, 0xC0, 0x09, 0x4A}, /* CVBS AI11 */ + { 0x02, 0xC1, 0x09, 0x4A}, /* CVBS AI12 */ + { 0x02, 0xC2, 0x09, 0x4A}, /* CVBS AI21 */ + { 0x02, 0xC3, 0x09, 0x4A}, /* CVBS AI22 */ }; /** SAA7111 control sequences for selecting one out of two - s-video input channels */ + s-video input channels */ static I2CByte SAA7111SVideoChannelSelect[N_SVIDEO_CHANNELS][4] = { - { 0x02, 0xC6, 0x09, 0xCA}, /* Y/C AI11/AI21 */ - { 0x02, 0xC7, 0x09, 0xCA}, /* Y/C AI12/AI22 */ + { 0x02, 0xC6, 0x09, 0xCA}, /* Y/C AI11/AI21 */ + { 0x02, 0xC7, 0x09, 0xCA}, /* Y/C AI12/AI22 */ }; /** SAA7111 control sequences for selecting one out of three - video norms */ + video norms */ static I2CByte SAA7111VideoStd[3][8] = { - {0x06, 108, 0x07, 108, 0x08, 0x09, 0x0E, 0x01}, /* PAL */ - {0x06, 107, 0x07, 107, 0x08, 0x49, 0x0E, 0x01}, /* NTSC */ - {0x06, 108, 0x07, 108, 0x08, 0x01, 0x0E, 0x51} /* SECAM */ + {0x06, 108, 0x07, 108, 0x08, 0x09, 0x0E, 0x01}, /* PAL */ + {0x06, 107, 0x07, 107, 0x08, 0x49, 0x0E, 0x01}, /* NTSC */ + {0x06, 108, 0x07, 108, 0x08, 0x01, 0x0E, 0x51} /* SECAM */ }; @@ -396,64 +448,64 @@ static I2CByte SAA7111VideoStd[3][8] = { static I2CByte SAA7110InitData[] = { /* Configuration */ - 0x00, 0x4C, 0x01, 0x3C, 0x02, 0x00, 0x03, 0xEF, - 0x04, 0xBD, 0x05, 0xE2, 0x06, 0x00, 0x07, 0x00, - 0x08, 0xF8, 0x09, 0xF8, 0x0A, 0x60, 0x0B, 0x60, - 0x0C, 0x00, 0x0D, 0x80, 0x0E, 0x18, 0x0F, 0xD9, - 0x10, 0x00, 0x11, 0x2B, 0x12, 0x40, 0x13, 0x40, - 0x14, 0x42, 0x15, 0x1A, 0x16, 0xFF, 0x17, 0xDA, - 0x18, 0xE6, 0x19, 0x90, 0x20, 0xD9, 0x21, 0x16, - 0x22, 0x40, 0x23, 0x40, 0x24, 0x80, 0x25, 0x40, - 0x26, 0x80, 0x27, 0x4F, 0x28, 0xFE, 0x29, 0x01, - 0x2A, 0xCF, 0x2B, 0x0F, 0x2C, 0x03, 0x2D, 0x01, - 0x2E, 0x83, 0x2F, 0x03, 0x30, 0x40, 0x31, 0x35, - 0x32, 0x02, 0x33, 0x8C, 0x34, 0x03, + 0x00, 0x4C, 0x01, 0x3C, 0x02, 0x00, 0x03, 0xEF, + 0x04, 0xBD, 0x05, 0xE2, 0x06, 0x00, 0x07, 0x00, + 0x08, 0xF8, 0x09, 0xF8, 0x0A, 0x60, 0x0B, 0x60, + 0x0C, 0x00, 0x0D, 0x80, 0x0E, 0x18, 0x0F, 0xD9, + 0x10, 0x00, 0x11, 0x2B, 0x12, 0x40, 0x13, 0x40, + 0x14, 0x42, 0x15, 0x1A, 0x16, 0xFF, 0x17, 0xDA, + 0x18, 0xE6, 0x19, 0x90, 0x20, 0xD9, 0x21, 0x16, + 0x22, 0x40, 0x23, 0x40, 0x24, 0x80, 0x25, 0x40, + 0x26, 0x80, 0x27, 0x4F, 0x28, 0xFE, 0x29, 0x01, + 0x2A, 0xCF, 0x2B, 0x0F, 0x2C, 0x03, 0x2D, 0x01, + 0x2E, 0x83, 0x2F, 0x03, 0x30, 0x40, 0x31, 0x35, + 0x32, 0x02, 0x33, 0x8C, 0x34, 0x03, /* NTSC */ - 0x11, 0x2B, 0x0F, 0xD9, + 0x11, 0x2B, 0x0F, 0xD9, /* RCA input connector */ - 0x06, 0x00, 0x0E, 0x18, 0x20, 0xD9, 0x21, 0x16, - 0x22, 0x40, 0x2C, 0x03, + 0x06, 0x00, 0x0E, 0x18, 0x20, 0xD9, 0x21, 0x16, + 0x22, 0x40, 0x2C, 0x03, }; #endif static I2CByte SAA7111InitData[] = { - 0x11, 0x1D, /* 0D D0=1: automatic colour killer off + 0x11, 0x1D, /* 0D D0=1: automatic colour killer off D1=0: DMSD data to YUV output D2=1: output enable H/V sync on D3=1: output enable YUV data on */ - 0x02, 0xC0, /* Mode 0 */ - 0x03, 0x23, /* automatic gain */ - 0x04, 0x00, /* */ - 0x05, 0x00, /* */ - 0x06, 108, /* hor sync begin */ - 0x07, 108, /* hor sync stop */ - 0x08, 0x88, /* sync control: + 0x02, 0xC0, /* Mode 0 */ + 0x03, 0x23, /* automatic gain */ + 0x04, 0x00, /* */ + 0x05, 0x00, /* */ + 0x06, 108, /* hor sync begin */ + 0x07, 108, /* hor sync stop */ + 0x08, 0x88, /* sync control: D1-0=00: VNOI = normal mode D2=0: PLL closed D3=1: VTR mode D7=1: automatic field detection */ - 0x09, 0x41, /* 4A luminance control */ - 0x0A, 0x80, /* brightness = 128 (CCIR level) */ - 0x0B, 0x40, /* contrast = 1.0 */ - 0x0C, 0x40, /* crominance = 1.0 (CCIR level) */ - 0x0D, 0x00, /* hue = 0 */ - 0x0E, 0x01, /* chroma bandwidth = nominal + 0x09, 0x41, /* 4A luminance control */ + 0x0A, 0x80, /* brightness = 128 (CCIR level) */ + 0x0B, 0x40, /* contrast = 1.0 */ + 0x0C, 0x40, /* crominance = 1.0 (CCIR level) */ + 0x0D, 0x00, /* hue = 0 */ + 0x0E, 0x01, /* chroma bandwidth = nominal fast colour time constant = nominal chrom comp filter on colour standard PAL BGHI, NTSC M */ - 0x10, 0x48, /* luminance delay compensation = 0 + 0x10, 0x48, /* luminance delay compensation = 0 VRLN = 1 fine pos of hs = 0 output format = YUV 422 */ - 0x12, 0x00, /* 20 D5=1: VPO in tristate */ - 0x13, 0x00, - 0x15, 0x00, - 0x16, 0x00, - 0x17, 0x00, + 0x12, 0x00, /* 20 D5=1: VPO in tristate */ + 0x13, 0x00, + 0x15, 0x00, + 0x16, 0x00, + 0x17, 0x00, }; @@ -517,30 +569,30 @@ static int SMI_AddEncoding(XF86VideoEncodingPtr enc, int i, int norm, int input, int channel) { - char* norm_string; - char* input_string; - char channel_string[20]; - - ENTER_PROC("SMI_AddEncoding"); - - norm_string = VideoNorms[norm].name; - input_string = VideoInputs[input].name; - sprintf(channel_string, "%d", channel); - enc[i].id = i; - enc[i].name = xalloc(strlen(norm_string) + - strlen(input_string) + + char* norm_string; + char* input_string; + char channel_string[20]; + + ENTER_PROC("SMI_AddEncoding"); + + norm_string = VideoNorms[norm].name; + input_string = VideoInputs[input].name; + sprintf(channel_string, "%d", channel); + enc[i].id = i; + enc[i].name = xalloc(strlen(norm_string) + + strlen(input_string) + strlen(channel_string)+3); - if (NULL == enc[i].name) { + if (NULL == enc[i].name) { LEAVE_PROC("SMI_AddEncoding"); return -1; - } - enc[i].width = VideoNorms[norm].Wa; - enc[i].height = VideoNorms[norm].Ha; - enc[i].rate = VideoNorms[norm].rate; - sprintf(enc[i].name,"%s-%s-%s", norm_string, input_string, channel_string); + } + enc[i].width = VideoNorms[norm].Wa; + enc[i].height = VideoNorms[norm].Ha; + enc[i].rate = VideoNorms[norm].rate; + sprintf(enc[i].name,"%s-%s-%s", norm_string, input_string, channel_string); - LEAVE_PROC("SMI_AddEncoding"); - return 0; + LEAVE_PROC("SMI_AddEncoding"); + return 0; } @@ -551,136 +603,136 @@ SMI_AddEncoding(XF86VideoEncodingPtr enc static void SMI_BuildEncodings(SMI_PortPtr p) { - int ch, n; + int ch, n; - ENTER_PROC("SMI_BuildEncodings"); + ENTER_PROC("SMI_BuildEncodings"); - /* allocate memory for encoding array */ - p->enc = xalloc(sizeof(XF86VideoEncodingRec) * N_ENCODINGS); - if (NULL == p->enc) + /* allocate memory for encoding array */ + p->enc = xalloc(sizeof(XF86VideoEncodingRec) * N_ENCODINGS); + if (NULL == p->enc) goto fail; - memset(p->enc,0,sizeof(XF86VideoEncodingRec) * N_ENCODINGS); - /* allocate memory for video norm array */ - p->norm = xalloc(sizeof(int) * N_ENCODINGS); - if (NULL == p->norm) + memset(p->enc,0,sizeof(XF86VideoEncodingRec) * N_ENCODINGS); + /* allocate memory for video norm array */ + p->norm = xalloc(sizeof(int) * N_ENCODINGS); + if (NULL == p->norm) goto fail; - memset(p->norm,0,sizeof(int) * N_ENCODINGS); - /* allocate memory for video input format array */ - p->input = xalloc(sizeof(int) * N_ENCODINGS); - if (NULL == p->input) + memset(p->norm,0,sizeof(int) * N_ENCODINGS); + /* allocate memory for video input format array */ + p->input = xalloc(sizeof(int) * N_ENCODINGS); + if (NULL == p->input) goto fail; - memset(p->input,0,sizeof(int) * N_ENCODINGS); - /* allocate memory for video channel number array */ - p->channel = xalloc(sizeof(int) * N_ENCODINGS); - if (NULL == p->channel) + memset(p->input,0,sizeof(int) * N_ENCODINGS); + /* allocate memory for video channel number array */ + p->channel = xalloc(sizeof(int) * N_ENCODINGS); + if (NULL == p->channel) goto fail; - memset(p->channel,0,sizeof(int) * N_ENCODINGS); + memset(p->channel,0,sizeof(int) * N_ENCODINGS); - /* fill arrays */ - p->nenc = 0; - for (ch = 0; ch < N_COMPOSITE_CHANNELS; ch++) { + /* fill arrays */ + p->nenc = 0; + for (ch = 0; ch < N_COMPOSITE_CHANNELS; ch++) { for (n = 0; n < N_VIDEO_NORMS; n++) { - SMI_AddEncoding(p->enc, p->nenc, n, VID_COMPOSITE, ch); - p->norm[p->nenc] = n; - p->input[p->nenc] = VID_COMPOSITE; - p->channel[p->nenc] = ch; - p->nenc++; + SMI_AddEncoding(p->enc, p->nenc, n, VID_COMPOSITE, ch); + p->norm[p->nenc] = n; + p->input[p->nenc] = VID_COMPOSITE; + p->channel[p->nenc] = ch; + p->nenc++; } - } - for (ch = 0; ch < N_SVIDEO_CHANNELS; ch++) { + } + for (ch = 0; ch < N_SVIDEO_CHANNELS; ch++) { for (n = 0; n < N_VIDEO_NORMS; n++) { - SMI_AddEncoding(p->enc, p->nenc, n, VID_SVIDEO, ch); - p->norm[p->nenc] = n; - p->input[p->nenc] = VID_SVIDEO; - p->channel[p->nenc] = ch; - p->nenc++; - } - } - LEAVE_PROC("SMI_BuildEncodings"); - return; - + SMI_AddEncoding(p->enc, p->nenc, n, VID_SVIDEO, ch); + p->norm[p->nenc] = n; + p->input[p->nenc] = VID_SVIDEO; + p->channel[p->nenc] = ch; + p->nenc++; + } + } + LEAVE_PROC("SMI_BuildEncodings"); + return; + fail: - if (p->input) xfree(p->input); - p->input = NULL; - if (p->norm) xfree(p->norm); - p->norm = NULL; - if (p->channel) xfree(p->channel); - p->channel = NULL; - if (p->enc) xfree(p->enc); - p->enc = NULL; - p->nenc = 0; - LEAVE_PROC("SMI_BuildEncodings"); + if (p->input) xfree(p->input); + p->input = NULL; + if (p->norm) xfree(p->norm); + p->norm = NULL; + if (p->channel) xfree(p->channel); + p->channel = NULL; + if (p->enc) xfree(p->enc); + p->enc = NULL; + p->nenc = 0; + LEAVE_PROC("SMI_BuildEncodings"); } /******************************************************************************\ -** ** -** X V E X T E N S I O N I N T E R F A C E ** -** ** +** ** +** X V E X T E N S I O N I N T E R F A C E ** +** ** \******************************************************************************/ void SMI_InitVideo(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - SMIPtr psmi = SMIPTR(pScrn); - XF86VideoAdaptorPtr *ptrAdaptors, *newAdaptors = NULL; - XF86VideoAdaptorPtr newAdaptor = NULL; - int numAdaptors; - - ENTER_PROC("SMI_InitVideo"); - - numAdaptors = xf86XVListGenericAdaptors(pScrn, &ptrAdaptors); - - DEBUG((VERBLEV, "numAdaptors=%d\n", numAdaptors)); - - if (psmi->rotate == 0) - { - newAdaptor = SMI_SetupVideo(pScreen); - DEBUG((VERBLEV, "newAdaptor=%p\n", newAdaptor)); - SMI_InitOffscreenImages(pScreen); - } - - if (newAdaptor != NULL) - { - if (numAdaptors == 0) - { - numAdaptors = 1; - ptrAdaptors = &newAdaptor; - } - else - { - newAdaptors = xalloc((numAdaptors + 1) * - sizeof(XF86VideoAdaptorPtr*)); - if (newAdaptors != NULL) - { - memcpy(newAdaptors, ptrAdaptors, - numAdaptors * sizeof(XF86VideoAdaptorPtr)); - newAdaptors[numAdaptors++] = newAdaptor; - ptrAdaptors = newAdaptors; - } - } - } - - if (numAdaptors != 0) - { - DEBUG((VERBLEV, "ScreenInit %i\n",numAdaptors)); - xf86XVScreenInit(pScreen, ptrAdaptors, numAdaptors); - } - - if (newAdaptors != NULL) - { - xfree(newAdaptors); - } + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SMIPtr psmi = SMIPTR(pScrn); + XF86VideoAdaptorPtr *ptrAdaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL; + int numAdaptors; + + ENTER_PROC("SMI_InitVideo"); + + numAdaptors = xf86XVListGenericAdaptors(pScrn, &ptrAdaptors); + + DEBUG((VERBLEV, "numAdaptors=%d\n", numAdaptors)); + + if (psmi->rotate == 0) + { + newAdaptor = SMI_SetupVideo(pScreen); + DEBUG((VERBLEV, "newAdaptor=%p\n", newAdaptor)); + SMI_InitOffscreenImages(pScreen); + } + + if (newAdaptor != NULL) + { + if (numAdaptors == 0) + { + numAdaptors = 1; + ptrAdaptors = &newAdaptor; + } + else + { + newAdaptors = xalloc((numAdaptors + 1) * + sizeof(XF86VideoAdaptorPtr*)); + if (newAdaptors != NULL) + { + memcpy(newAdaptors, ptrAdaptors, + numAdaptors * sizeof(XF86VideoAdaptorPtr)); + newAdaptors[numAdaptors++] = newAdaptor; + ptrAdaptors = newAdaptors; + } + } + } + + if (numAdaptors != 0) + { + DEBUG((VERBLEV, "ScreenInit %i\n",numAdaptors)); + xf86XVScreenInit(pScreen, ptrAdaptors, numAdaptors); + } + + if (newAdaptors != NULL) + { + xfree(newAdaptors); + } - LEAVE_PROC("SMI_InitVideo"); + LEAVE_PROC("SMI_InitVideo"); } /*************************************************************************/ /* - * Video codec controls + * Video codec controls */ #if 0 @@ -690,7 +742,7 @@ SMI_InitVideo(ScreenPtr pScreen) static int Scale(int i, int value, int min, int max) { - return min + (value - SMI_VideoAttributes[i].min_value) * (max - min) / + return min + (value - SMI_VideoAttributes[i].min_value) * (max - min) / (SMI_VideoAttributes[i].max_value - SMI_VideoAttributes[i].min_value); } #endif @@ -700,32 +752,32 @@ Scale(int i, int value, int min, int max static int SetAttr(ScrnInfoPtr pScrn, int i, int value) { - SMIPtr pSmi = SMIPTR(pScrn); - SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; + SMIPtr pSmi = SMIPTR(pScrn); + SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; - if (i < XV_ENCODING || i > XV_HUE) + if (i < XV_ENCODING || i > XV_HUE) return BadMatch; - - /* clamps value to attribute range */ - value = CLAMP(value, SMI_VideoAttributes[i].min_value, + + /* clamps value to attribute range */ + value = CLAMP(value, SMI_VideoAttributes[i].min_value, SMI_VideoAttributes[i].max_value); - if (i == XV_BRIGHTNESS) { + if (i == XV_BRIGHTNESS) { int my_value = (value <= 128? value + 128 : value - 128); SetKeyReg(pSmi, 0x5C, 0xEDEDED | (my_value << 24)); - } else if (pPort->I2CDev.SlaveAddr == SAA7110) { + } else if (pPort->I2CDev.SlaveAddr == SAA7110) { return SetAttrSAA7110(pScrn, i, value); - } - else if (pPort->I2CDev.SlaveAddr == SAA7111) { + } + else if (pPort->I2CDev.SlaveAddr == SAA7111) { return SetAttrSAA7111(pScrn, i, value); - } + } #if 0 - else { + else { return XvBadAlloc; - } + } #endif - return Success; + return Success; } @@ -735,8 +787,8 @@ SetAttr(ScrnInfoPtr pScrn, int i, int va static int SetAttrSAA7110(ScrnInfoPtr pScrn, int i, int value) { - /* not supported */ - return XvBadAlloc; + /* not supported */ + return XvBadAlloc; } @@ -747,10 +799,10 @@ SetAttrSAA7110(ScrnInfoPtr pScrn, int i, static int SetAttrSAA7111(ScrnInfoPtr pScrn, int i, int value) { - SMIPtr pSmi = SMIPTR(pScrn); - SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; + SMIPtr pSmi = SMIPTR(pScrn); + SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; - if (i == XV_ENCODING) { + if (i == XV_ENCODING) { int norm; int input; int channel; @@ -759,83 +811,83 @@ SetAttrSAA7111(ScrnInfoPtr pScrn, int i, channel = pPort->channel[value]; DEBUG((VERBLEV, "SetAttribute XV_ENCODING: %d. norm=%d input=%d channel=%d\n", - value, norm, input, channel)); + value, norm, input, channel)); /* set video norm */ if (!xf86I2CWriteVec(&(pPort->I2CDev), SAA7111VideoStd[norm], - ENTRIES(SAA7111VideoStd[norm]) / 2)) { - return XvBadAlloc; + ENTRIES(SAA7111VideoStd[norm]) / 2)) { + return XvBadAlloc; } /* set video input format and channel */ if (input == VID_COMPOSITE) { - if (!xf86I2CWriteVec(&(pPort->I2CDev), + if (!xf86I2CWriteVec(&(pPort->I2CDev), SAA7111CompositeChannelSelect[channel], ENTRIES(SAA7111CompositeChannelSelect[channel]) / 2)) { return XvBadAlloc; - } + } } else { - if (!xf86I2CWriteVec(&(pPort->I2CDev), + if (!xf86I2CWriteVec(&(pPort->I2CDev), SAA7111SVideoChannelSelect[channel], ENTRIES(SAA7111SVideoChannelSelect[channel]) / 2)) { return XvBadAlloc; - } + } + } } - } - else if (i >= XV_CAPTURE_BRIGHTNESS && i <= XV_HUE) { + else if (i >= XV_CAPTURE_BRIGHTNESS && i <= XV_HUE) { int slave_adr = 0; switch (i) { case XV_CAPTURE_BRIGHTNESS: - DEBUG((VERBLEV, "SetAttribute XV_BRIGHTNESS: %d\n", value)); - slave_adr = 0x0a; - break; - + DEBUG((VERBLEV, "SetAttribute XV_BRIGHTNESS: %d\n", value)); + slave_adr = 0x0a; + break; + case XV_CONTRAST: - DEBUG((VERBLEV, "SetAttribute XV_CONTRAST: %d\n", value)); - slave_adr = 0x0b; - break; + DEBUG((VERBLEV, "SetAttribute XV_CONTRAST: %d\n", value)); + slave_adr = 0x0b; + break; case XV_SATURATION: - DEBUG((VERBLEV, "SetAttribute XV_SATURATION: %d\n", value)); - slave_adr = 0x0c; - break; + DEBUG((VERBLEV, "SetAttribute XV_SATURATION: %d\n", value)); + slave_adr = 0x0c; + break; case XV_HUE: - DEBUG((VERBLEV, "SetAttribute XV_HUE: %d\n", value)); - slave_adr = 0x0d; - break; + DEBUG((VERBLEV, "SetAttribute XV_HUE: %d\n", value)); + slave_adr = 0x0d; + break; default: - return XvBadAlloc; + return XvBadAlloc; } if (!xf86I2CWriteByte(&(pPort->I2CDev), slave_adr, (value & 0xff))) - return XvBadAlloc; - } - else { + return XvBadAlloc; + } + else { return BadMatch; - } + } - /* debug: show registers */ - { + /* debug: show registers */ + { I2CByte i2c_bytes[32]; int i; xf86I2CReadBytes(&(pPort->I2CDev), 0, i2c_bytes, 32); DEBUG((VERBLEV, "SAA7111 Registers\n")); for (i=0; i<32; i++) { - DEBUG((VERBLEV, "%02X=%02X ", i, i2c_bytes[i])); - if ((i&7) == 7) DEBUG((VERBLEV, "\n")); + DEBUG((VERBLEV, "%02X=%02X ", i, i2c_bytes[i])); + if ((i&7) == 7) DEBUG((VERBLEV, "\n")); + } } - } - return Success; + return Success; } /******************************************************************************\ ** ** -** V I D E O M A N A G E M E N T ** +** V I D E O M A N A G E M E N T ** ** ** \******************************************************************************/ @@ -874,17 +926,17 @@ SMI_SetupVideo( ptrAdaptor->name = "Silicon Motion Lynx Series Video Engine"; - ptrAdaptor->nPorts = 1; - ptrAdaptor->pPortPrivates = (DevUnion*) &ptrAdaptor[1]; - ptrAdaptor->pPortPrivates[0].ptr = (pointer) &ptrAdaptor->pPortPrivates[1]; - - smiPortPtr = (SMI_PortPtr) ptrAdaptor->pPortPrivates[0].ptr; - - SMI_BuildEncodings(smiPortPtr); - ptrAdaptor->nEncodings = smiPortPtr->nenc; - ptrAdaptor->pEncodings = smiPortPtr->enc; + ptrAdaptor->nPorts = 1; + ptrAdaptor->pPortPrivates = (DevUnion*) &ptrAdaptor[1]; + ptrAdaptor->pPortPrivates[0].ptr = (pointer) &ptrAdaptor->pPortPrivates[1]; + + smiPortPtr = (SMI_PortPtr) ptrAdaptor->pPortPrivates[0].ptr; + + SMI_BuildEncodings(smiPortPtr); + ptrAdaptor->nEncodings = smiPortPtr->nenc; + ptrAdaptor->pEncodings = smiPortPtr->enc; #if 0 - /* aaa whats this? */ + /* aaa whats this? */ for (i = 0; i < nElems(SMI_VideoEncodings); i++) { SMI_VideoEncodings[i].width = pSmi->lcdWidth; @@ -898,16 +950,25 @@ SMI_SetupVideo( ptrAdaptor->nAttributes = nElems(SMI_VideoAttributes); ptrAdaptor->pAttributes = SMI_VideoAttributes; - ptrAdaptor->nImages = nElems(SMI_VideoImages); - ptrAdaptor->pImages = SMI_VideoImages; + if (pSmi->Chipset != SMI_MSOC) + { + ptrAdaptor->nImages = nElems(SMI_VideoImages); + ptrAdaptor->pImages = SMI_VideoImages; + } + else + { + ptrAdaptor->nImages = nElems(SMI501_VideoImages); + ptrAdaptor->pImages = SMI501_VideoImages; + } #if SMI_USE_CAPTURE - if (pSmi->Chipset == SMI_COUGAR3DR) + if ((pSmi->Chipset == SMI_COUGAR3DR) || (pSmi->Chipset == SMI_MSOC)) ptrAdaptor->PutVideo = NULL; else ptrAdaptor->PutVideo = SMI_PutVideo; + ptrAdaptor->PutStill = NULL; - ptrAdaptor->GetVideo = NULL; + ptrAdaptor->GetVideo = NULL; ptrAdaptor->GetStill = NULL; #else ptrAdaptor->PutVideo = NULL; @@ -922,62 +983,61 @@ SMI_SetupVideo( ptrAdaptor->PutImage = SMI_PutImage; ptrAdaptor->QueryImageAttributes = SMI_QueryImageAttributes; - smiPortPtr->Attribute[XV_COLORKEY] = pSmi->videoKey; - smiPortPtr->Attribute[XV_INTERLACED] = pSmi->interlaced; + smiPortPtr->Attribute[XV_COLORKEY] = pSmi->videoKey; + smiPortPtr->Attribute[XV_INTERLACED] = pSmi->interlaced; smiPortPtr->videoStatus = 0; #if 0 - /* aaa does not work ? */ - if (xf86I2CProbeAddress(pSmi->I2C, SAA7111)) - { - LEAVE_PROC("SMI_SetupVideo"); - return(NULL); - } - DEBUG((VERBLEV, "SAA7111 detected\n")); -#endif - - smiPortPtr->I2CDev.DevName = "SAA 7111A"; - smiPortPtr->I2CDev.SlaveAddr = SAA7111; - smiPortPtr->I2CDev.pI2CBus = pSmi->I2C; - - - if (xf86I2CDevInit(&(smiPortPtr->I2CDev))) - { - - if (xf86I2CWriteVec(&(smiPortPtr->I2CDev), SAA7111InitData, - ENTRIES(SAA7111InitData) / 2)) { - xvEncoding = MAKE_ATOM(XV_ENCODING_NAME); - xvHue = MAKE_ATOM(XV_HUE_NAME); - xvSaturation = MAKE_ATOM(XV_SATURATION_NAME); - xvContrast = MAKE_ATOM(XV_CONTRAST_NAME); - - xvInterlaced = MAKE_ATOM(XV_INTERLACED_NAME); - DEBUG((VERBLEV, "SAA7111 intialized\n")); - - } else { - xf86DestroyI2CDevRec(&(smiPortPtr->I2CDev),FALSE); - smiPortPtr->I2CDev.SlaveAddr = 0; - } - } else - smiPortPtr->I2CDev.SlaveAddr = 0; - + /* aaa does not work ? */ + if (xf86I2CProbeAddress(pSmi->I2C, SAA7111)) + { + LEAVE_PROC("SMI_SetupVideo"); + return(NULL); + } + DEBUG((VERBLEV, "SAA7111 detected\n")); +#endif + + smiPortPtr->I2CDev.DevName = "SAA 7111A"; + smiPortPtr->I2CDev.SlaveAddr = SAA7111; + smiPortPtr->I2CDev.pI2CBus = pSmi->I2C; + + if ((pSmi->Chipset != SMI_MSOC) && (xf86I2CDevInit(&(smiPortPtr->I2CDev)))) + { + + if (xf86I2CWriteVec(&(smiPortPtr->I2CDev), SAA7111InitData, + ENTRIES(SAA7111InitData) / 2)) { + xvEncoding = MAKE_ATOM(XV_ENCODING_NAME); + xvHue = MAKE_ATOM(XV_HUE_NAME); + xvSaturation = MAKE_ATOM(XV_SATURATION_NAME); + xvContrast = MAKE_ATOM(XV_CONTRAST_NAME); + + xvInterlaced = MAKE_ATOM(XV_INTERLACED_NAME); + DEBUG((VERBLEV, "SAA7111 intialized\n")); + + } else { + xf86DestroyI2CDevRec(&(smiPortPtr->I2CDev),FALSE); + smiPortPtr->I2CDev.SlaveAddr = 0; + } + } else + smiPortPtr->I2CDev.SlaveAddr = 0; + #if defined(REGION_NULL) - REGION_NULL(pScreen, &smiPortPtr->clip); + REGION_NULL(pScreen, &smiPortPtr->clip); #else - REGION_INIT(pScreen, &smiPortPtr->clip, NullBox, 0); + REGION_INIT(pScreen, &smiPortPtr->clip, NullBox, 0); #endif - - pSmi->ptrAdaptor = ptrAdaptor; - pSmi->BlockHandler = pScreen->BlockHandler; - pScreen->BlockHandler = SMI_BlockHandler; - - xvColorKey = MAKE_ATOM(XV_COLORKEY_NAME); - xvBrightness = MAKE_ATOM(XV_BRIGHTNESS_NAME); - xvCapBrightness = MAKE_ATOM(XV_CAPTURE_BRIGHTNESS_NAME); - - SMI_ResetVideo(pScrn); - LEAVE_PROC("SMI_SetupVideo"); - return(ptrAdaptor); + + pSmi->ptrAdaptor = ptrAdaptor; + pSmi->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = SMI_BlockHandler; + + xvColorKey = MAKE_ATOM(XV_COLORKEY_NAME); + xvBrightness = MAKE_ATOM(XV_BRIGHTNESS_NAME); + xvCapBrightness = MAKE_ATOM(XV_CAPTURE_BRIGHTNESS_NAME); + + SMI_ResetVideo(pScrn); + LEAVE_PROC("SMI_SetupVideo"); + return(ptrAdaptor); } @@ -987,22 +1047,22 @@ SMI_ResetVideo( ) { SMIPtr pSmi = SMIPTR(pScrn); - SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; + SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; int r, g, b; ENTER_PROC("SMI_ResetVideo"); - SetAttr(pScrn, XV_ENCODING, 0); /* Encoding = pal-composite-0 */ - SetAttr(pScrn, XV_BRIGHTNESS, 128); /* Brightness = 128 (CCIR level) */ - SetAttr(pScrn, XV_CAPTURE_BRIGHTNESS, 128); /* Brightness = 128 (CCIR level) */ - SetAttr(pScrn, XV_CONTRAST, 71); /* Contrast = 71 (CCIR level) */ - SetAttr(pScrn, XV_SATURATION, 64); /* Color saturation = 64 (CCIR level) */ - SetAttr(pScrn, XV_HUE, 0); /* Hue = 0 */ + SetAttr(pScrn, XV_ENCODING, 0); /* Encoding = pal-composite-0 */ + SetAttr(pScrn, XV_BRIGHTNESS, 128); /* Brightness = 128 (CCIR level) */ + SetAttr(pScrn, XV_CAPTURE_BRIGHTNESS, 128); /* Brightness = 128 (CCIR level) */ + SetAttr(pScrn, XV_CONTRAST, 71); /* Contrast = 71 (CCIR level) */ + SetAttr(pScrn, XV_SATURATION, 64); /* Color saturation = 64 (CCIR level) */ + SetAttr(pScrn, XV_HUE, 0); /* Hue = 0 */ switch (pScrn->depth) { case 8: - SetKeyReg(pSmi, FPR04, pPort->Attribute[XV_COLORKEY] & 0x00FF); + SetKeyReg(pSmi, FPR04, pPort->Attribute[XV_COLORKEY] & 0x00FF); SetKeyReg(pSmi, FPR08, 0); break; @@ -1013,9 +1073,9 @@ SMI_ResetVideo( break; default: - r = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.red) >> pScrn->offset.red; - g = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.green) >> pScrn->offset.green; - b = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.blue) >> pScrn->offset.blue; + r = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.red) >> pScrn->offset.red; + g = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.green) >> pScrn->offset.green; + b = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.blue) >> pScrn->offset.blue; SetKeyReg(pSmi, FPR04, ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)); SetKeyReg(pSmi, FPR08, 0); break; @@ -1043,34 +1103,34 @@ SMI_PutVideo( pointer data ) { - SMI_PortPtr pPort = (SMI_PortPtr) data; + SMI_PortPtr pPort = (SMI_PortPtr) data; SMIPtr pSmi = SMIPTR(pScrn); CARD32 vid_pitch, vid_address; CARD32 vpr00, cpr00; int xscale, yscale; BoxRec dstBox; INT32 x1, y1, x2, y2; - int norm; + int norm; int areaHeight, width, height, fbPitch; int top, left; - ENTER_PROC("SMI_PutVideo"); + ENTER_PROC("SMI_PutVideo"); - DEBUG((VERBLEV, "Interlaced Video %d\n", pPort->Attribute[XV_INTERLACED])); + DEBUG((VERBLEV, "Interlaced Video %d\n", pPort->Attribute[XV_INTERLACED])); - if (!pPort->Attribute[XV_INTERLACED]) { + if (!pPort->Attribute[XV_INTERLACED]) { /* no interlace: lines will be doubled */ vid_h /= 2; - } + } - /* field start aaa*/ - norm = pPort->norm[pPort->Attribute[XV_ENCODING]]; - vid_x += VideoNorms[norm].HStart; - vid_y += VideoNorms[norm].VStart; - /* only even values allowed (UV-phase) */ - vid_x &= ~1; + /* field start aaa*/ + norm = pPort->norm[pPort->Attribute[XV_ENCODING]]; + vid_x += VideoNorms[norm].HStart; + vid_y += VideoNorms[norm].VStart; + /* only even values allowed (UV-phase) */ + vid_x &= ~1; - DEBUG((VERBLEV, "vid_x=%d vid_y=%d drw_x=%d drw_y=%d " + DEBUG((VERBLEV, "vid_x=%d vid_y=%d drw_x=%d drw_y=%d " "vid_w=%d vid_h=%d drw_w=%d drw_h=%d\n", vid_x, vid_y, drw_x, drw_y, vid_w, vid_h, drw_w, drw_h)); @@ -1091,15 +1151,15 @@ SMI_PutVideo( if (!SMI_ClipVideo(pScrn, &dstBox, &x1, &y1, &x2, &y2, clipBoxes, width, height)) #else - if (!xf86XVClipVideoHelper(&dstBox, &x1, &y1, &x2, &y2, clipBoxes, width, - height)) + if (!xf86XVClipVideoHelper(&dstBox, &x1, &y1, &x2, &y2, clipBoxes, width, + height)) #endif { - LEAVE_PROC("SMI_PutVideo"); + LEAVE_PROC("SMI_PutVideo"); return(Success); } - DEBUG((VERBLEV, "Clip: x1=%d y1=%d x2=%d y2=%d\n", x1 >> 16, y1 >> 16, x2 >> 16, y2 >> 16)); + DEBUG((VERBLEV, "Clip: x1=%d y1=%d x2=%d y2=%d\n", x1 >> 16, y1 >> 16, x2 >> 16, y2 >> 16)); dstBox.x1 -= pScrn->frameX0; dstBox.y1 -= pScrn->frameY0; @@ -1111,71 +1171,71 @@ SMI_PutVideo( vpr00 = READ_VPR(pSmi, 0x00) & ~0x0FF000FF; cpr00 = READ_CPR(pSmi, 0x00) & ~0x000FFF00; - /* vpr00: - Bit 2..0 = 6: Video Window I Format = YUV4:2:2 - Bit 3 = 1: Video Window I Enable = enabled - Bit 4 = 0: Video Window I YUV Averaging = disabled - Bit 5 = 0: Video Window I Hor. Replication = disabled - Bit 6 = 0: Video Window I data doubling = disabled - Bit 14..8 = 0: Video Window II = disabled - Bit 18..16 = 0: Graphics Data Format = 8-bit index - Bit 19 = 0: Top Video Window Select = window I - Bit 20 = 1: Color Key for Window I = enabled - Bit 21 = 0: Vertical Interpolation = s. below - Bit 22 = 0: Flicker Reduction for TV Modes = disabled - Bit 23 = 0: Fixed Vertical Interpolation = disabled - Bit 24 = 1: Select Video Window I Source Addr = - Bit 25 = 0: Enable V0FIFO to fetch 8-Bit color data = disabled - Bit 26 = 0: - Bit 27 = 1: Color Key for Window II = disabled - Bit 31..28 = reserved - */ - if (pPort->Attribute[XV_INTERLACED]) { + /* vpr00: + Bit 2..0 = 6: Video Window I Format = YUV4:2:2 + Bit 3 = 1: Video Window I Enable = enabled + Bit 4 = 0: Video Window I YUV Averaging = disabled + Bit 5 = 0: Video Window I Hor. Replication = disabled + Bit 6 = 0: Video Window I data doubling = disabled + Bit 14..8 = 0: Video Window II = disabled + Bit 18..16 = 0: Graphics Data Format = 8-bit index + Bit 19 = 0: Top Video Window Select = window I + Bit 20 = 1: Color Key for Window I = enabled + Bit 21 = 0: Vertical Interpolation = s. below + Bit 22 = 0: Flicker Reduction for TV Modes = disabled + Bit 23 = 0: Fixed Vertical Interpolation = disabled + Bit 24 = 1: Select Video Window I Source Addr = + Bit 25 = 0: Enable V0FIFO to fetch 8-Bit color data = disabled + Bit 26 = 0: + Bit 27 = 1: Color Key for Window II = disabled + Bit 31..28 = reserved + */ + if (pPort->Attribute[XV_INTERLACED]) { /* - Bit 21 = 0: Vertical Interpolation = disabled - Bit 24 = 0: Select Video Window I Source Addr = 0 + Bit 21 = 0: Vertical Interpolation = disabled + Bit 24 = 0: Select Video Window I Source Addr = 0 */ - vpr00 |= 0x0010000E; - } - else { + vpr00 |= 0x0010000E; + } + else { /* - Bit 21 = 10: Vertical Interpolation = enabled - Bit 24 = 1: Select Video Window I Source Addr = 1 + Bit 21 = 10: Vertical Interpolation = enabled + Bit 24 = 1: Select Video Window I Source Addr = 1 1= Video window I source addr = capture port buffer ? */ - vpr00 |= 0x0130000E; - } + vpr00 |= 0x0130000E; + } - /* cpr00: - Bit 0 = 1: Video Capture Enable = enabled - Bit 8 = 0: Capture Control = continous - Bit 9 = 0: Double Buffer Enable = s. below - Bit 10 = 0: Interlace Data Capture = s. below - Bit 13..11 = 0: Frame Skip Enable = s. below - Bit 15..14 = 0: Video Capture Input Format = YUV4:2:2 - Bit 17..16 = 0: Enable Hor. Reduction = s. below - Bit 19..18 = 0: Enable Vert. Reduction = s. below - Bit 21..20 = 0: Enable Hor. Filtering = s. below - Bit 22 = 0: HREF Polarity = high active - Bit 23 = 0: VREF Polarity = high active - Bit 24 = 1: Field Detection Method VSYNC edge = rising - */ - if (pPort->Attribute[XV_INTERLACED]) { + /* cpr00: + Bit 0 = 1: Video Capture Enable = enabled + Bit 8 = 0: Capture Control = continous + Bit 9 = 0: Double Buffer Enable = s. below + Bit 10 = 0: Interlace Data Capture = s. below + Bit 13..11 = 0: Frame Skip Enable = s. below + Bit 15..14 = 0: Video Capture Input Format = YUV4:2:2 + Bit 17..16 = 0: Enable Hor. Reduction = s. below + Bit 19..18 = 0: Enable Vert. Reduction = s. below + Bit 21..20 = 0: Enable Hor. Filtering = s. below + Bit 22 = 0: HREF Polarity = high active + Bit 23 = 0: VREF Polarity = high active + Bit 24 = 1: Field Detection Method VSYNC edge = rising + */ + if (pPort->Attribute[XV_INTERLACED]) { /* - Bit 9 = 1: Double Buffer Enable = enabled - Bit 10 = 1: Interlace Data Capture = enabled - Bit 13..11 = 0: Frame Skip Enable = no skip + Bit 9 = 1: Double Buffer Enable = enabled + Bit 10 = 1: Interlace Data Capture = enabled + Bit 13..11 = 0: Frame Skip Enable = no skip */ - cpr00 |= 0x01000601; - } - else { + cpr00 |= 0x01000601; + } + else { /* - Bit 9 = 0: Double Buffer Enable = disabled - Bit 10 = 0: Interlace Data Capture = disabled - Bit 13..11 = 010: Frame Skip Enable = skip every other frame + Bit 9 = 0: Double Buffer Enable = disabled + Bit 10 = 0: Interlace Data Capture = disabled + Bit 13..11 = 010: Frame Skip Enable = skip every other frame */ - cpr00 |= 0x01000801; - } + cpr00 |= 0x01000801; + } if (pSmi->ByteSwap) cpr00 |= 0x00004000; @@ -1239,9 +1299,9 @@ SMI_PutVideo( { areaHeight = (vid_pitch * height + fbPitch - 1) / fbPitch; DEBUG((VERBLEV, "SMI_AllocateMemory: vid_pitch=%d height=%d fbPitch=%d areaHeight=%d\n", - vid_pitch, height, fbPitch, areaHeight)); - pPort->area = SMI_AllocateMemory(pScrn, pPort->area, areaHeight); - if (pPort->area == NULL) + vid_pitch, height, fbPitch, areaHeight)); + pPort->area = SMI_AllocateMemory(pScrn, pPort->area, areaHeight); + if (pPort->area == NULL) { if ((cpr00 & 0x000C0000) == 0) { @@ -1276,31 +1336,31 @@ SMI_PutVideo( } else { - DEBUG((VERBLEV, "allocate error\n")); - LEAVE_PROC("SMI_PutVideo"); + DEBUG((VERBLEV, "allocate error\n")); + LEAVE_PROC("SMI_PutVideo"); return(BadAlloc); } } } } - while (pPort->area == NULL); + while (pPort->area == NULL); - DEBUG((VERBLEV, "xscale==%d yscale=%d width=%d height=%d\n", + DEBUG((VERBLEV, "xscale==%d yscale=%d width=%d height=%d\n", xscale, yscale, width, height)); - /* aaa whats this ----------------------v ? - vid_address = (pPort->area->box.y1 * fbPitch) + ((y1 >> 16) * vid_pitch);*/ - vid_address = (pPort->area->box.y1 * fbPitch); + /* aaa whats this ----------------------v ? + vid_address = (pPort->area->box.y1 * fbPitch) + ((y1 >> 16) * vid_pitch);*/ + vid_address = (pPort->area->box.y1 * fbPitch); - DEBUG((VERBLEV, "test RegionsEqual\n")); + DEBUG((VERBLEV, "test RegionsEqual\n")); #if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) - if (!RegionsEqual(&pPort->clip, clipBoxes)) + if (!RegionsEqual(&pPort->clip, clipBoxes)) #else - if (!REGION_EQUAL(pScrn->pScreen, &pPort->clip, clipBoxes)) + if (!REGION_EQUAL(pScrn->pScreen, &pPort->clip, clipBoxes)) #endif - { + { DEBUG((VERBLEV, "RegionCopy\n")); - REGION_COPY(pScrn->pScreen, &pPort->clip, clipBoxes); + REGION_COPY(pScrn->pScreen, &pPort->clip, clipBoxes); DEBUG((VERBLEV, "FillKey\n")); xf86XVFillKeyHelper(pScrn->pScreen, pPort->Attribute[XV_COLORKEY], clipBoxes); @@ -1316,16 +1376,16 @@ SMI_PutVideo( #if 0 SMI_WaitForSync(pScrn); #endif - /* Video Window I Left and Top Boundaries */ + /* Video Window I Left and Top Boundaries */ WRITE_VPR(pSmi, 0x14, dstBox.x1 + (dstBox.y1 << 16)); - /* Video Window I Right and Bottom Boundaries */ + /* Video Window I Right and Bottom Boundaries */ WRITE_VPR(pSmi, 0x18, dstBox.x2 + (dstBox.y2 << 16)); - /* Video Window I Source Width and Offset */ + /* Video Window I Source Width and Offset */ WRITE_VPR(pSmi, 0x20, (vid_pitch / 8) + ((vid_pitch / 8) << 16)); - /* Video Window I Stretch Factor */ + /* Video Window I Stretch Factor */ WRITE_VPR(pSmi, 0x24, (xscale << 8) + yscale); - if (pPort->Attribute[XV_INTERLACED]) { + if (pPort->Attribute[XV_INTERLACED]) { /* Video Window II Left and Top Boundaries */ WRITE_VPR(pSmi, 0x28, dstBox.x1 + (dstBox.y1 << 16)); /* Video Window II Right and Bottom Boundaries */ @@ -1344,7 +1404,7 @@ SMI_PutVideo( WRITE_VPR(pSmi, 0x48, vid_address / 8); /* Video Window II Source Start Address */ WRITE_VPR(pSmi, 0x4C, vid_address / 8 + vid_pitch / 8); - + /* Video Source Clipping Control */ WRITE_CPR(pSmi, 0x04, left + ((top/2) << 16)); /* Video Source Capture Size Control */ @@ -1355,8 +1415,8 @@ SMI_PutVideo( WRITE_CPR(pSmi, 0x10, vid_address / 8 + vid_pitch / 8); /* Capture Port Source Offset Address */ WRITE_CPR(pSmi, 0x14, 2*(vid_pitch / 8) + ((2*(vid_pitch / 8)) << 16)); - } - else { + } + else { /* Video Source Clipping Control */ WRITE_CPR(pSmi, 0x04, left + (top << 16)); /* Video Source Capture Size Control */ @@ -1367,14 +1427,14 @@ SMI_PutVideo( WRITE_CPR(pSmi, 0x10, vid_address / 8); /* Capture Port Source Offset Address */ WRITE_CPR(pSmi, 0x14, (vid_pitch / 8) + ((vid_pitch / 8) << 16)); - } + } WRITE_CPR(pSmi, 0x00, cpr00); WRITE_VPR(pSmi, 0x00, vpr00); - pPort->videoStatus = CLIENT_VIDEO_ON; - DEBUG((VERBLEV, "SMI_PutVideo success\n")); - LEAVE_PROC("SMI_PutVideo"); + pPort->videoStatus = CLIENT_VIDEO_ON; + DEBUG((VERBLEV, "SMI_PutVideo success\n")); + LEAVE_PROC("SMI_PutVideo"); return(Success); } #endif @@ -1402,12 +1462,16 @@ SMI_StopVideo( { WRITE_FPR(pSmi, FPR00, READ_FPR(pSmi, 0x00) & ~(FPR00_VWIENABLE)); } + else if (pSmi->Chipset == SMI_MSOC) + { + WRITE_DCR(pSmi, DCR40, READ_DCR(pSmi, DCR40) & ~0x00000004); + } else { WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x01000008); } #if SMI_USE_CAPTURE - if (pSmi->Chipset != SMI_COUGAR3DR) + if ((pSmi->Chipset != SMI_COUGAR3DR) && (pSmi->Chipset != SMI_MSOC)) { WRITE_CPR(pSmi, 0x00, READ_CPR(pSmi, 0x00) & ~0x00000001); WRITE_VPR(pSmi, 0x54, READ_VPR(pSmi, 0x54) & ~0x00F00000); @@ -1415,20 +1479,20 @@ SMI_StopVideo( /* #864 OUT_SEQ(pSmi, 0x21, IN_SEQ(pSmi, 0x21) | 0x04); */ #endif } - if (pPort->area != NULL) + if (pPort->area != NULL) { - xf86FreeOffscreenArea(pPort->area); - pPort->area = NULL; + xf86FreeOffscreenArea(pPort->area); + pPort->area = NULL; } - pPort->videoStatus = 0; - /* pPort->i2cDevice = 0;aaa*/ + pPort->videoStatus = 0; + /* pPort->i2cDevice = 0;aaa*/ } else { - if (pPort->videoStatus & CLIENT_VIDEO_ON) + if (pPort->videoStatus & CLIENT_VIDEO_ON) { - pPort->videoStatus |= OFF_TIMER; - pPort->offTime = currentTime.milliseconds + OFF_DELAY; + pPort->videoStatus |= OFF_TIMER; + pPort->offTime = currentTime.milliseconds + OFF_DELAY; } } @@ -1444,16 +1508,16 @@ SMI_SetPortAttribute( pointer data ) { - int res; - SMI_PortPtr pPort = (SMI_PortPtr) data; + int res; + SMI_PortPtr pPort = (SMI_PortPtr) data; SMIPtr pSmi = SMIPTR(pScrn); ENTER_PROC("SMI_SetPortAttribute"); - if (attribute == xvColorKey) { + if (attribute == xvColorKey) { int r, g, b; - pPort->Attribute[XV_COLORKEY] = value; + pPort->Attribute[XV_COLORKEY] = value; switch (pScrn->depth) { case 8: @@ -1475,34 +1539,34 @@ SMI_SetPortAttribute( } res = Success; } - else if (attribute == xvInterlaced) { - pPort->Attribute[XV_INTERLACED] = (value != 0); + else if (attribute == xvInterlaced) { + pPort->Attribute[XV_INTERLACED] = (value != 0); res = Success; } - else if (attribute == xvEncoding) { - res = SetAttr(pScrn, XV_ENCODING, value); + else if (attribute == xvEncoding) { + res = SetAttr(pScrn, XV_ENCODING, value); + } + else if (attribute == xvBrightness) { + res = SetAttr(pScrn, XV_BRIGHTNESS, value); + } + else if (attribute == xvCapBrightness) { + res = SetAttr(pScrn, XV_CAPTURE_BRIGHTNESS, value); + } + else if (attribute == xvContrast) { + res = SetAttr(pScrn, XV_CONTRAST, value); + } + else if (attribute == xvSaturation) { + res = SetAttr(pScrn, XV_SATURATION, value); + } + else if (attribute == xvHue) { + res = SetAttr(pScrn, XV_HUE, value); } - else if (attribute == xvBrightness) { - res = SetAttr(pScrn, XV_BRIGHTNESS, value); - } - else if (attribute == xvCapBrightness) { - res = SetAttr(pScrn, XV_CAPTURE_BRIGHTNESS, value); - } - else if (attribute == xvContrast) { - res = SetAttr(pScrn, XV_CONTRAST, value); - } - else if (attribute == xvSaturation) { - res = SetAttr(pScrn, XV_SATURATION, value); - } - else if (attribute == xvHue) { - res = SetAttr(pScrn, XV_HUE, value); - } - else { - res = BadMatch; + else { + res = BadMatch; } LEAVE_PROC("SMI_SetPortAttribute"); - return(res); + return(res); } @@ -1514,23 +1578,23 @@ SMI_GetPortAttribute( pointer data ) { - SMI_PortPtr pPort = (SMI_PortPtr) data; + SMI_PortPtr pPort = (SMI_PortPtr) data; ENTER_PROC("SMI_GetPortAttribute"); - if (attribute == xvEncoding) - *value = pPort->Attribute[XV_ENCODING]; - else if (attribute == xvBrightness) - *value = pPort->Attribute[XV_BRIGHTNESS]; - else if (attribute == xvCapBrightness) - *value = pPort->Attribute[XV_CAPTURE_BRIGHTNESS]; - else if (attribute == xvContrast) - *value = pPort->Attribute[XV_CONTRAST]; - else if (attribute == xvSaturation) - *value = pPort->Attribute[XV_SATURATION]; - else if (attribute == xvHue) - *value = pPort->Attribute[XV_HUE]; - else if (attribute == xvColorKey) - *value = pPort->Attribute[XV_COLORKEY]; + if (attribute == xvEncoding) + *value = pPort->Attribute[XV_ENCODING]; + else if (attribute == xvBrightness) + *value = pPort->Attribute[XV_BRIGHTNESS]; + else if (attribute == xvCapBrightness) + *value = pPort->Attribute[XV_CAPTURE_BRIGHTNESS]; + else if (attribute == xvContrast) + *value = pPort->Attribute[XV_CONTRAST]; + else if (attribute == xvSaturation) + *value = pPort->Attribute[XV_SATURATION]; + else if (attribute == xvHue) + *value = pPort->Attribute[XV_HUE]; + else if (attribute == xvColorKey) + *value = pPort->Attribute[XV_COLORKEY]; else { @@ -1588,7 +1652,7 @@ SMI_PutImage( ) { SMIPtr pSmi = SMIPTR(pScrn); - SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; + SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; INT32 x1, y1, x2, y2; int bpp = 0; int fbPitch, srcPitch, srcPitch2 = 0, dstPitch, areaHeight; @@ -1671,8 +1735,8 @@ SMI_PutImage( } areaHeight = ((dstPitch * height) + fbPitch - 1) / fbPitch; - pPort->area = SMI_AllocateMemory(pScrn, pPort->area, areaHeight); - if (pPort->area == NULL) + pPort->area = SMI_AllocateMemory(pScrn, pPort->area, areaHeight); + if (pPort->area == NULL) { LEAVE_PROC("SMI_PutImage"); return(BadAlloc); @@ -1683,12 +1747,12 @@ SMI_PutImage( nPixels = ((((x2 + 0xFFFF) >> 16) + 1) & ~1) - left; left *= bpp; - offset = (pPort->area->box.y1 * fbPitch) + (top * dstPitch); + offset = (pPort->area->box.y1 * fbPitch) + (top * dstPitch); dstStart = pSmi->FBBase + offset + left; switch(id) { - case FOURCC_YV12: - case FOURCC_I420: + case FOURCC_YV12: + case FOURCC_I420: top &= ~1; tmp = ((top >> 1) * srcPitch2) + (left >> 2); offset2 += tmp; @@ -1699,41 +1763,60 @@ SMI_PutImage( offset3 = tmp; } nLines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; - xf86XVCopyYUV12ToPacked(buf + (top * srcPitch) + (left >> 1), + xf86XVCopyYUV12ToPacked(buf + (top * srcPitch) + (left >> 1), buf + offset2, buf + offset3, dstStart, srcPitch, srcPitch2, dstPitch, nLines, nPixels); break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: + case FOURCC_UYVY: + case FOURCC_YUY2: + default: buf += (top * srcPitch) + left; nLines = ((y2 + 0xffff) >> 16) - top; xf86XVCopyPacked(buf, dstStart, srcPitch, dstPitch, nLines, nPixels); - break; - } + break; + } + if (pSmi->Chipset != SMI_MSOC) + { #if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) - if (!RegionsEqual(&pPort->clip, clipBoxes)) + if (!RegionsEqual(&pPort->clip, clipBoxes)) #else - if (!REGION_EQUAL(pScrn->pScreen, &pPort->clip, clipBoxes)) + if (!REGION_EQUAL(pScrn->pScreen, &pPort->clip, clipBoxes)) #endif + { + REGION_COPY(pScrn->pScreen, &pPort->clip, clipBoxes); + xf86XVFillKeyHelper(pScrn->pScreen, pPort->Attribute[XV_COLORKEY], + clipBoxes); + } + } + else { - REGION_COPY(pScrn->pScreen, &pPort->clip, clipBoxes); - xf86XVFillKeyHelper(pScrn->pScreen, pPort->Attribute[XV_COLORKEY], - clipBoxes); + REGION_COPY(pScrn->pScreen, &pPort->clip, clipBoxes); + xf86XVFillKeyHelper(pScrn->pScreen, pPort->Attribute[XV_COLORKEY], + clipBoxes); } - if (pSmi->Chipset != SMI_COUGAR3DR) - SMI_DisplayVideo(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2, + + if (pSmi->Chipset == SMI_COUGAR3DR) + { + SMI_DisplayVideo0730(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2, + &dstBox, src_w, src_h, drw_w, drw_h); + } + else if (pSmi->Chipset == SMI_MSOC) + { + SMI_DisplayVideo0501(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h); + } else - SMI_DisplayVideo0730(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2, + { + SMI_DisplayVideo(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h); + } - pPort->videoStatus = CLIENT_VIDEO_ON; + pPort->videoStatus = CLIENT_VIDEO_ON; LEAVE_PROC("SMI_PutImage"); return(Success); - + } @@ -1834,7 +1917,7 @@ SMI_QueryImageAttributes( /******************************************************************************\ ** ** -** S U P P O R T F U N C T I O N S ** +** S U P P O R T F U N C T I O N S ** ** ** \******************************************************************************/ #if 0 @@ -1866,14 +1949,14 @@ SMI_ClipVideo( INT32 height ) { - ScreenPtr pScreen = pScrn->pScreen; - INT32 vscale, hscale; + ScreenPtr pScreen = pScrn->pScreen; + INT32 vscale, hscale; BoxPtr extents = REGION_EXTENTS(pScreen, reg); int diff; ENTER_PROC("SMI_ClipVideo"); - DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); + DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); /* PDR#941 */ extents->x1 = max(extents->x1, pScrn->frameX0); extents->y1 = max(extents->y1, pScrn->frameY0); @@ -1884,7 +1967,7 @@ SMI_ClipVideo( *x1 <<= 16; *y1 <<= 16; *x2 <<= 16; *y2 <<= 16; - DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); + DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); diff = extents->x1 - dst->x1; if (diff > 0) @@ -1914,7 +1997,7 @@ SMI_ClipVideo( *y2 -= diff * vscale; } - DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); + DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); if (*x1 < 0) { @@ -1930,7 +2013,7 @@ SMI_ClipVideo( *y1 += diff * vscale; } - DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); + DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); #if 0 /* aaa was macht dieser code? */ delta = *x2 - (width << 16); @@ -1950,7 +2033,7 @@ SMI_ClipVideo( } #endif - DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); + DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); if ((*x1 >= *x2) || (*y1 >= *y2)) { @@ -1968,7 +2051,7 @@ SMI_ClipVideo( REGION_UNINIT(pScreen, &clipReg); } - DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); + DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); LEAVE_PROC("SMI_ClipVideo"); return(TRUE); @@ -2026,7 +2109,6 @@ SMI_DisplayVideo( break; } - if (drw_w > vid_w) { hstretch = (2560 * vid_w / drw_w + 5) / 10; @@ -2055,9 +2137,114 @@ SMI_DisplayVideo( WRITE_VPR(pSmi, 0x20, (pitch >> 3) | ((pitch >> 3) << 16)); WRITE_VPR(pSmi, 0x24, (hstretch << 8) | vstretch); + vpr00 = READ_VPR(pSmi, 0x00); + LEAVE_PROC("SMI_DisplayVideo"); } + +static void +SMI_DisplayVideo0501( + ScrnInfoPtr pScrn, + int id, + int offset, + short width, + short height, + int pitch, + int x1, + int y1, + int x2, + int y2, + BoxPtr dstBox, + short vid_w, + short vid_h, + short drw_w, + short drw_h +) +{ + SMIPtr pSmi = SMIPTR(pScrn); + CARD32 dcr40; + int hstretch, vstretch; + + ENTER_PROC("SMI_DisplayVideo0501"); + + dcr40 = READ_DCR(pSmi, DCR40) & ~0x00003FFF; + + switch (id) + { + case FOURCC_YV12: + case FOURCC_I420: + case FOURCC_YUY2: + dcr40 |= 0x3; + break; + + case FOURCC_RV16: + dcr40 |= 0x1; + break; + + case FOURCC_RV32: + dcr40 |= 0x2; + break; + } + + + if (drw_w > vid_w) /* Horizontal Stretch */ + { + hstretch = ((40960 * vid_w / drw_w + 5) / 10); + dcr40 |= 1 << 8; + } + else /* Horizontal Shrink */ + { + hstretch = ((40960 * drw_w / vid_w + 5) / 10) | 0x8000; + } + + if (drw_h > vid_h) /* Vertical Stretch */ + { + vstretch = ((40960 * vid_h / drw_h + 5) / 10); + dcr40 |= 1 << 9; + } + else /* Vertical Shrink */ + { + vstretch = ((40960 * drw_h / vid_h + 5) / 10) | 0x8000; + } +#if 0 + SMI_WaitForSync(pScrn); +#endif + + /* Set Color Key Enable bit */ + WRITE_DCR(pSmi, DCR00, READ_DCR(pSmi, DCR00) | (1 << 9)); + + WRITE_DCR(pSmi, DCR40, dcr40 | (1 << 2)); + WRITE_DCR(pSmi, DCR50, (dstBox->x1) | (dstBox->y1 << 16)); + WRITE_DCR(pSmi, DCR54, (dstBox->x2) | (dstBox->y2 << 16)); + WRITE_DCR(pSmi, DCR44, offset); + WRITE_DCR(pSmi, DCR48, (pitch) | ((pitch) << 16)); + WRITE_DCR(pSmi, DCR4C, (offset + (pitch * height))) ; + WRITE_DCR(pSmi, DCR58, (vstretch << 16) | hstretch); + WRITE_DCR(pSmi, DCR5C, 0x00000000); + WRITE_DCR(pSmi, DCR60, 0x00EDEDED); + + /* + ErrorF("SMI 510 Video Debug Parameters\n"); + ErrorF("offset = %8X, pitch = %8X, width = %8X, height = %8X\n", offset, pitch, width, height); + ErrorF("drw_w = %8X, vid_w = %8X, drw_h = %8X, vid_h = %8X\n", drw_w, vid_w, drw_h, vid_h); + ErrorF("dstBox x1 = %8X, y1 = %8X, x2 = %8X, y2 = %8X\n", dstBox->x1, dstBox->y1, dstBox->x2, dstBox->y2); + ErrorF("DCR40 = %8X\n", READ_DCR(pSmi, DCR40)); + ErrorF("DCR50 = %8X\n", READ_DCR(pSmi, DCR50)); + ErrorF("DCR54 = %8X\n", READ_DCR(pSmi, DCR54)); + ErrorF("DCR44 = %8X\n", READ_DCR(pSmi, DCR44)); + ErrorF("DCR48 = %8X\n", READ_DCR(pSmi, DCR48)); + ErrorF("DCR4C = %8X\n", READ_DCR(pSmi, DCR4C)); + ErrorF("DCR58 = %8X\n", READ_DCR(pSmi, DCR58)); + ErrorF("DCR5C = %8X\n", READ_DCR(pSmi, DCR5C)); + */ + + LEAVE_PROC("SMI_DisplayVideo0501"); +} + + + + static void SMI_DisplayVideo0730( ScrnInfoPtr pScrn, @@ -2129,15 +2316,15 @@ SMI_DisplayVideo0730( { vstretch = 0; } - + WRITE_FPR(pSmi, FPR00, fpr00 | FPR00_VWIENABLE | FPR00_VWIKEYENABLE); WRITE_FPR(pSmi, FPR14, (dstBox->x1) | (dstBox->y1 << 16)); WRITE_FPR(pSmi, FPR18, (dstBox->x2) | (dstBox->y2 << 16)); WRITE_FPR(pSmi, FPR1C, offset >> 3); WRITE_FPR(pSmi, FPR20, (pitch >> 3) | ((pitch >> 3) << 16)); - WRITE_FPR(pSmi, FPR24, (hstretch & 0xFF00) | ((vstretch & 0xFF00)>>8)); - WRITE_FPR(pSmi, FPR68, ((hstretch & 0x00FF)<<8) | (vstretch & 0x00FF)); + WRITE_FPR(pSmi, FPR24, (hstretch & 0xFF00) | ((vstretch & 0xFF00)>>8)); + WRITE_FPR(pSmi, FPR68, ((hstretch & 0x00FF)<<8) | (vstretch & 0x00FF)); LEAVE_PROC("SMI_DisplayVideo0730"); } @@ -2152,40 +2339,44 @@ SMI_BlockHandler( { ScreenPtr pScreen = screenInfo.screens[i]; ScrnInfoPtr pScrn = xf86Screens[i]; - SMIPtr pSmi = SMIPTR(pScrn); - SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; + SMIPtr pSmi = SMIPTR(pScrn); + SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; pScreen->BlockHandler = pSmi->BlockHandler; (*pScreen->BlockHandler)(i, blockData, pTimeout, pReadMask); pScreen->BlockHandler = SMI_BlockHandler; - if (pPort->videoStatus & TIMER_MASK) + if (pPort->videoStatus & TIMER_MASK) { UpdateCurrentTime(); - if (pPort->videoStatus & OFF_TIMER) + if (pPort->videoStatus & OFF_TIMER) { - if (pPort->offTime < currentTime.milliseconds) + if (pPort->offTime < currentTime.milliseconds) { if (pSmi->Chipset == SMI_COUGAR3DR) { WRITE_FPR(pSmi, FPR00, READ_FPR(pSmi, 0x00) & ~(FPR00_VWIENABLE)); } + else if (pSmi->Chipset == SMI_MSOC) + { + WRITE_DCR(pSmi, DCR40, READ_DCR(pSmi, DCR40) & ~0x00000004); + } else { WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x00000008); } - pPort->videoStatus = FREE_TIMER; - pPort->freeTime = currentTime.milliseconds + FREE_DELAY; + pPort->videoStatus = FREE_TIMER; + pPort->freeTime = currentTime.milliseconds + FREE_DELAY; } } else { - if (pPort->freeTime < currentTime.milliseconds) + if (pPort->freeTime < currentTime.milliseconds) { - xf86FreeOffscreenArea(pPort->area); - pPort->area = NULL; + xf86FreeOffscreenArea(pPort->area); + pPort->area = NULL; } - pPort->videoStatus = 0; + pPort->videoStatus = 0; } } } @@ -2246,7 +2437,7 @@ SMI_SendI2C( /******************************************************************************\ ** ** -** O F F S C R E E N M E M O R Y M A N A G E R ** +** O F F S C R E E N M E M O R Y M A N A G E R ** ** ** \******************************************************************************/ @@ -2281,12 +2472,12 @@ SMI_InitOffscreenImages( offscreenImages->max_width = pSmi->lcdWidth; offscreenImages->max_height = pSmi->lcdHeight; if (!pPort->I2CDev.SlaveAddr) { - offscreenImages->num_attributes = nElems(SMI_VideoAttributes); - offscreenImages->attributes = SMI_VideoAttributes; + offscreenImages->num_attributes = nElems(SMI_VideoAttributes); + offscreenImages->attributes = SMI_VideoAttributes; } else { - offscreenImages->num_attributes = + offscreenImages->num_attributes = nElems(SMI_VideoAttributesSAA711x); - offscreenImages->attributes = SMI_VideoAttributesSAA711x; + offscreenImages->attributes = SMI_VideoAttributesSAA711x; } xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1); @@ -2308,13 +2499,13 @@ SMI_AllocateMemory( { if ((area->box.y2 - area->box.y1) >= numLines) { - LEAVE_PROC("SMI_AllocateMemory (area->box.y2 - area->box.y1) >= numLines ok"); + LEAVE_PROC("SMI_AllocateMemory (area->box.y2 - area->box.y1) >= numLines ok"); return(area); } if (xf86ResizeOffscreenArea(area, pScrn->displayWidth, numLines)) { - LEAVE_PROC("SMI_AllocateMemory xf86ResizeOffscreenArea ok"); + LEAVE_PROC("SMI_AllocateMemory xf86ResizeOffscreenArea ok"); return(area); } @@ -2332,10 +2523,10 @@ SMI_AllocateMemory( FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME); DEBUG((VERBLEV, "QueryLargestOffscreenArea maxW=%d maxH=%d displayWidth=%d numlines=%d\n", - maxW, maxH, pScrn->displayWidth, numLines)); + maxW, maxH, pScrn->displayWidth, numLines)); if ((maxW < pScrn->displayWidth) || (maxH < numLines)) { - LEAVE_PROC("SMI_AllocateMemory (maxW < pScrn->displayWidth) || (maxH < numLines)"); + LEAVE_PROC("SMI_AllocateMemory (maxW < pScrn->displayWidth) || (maxH < numLines)"); return(NULL); } @@ -2344,7 +2535,7 @@ SMI_AllocateMemory( 0, NULL, NULL, NULL); } - DEBUG((VERBLEV, "area = %p\n", area)); + DEBUG((VERBLEV, "area = %p\n", area)); LEAVE_PROC("SMI_AllocateMemory"); return(area); } @@ -2494,7 +2685,7 @@ SMI_DisplaySurface( { SMI_OffscreenPtr ptrOffscreen = (SMI_OffscreenPtr) surface->devPrivate.ptr; SMIPtr pSmi = SMIPTR(surface->pScrn); - SMI_PortPtr pPort = pSmi->ptrAdaptor->pPortPrivates[0].ptr; + SMI_PortPtr pPort = pSmi->ptrAdaptor->pPortPrivates[0].ptr; INT32 x1, y1, x2, y2; BoxRec dstBox; @@ -2523,30 +2714,37 @@ SMI_DisplaySurface( dstBox.y2 -= surface->pScrn->frameY0; xf86XVFillKeyHelper(surface->pScrn->pScreen, - pPort->Attribute[XV_COLORKEY], clipBoxes); + pPort->Attribute[XV_COLORKEY], clipBoxes); - if (pSmi->Chipset != SMI_COUGAR3DR) + if (pSmi->Chipset == SMI_COUGAR3DR) { SMI_ResetVideo(surface->pScrn); - SMI_DisplayVideo(surface->pScrn, surface->id, surface->offsets[0], + SMI_DisplayVideo0730(surface->pScrn, surface->id, surface->offsets[0], + surface->width, surface->height, surface->pitches[0], x1, y1, x2, + y2, &dstBox, vid_w, vid_h, drw_w, drw_h); + } + else if (pSmi->Chipset == SMI_MSOC) + { + SMI_ResetVideo(surface->pScrn); + SMI_DisplayVideo0501(surface->pScrn, surface->id, surface->offsets[0], surface->width, surface->height, surface->pitches[0], x1, y1, x2, y2, &dstBox, vid_w, vid_h, drw_w, drw_h); } else { SMI_ResetVideo(surface->pScrn); - SMI_DisplayVideo0730(surface->pScrn, surface->id, surface->offsets[0], + SMI_DisplayVideo(surface->pScrn, surface->id, surface->offsets[0], surface->width, surface->height, surface->pitches[0], x1, y1, x2, y2, &dstBox, vid_w, vid_h, drw_w, drw_h); } ptrOffscreen->isOn = TRUE; - if (pPort->videoStatus & CLIENT_VIDEO_ON) + if (pPort->videoStatus & CLIENT_VIDEO_ON) { - REGION_EMPTY(surface->pScrn->pScreen, &pPort->clip); + REGION_EMPTY(surface->pScrn->pScreen, &pPort->clip); UpdateCurrentTime(); - pPort->videoStatus = FREE_TIMER; - pPort->freeTime = currentTime.milliseconds + FREE_DELAY; + pPort->videoStatus = FREE_TIMER; + pPort->freeTime = currentTime.milliseconds + FREE_DELAY; } LEAVE_PROC("SMI_DisplaySurface"); @@ -2614,6 +2812,16 @@ SetKeyReg(SMIPtr pSmi, int reg, int valu { WRITE_FPR(pSmi, reg, value); } + else if (pSmi->Chipset == SMI_MSOC) + { + /* We don't change the color mask, and we don't do brightness. IF + * they write to the colorkey register, we'll write the value to the + * 501 colorkey register */ + if (reg == FPR04) /* Only act on colorkey value writes */ + { + WRITE_DCR(pSmi, DCR08, value); /* ColorKey register is DCR08 */ + } + } else { WRITE_VPR(pSmi, reg, value);