From b1bfcdcf99e0c47a19a6190a23bf52db02f64e84 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 14 Jan 2008 21:23:29 +0000 Subject: Merging the trunk changes made in r482, r484, r487, r490, r491, and r494-r501 into the randr branch. --- ChangeLog | 18 + configure.ac | 2 +- src/openchrome.man | 83 +-- src/via_accel.c | 1869 +++++++++++++++++++++++++--------------------------- src/via_driver.c | 137 ++-- src/via_driver.h | 2 +- src/via_id.c | 2 + src/via_mode.c | 4 +- 8 files changed, 1010 insertions(+), 1107 deletions(-) diff --git a/ChangeLog b/ChangeLog index a685a68..8d41081 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2008-01-11 Benno Schulenberg + + * src/openchrome.man: + * src/via_driver.c: (VIASetupDefaultOptions), (VIAPreInit): + + Removing the redundant HWCursor option. + +2008-01-10 Benno Schulenberg + + * src/openchrome.man: Tweaking the text, clarifying the effect + of an option, giving the default value. + +2008-01-08 Benno Schulenberg + + * src/via_accel.c: (viaBitExpandHelper), (viaPixelARGB8888): + + Moving a little more computation into the helper function. + 2007-12-11 Gabriel Mansi * src/via_accel.c: (viaInitAccel): diff --git a/configure.ac b/configure.ac index 43d4902..ab31cbd 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ AC_PREREQ(2.57) AC_INIT([xf86-video-openchrome], - 0.2.900, + 0.2.901, [https://www.openchrome.org/trac/report], xf86-video-openchrome) diff --git a/src/openchrome.man b/src/openchrome.man index 8191b53..1204ae3 100644 --- a/src/openchrome.man +++ b/src/openchrome.man @@ -35,8 +35,8 @@ The XvMC client library implements a non-standard "VLD" extension to the XvMC standard. The current Direct Rendering Manager (DRM) kernel module is available at dri.sourceforge.net. .PP -The driver supports free modes for Unichrome Pros (K8M/N800, PM/N800, and -CN400). For plain Unichromes (CLE266, KM/N400), it currently supports +The driver supports free modes for Unichrome Pros (K8M800/K8N800, PM800/PN800, +and CN400). For plain Unichromes (CLE266, KM400/KN400), it currently supports only a limited number of dotclocks, so if you are using X modelines you must make sure that the dotclock is one of those supported. Supported dotclocks on plain Unichromes are currently (in MHz): 25.2, 25.312, @@ -73,41 +73,42 @@ to use LCD and TV simultaneously, and will favour the LCD. .BI "Option \*qAGPMem\*q \*q" integer \*q Sets the amount of AGP memory that is allocated at X server startup. The allocated memory will be "integer" kB. This AGP memory is used for -the AGP command buffer (if option "EnableAGPDMA" is set to "true"), for +the AGP command buffer (if the option "EnableAGPDMA" is set to "true"), for DRI textures, and for the EXA scratch area. The driver will allocate at -least one system page of AGP memory and, if the AGP command buffer is -used, at least 2MB + one system page. If there is no room for the EXA -scratch area in AGP space, it will be allocated from VRAM. If there is +least one system page of AGP memory, or \-\- if the AGP command buffer is +used \-\- at least 2 MB plus one system page. If there is no room for the +EXA scratch area in AGP space, it will be allocated from VRAM. If there is no room for DRI textures, they will be allocated from the DRI part of VRAM (see the option "MaxDRIMem"). The default amount of AGP is -32768kB. Note that the AGP aperture set in the BIOS must be able +32768 kB. Note that the AGP aperture set in the BIOS must be able to accomodate the amount of AGP memory specified here. Otherwise no AGP memory will be available. It is safe to set a very large AGP aperture in the BIOS. .TP .BI "Option \*qCenter\*q \*q" boolean \*q -Enables or disables image centering on DVI displays. +Enables image centering on DVI displays. The default is disabled. .TP .BI "Option \*qDisableIRQ\*q \*q" boolean \*q -Disables the Vblank IRQ. This is a workaround for some mainboards that -have problems with IRQs from the Unichrome engine. With IRQs disabled, -DRI clients have no way to synchronize drawing to Vblank. (This option -is enabled by default on the KM400 and K8M800 chipsets.) +Disables the vertical blank IRQ. This is a workaround for some mainboards +that have problems with IRQs coming from the Unichrome engine. With IRQs +disabled, DRI clients have no way to synchronize their drawing to Vblank. +(IRQ is disabled by default on the KM400 and K8M800 chipsets.) .TP .BI "Option \*qDisableVQ\*q \*q" boolean \*q -Disables the use of VQ. VQ is enabled by default. +Disables the use of the virtual command queue. The queue is enabled +by default. .TP .BI "Option \*qEnableAGPDMA\*q \*q" boolean \*q Enables the AGP DMA functionality in DRM. This requires that DRI is enabled -and will force 2D and 3D acceleration to use AGP DMA. The XvMC DRI client -will also make use of this on the CLE266 to consume much less CPU. (This -option is enabled by default on all chipsets except the K8M890 and P4M900.) +and will force 2D and 3D acceleration to use AGP DMA. The XvMC DRI +client will also make use of this on the CLE266 to consume much less CPU. +(This option is enabled by default, except on the K8M890 and P4M900.) .TP .BI "Option \*qExaNoComposite\*q \*q" boolean \*q If EXA is enabled (using the option "AccelMethod"), this option enables -or disables acceleration of compositing. Since EXA, and in particular its -composite acceleration, is still experimental, this is a way to disable -a misbehaving composite acceleration. +acceleration of compositing. Since EXA, and in particular its composite +acceleration, is still experimental, this is a way to disable a misbehaving +composite acceleration. .TP .BI "Option \*qExaScratchSize\*q \*q" integer \*q Sets the size of the EXA scratch area to "integer" kB. This area is @@ -118,11 +119,8 @@ over 1024 pixels and use 24 bpp, set this to 8192. Otherwise you can leave this at the default 4096. The space will be allocated from AGP memory if available, otherwise from VRAM. .TP -.BI "Option \*qHWCursor\*q \*q" boolean \*q -Enables or disables the use of hardware cursors. The default is enabled. -.TP .BI "Option \*qLCDDualEdge\*q \*q" boolean \*q -Enables or disables the use of dual-edge mode to set the LCD. +Enables the use of dual-edge mode to set the LCD. The default is disabled. .TP .BI "Option \*qMaxDRIMem\*q \*q" integer \*q Sets the maximum amount of VRAM memory allocated for DRI clients to @@ -133,17 +131,18 @@ as possible to the EXA pixmap storage area. .TP .BI "Option \*qMigrationHeuristic\*q \*q" string \*q Sets the heuristic for EXA pixmap migration. This is an EXA core -option, and on Xorg xserver versions after 1.1.0 this defaults to -"smart". The Openchrome driver performs best with "greedy", so you +option, and on Xorg server versions after 1.1.0 this defaults to +"smart". The openchrome driver performs best with "greedy", so you should really add this option to your configuration file. The third possibility is "always", which might become more useful in the future. .TP .BI "Option \*qNoAccel\*q \*q" boolean \*q -Disables or enables acceleration. Default: acceleration is enabled. +Disables the use of hardware acceleration. Acceleration is enabled +by default. .TP .BI "Option \*qNoAGPFor2D\*q \*q" boolean \*q -With this option set, 2D acceleration will not use AGP DMA even if -it is enabled. +Disables the use of AGP DMA for 2D acceleration, even when AGP DMA is +enabled. The default is enabled. .TP .BI "Option \*qNoXVDMA\*q \*q" boolean \*q If DRI is enabled, Xv normally uses PCI DMA to transfer video images @@ -165,23 +164,25 @@ Rotates the display either clockwise ("CW") or counterclockwise ("CCW"). Rotation is only supported unaccelerated. .TP .BI "Option \*qShadowFB\*q \*q" boolean \*q -Uses a shadow frame buffer. This is required when rotating the display, -but otherwise defaults to disabled. +Enables the use of a shadow frame buffer. This is required when +rotating the display, but otherwise defaults to disabled. .TP .BI "Option \*qSWCursor\*q \*q" boolean \*q -Enables or disables the use of a software cursor. The default is disabled. +Enables the use of a software cursor. The default is disabled: +the hardware cursor is used. .TP .BI "Option \*qTVDeflicker\*q \*q" integer \*q Specifies the deflicker setting for TV output. Valid values are "0", "1", -and "2". 0) No deflicker, 1) 1:1:1 deflicker, 2) 1:2:1 deflicker. +and "2". Here 0 means no deflicker, 1 means 1:1:1 deflicker, and 2 means +1:2:1 deflicker. .TP .BI "Option \*qTVDotCrawl\*q \*q" boolean \*q -Enables or disables dotcrawl. +Enables dot-crawl suppression. The default is disabled. .TP .BI "Option \*qTVOutput\*q \*q" string \*q Specifies which TV output to use. The driver supports "S-Video", -"Composite", "SC", "RGB" and "YCbCr" outputs. Note that on some -EPIA boards the compositer-video port is shared with audio-out and +"Composite", "SC", "RGB", and "YCbCr" outputs. Note that on some +EPIA boards the composite-video port is shared with audio-out and is selected via a jumper. .TP .BI "Option \*qTVType\*q \*q" string \*q @@ -189,19 +190,19 @@ Specifies TV output format. The driver currently supports "NTSC" and "PAL" timings only. .TP .BI "Option \*qVBEModes\*q \*q" boolean \*q -Uses the VBE BIOS calls to set the display mode. This mimics the -behaviour of the vesa video driver but still provides acceleration and +Enables the use of VBE BIOS calls for setting the display mode. This mimics +the behaviour of the vesa driver but still provides acceleration and other features. This option may be used if your hardware works with -the vesa driver but not with the Openchrome driver. It may not work +the vesa driver but not with the openchrome driver. It may not work on 64-bit systems. Using "VBEModes" may speed up driver acceleration significantly due to a more aggressive hardware setting, particularly on systems with low memory bandwidth. Your refresh rate may be limited to 60 Hz on some systems. .TP .BI "Option \*qVBESaveRestore\*q \*q" boolean \*q -Uses the VBE BIOS calls to save and restore the display state when the -X server is launched. This can be extremely slow on some hardware, and -the system may appear to have locked for 10 seconds or so. The default +Enables the use of VBE BIOS calls for saving and restoring the display state +when the X server is launched. This can be extremely slow on some hardware, +and the system may appear to have locked for 10 seconds or so. The default is to use the driver builtin function. This option only works if option "VBEModes" is enabled. .TP diff --git a/src/via_accel.c b/src/via_accel.c index 4aa49c2..c2122b4 100644 --- a/src/via_accel.c +++ b/src/via_accel.c @@ -1,7 +1,7 @@ /* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * Copyright 2006 Thomas Hellstrom. All Rights Reserved. + * Copyright 2006 Thomas Hellström. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -21,16 +21,13 @@ * 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. - * - * Mostly rewritten and modified for EXA support by Thomas Hellstrom 2005. */ -/************************************************************************* - * - * File: via_accel.c - * Content: 2D acceleration function for VIA/S3G UniChrome +/* + * 2D acceleration functions for the VIA/S3G UniChrome IGPs. * - ************************************************************************/ + * Mostly rewritten, and modified for EXA support, by Thomas Hellström. + */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -58,7 +55,6 @@ /* * Use PCI MMIO to flush the command buffer when AGP DMA is not available. */ - static void viaDumpDMA(ViaCommandBuffer * buf) { @@ -66,10 +62,10 @@ viaDumpDMA(ViaCommandBuffer * buf) CARD32 *endp = bp + buf->pos; while (bp != endp) { - if (((bp - buf->buf) & 3) == 0) { - ErrorF("\n %04lx: ", (unsigned long)(bp - buf->buf)); - } - ErrorF("0x%08x ", (unsigned)*bp++); + if (((bp - buf->buf) & 3) == 0) { + ErrorF("\n %04lx: ", (unsigned long)(bp - buf->buf)); + } + ErrorF("0x%08x ", (unsigned)*bp++); } ErrorF("\n"); } @@ -86,57 +82,57 @@ viaFlushPCI(ViaCommandBuffer * buf) VIAPtr pVia = VIAPTR(buf->pScrn); while (bp < endp) { - if (*bp == HALCYON_HEADER2) { - if (++bp == endp) - return; - VIASETREG(VIA_REG_TRANSET, transSetting = *bp++); - while (bp < endp) { - if ((transSetting != HC_ParaType_CmdVdata) && - ((*bp == HALCYON_HEADER2) - || (*bp & HALCYON_HEADER1MASK) == HALCYON_HEADER1)) - break; - VIASETREG(VIA_REG_TRANSPACE, *bp++); - } - } else if ((*bp & HALCYON_HEADER1MASK) == HALCYON_HEADER1) { - - while (bp < endp) { - if (*bp == HALCYON_HEADER2) - break; - if (offset == 0) { - /* - * Not doing this wait will probably stall the processor - * for an unacceptable amount of time in VIASETREG while - * other high priority interrupts may be pending. - */ - if (pVia->Chipset != VIA_P4M890 && pVia->Chipset != VIA_K8M890 && - pVia->Chipset != VIA_P4M900) { - while (!(VIAGETREG(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) - && (loop++ < MAXLOOP)) ; + if (*bp == HALCYON_HEADER2) { + if (++bp == endp) + return; + VIASETREG(VIA_REG_TRANSET, transSetting = *bp++); + while (bp < endp) { + if ((transSetting != HC_ParaType_CmdVdata) + && ((*bp == HALCYON_HEADER2) + || (*bp & HALCYON_HEADER1MASK) == HALCYON_HEADER1)) + break; + VIASETREG(VIA_REG_TRANSPACE, *bp++); + } + } else if ((*bp & HALCYON_HEADER1MASK) == HALCYON_HEADER1) { + + while (bp < endp) { + if (*bp == HALCYON_HEADER2) + break; + if (offset == 0) { + /* + * Not doing this wait will probably stall the processor + * for an unacceptable amount of time in VIASETREG while + * other high priority interrupts may be pending. + */ + if (pVia->Chipset != VIA_P4M890 && + pVia->Chipset != VIA_K8M890 && + pVia->Chipset != VIA_P4M900) { + while (!(VIAGETREG(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) + && (loop++ < MAXLOOP)) ; } - while ((VIAGETREG(VIA_REG_STATUS) & - (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY)) && - (loop++ < MAXLOOP)) ; - } - offset = (*bp++ & 0x0FFFFFFF) << 2; - value = *bp++; - VIASETREG(offset, value); - } - } else { - ErrorF("Command stream parser error.\n"); - } + while ((VIAGETREG(VIA_REG_STATUS) & + (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY)) + && (loop++ < MAXLOOP)) ; + } + offset = (*bp++ & 0x0FFFFFFF) << 2; + value = *bp++; + VIASETREG(offset, value); + } + } else { + ErrorF("Command stream parser error.\n"); + } } buf->pos = 0; buf->mode = 0; buf->has3dState = FALSE; } +#ifdef XF86DRI /* * Flush the command buffer using DRM. If in PCI mode, we can bypass DRM, - * but not for command buffers that contains 3D engine state, since then + * but not for command buffers that contain 3D engine state, since then * the DRM command verifier will lose track of the 3D engine state. */ - -#ifdef XF86DRI static void viaFlushDRIEnabled(ViaCommandBuffer * cb) { @@ -146,36 +142,33 @@ viaFlushDRIEnabled(ViaCommandBuffer * cb) int tmpSize; drm_via_cmdbuffer_t b; - /* - * Align command buffer end for AGP DMA. - */ - + /* Align end of command buffer for AGP DMA. */ OUT_RING_H1(0x2f8, 0x67676767); if (pVia->agpDMA && cb->mode == 2 && cb->rindex != HC_ParaType_CmdVdata - && (cb->pos & 1)) { - OUT_RING(HC_DUMMY); + && (cb->pos & 1)) { + OUT_RING(HC_DUMMY); } tmpSize = cb->pos * sizeof(CARD32); if (pVia->agpDMA || (pVia->directRenderingEnabled && cb->has3dState)) { - cb->mode = 0; - cb->has3dState = FALSE; - while (tmpSize > 0) { - b.size = (tmpSize > VIA_DMASIZE) ? VIA_DMASIZE : tmpSize; - tmpSize -= b.size; - b.buf = tmp; - tmp += b.size; - if (drmCommandWrite(pVia->drmFD, - ((pVia->agpDMA) ? DRM_VIA_CMDBUFFER : DRM_VIA_PCICMD), &b, - sizeof(b))) { - ErrorF("DRM command buffer submission failed.\n"); - viaDumpDMA(cb); - return; - } - } - cb->pos = 0; + cb->mode = 0; + cb->has3dState = FALSE; + while (tmpSize > 0) { + b.size = (tmpSize > VIA_DMASIZE) ? VIA_DMASIZE : tmpSize; + tmpSize -= b.size; + b.buf = tmp; + tmp += b.size; + if (drmCommandWrite(pVia->drmFD, ((pVia->agpDMA) + ? DRM_VIA_CMDBUFFER : + DRM_VIA_PCICMD), &b, sizeof(b))) { + ErrorF("DRM command buffer submission failed.\n"); + viaDumpDMA(cb); + return; + } + } + cb->pos = 0; } else { - viaFlushPCI(cb); + viaFlushPCI(cb); } } #endif @@ -184,7 +177,6 @@ viaFlushDRIEnabled(ViaCommandBuffer * cb) * Initialize a command buffer. Some fields are currently not used since they * are intended for Unichrome Pro group A video commands. */ - int viaSetupCBuffer(ScrnInfoPtr pScrn, ViaCommandBuffer * buf, unsigned size) { @@ -196,7 +188,7 @@ viaSetupCBuffer(ScrnInfoPtr pScrn, ViaCommandBuffer * buf, unsigned size) buf->bufSize = ((size == 0) ? VIA_DMASIZE : size) >> 2; buf->buf = (CARD32 *) xcalloc(buf->bufSize, sizeof(CARD32)); if (!buf->buf) - return BadAlloc; + return BadAlloc; buf->waitFlags = 0; buf->pos = 0; buf->mode = 0; @@ -206,7 +198,7 @@ viaSetupCBuffer(ScrnInfoPtr pScrn, ViaCommandBuffer * buf, unsigned size) buf->flushFunc = viaFlushPCI; #ifdef XF86DRI if (pVia->directRenderingEnabled) { - buf->flushFunc = viaFlushDRIEnabled; + buf->flushFunc = viaFlushDRIEnabled; } #endif return Success; @@ -215,12 +207,11 @@ viaSetupCBuffer(ScrnInfoPtr pScrn, ViaCommandBuffer * buf, unsigned size) /* * Free resources associated with a command buffer. */ - void viaTearDownCBuffer(ViaCommandBuffer * buf) { if (buf && buf->buf) - xfree(buf->buf); + xfree(buf->buf); buf->buf = NULL; } @@ -253,12 +244,11 @@ viaInitAgp(VIAPtr pVia) } /* - * Initialize the virtual command queue. Header 2 commands can be put - * in this queue for buffering. AFAIK it doesn't handle Header 1 + * Initialize the virtual command queue. Header-2 commands can be put + * in this queue for buffering. AFAIK it doesn't handle Header-1 * commands, which is really a pity, since it has to be idled before - * issuing a H1 command. + * issuing a Header-1 command. */ - static void viaEnableAgpVQ(VIAPtr pVia) { @@ -271,28 +261,27 @@ viaEnableAgpVQ(VIAPtr pVia) ((vqEndAddr & 0xFF000000) >> 16), vqLen = 0x53000000 | (VIA_VQ_SIZE >> 3); - - VIASETREG(VIA_REG_TRANSET, 0x00fe0000); - VIASETREG(VIA_REG_TRANSPACE, 0x080003fe); - VIASETREG(VIA_REG_TRANSPACE, 0x0a00027c); - VIASETREG(VIA_REG_TRANSPACE, 0x0b000260); - VIASETREG(VIA_REG_TRANSPACE, 0x0c000274); - VIASETREG(VIA_REG_TRANSPACE, 0x0d000264); - VIASETREG(VIA_REG_TRANSPACE, 0x0e000000); - VIASETREG(VIA_REG_TRANSPACE, 0x0f000020); - VIASETREG(VIA_REG_TRANSPACE, 0x1000027e); - VIASETREG(VIA_REG_TRANSPACE, 0x110002fe); - VIASETREG(VIA_REG_TRANSPACE, 0x200f0060); - VIASETREG(VIA_REG_TRANSPACE, 0x00000006); - VIASETREG(VIA_REG_TRANSPACE, 0x40008c0f); - VIASETREG(VIA_REG_TRANSPACE, 0x44000000); - VIASETREG(VIA_REG_TRANSPACE, 0x45080c04); - VIASETREG(VIA_REG_TRANSPACE, 0x46800408); - - VIASETREG(VIA_REG_TRANSPACE, vqStartEndH); - VIASETREG(VIA_REG_TRANSPACE, vqStartL); - VIASETREG(VIA_REG_TRANSPACE, vqEndL); - VIASETREG(VIA_REG_TRANSPACE, vqLen); + VIASETREG(VIA_REG_TRANSET, 0x00fe0000); + VIASETREG(VIA_REG_TRANSPACE, 0x080003fe); + VIASETREG(VIA_REG_TRANSPACE, 0x0a00027c); + VIASETREG(VIA_REG_TRANSPACE, 0x0b000260); + VIASETREG(VIA_REG_TRANSPACE, 0x0c000274); + VIASETREG(VIA_REG_TRANSPACE, 0x0d000264); + VIASETREG(VIA_REG_TRANSPACE, 0x0e000000); + VIASETREG(VIA_REG_TRANSPACE, 0x0f000020); + VIASETREG(VIA_REG_TRANSPACE, 0x1000027e); + VIASETREG(VIA_REG_TRANSPACE, 0x110002fe); + VIASETREG(VIA_REG_TRANSPACE, 0x200f0060); + VIASETREG(VIA_REG_TRANSPACE, 0x00000006); + VIASETREG(VIA_REG_TRANSPACE, 0x40008c0f); + VIASETREG(VIA_REG_TRANSPACE, 0x44000000); + VIASETREG(VIA_REG_TRANSPACE, 0x45080c04); + VIASETREG(VIA_REG_TRANSPACE, 0x46800408); + + VIASETREG(VIA_REG_TRANSPACE, vqStartEndH); + VIASETREG(VIA_REG_TRANSPACE, vqStartL); + VIASETREG(VIA_REG_TRANSPACE, vqEndL); + VIASETREG(VIA_REG_TRANSPACE, vqLen); } static void @@ -307,65 +296,62 @@ viaEnablePCIeVQ(VIAPtr pVia) ((vqEndAddr & 0xFF000000) >> 16), vqLen = 0x73000000 | (VIA_VQ_SIZE >> 3); - VIASETREG(0x41c, 0x00100000); - VIASETREG(0x420, vqStartEndH); - VIASETREG(0x420, vqStartL); - VIASETREG(0x420, vqEndL); - VIASETREG(0x420, vqLen); - VIASETREG(0x420, 0x74301001); - VIASETREG(0x420, 0x00000000); + VIASETREG(0x41c, 0x00100000); + VIASETREG(0x420, vqStartEndH); + VIASETREG(0x420, vqStartL); + VIASETREG(0x420, vqEndL); + VIASETREG(0x420, vqLen); + VIASETREG(0x420, 0x74301001); + VIASETREG(0x420, 0x00000000); } /* * Disable the virtual command queue. */ - void viaDisableVQ(ScrnInfoPtr pScrn) { VIAPtr pVia = VIAPTR(pScrn); - switch ( pVia->Chipset ) - { - case VIA_P4M890: - case VIA_K8M890: - VIASETREG(0x41c, 0x00100000); - VIASETREG(0x420, 0x74301000); - break; - default: - VIASETREG(VIA_REG_TRANSET, 0x00fe0000); - VIASETREG(VIA_REG_TRANSPACE, 0x00000004); - VIASETREG(VIA_REG_TRANSPACE, 0x40008c0f); - VIASETREG(VIA_REG_TRANSPACE, 0x44000000); - VIASETREG(VIA_REG_TRANSPACE, 0x45080c04); - VIASETREG(VIA_REG_TRANSPACE, 0x46800408); - break; - } + switch (pVia->Chipset) { + case VIA_P4M890: + case VIA_K8M890: + VIASETREG(0x41c, 0x00100000); + VIASETREG(0x420, 0x74301000); + break; + default: + VIASETREG(VIA_REG_TRANSET, 0x00fe0000); + VIASETREG(VIA_REG_TRANSPACE, 0x00000004); + VIASETREG(VIA_REG_TRANSPACE, 0x40008c0f); + VIASETREG(VIA_REG_TRANSPACE, 0x44000000); + VIASETREG(VIA_REG_TRANSPACE, 0x45080c04); + VIASETREG(VIA_REG_TRANSPACE, 0x46800408); + break; + } } /* * Update our 2D state (TwoDContext) with a new mode. */ - static Bool viaAccelSetMode(int bpp, ViaTwodContext * tdc) { switch (bpp) { - case 16: - tdc->mode = VIA_GEM_16bpp; - tdc->bytesPPShift = 1; - return TRUE; - case 32: - tdc->mode = VIA_GEM_32bpp; - tdc->bytesPPShift = 2; - return TRUE; - case 8: - tdc->mode = VIA_GEM_8bpp; - tdc->bytesPPShift = 0; - return TRUE; - default: - tdc->bytesPPShift = 0; - return FALSE; + case 16: + tdc->mode = VIA_GEM_16bpp; + tdc->bytesPPShift = 1; + return TRUE; + case 32: + tdc->mode = VIA_GEM_32bpp; + tdc->bytesPPShift = 2; + return TRUE; + case 8: + tdc->mode = VIA_GEM_8bpp; + tdc->bytesPPShift = 0; + return TRUE; + default: + tdc->bytesPPShift = 0; + return FALSE; } } @@ -373,7 +359,6 @@ viaAccelSetMode(int bpp, ViaTwodContext * tdc) * Initialize the 2D engine and set the 2D context mode to the * current screen depth. Also enable the virtual queue. */ - void viaInitialize2DEngine(ScrnInfoPtr pScrn) { @@ -381,34 +366,31 @@ viaInitialize2DEngine(ScrnInfoPtr pScrn) ViaTwodContext *tdc = &pVia->td; int i; - /* - * init 2D engine regs to reset 2D engine - */ - + /* Initialize the 2D engine registers to reset the 2D engine. */ for (i = 0x04; i < 0x44; i += 4) { - VIASETREG(i, 0x0); + VIASETREG(i, 0x0); } - switch( pVia->Chipset ) { + switch (pVia->Chipset) { case VIA_K8M890: - viaInitPCIe(pVia); - break; + viaInitPCIe(pVia); + break; default: - viaInitAgp(pVia); - break; + viaInitAgp(pVia); + break; } if (pVia->VQStart != 0) { - switch( pVia->Chipset ) { + switch (pVia->Chipset) { case VIA_K8M890: - viaEnablePCIeVQ(pVia); - break; + viaEnablePCIeVQ(pVia); + break; default: - viaEnableAgpVQ(pVia); - break; + viaEnableAgpVQ(pVia); + break; } } else { - viaDisableVQ(pScrn); + viaDisableVQ(pScrn); } viaAccelSetMode(pScrn->bitsPerPixel, tdc); @@ -417,7 +399,6 @@ viaInitialize2DEngine(ScrnInfoPtr pScrn) /* * Wait for acceleration engines idle. An expensive way to sync. */ - void viaAccelSync(ScrnInfoPtr pScrn) { @@ -426,29 +407,28 @@ viaAccelSync(ScrnInfoPtr pScrn) mem_barrier(); - switch (pVia->Chipset) { - case VIA_P4M890: - case VIA_K8M890: - case VIA_P4M900: - while ((VIAGETREG(VIA_REG_STATUS) & - (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY)) && - (loop++ < MAXLOOP)) ; - break; - default: - while (!(VIAGETREG(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) - && (loop++ < MAXLOOP)) ; + switch (pVia->Chipset) { + case VIA_P4M890: + case VIA_K8M890: + case VIA_P4M900: + while ((VIAGETREG(VIA_REG_STATUS) & + (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY)) + && (loop++ < MAXLOOP)) ; + break; + default: + while (!(VIAGETREG(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) + && (loop++ < MAXLOOP)) ; - while ((VIAGETREG(VIA_REG_STATUS) & - (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY)) && - (loop++ < MAXLOOP)) ; - break; + while ((VIAGETREG(VIA_REG_STATUS) & + (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY)) + && (loop++ < MAXLOOP)) ; + break; } } /* - * Set 2D state clipping on. + * Switch 2D state clipping on. */ - static void viaSetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2) { @@ -463,9 +443,8 @@ viaSetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2) } /* - * Set 2D state clipping off. + * Switch 2D state clipping off. */ - static void viaDisableClipping(ScrnInfoPtr pScrn) { @@ -479,32 +458,28 @@ viaDisableClipping(ScrnInfoPtr pScrn) * Emit clipping borders to the command buffer and update the 2D context * current command with clipping info. */ - static int viaAccelClippingHelper(ViaCommandBuffer * cb, int refY, ViaTwodContext * tdc) { if (tdc->clipping) { - refY = (refY < tdc->clipY1) ? refY : tdc->clipY1; - tdc->cmd |= VIA_GEC_CLIP_ENABLE; - BEGIN_RING(4); - OUT_RING_H1(VIA_REG_CLIPTL, - ((tdc->clipY1 - refY) << 16) | tdc->clipX1); - OUT_RING_H1(VIA_REG_CLIPBR, - ((tdc->clipY2 - refY) << 16) | tdc->clipX2); + refY = (refY < tdc->clipY1) ? refY : tdc->clipY1; + tdc->cmd |= VIA_GEC_CLIP_ENABLE; + BEGIN_RING(4); + OUT_RING_H1(VIA_REG_CLIPTL, ((tdc->clipY1 - refY) << 16) | tdc->clipX1); + OUT_RING_H1(VIA_REG_CLIPBR, ((tdc->clipY2 - refY) << 16) | tdc->clipX2); } else { - tdc->cmd &= ~VIA_GEC_CLIP_ENABLE; + tdc->cmd &= ~VIA_GEC_CLIP_ENABLE; } return refY; - } /* * Emit a solid blit operation to the command buffer. */ - static void viaAccelSolidHelper(ViaCommandBuffer * cb, int x, int y, int w, int h, - unsigned fbBase, CARD32 mode, unsigned pitch, CARD32 fg, CARD32 cmd) + unsigned fbBase, CARD32 mode, unsigned pitch, + CARD32 fg, CARD32 cmd) { BEGIN_RING(14); OUT_RING_H1(VIA_REG_GEMODE, mode); @@ -519,7 +494,6 @@ viaAccelSolidHelper(ViaCommandBuffer * cb, int x, int y, int w, int h, /* * Check if we can use a planeMask and update the 2D context accordingly. */ - static Bool viaAccelPlaneMaskHelper(ViaTwodContext * tdc, CARD32 planeMask) { @@ -530,33 +504,27 @@ viaAccelPlaneMaskHelper(ViaTwodContext * tdc, CARD32 planeMask) if ((planeMask & modeMask) != modeMask) { - /* - * Masking doesn't work in 8bpp. - */ - - if (modeMask == 0xFF) { - tdc->keyControl &= 0x0FFFFFFF; - return FALSE; - } - - /* - * Translate the bit planemask to a byte planemask. - */ + /* Masking doesn't work in 8bpp. */ + if (modeMask == 0xFF) { + tdc->keyControl &= 0x0FFFFFFF; + return FALSE; + } - for (i = 0; i < (1 << tdc->bytesPPShift); ++i) { - curByteMask = (0xFF << (i << 3)); + /* Translate the bit planemask to a byte planemask. */ + for (i = 0; i < (1 << tdc->bytesPPShift); ++i) { + curByteMask = (0xFF << (i << 3)); - if ((planeMask & curByteMask) == 0) { - curMask |= (1 << i); - } else if ((planeMask & curByteMask) != curByteMask) { - tdc->keyControl &= 0x0FFFFFFF; - return FALSE; - } - } - ErrorF("DEBUG: planeMask 0x%08x, curMask 0%02x\n", - (unsigned)planeMask, (unsigned)curMask); + if ((planeMask & curByteMask) == 0) { + curMask |= (1 << i); + } else if ((planeMask & curByteMask) != curByteMask) { + tdc->keyControl &= 0x0FFFFFFF; + return FALSE; + } + } + ErrorF("DEBUG: planeMask 0x%08x, curMask 0%02x\n", + (unsigned)planeMask, (unsigned)curMask); - tdc->keyControl = (tdc->keyControl & 0x0FFFFFFF) | (curMask << 28); + tdc->keyControl = (tdc->keyControl & 0x0FFFFFFF) | (curMask << 28); } return TRUE; @@ -565,37 +533,37 @@ viaAccelPlaneMaskHelper(ViaTwodContext * tdc, CARD32 planeMask) /* * Emit transparency state and color to the command buffer. */ - static void viaAccelTransparentHelper(ViaTwodContext * tdc, ViaCommandBuffer * cb, - CARD32 keyControl, CARD32 transColor, Bool usePlaneMask) + CARD32 keyControl, CARD32 transColor, + Bool usePlaneMask) { tdc->keyControl &= ((usePlaneMask) ? 0xF0000000 : 0x00000000); tdc->keyControl |= (keyControl & 0x0FFFFFFF); BEGIN_RING(4); OUT_RING_H1(VIA_REG_KEYCONTROL, tdc->keyControl); if (keyControl) { - OUT_RING_H1(VIA_REG_SRCCOLORKEY, transColor); + OUT_RING_H1(VIA_REG_SRCCOLORKEY, transColor); } } /* * Emit a copy blit operation to the command buffer. */ - static void viaAccelCopyHelper(ViaCommandBuffer * cb, int xs, int ys, int xd, int yd, - int w, int h, unsigned srcFbBase, unsigned dstFbBase, CARD32 mode, - unsigned srcPitch, unsigned dstPitch, CARD32 cmd) + int w, int h, unsigned srcFbBase, unsigned dstFbBase, + CARD32 mode, unsigned srcPitch, unsigned dstPitch, + CARD32 cmd) { if (cmd & VIA_GEC_DECY) { - ys += h - 1; - yd += h - 1; + ys += h - 1; + yd += h - 1; } if (cmd & VIA_GEC_DECX) { - xs += w - 1; - xd += w - 1; + xs += w - 1; + xd += w - 1; } BEGIN_RING(16); @@ -603,7 +571,7 @@ viaAccelCopyHelper(ViaCommandBuffer * cb, int xs, int ys, int xd, int yd, OUT_RING_H1(VIA_REG_SRCBASE, srcFbBase >> 3); OUT_RING_H1(VIA_REG_DSTBASE, dstFbBase >> 3); OUT_RING_H1(VIA_REG_PITCH, VIA_PITCH_ENABLE | - ((dstPitch >> 3) << 16) | (srcPitch >> 3)); + ((dstPitch >> 3) << 16) | (srcPitch >> 3)); OUT_RING_H1(VIA_REG_SRCPOS, (ys << 16) | (xs & 0xFFFF)); OUT_RING_H1(VIA_REG_DSTPOS, (yd << 16) | (xd & 0xFFFF)); OUT_RING_H1(VIA_REG_DIMENSION, ((h - 1) << 16) | (w - 1)); @@ -611,14 +579,14 @@ viaAccelCopyHelper(ViaCommandBuffer * cb, int xs, int ys, int xd, int yd, } /* - * XAA functions. Note that the 2047 line blitter limit has been worked around by adding - * min(y1, y2, clipping y) * stride to the offset (which is recommended by VIA docs). - * The y values (including clipping) must be subtracted accordingly. + * XAA functions. Note that the blitter limit of 2047 lines has been worked + * around by adding min(y1, y2, clipping y) * stride to the offset (which is + * recommended by VIA docs). The y values (including clipping) must be + * subtracted accordingly. */ - static void viaSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, - unsigned planemask, int trans_color) + unsigned planemask, int trans_color) { VIAPtr pVia = VIAPTR(pScrn); CARD32 cmd; @@ -629,19 +597,19 @@ viaSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, cmd = VIA_GEC_BLT | VIAACCELCOPYROP(rop); if (xdir < 0) - cmd |= VIA_GEC_DECX; + cmd |= VIA_GEC_DECX; if (ydir < 0) - cmd |= VIA_GEC_DECY; + cmd |= VIA_GEC_DECY; tdc->cmd = cmd; viaAccelTransparentHelper(tdc, cb, (trans_color != -1) ? 0x4000 : 0x0000, - trans_color, FALSE); + trans_color, FALSE); } static void viaSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, - int x2, int y2, int w, int h) + int x2, int y2, int w, int h) { VIAPtr pVia = VIAPTR(pScrn); ViaTwodContext *tdc = &pVia->td; @@ -650,22 +618,21 @@ viaSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, RING_VARS; if (!w || !h) - return; + return; sub = viaAccelClippingHelper(cb, y2, tdc); viaAccelCopyHelper(cb, x1, 0, x2, y2 - sub, w, h, - pScrn->fbOffset + pVia->Bpl * y1, pScrn->fbOffset + pVia->Bpl * sub, - tdc->mode, pVia->Bpl, pVia->Bpl, tdc->cmd); + pScrn->fbOffset + pVia->Bpl * y1, + pScrn->fbOffset + pVia->Bpl * sub, + tdc->mode, pVia->Bpl, pVia->Bpl, tdc->cmd); ADVANCE_RING; } /* * SetupForSolidFill is also called to set up for lines. */ - static void -viaSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, - unsigned planemask) +viaSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, unsigned planemask) { VIAPtr pVia = VIAPTR(pScrn); ViaTwodContext *tdc = &pVia->td; @@ -687,18 +654,18 @@ viaSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) RING_VARS; if (!w || !h) - return; + return; sub = viaAccelClippingHelper(cb, y, tdc); viaAccelSolidHelper(cb, x, y - sub, w, h, - pScrn->fbOffset + pVia->Bpl * sub, tdc->mode, pVia->Bpl, tdc->fgColor, - tdc->cmd); + pScrn->fbOffset + pVia->Bpl * sub, tdc->mode, pVia->Bpl, + tdc->fgColor, tdc->cmd); ADVANCE_RING; } /* * Original VIA comment: - * The meaning of the two pattern paremeters to Setup & Subsequent for + * The meaning of the two pattern parameters to Setup & Subsequent for * Mono8x8Patterns varies depending on the flag bits. We specify * HW_PROGRAMMED_BITS, which means our hardware can handle 8x8 patterns * without caching in the frame buffer. Thus, Setup gets the pattern bits. @@ -708,10 +675,9 @@ viaSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) * then Setup would get the unrotated pattern, and Subsequent gets the * origin values. */ - static void viaSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int pattern0, int pattern1, - int fg, int bg, int rop, unsigned planemask) + int fg, int bg, int rop, unsigned planemask) { VIAPtr pVia = VIAPTR(pScrn); int cmd; @@ -720,10 +686,10 @@ viaSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int pattern0, int pattern1, RING_VARS; cmd = VIA_GEC_BLT | VIA_GEC_PAT_REG | VIA_GEC_PAT_MONO | - VIAACCELPATTERNROP(rop); + VIAACCELPATTERNROP(rop); if (bg == -1) { - cmd |= VIA_GEC_MPAT_TRANS; + cmd |= VIA_GEC_MPAT_TRANS; } tdc->cmd = cmd; @@ -732,12 +698,11 @@ viaSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int pattern0, int pattern1, tdc->pattern0 = pattern0; tdc->pattern1 = pattern1; viaAccelTransparentHelper(tdc, cb, 0x00, 0x00, FALSE); - } static void viaSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int patOffx, - int patOffy, int x, int y, int w, int h) + int patOffy, int x, int y, int w, int h) { VIAPtr pVia = VIAPTR(pScrn); CARD32 patOffset; @@ -748,7 +713,7 @@ viaSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int patOffx, RING_VARS; if (!w || !h) - return; + return; patOffset = ((patOffy & 0x7) << 29) | ((patOffx & 0x7) << 26); sub = viaAccelClippingHelper(cb, y, tdc); @@ -771,7 +736,7 @@ viaSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int patOffx, static void viaSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, - int rop, unsigned planemask, int trans_color) + int rop, unsigned planemask, int trans_color) { VIAPtr pVia = VIAPTR(pScrn); ViaTwodContext *tdc = &pVia->td; @@ -781,12 +746,12 @@ viaSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, tdc->cmd = VIA_GEC_BLT | VIAACCELPATTERNROP(rop); tdc->patternAddr = (patternx * pVia->Bpp + patterny * pVia->Bpl); viaAccelTransparentHelper(tdc, cb, (trans_color != -1) ? 0x4000 : 0x0000, - trans_color, FALSE); + trans_color, FALSE); } static void viaSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patOffx, - int patOffy, int x, int y, int w, int h) + int patOffy, int x, int y, int w, int h) { VIAPtr pVia = VIAPTR(pScrn); CARD32 patAddr; @@ -797,10 +762,10 @@ viaSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patOffx, RING_VARS; if (!w || !h) - return; + return; patAddr = (tdc->patternAddr >> 3) | - ((patOffy & 0x7) << 29) | ((patOffx & 0x7) << 26); + ((patOffy & 0x7) << 29) | ((patOffx & 0x7) << 26); sub = viaAccelClippingHelper(cb, y, tdc); dstBase = pScrn->fbOffset + sub * pVia->Bpl; @@ -816,16 +781,15 @@ viaSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patOffx, } /* - * CPU to screen functions cannot use AGP due to complicated syncing. Therefore the - * command buffer is flushed before new command emissions and viaFluchPCI is called - * explicitly instead of cb->flushFunc() at the end of each CPU to screen function. - * Should the buffer get completely filled again by a CPU to screen command emission, - * a horrible error will occur. + * CPU-to-screen functions cannot use AGP due to complicated syncing. + * Therefore the command buffer is flushed before new command emissions, and + * viaFluchPCI() is called explicitly instead of cb->flushFunc() at the end of + * each CPU-to-screen function. Should the buffer get completely filled again + * by a CPU-to-screen command emission, a horrible error will occur. */ - static void viaSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, - int rop, unsigned planemask) + int rop, unsigned planemask) { VIAPtr pVia = VIAPTR(pScrn); int cmd; @@ -834,10 +798,10 @@ viaSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, RING_VARS; cmd = VIA_GEC_BLT | VIA_GEC_SRC_SYS | VIA_GEC_SRC_MONO | - VIAACCELCOPYROP(rop); + VIAACCELCOPYROP(rop); if (bg == -1) { - cmd |= VIA_GEC_MSRC_TRANS; + cmd |= VIA_GEC_MSRC_TRANS; } tdc->cmd = cmd; @@ -851,7 +815,8 @@ viaSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, static void viaSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, - int y, int w, int h, int skipleft) + int y, int w, int h, + int skipleft) { VIAPtr pVia = VIAPTR(pScrn); ViaTwodContext *tdc = &pVia->td; @@ -860,8 +825,8 @@ viaSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, RING_VARS; if (skipleft) { - viaSetClippingRectangle(pScrn, (x + skipleft), y, (x + w - 1), - (y + h - 1)); + viaSetClippingRectangle(pScrn, (x + skipleft), y, (x + w - 1), + (y + h - 1)); } sub = viaAccelClippingHelper(cb, y, tdc); @@ -869,8 +834,8 @@ viaSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, OUT_RING_H1(VIA_REG_BGCOLOR, tdc->bgColor); OUT_RING_H1(VIA_REG_FGCOLOR, tdc->fgColor); viaAccelCopyHelper(cb, 0, 0, x, y - sub, w, h, 0, - pScrn->fbOffset + sub * pVia->Bpl, tdc->mode, pVia->Bpl, pVia->Bpl, - tdc->cmd); + pScrn->fbOffset + sub * pVia->Bpl, tdc->mode, + pVia->Bpl, pVia->Bpl, tdc->cmd); viaFlushPCI(cb); viaDisableClipping(pScrn); @@ -878,7 +843,7 @@ viaSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, static void viaSetupForImageWrite(ScrnInfoPtr pScrn, int rop, unsigned planemask, - int trans_color, int bpp, int depth) + int trans_color, int bpp, int depth) { VIAPtr pVia = VIAPTR(pScrn); ViaTwodContext *tdc = &pVia->td; @@ -888,12 +853,12 @@ viaSetupForImageWrite(ScrnInfoPtr pScrn, int rop, unsigned planemask, tdc->cmd = VIA_GEC_BLT | VIA_GEC_SRC_SYS | VIAACCELCOPYROP(rop); ADVANCE_RING; viaAccelTransparentHelper(tdc, cb, (trans_color != -1) ? 0x4000 : 0x0000, - trans_color, FALSE); + trans_color, FALSE); } static void viaSubsequentImageWriteRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, - int skipleft) + int skipleft) { VIAPtr pVia = VIAPTR(pScrn); ViaTwodContext *tdc = &pVia->td; @@ -902,14 +867,14 @@ viaSubsequentImageWriteRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, RING_VARS; if (skipleft) { - viaSetClippingRectangle(pScrn, (x + skipleft), y, (x + w - 1), - (y + h - 1)); + viaSetClippingRectangle(pScrn, (x + skipleft), y, (x + w - 1), + (y + h - 1)); } sub = viaAccelClippingHelper(cb, y, tdc); viaAccelCopyHelper(cb, 0, 0, x, y - sub, w, h, 0, - pScrn->fbOffset + pVia->Bpl * sub, tdc->mode, pVia->Bpl, pVia->Bpl, - tdc->cmd); + pScrn->fbOffset + pVia->Bpl * sub, tdc->mode, + pVia->Bpl, pVia->Bpl, tdc->cmd); viaFlushPCI(cb); viaDisableClipping(pScrn); @@ -917,7 +882,7 @@ viaSubsequentImageWriteRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, static void viaSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, - unsigned int planemask) + unsigned int planemask) { VIAPtr pVia = VIAPTR(pScrn); ViaTwodContext *tdc = &pVia->td; @@ -937,7 +902,7 @@ viaSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, static void viaSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, - int x2, int y2, int flags) + int x2, int y2, int flags) { VIAPtr pVia = VIAPTR(pScrn); int dx, dy, cmd, tmp, error = 1; @@ -952,26 +917,26 @@ viaSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, dx = x2 - x1; if (dx < 0) { - dx = -dx; - cmd |= VIA_GEC_DECX; /* line will be drawn from right */ - error = 0; + dx = -dx; + cmd |= VIA_GEC_DECX; /* line will be drawn from right */ + error = 0; } dy = y2 - y1; if (dy < 0) { - dy = -dy; - cmd |= VIA_GEC_DECY; /* line will be drawn from bottom */ + dy = -dy; + cmd |= VIA_GEC_DECY; /* line will be drawn from bottom */ } if (dy > dx) { - tmp = dy; - dy = dx; - dx = tmp; /* Swap 'dx' and 'dy' */ - cmd |= VIA_GEC_Y_MAJOR; /* Y major line */ + tmp = dy; + dy = dx; + dx = tmp; /* Swap 'dx' and 'dy' */ + cmd |= VIA_GEC_Y_MAJOR; /* Y major line */ } if (flags & OMIT_LAST) { - cmd |= VIA_GEC_LASTPIXEL_OFF; + cmd |= VIA_GEC_LASTPIXEL_OFF; } dstBase = pScrn->fbOffset + sub * pVia->Bpl; @@ -989,19 +954,18 @@ viaSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, */ OUT_RING_H1(VIA_REG_LINE_K1K2, - ((((dy << 1) & 0x3fff) << 16) | (((dy - dx) << 1) & 0x3fff))); + ((((dy << 1) & 0x3fff) << 16) | (((dy - dx) << 1) & 0x3fff))); OUT_RING_H1(VIA_REG_LINE_XY, ((y1 << 16) | (x1 & 0xFFFF))); OUT_RING_H1(VIA_REG_DIMENSION, dx); OUT_RING_H1(VIA_REG_LINE_ERROR, - (((dy << 1) - dx - error) & 0x3fff) | ((tdc->dashed) ? 0xFF0000 : 0)); + (((dy << 1) - dx - error) & 0x3fff) | + ((tdc->dashed) ? 0xFF0000 : 0)); OUT_RING_H1(VIA_REG_GECMD, cmd); ADVANCE_RING; - } static void -viaSubsequentSolidHorVertLine(ScrnInfoPtr pScrn, int x, int y, int len, - int dir) +viaSubsequentSolidHorVertLine(ScrnInfoPtr pScrn, int x, int y, int len, int dir) { VIAPtr pVia = VIAPTR(pScrn); ViaTwodContext *tdc = &pVia->td; @@ -1018,20 +982,21 @@ viaSubsequentSolidHorVertLine(ScrnInfoPtr pScrn, int x, int y, int len, OUT_RING_H1(VIA_REG_PITCH, VIA_PITCH_ENABLE | ((pVia->Bpl >> 3) << 16)); if (dir == DEGREES_0) { - OUT_RING_H1(VIA_REG_DSTPOS, ((y - sub) << 16) | (x & 0xFFFF)); - OUT_RING_H1(VIA_REG_DIMENSION, (len - 1)); - OUT_RING_H1(VIA_REG_GECMD, tdc->cmd | VIA_GEC_BLT); + OUT_RING_H1(VIA_REG_DSTPOS, ((y - sub) << 16) | (x & 0xFFFF)); + OUT_RING_H1(VIA_REG_DIMENSION, (len - 1)); + OUT_RING_H1(VIA_REG_GECMD, tdc->cmd | VIA_GEC_BLT); } else { - OUT_RING_H1(VIA_REG_DSTPOS, ((y - sub) << 16) | (x & 0xFFFF)); - OUT_RING_H1(VIA_REG_DIMENSION, ((len - 1) << 16)); - OUT_RING_H1(VIA_REG_GECMD, tdc->cmd | VIA_GEC_BLT); + OUT_RING_H1(VIA_REG_DSTPOS, ((y - sub) << 16) | (x & 0xFFFF)); + OUT_RING_H1(VIA_REG_DIMENSION, ((len - 1) << 16)); + OUT_RING_H1(VIA_REG_GECMD, tdc->cmd | VIA_GEC_BLT); } ADVANCE_RING; } static void viaSetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, - unsigned int planemask, int length, unsigned char *pattern) + unsigned int planemask, int length, + unsigned char *pattern) { VIAPtr pVia = VIAPTR(pScrn); int cmd; @@ -1044,7 +1009,7 @@ viaSetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, cmd = VIA_GEC_LINE | VIA_GEC_FIXCOLOR_PAT | VIAACCELPATTERNROP(rop); if (bg == -1) { - cmd |= VIA_GEC_MPAT_TRANS; + cmd |= VIA_GEC_MPAT_TRANS; } tdc->cmd = cmd; @@ -1052,14 +1017,14 @@ viaSetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, tdc->bgColor = bg; switch (length) { - case 2: - pat |= pat << 2; /* fall through */ - case 4: - pat |= pat << 4; /* fall through */ - case 8: - pat |= pat << 8; /* fall through */ - case 16: - pat |= pat << 16; + case 2: + pat |= pat << 2; /* fall through */ + case 4: + pat |= pat << 4; /* fall through */ + case 8: + pat |= pat << 8; /* fall through */ + case 16: + pat |= pat << 16; } tdc->pattern0 = pat; @@ -1074,7 +1039,7 @@ viaSetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, static void viaSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, int x2, - int y2, int flags, int phase) + int y2, int flags, int phase) { viaSubsequentSolidTwoPointLine(pScrn, x1, y1, x2, y2, flags); } @@ -1082,33 +1047,30 @@ viaSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, int x2, static int viaInitXAA(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; VIAPtr pVia = VIAPTR(pScrn); XAAInfoRecPtr xaaptr; - /* - * General acceleration flags - */ - if (!(xaaptr = pVia->AccelInfoRec = XAACreateInfoRec())) - return FALSE; + return FALSE; - xaaptr->Flags = PIXMAP_CACHE | - OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER | MICROSOFT_ZERO_LINE_BIAS | 0; + /* General acceleration flags. */ + xaaptr->Flags = (PIXMAP_CACHE | + OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER | + MICROSOFT_ZERO_LINE_BIAS | 0); if (pScrn->bitsPerPixel == 8) - xaaptr->CachePixelGranularity = 128; + xaaptr->CachePixelGranularity = 128; xaaptr->SetClippingRectangle = viaSetClippingRectangle; xaaptr->DisableClipping = viaDisableClipping; - xaaptr->ClippingFlags = HARDWARE_CLIP_SOLID_FILL | - HARDWARE_CLIP_SOLID_LINE | - HARDWARE_CLIP_DASHED_LINE | - HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY | - HARDWARE_CLIP_MONO_8x8_FILL | - HARDWARE_CLIP_COLOR_8x8_FILL | - HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND | 0; + xaaptr->ClippingFlags = (HARDWARE_CLIP_SOLID_FILL | + HARDWARE_CLIP_SOLID_LINE | + HARDWARE_CLIP_DASHED_LINE | + HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY | + HARDWARE_CLIP_MONO_8x8_FILL | + HARDWARE_CLIP_COLOR_8x8_FILL | + HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND | 0); xaaptr->Sync = viaAccelSync; @@ -1122,18 +1084,19 @@ viaInitXAA(ScreenPtr pScreen) xaaptr->SetupForMono8x8PatternFill = viaSetupForMono8x8PatternFill; xaaptr->SubsequentMono8x8PatternFillRect = - viaSubsequentMono8x8PatternFillRect; - xaaptr->Mono8x8PatternFillFlags = NO_PLANEMASK | - HARDWARE_PATTERN_PROGRAMMED_BITS | - HARDWARE_PATTERN_PROGRAMMED_ORIGIN | BIT_ORDER_IN_BYTE_MSBFIRST | 0; + viaSubsequentMono8x8PatternFillRect; + xaaptr->Mono8x8PatternFillFlags = (NO_PLANEMASK | + HARDWARE_PATTERN_PROGRAMMED_BITS | + HARDWARE_PATTERN_PROGRAMMED_ORIGIN | + BIT_ORDER_IN_BYTE_MSBFIRST | 0); xaaptr->SetupForColor8x8PatternFill = viaSetupForColor8x8PatternFill; xaaptr->SubsequentColor8x8PatternFillRect = - viaSubsequentColor8x8PatternFillRect; - xaaptr->Color8x8PatternFillFlags = NO_PLANEMASK | - NO_TRANSPARENCY | - HARDWARE_PATTERN_PROGRAMMED_BITS | - HARDWARE_PATTERN_PROGRAMMED_ORIGIN | 0; + viaSubsequentColor8x8PatternFillRect; + xaaptr->Color8x8PatternFillFlags = (NO_PLANEMASK | + NO_TRANSPARENCY | + HARDWARE_PATTERN_PROGRAMMED_BITS | + HARDWARE_PATTERN_PROGRAMMED_ORIGIN | 0); xaaptr->SetupForSolidLine = viaSetupForSolidLine; xaaptr->SubsequentSolidTwoPointLine = viaSubsequentSolidTwoPointLine; @@ -1144,37 +1107,41 @@ viaInitXAA(ScreenPtr pScreen) xaaptr->SetupForDashedLine = viaSetupForDashedLine; xaaptr->SubsequentDashedTwoPointLine = viaSubsequentDashedTwoPointLine; xaaptr->DashPatternMaxLength = 8; - xaaptr->DashedLineFlags = NO_PLANEMASK | - ROP_NEEDS_SOURCE | - LINE_PATTERN_POWER_OF_2_ONLY | LINE_PATTERN_MSBFIRST_LSBJUSTIFIED | 0; + xaaptr->DashedLineFlags = (NO_PLANEMASK | + ROP_NEEDS_SOURCE | + LINE_PATTERN_POWER_OF_2_ONLY | + LINE_PATTERN_MSBFIRST_LSBJUSTIFIED | 0); xaaptr->ScanlineCPUToScreenColorExpandFillFlags = NO_PLANEMASK | - CPU_TRANSFER_PAD_DWORD | - SCANLINE_PAD_DWORD | - BIT_ORDER_IN_BYTE_MSBFIRST | - LEFT_EDGE_CLIPPING | ROP_NEEDS_SOURCE | 0; + CPU_TRANSFER_PAD_DWORD | + SCANLINE_PAD_DWORD | + BIT_ORDER_IN_BYTE_MSBFIRST | + LEFT_EDGE_CLIPPING | ROP_NEEDS_SOURCE | 0; xaaptr->SetupForScanlineCPUToScreenColorExpandFill = - viaSetupForCPUToScreenColorExpandFill; + viaSetupForCPUToScreenColorExpandFill; xaaptr->SubsequentScanlineCPUToScreenColorExpandFill = - viaSubsequentScanlineCPUToScreenColorExpandFill; + viaSubsequentScanlineCPUToScreenColorExpandFill; xaaptr->ColorExpandBase = pVia->BltBase; xaaptr->ColorExpandRange = VIA_MMIO_BLTSIZE; - xaaptr->ImageWriteFlags = NO_PLANEMASK | - CPU_TRANSFER_PAD_DWORD | - SCANLINE_PAD_DWORD | - BIT_ORDER_IN_BYTE_MSBFIRST | - LEFT_EDGE_CLIPPING | ROP_NEEDS_SOURCE | SYNC_AFTER_IMAGE_WRITE | 0; + xaaptr->ImageWriteFlags = (NO_PLANEMASK | + CPU_TRANSFER_PAD_DWORD | + SCANLINE_PAD_DWORD | + BIT_ORDER_IN_BYTE_MSBFIRST | + LEFT_EDGE_CLIPPING | ROP_NEEDS_SOURCE | + SYNC_AFTER_IMAGE_WRITE | 0); /* - * Most Unichromes are much faster using processor to - * framebuffer writes than using the 2D engine for this. + * Most Unichromes are much faster using processor-to-framebuffer writes + * than when using the 2D engine for this. * test with x11perf -shmput500! */ - if (pVia->Chipset != VIA_K8M800 && pVia->Chipset != VIA_K8M890 && pVia->Chipset != VIA_P4M900) - xaaptr->ImageWriteFlags |= NO_GXCOPY; + if (pVia->Chipset != VIA_K8M800 && + pVia->Chipset != VIA_K8M890 && + pVia->Chipset != VIA_P4M900) + xaaptr->ImageWriteFlags |= NO_GXCOPY; xaaptr->SetupForImageWrite = viaSetupForImageWrite; xaaptr->SubsequentImageWriteRect = viaSubsequentImageWriteRect; @@ -1191,7 +1158,6 @@ viaInitXAA(ScreenPtr pScreen) * to have an interrupt generated, provided it is possible to * write to the PCI DMA engines from the AGP command stream. */ - int viaAccelMarkSync(ScreenPtr pScreen) { @@ -1202,19 +1168,16 @@ viaAccelMarkSync(ScreenPtr pScreen) ++pVia->curMarker; - /* - * Wrap around without possibly affecting the int sign bit. - */ - + /* Wrap around without affecting the sign bit. */ pVia->curMarker &= 0x7FFFFFFF; if (pVia->agpDMA) { - BEGIN_RING(2); - OUT_RING_H1(VIA_REG_KEYCONTROL, 0x00); - viaAccelSolidHelper(cb, 0, 0, 1, 1, pVia->markerOffset, - VIA_GEM_32bpp, 4, pVia->curMarker, - (0xF0 << 24) | VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT); - ADVANCE_RING; + BEGIN_RING(2); + OUT_RING_H1(VIA_REG_KEYCONTROL, 0x00); + viaAccelSolidHelper(cb, 0, 0, 1, 1, pVia->markerOffset, + VIA_GEM_32bpp, 4, pVia->curMarker, + (0xF0 << 24) | VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT); + ADVANCE_RING; } return pVia->curMarker; } @@ -1222,7 +1185,6 @@ viaAccelMarkSync(ScreenPtr pScreen) /* * Wait for the value to get blitted, or in the PCI case for engine idle. */ - void viaAccelWaitMarker(ScreenPtr pScreen, int marker) { @@ -1231,19 +1193,17 @@ viaAccelWaitMarker(ScreenPtr pScreen, int marker) CARD32 uMarker = marker; if (pVia->agpDMA) { - while ((pVia->lastMarkerRead - uMarker) > (1 << 24)) - pVia->lastMarkerRead = *pVia->markerBuf; + while ((pVia->lastMarkerRead - uMarker) > (1 << 24)) + pVia->lastMarkerRead = *pVia->markerBuf; } else { - viaAccelSync(pScrn); + viaAccelSync(pScrn); } } #ifdef VIA_HAVE_EXA - /* * Exa functions. It is assumed that EXA does not exceed the blitter limits. */ - static Bool viaExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) { @@ -1254,13 +1214,13 @@ viaExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) RING_VARS; if (exaGetPixmapPitch(pPixmap) & 7) - return FALSE; + return FALSE; if (!viaAccelSetMode(pPixmap->drawable.depth, tdc)) - return FALSE; + return FALSE; if (!viaAccelPlaneMaskHelper(tdc, planeMask)) - return FALSE; + return FALSE; viaAccelTransparentHelper(tdc, cb, 0x0, 0x0, TRUE); tdc->cmd = VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | VIAACCELPATTERNROP(alu); @@ -1286,7 +1246,7 @@ viaExaSolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2) dstOffset = exaGetPixmapOffset(pPixmap); viaAccelSolidHelper(cb, x1, y1, w, h, dstOffset, - tdc->mode, dstPitch, tdc->fgColor, tdc->cmd); + tdc->mode, dstPitch, tdc->fgColor, tdc->cmd); ADVANCE_RING; } @@ -1297,7 +1257,7 @@ viaExaDoneSolidCopy(PixmapPtr pPixmap) static Bool viaExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, - int ydir, int alu, Pixel planeMask) + int ydir, int alu, Pixel planeMask) { ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; VIAPtr pVia = VIAPTR(pScrn); @@ -1305,29 +1265,28 @@ viaExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, RING_VARS; - if (pSrcPixmap->drawable.bitsPerPixel != - pDstPixmap->drawable.bitsPerPixel) - return FALSE; + if (pSrcPixmap->drawable.bitsPerPixel != pDstPixmap->drawable.bitsPerPixel) + return FALSE; if ((tdc->srcPitch = exaGetPixmapPitch(pSrcPixmap)) & 3) - return FALSE; + return FALSE; if (exaGetPixmapPitch(pDstPixmap) & 7) - return FALSE; + return FALSE; tdc->srcOffset = exaGetPixmapOffset(pSrcPixmap); tdc->cmd = VIA_GEC_BLT | VIAACCELCOPYROP(alu); if (xdir < 0) - tdc->cmd |= VIA_GEC_DECX; + tdc->cmd |= VIA_GEC_DECX; if (ydir < 0) - tdc->cmd |= VIA_GEC_DECY; + tdc->cmd |= VIA_GEC_DECY; if (!viaAccelSetMode(pDstPixmap->drawable.bitsPerPixel, tdc)) - return FALSE; + return FALSE; if (!viaAccelPlaneMaskHelper(tdc, planeMask)) - return FALSE; + return FALSE; viaAccelTransparentHelper(tdc, cb, 0x0, 0x0, TRUE); return TRUE; @@ -1335,7 +1294,7 @@ viaExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, static void viaExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, - int width, int height) + int width, int height) { ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; VIAPtr pVia = VIAPTR(pScrn); @@ -1346,11 +1305,11 @@ viaExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, RING_VARS; if (!width || !height) - return; + return; viaAccelCopyHelper(cb, srcX, srcY, dstX, dstY, width, height, - srcOffset, dstOffset, tdc->mode, tdc->srcPitch, - exaGetPixmapPitch(pDstPixmap), tdc->cmd); + srcOffset, dstOffset, tdc->mode, tdc->srcPitch, + exaGetPixmapPitch(pDstPixmap), tdc->cmd); ADVANCE_RING; } @@ -1362,58 +1321,58 @@ viaExaCompositePictDesc(PicturePtr pict, char *string, int n) char size[20]; if (!pict) { - snprintf(string, n, "None"); - return; + snprintf(string, n, "None"); + return; } switch (pict->format) { - case PICT_x8r8g8b8: - snprintf(format, 20, "RGB8888"); - break; - case PICT_a8r8g8b8: - snprintf(format, 20, "ARGB8888"); - break; - case PICT_r5g6b5: - snprintf(format, 20, "RGB565 "); - break; - case PICT_x1r5g5b5: - snprintf(format, 20, "RGB555 "); - break; - case PICT_a8: - snprintf(format, 20, "A8 "); - break; - case PICT_a1: - snprintf(format, 20, "A1 "); - break; - default: - snprintf(format, 20, "0x%x", (int)pict->format); - break; + case PICT_x8r8g8b8: + snprintf(format, 20, "RGB8888"); + break; + case PICT_a8r8g8b8: + snprintf(format, 20, "ARGB8888"); + break; + case PICT_r5g6b5: + snprintf(format, 20, "RGB565 "); + break; + case PICT_x1r5g5b5: + snprintf(format, 20, "RGB555 "); + break; + case PICT_a8: + snprintf(format, 20, "A8 "); + break; + case PICT_a1: + snprintf(format, 20, "A1 "); + break; + default: + snprintf(format, 20, "0x%x", (int)pict->format); + break; } snprintf(size, 20, "%dx%d%s", pict->pDrawable->width, - pict->pDrawable->height, pict->repeat ? " R" : ""); + pict->pDrawable->height, pict->repeat ? " R" : ""); snprintf(string, n, "0x%lx: fmt %s (%s)", (long)pict->pDrawable, format, - size); + size); } static void viaExaPrintComposite(CARD8 op, - PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst) + PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst) { char sop[20]; char srcdesc[40], maskdesc[40], dstdesc[40]; switch (op) { - case PictOpSrc: - sprintf(sop, "Src"); - break; - case PictOpOver: - sprintf(sop, "Over"); - break; - default: - sprintf(sop, "0x%x", (int)op); - break; + case PictOpSrc: + sprintf(sop, "Src"); + break; + case PictOpOver: + sprintf(sop, "Over"); + break; + default: + sprintf(sop, "0x%x", (int)op); + break; } viaExaCompositePictDesc(pSrc, srcdesc, 40); @@ -1421,32 +1380,31 @@ viaExaPrintComposite(CARD8 op, viaExaCompositePictDesc(pDst, dstdesc, 40); ErrorF("Composite fallback: op %s, \n" - " src %s, \n" - " mask %s, \n" - " dst %s, \n", sop, srcdesc, maskdesc, dstdesc); + " src %s, \n" + " mask %s, \n" + " dst %s, \n", sop, srcdesc, maskdesc, dstdesc); } #endif /* VIA_DEBUG_COMPOSITE */ /* * Helper for bitdepth expansion. */ - static CARD32 -viaBitExpandHelper(CARD32 component, CARD32 bits) +viaBitExpandHelper(CARD32 pixel, CARD32 bits) { - CARD32 tmp, mask; + CARD32 component, mask, tmp; + component = pixel & ((1 << bits) - 1); mask = (1 << (8 - bits)) - 1; tmp = component << (8 - bits); - return ((component & 1) ? tmp | mask : tmp); + return ((component & 1) ? (tmp | mask) : tmp); } /* - * Extract the components from a pixel of format "format" to an - * argb8888 pixel. This is used to extract data from one-pixel repeat pixmaps. + * Extract the components from a pixel of the given format to an argb8888 pixel. + * This is used to extract data from one-pixel repeat pixmaps. * Assumes little endian. */ - static void viaPixelARGB8888(unsigned format, void *pixelP, CARD32 * argb8888) { @@ -1455,59 +1413,50 @@ viaPixelARGB8888(unsigned format, void *pixelP, CARD32 * argb8888) bpp = PICT_FORMAT_BPP(format); if (bpp <= 8) { - pixel = *((CARD8 *) pixelP); + pixel = *((CARD8 *) pixelP); } else if (bpp <= 16) { - pixel = *((CARD16 *) pixelP); + pixel = *((CARD16 *) pixelP); } else { - pixel = *((CARD32 *) pixelP); + pixel = *((CARD32 *) pixelP); } switch (PICT_FORMAT_TYPE(format)) { - case PICT_TYPE_A: - bits = PICT_FORMAT_A(format); - *argb8888 = viaBitExpandHelper(pixel & ((1 << bits) - 1), bits) << 24; - return; - case PICT_TYPE_ARGB: - shift = 0; - bits = PICT_FORMAT_B(format); - *argb8888 = viaBitExpandHelper(pixel & ((1 << bits) - 1), bits); - shift += bits; - bits = PICT_FORMAT_G(format); - *argb8888 |= - viaBitExpandHelper((pixel >> shift) & ((1 << bits) - 1), - bits) << 8; - shift += bits; - bits = PICT_FORMAT_R(format); - *argb8888 |= - viaBitExpandHelper((pixel >> shift) & ((1 << bits) - 1), - bits) << 16; - shift += bits; - bits = PICT_FORMAT_A(format); - *argb8888 |= ((bits) ? - viaBitExpandHelper((pixel >> shift) & ((1 << bits) - 1), - bits) : 0xFF) << 24; - return; - case PICT_TYPE_ABGR: - shift = 0; - bits = PICT_FORMAT_B(format); - *argb8888 = viaBitExpandHelper(pixel & ((1 << bits) - 1), bits) << 16; - shift += bits; - bits = PICT_FORMAT_G(format); - *argb8888 |= - viaBitExpandHelper((pixel >> shift) & ((1 << bits) - 1), - bits) << 8; - shift += bits; - bits = PICT_FORMAT_R(format); - *argb8888 |= - viaBitExpandHelper((pixel >> shift) & ((1 << bits) - 1), bits); - shift += bits; - bits = PICT_FORMAT_A(format); - *argb8888 |= ((bits) ? - viaBitExpandHelper((pixel >> shift) & ((1 << bits) - 1), - bits) : 0xFF) << 24; - return; - default: - break; + case PICT_TYPE_A: + bits = PICT_FORMAT_A(format); + *argb8888 = viaBitExpandHelper(pixel, bits) << 24; + return; + case PICT_TYPE_ARGB: + shift = 0; + bits = PICT_FORMAT_B(format); + *argb8888 = viaBitExpandHelper(pixel, bits); + shift += bits; + bits = PICT_FORMAT_G(format); + *argb8888 |= viaBitExpandHelper(pixel >> shift, bits) << 8; + shift += bits; + bits = PICT_FORMAT_R(format); + *argb8888 |= viaBitExpandHelper(pixel >> shift, bits) << 16; + shift += bits; + bits = PICT_FORMAT_A(format); + *argb8888 |= ((bits) ? viaBitExpandHelper(pixel >> shift, + bits) : 0xFF) << 24; + return; + case PICT_TYPE_ABGR: + shift = 0; + bits = PICT_FORMAT_B(format); + *argb8888 = viaBitExpandHelper(pixel, bits) << 16; + shift += bits; + bits = PICT_FORMAT_G(format); + *argb8888 |= viaBitExpandHelper(pixel >> shift, bits) << 8; + shift += bits; + bits = PICT_FORMAT_R(format); + *argb8888 |= viaBitExpandHelper(pixel >> shift, bits); + shift += bits; + bits = PICT_FORMAT_A(format); + *argb8888 |= ((bits) ? viaBitExpandHelper(pixel >> shift, + bits) : 0xFF) << 24; + return; + default: + break; } return; } @@ -1515,14 +1464,13 @@ viaPixelARGB8888(unsigned format, void *pixelP, CARD32 * argb8888) /* * Check if the above function will work. */ - static Bool viaExpandablePixel(int format) { int formatType = PICT_FORMAT_TYPE(format); return (formatType == PICT_TYPE_A || - formatType == PICT_TYPE_ABGR || formatType == PICT_TYPE_ARGB); + formatType == PICT_TYPE_ABGR || formatType == PICT_TYPE_ARGB); } /* @@ -1530,7 +1478,6 @@ viaExpandablePixel(int format) * clients or subsystems have touched the 3D engine). Also tell DRI * clients and subsystems that we have touched the 3D engine. */ - static Bool viaCheckUpload(ScrnInfoPtr pScrn, Via3DState * v3d) { @@ -1542,12 +1489,12 @@ viaCheckUpload(ScrnInfoPtr pScrn, Via3DState * v3d) #ifdef XF86DRI if (pVia->directRenderingEnabled) { - volatile drm_via_sarea_t *saPriv = (drm_via_sarea_t *) - DRIGetSAREAPrivate(pScrn->pScreen); - int myContext = DRIGetContext(pScrn->pScreen); + volatile drm_via_sarea_t *saPriv = (drm_via_sarea_t *) + DRIGetSAREAPrivate(pScrn->pScreen); + int myContext = DRIGetContext(pScrn->pScreen); - forceUpload = forceUpload || (saPriv->ctxOwner != myContext); - saPriv->ctxOwner = myContext; + forceUpload = forceUpload || (saPriv->ctxOwner != myContext); + saPriv->ctxOwner = myContext; } #endif return forceUpload; @@ -1559,7 +1506,7 @@ viaOrder(CARD32 val, CARD32 * shift) *shift = 0; while (val > (1 << *shift)) - (*shift)++; + (*shift)++; return (val == (1 << *shift)); } @@ -1567,8 +1514,8 @@ viaOrder(CARD32 val, CARD32 * shift) static int viaAccelDMADownload(ScrnInfoPtr pScrn, unsigned long fbOffset, - unsigned srcPitch, unsigned char *dst, - unsigned dstPitch, unsigned w, unsigned h) + unsigned srcPitch, unsigned char *dst, + unsigned dstPitch, unsigned w, unsigned h) { VIAPtr pVia = VIAPTR(pScrn); drm_via_dmablit_t blit[2], *curBlit; @@ -1586,65 +1533,65 @@ viaAccelDMADownload(ScrnInfoPtr pScrn, unsigned long fbOffset, blitHeight = h; pitch = dstPitch; if (useBounceBuffer) { - pitch = ALIGN_TO(dstPitch, 16); - blitHeight = VIA_DMA_DL_SIZE / pitch; + pitch = ALIGN_TO(dstPitch, 16); + blitHeight = VIA_DMA_DL_SIZE / pitch; } while (doSync[0] || doSync[1] || h != 0) { - curBuf = 1 - curBuf; - curBlit = &blit[curBuf]; - if (doSync[curBuf]) { - - do { - err = drmCommandWrite(pVia->drmFD, DRM_VIA_BLIT_SYNC, - &curBlit->sync, sizeof(curBlit->sync)); - } while (err == -EAGAIN); - - if (err) - return err; - - doSync[curBuf] = FALSE; - if (useBounceBuffer) { - for (i = 0; i < numLines[curBuf]; ++i) { - memcpy(dst, curBlit->mem_addr, w); - dst += dstPitch; - curBlit->mem_addr += pitch; - } - } - } - - if (h == 0) - continue; - - curBlit->num_lines = (h > blitHeight) ? blitHeight : h; - h -= curBlit->num_lines; - numLines[curBuf] = curBlit->num_lines; - - sysAligned = - (unsigned char *)pVia->dBounce + (curBuf * VIA_DMA_DL_SIZE); - sysAligned = (unsigned char *) - ALIGN_TO((unsigned long)sysAligned, 16); - - curBlit->mem_addr = (useBounceBuffer) ? sysAligned : dst; - curBlit->line_length = w; - curBlit->mem_stride = pitch; - curBlit->fb_addr = fbOffset; - curBlit->fb_stride = srcPitch; - curBlit->to_fb = 0; - fbOffset += curBlit->num_lines * srcPitch; - - do { - err = drmCommandWriteRead(pVia->drmFD, DRM_VIA_DMA_BLIT, curBlit, - sizeof(*curBlit)); - } while (err == -EAGAIN); - - if (err) { - ret = err; - h = 0; - continue; - } - - doSync[curBuf] = TRUE; + curBuf = 1 - curBuf; + curBlit = &blit[curBuf]; + if (doSync[curBuf]) { + + do { + err = drmCommandWrite(pVia->drmFD, DRM_VIA_BLIT_SYNC, + &curBlit->sync, sizeof(curBlit->sync)); + } while (err == -EAGAIN); + + if (err) + return err; + + doSync[curBuf] = FALSE; + if (useBounceBuffer) { + for (i = 0; i < numLines[curBuf]; ++i) { + memcpy(dst, curBlit->mem_addr, w); + dst += dstPitch; + curBlit->mem_addr += pitch; + } + } + } + + if (h == 0) + continue; + + curBlit->num_lines = (h > blitHeight) ? blitHeight : h; + h -= curBlit->num_lines; + numLines[curBuf] = curBlit->num_lines; + + sysAligned = + (unsigned char *)pVia->dBounce + (curBuf * VIA_DMA_DL_SIZE); + sysAligned = (unsigned char *) + ALIGN_TO((unsigned long)sysAligned, 16); + + curBlit->mem_addr = (useBounceBuffer) ? sysAligned : dst; + curBlit->line_length = w; + curBlit->mem_stride = pitch; + curBlit->fb_addr = fbOffset; + curBlit->fb_stride = srcPitch; + curBlit->to_fb = 0; + fbOffset += curBlit->num_lines * srcPitch; + + do { + err = drmCommandWriteRead(pVia->drmFD, DRM_VIA_DMA_BLIT, curBlit, + sizeof(*curBlit)); + } while (err == -EAGAIN); + + if (err) { + ret = err; + h = 0; + continue; + } + + doSync[curBuf] = TRUE; } return ret; @@ -1655,10 +1602,9 @@ viaAccelDMADownload(ScrnInfoPtr pScrn, unsigned long fbOffset, * an aligned bounce buffer for pipelined PCI DMA and memcpy. * Throughput for large transfers is around 65 MB/s. */ - static Bool viaExaDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, - char *dst, int dst_pitch) + char *dst, int dst_pitch) { ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; VIAPtr pVia = VIAPTR(pScrn); @@ -1669,37 +1615,37 @@ viaExaDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, unsigned totSize; if (!w || !h) - return TRUE; + return TRUE; srcOffset = x * pSrc->drawable.bitsPerPixel; if (srcOffset & 3) - return FALSE; + return FALSE; srcOffset = exaGetPixmapOffset(pSrc) + y * srcPitch + (srcOffset >> 3); totSize = wBytes * h; exaWaitSync(pScrn->pScreen); if (totSize < VIA_MIN_DOWNLOAD) { - bounceAligned = (char *)pVia->FBBase + srcOffset; - while (h--) { - memcpy(dst, bounceAligned, wBytes); - dst += dst_pitch; - bounceAligned += srcPitch; - } - return TRUE; + bounceAligned = (char *)pVia->FBBase + srcOffset; + while (h--) { + memcpy(dst, bounceAligned, wBytes); + dst += dst_pitch; + bounceAligned += srcPitch; + } + return TRUE; } if (!pVia->directRenderingEnabled) - return FALSE; + return FALSE; if ((srcPitch & 3) || (srcOffset & 3)) { - ErrorF("VIA EXA download src_pitch misaligned\n"); - return FALSE; + ErrorF("VIA EXA download src_pitch misaligned\n"); + return FALSE; } if (viaAccelDMADownload(pScrn, srcOffset, srcPitch, (unsigned char *)dst, - dst_pitch, wBytes, h)) - return FALSE; + dst_pitch, wBytes, h)) + return FALSE; return TRUE; } @@ -1709,10 +1655,9 @@ viaExaDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, * 3D engine texture operation from AGP to framebuffer. The AGP buffers (2) * should be kept rather small for optimal pipelining. */ - static Bool viaExaTexUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, - int src_pitch) + int src_pitch) { ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; VIAPtr pVia = VIAPTR(pScrn); @@ -1727,54 +1672,53 @@ viaExaTexUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, Via3DState *v3d = &pVia->v3d; if (!w || !h) - return TRUE; + return TRUE; if (wBytes * h < VIA_MIN_TEX_UPLOAD) { - dstOffset = x * pDst->drawable.bitsPerPixel; - if (dstOffset & 3) - return FALSE; - dst = - (char *)pVia->FBBase + (exaGetPixmapOffset(pDst) + y * dstPitch + - (dstOffset >> 3)); - exaWaitSync(pScrn->pScreen); - - while (h--) { - memcpy(dst, src, wBytes); - dst += dstPitch; - src += src_pitch; - } - return TRUE; + dstOffset = x * pDst->drawable.bitsPerPixel; + if (dstOffset & 3) + return FALSE; + dst = (char *)pVia->FBBase + (exaGetPixmapOffset(pDst) + y * dstPitch + + (dstOffset >> 3)); + exaWaitSync(pScrn->pScreen); + + while (h--) { + memcpy(dst, src, wBytes); + dst += dstPitch; + src += src_pitch; + } + return TRUE; } if (!pVia->texAddr) - return FALSE; + return FALSE; switch (pDst->drawable.bitsPerPixel) { - case 32: - format = PICT_a8r8g8b8; - break; - case 16: - format = PICT_r5g6b5; - break; - default: - return FALSE; + case 32: + format = PICT_a8r8g8b8; + break; + case 16: + format = PICT_r5g6b5; + break; + default: + return FALSE; } dstOffset = exaGetPixmapOffset(pDst); if (pVia->nPOT[0]) { - texPitch = ALIGN_TO(wBytes, 32); - height = VIA_AGP_UPL_SIZE / texPitch; + texPitch = ALIGN_TO(wBytes, 32); + height = VIA_AGP_UPL_SIZE / texPitch; } else { - viaOrder(wBytes, &texPitch); - if (texPitch < 3) - texPitch = 3; - height = VIA_AGP_UPL_SIZE >> texPitch; - texPitch = 1 << texPitch; + viaOrder(wBytes, &texPitch); + if (texPitch < 3) + texPitch = 3; + height = VIA_AGP_UPL_SIZE >> texPitch; + texPitch = 1 << texPitch; } if (height > 1024) - height = 1024; + height = 1024; viaOrder(w, &texWidth); texWidth = 1 << texWidth; @@ -1785,13 +1729,13 @@ viaExaTexUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, v3d->setDrawing(v3d, 0x0c, 0xFFFFFFFF, 0x000000FF, 0x00); v3d->setFlags(v3d, 1, TRUE, TRUE, FALSE); if (!v3d->setTexture(v3d, 0, pVia->texOffset + pVia->agpAddr, texPitch, - pVia->nPOT[0], texWidth, texHeight, format, via_single, - via_single, via_src, TRUE)) - return FALSE; + pVia->nPOT[0], texWidth, texHeight, format, + via_single, via_single, via_src, TRUE)) + return FALSE; v3d->emitState(v3d, &pVia->cb, viaCheckUpload(pScrn, v3d)); v3d->emitClipRect(v3d, &pVia->cb, 0, 0, pDst->drawable.width, - pDst->drawable.height); + pDst->drawable.height); buf = 1; yOffs = 0; @@ -1799,30 +1743,30 @@ viaExaTexUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, sync[1] = -1; while (h) { - buf = (buf) ? 0 : 1; - bufH = (h > height) ? height : h; - dst = pVia->texAddr + ((buf) ? bufOffs : 0); + buf = (buf) ? 0 : 1; + bufH = (h > height) ? height : h; + dst = pVia->texAddr + ((buf) ? bufOffs : 0); - if (sync[buf] >= 0) - viaAccelWaitMarker(pScrn->pScreen, sync[buf]); + if (sync[buf] >= 0) + viaAccelWaitMarker(pScrn->pScreen, sync[buf]); - for (i = 0; i < bufH; ++i) { - memcpy(dst, src, wBytes); - dst += texPitch; - src += src_pitch; - } + for (i = 0; i < bufH; ++i) { + memcpy(dst, src, wBytes); + dst += texPitch; + src += src_pitch; + } - v3d->emitQuad(v3d, &pVia->cb, x, y + yOffs, 0, (buf) ? height : 0, 0, - 0, w, bufH); + v3d->emitQuad(v3d, &pVia->cb, x, y + yOffs, 0, (buf) ? height : 0, 0, + 0, w, bufH); - sync[buf] = viaAccelMarkSync(pScrn->pScreen); + sync[buf] = viaAccelMarkSync(pScrn->pScreen); - h -= bufH; - yOffs += bufH; + h -= bufH; + yOffs += bufH; } if (sync[buf] >= 0) - viaAccelWaitMarker(pScrn->pScreen, sync[buf]); + viaAccelWaitMarker(pScrn->pScreen, sync[buf]); return TRUE; } @@ -1832,10 +1776,9 @@ viaExaTexUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, * and I'd guess that in most situations CPU direct writes are faster. * Use DMA only when alignments match. At least it saves some CPU cycles. */ - static Bool viaExaUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, - int src_pitch) + int src_pitch) { ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; VIAPtr pVia = VIAPTR(pScrn); @@ -1848,29 +1791,29 @@ viaExaUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, dstOffset = x * pDst->drawable.bitsPerPixel; if (dstOffset & 3) - return FALSE; + return FALSE; dstOffset = exaGetPixmapOffset(pDst) + y * dstPitch + (dstOffset >> 3); if (wBytes * h < VIA_MIN_UPLOAD || wBytes < 65) { - dst = (char *)pVia->FBBase + dstOffset; + dst = (char *)pVia->FBBase + dstOffset; - exaWaitSync(pScrn->pScreen); - while (h--) { - memcpy(dst, src, wBytes); - dst += dstPitch; - src += src_pitch; - } - return TRUE; + exaWaitSync(pScrn->pScreen); + while (h--) { + memcpy(dst, src, wBytes); + dst += dstPitch; + src += src_pitch; + } + return TRUE; } if (!pVia->directRenderingEnabled) - return FALSE; + return FALSE; if (((unsigned long)src & 15) || (src_pitch & 15)) - return FALSE; + return FALSE; if ((dstPitch & 3) || (dstOffset & 3)) - return FALSE; + return FALSE; blit.line_length = wBytes; blit.num_lines = h; @@ -1881,14 +1824,13 @@ viaExaUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, blit.to_fb = 1; exaWaitSync(pScrn->pScreen); - while (-EAGAIN == (err = - drmCommandWriteRead(pVia->drmFD, DRM_VIA_DMA_BLIT, &blit, - sizeof(blit)))) ; + while (-EAGAIN == (err = drmCommandWriteRead(pVia->drmFD, DRM_VIA_DMA_BLIT, + &blit, sizeof(blit)))) ; if (err < 0) - return FALSE; + return FALSE; while (-EAGAIN == (err = drmCommandWrite(pVia->drmFD, DRM_VIA_BLIT_SYNC, - &blit.sync, sizeof(blit.sync)))) ; + &blit.sync, sizeof(blit.sync)))) ; return (err == 0); } @@ -1897,7 +1839,6 @@ viaExaUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, static Bool viaExaUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst) { - ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; VIAPtr pVia = VIAPTR(pScrn); char *src, *dst; @@ -1905,7 +1846,7 @@ viaExaUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst) CARD32 dstPitch; if (!pVia->scratchAddr) - return FALSE; + return FALSE; *pDst = *pSrc; w = pSrc->drawable.width; @@ -1915,11 +1856,11 @@ viaExaUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst) viaOrder(wBytes, &dstPitch); dstPitch = 1 << dstPitch; if (dstPitch < 8) - dstPitch = 8; + dstPitch = 8; if (dstPitch * h > pVia->exaScratchSize * 1024) { - ErrorF("EXA UploadToScratch Failed %u %u %u %u\n", - dstPitch, h, dstPitch * h, pVia->exaScratchSize * 1024); - return FALSE; + ErrorF("EXA UploadToScratch Failed %u %u %u %u\n", + dstPitch, h, dstPitch * h, pVia->exaScratchSize * 1024); + return FALSE; } pDst->devKind = dstPitch; @@ -1935,9 +1876,9 @@ viaExaUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst) viaAccelSync(pScrn); while (h--) { - memcpy(dst, src, wBytes); - dst += dstPitch; - src += srcPitch; + memcpy(dst, src, wBytes); + dst += dstPitch; + src += srcPitch; } return TRUE; @@ -1945,42 +1886,38 @@ viaExaUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst) static Bool viaExaCheckComposite(int op, PicturePtr pSrcPicture, - PicturePtr pMaskPicture, PicturePtr pDstPicture) + PicturePtr pMaskPicture, PicturePtr pDstPicture) { - ScrnInfoPtr pScrn = xf86Screens[pDstPicture->pDrawable->pScreen->myNum]; VIAPtr pVia = VIAPTR(pScrn); Via3DState *v3d = &pVia->v3d; - /* - * Reject small composites early. They are done much faster in software. - */ - + /* Reject small composites early. They are done much faster in software. */ if (!pSrcPicture->repeat && - pSrcPicture->pDrawable->width * - pSrcPicture->pDrawable->height < VIA_MIN_COMPOSITE) - return FALSE; + pSrcPicture->pDrawable->width * + pSrcPicture->pDrawable->height < VIA_MIN_COMPOSITE) + return FALSE; if (pMaskPicture && - !pMaskPicture->repeat && - pMaskPicture->pDrawable->width * - pMaskPicture->pDrawable->height < VIA_MIN_COMPOSITE) - return FALSE; + !pMaskPicture->repeat && + pMaskPicture->pDrawable->width * + pMaskPicture->pDrawable->height < VIA_MIN_COMPOSITE) + return FALSE; if (pMaskPicture && pMaskPicture->componentAlpha) { #ifdef VIA_DEBUG_COMPOSITE - ErrorF("Component Alpha operation\n"); + ErrorF("Component Alpha operation\n"); #endif - return FALSE; + return FALSE; } if (!v3d->opSupported(op)) { #ifdef VIA_DEBUG_COMPOSITE #warning Composite verbose debug turned on. - ErrorF("Operator not supported\n"); - viaExaPrintComposite(op, pSrcPicture, pMaskPicture, pDstPicture); + ErrorF("Operator not supported\n"); + viaExaPrintComposite(op, pSrcPicture, pMaskPicture, pDstPicture); #endif - return FALSE; + return FALSE; } /* @@ -1992,22 +1929,22 @@ viaExaCheckComposite(int op, PicturePtr pSrcPicture, if (!v3d->dstSupported(pDstPicture->format)) { #ifdef VIA_DEBUG_COMPOSITE - ErrorF("Destination format not supported:\n"); - viaExaPrintComposite(op, pSrcPicture, pMaskPicture, pDstPicture); + ErrorF("Destination format not supported:\n"); + viaExaPrintComposite(op, pSrcPicture, pMaskPicture, pDstPicture); #endif - return FALSE; + return FALSE; } if (v3d->texSupported(pSrcPicture->format)) { - if (pMaskPicture && (PICT_FORMAT_A(pMaskPicture->format) == 0 || - !v3d->texSupported(pMaskPicture->format))) { + if (pMaskPicture && (PICT_FORMAT_A(pMaskPicture->format) == 0 || + !v3d->texSupported(pMaskPicture->format))) { #ifdef VIA_DEBUG_COMPOSITE - ErrorF("Mask format not supported:\n"); - viaExaPrintComposite(op, pSrcPicture, pMaskPicture, pDstPicture); + ErrorF("Mask format not supported:\n"); + viaExaPrintComposite(op, pSrcPicture, pMaskPicture, pDstPicture); #endif - return FALSE; - } - return TRUE; + return FALSE; + } + return TRUE; } #ifdef VIA_DEBUG_COMPOSITE ErrorF("Src format not supported:\n"); @@ -2023,13 +1960,13 @@ viaIsAGP(VIAPtr pVia, PixmapPtr pPix, unsigned long *offset) unsigned long offs; if (pVia->directRenderingEnabled && !pVia->IsPCI) { - offs = (unsigned long)pPix->devPrivate.ptr - - (unsigned long)pVia->agpMappedAddr; + offs = ((unsigned long)pPix->devPrivate.ptr + - (unsigned long)pVia->agpMappedAddr); - if ((offs - pVia->scratchOffset) < pVia->agpSize) { - *offset = offs + pVia->agpAddr; - return TRUE; - } + if ((offs - pVia->scratchOffset) < pVia->agpSize) { + *offset = offs + pVia->agpAddr; + return TRUE; + } } #endif return FALSE; @@ -2039,13 +1976,13 @@ static Bool viaIsOffscreen(VIAPtr pVia, PixmapPtr pPix) { return ((unsigned long)pPix->devPrivate.ptr - - (unsigned long)pVia->FBBase) < pVia->videoRambytes; + (unsigned long)pVia->FBBase) < pVia->videoRambytes; } static Bool viaExaPrepareComposite(int op, PicturePtr pSrcPicture, - PicturePtr pMaskPicture, PicturePtr pDstPicture, - PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) + PicturePtr pMaskPicture, PicturePtr pDstPicture, + PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) { CARD32 height, width; ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; @@ -2057,7 +1994,7 @@ viaExaPrepareComposite(int op, PicturePtr pSrcPicture, unsigned long offset; v3d->setDestination(v3d, exaGetPixmapOffset(pDst), - exaGetPixmapPitch(pDst), pDstPicture->format); + exaGetPixmapPitch(pDst), pDstPicture->format); v3d->setCompositeOperator(v3d, op); v3d->setDrawing(v3d, 0x0c, 0xFFFFFFFF, 0x000000FF, 0xFF); @@ -2068,21 +2005,20 @@ viaExaPrepareComposite(int op, PicturePtr pSrcPicture, * For one-pixel repeat mask pictures we avoid using multitexturing by * modifying the src's texture blending equation and feed the pixel * value as a constant alpha for the src's texture. Multitexturing on the - * unichromes seems somewhat slow, so this speeds up translucent windows. + * Unichromes seems somewhat slow, so this speeds up translucent windows. */ srcMode = via_src; pVia->maskP = NULL; if (pMaskPicture && - (pMaskPicture->pDrawable->height == 1) && - (pMaskPicture->pDrawable->width == 1) && - pMaskPicture->repeat && viaExpandablePixel(pMaskPicture->format)) { - pVia->maskP = pMask->devPrivate.ptr; - pVia->maskFormat = pMaskPicture->format; - pVia->componentAlpha = pMaskPicture->componentAlpha; - srcMode = - (pMaskPicture-> - componentAlpha) ? via_src_onepix_comp_mask : via_src_onepix_mask; + (pMaskPicture->pDrawable->height == 1) && + (pMaskPicture->pDrawable->width == 1) && + pMaskPicture->repeat && viaExpandablePixel(pMaskPicture->format)) { + pVia->maskP = pMask->devPrivate.ptr; + pVia->maskFormat = pMaskPicture->format; + pVia->componentAlpha = pMaskPicture->componentAlpha; + srcMode = ((pMaskPicture->componentAlpha) + ? via_src_onepix_comp_mask : via_src_onepix_mask); } /* @@ -2091,66 +2027,64 @@ viaExaPrepareComposite(int op, PicturePtr pSrcPicture, */ pVia->srcP = NULL; - if (pSrcPicture && - (pSrcPicture->pDrawable->height == 1) && - (pSrcPicture->pDrawable->width == 1) && - pSrcPicture->repeat && viaExpandablePixel(pSrcPicture->format)) { - pVia->srcP = pSrc->devPrivate.ptr; - pVia->srcFormat = pSrcPicture->format; + if (pSrcPicture && pSrcPicture->repeat + && (pSrcPicture->pDrawable->height == 1) + && (pSrcPicture->pDrawable->width == 1) + && viaExpandablePixel(pSrcPicture->format)) { + pVia->srcP = pSrc->devPrivate.ptr; + pVia->srcFormat = pSrcPicture->format; } - /* - * Exa should be smart enough to eliminate this IN operation. - */ - + /* Exa should be smart enough to eliminate this IN operation. */ if (pVia->srcP && pVia->maskP) { - ErrorF - ("Bad one-pixel IN composite operation. EXA needs to be smarter.\n"); - return FALSE; + ErrorF("Bad one-pixel IN composite operation. " + "EXA needs to be smarter.\n"); + return FALSE; } if (!pVia->srcP) { - offset = exaGetPixmapOffset(pSrc); - isAGP = viaIsAGP(pVia, pSrc, &offset); - if (!isAGP && !viaIsOffscreen(pVia, pSrc)) - return FALSE; - if (!v3d->setTexture(v3d, curTex, offset, - exaGetPixmapPitch(pSrc), pVia->nPOT[curTex], 1 << width, - 1 << height, pSrcPicture->format, via_repeat, via_repeat, - srcMode, isAGP)) { - return FALSE; - } - curTex++; + offset = exaGetPixmapOffset(pSrc); + isAGP = viaIsAGP(pVia, pSrc, &offset); + if (!isAGP && !viaIsOffscreen(pVia, pSrc)) + return FALSE; + if (!v3d->setTexture(v3d, curTex, offset, + exaGetPixmapPitch(pSrc), pVia->nPOT[curTex], + 1 << width, 1 << height, pSrcPicture->format, + via_repeat, via_repeat, srcMode, isAGP)) { + return FALSE; + } + curTex++; } if (pMaskPicture && !pVia->maskP) { - offset = exaGetPixmapOffset(pMask); - isAGP = viaIsAGP(pVia, pMask, &offset); - if (!isAGP && !viaIsOffscreen(pVia, pMask)) - return FALSE; - viaOrder(pMask->drawable.width, &width); - viaOrder(pMask->drawable.height, &height); - if (!v3d->setTexture(v3d, curTex, offset, - exaGetPixmapPitch(pMask), pVia->nPOT[curTex], 1 << width, - 1 << height, pMaskPicture->format, via_repeat, via_repeat, - (pMaskPicture->componentAlpha) ? via_comp_mask : via_mask, - isAGP)) { - return FALSE; - } - curTex++; + offset = exaGetPixmapOffset(pMask); + isAGP = viaIsAGP(pVia, pMask, &offset); + if (!isAGP && !viaIsOffscreen(pVia, pMask)) + return FALSE; + viaOrder(pMask->drawable.width, &width); + viaOrder(pMask->drawable.height, &height); + if (!v3d->setTexture(v3d, curTex, offset, + exaGetPixmapPitch(pMask), pVia->nPOT[curTex], + 1 << width, 1 << height, pMaskPicture->format, + via_repeat, via_repeat, + ((pMaskPicture->componentAlpha) + ? via_comp_mask : via_mask), isAGP)) { + return FALSE; + } + curTex++; } v3d->setFlags(v3d, curTex, FALSE, TRUE, TRUE); v3d->emitState(v3d, &pVia->cb, viaCheckUpload(pScrn, v3d)); v3d->emitClipRect(v3d, &pVia->cb, 0, 0, pDst->drawable.width, - pDst->drawable.height); + pDst->drawable.height); return TRUE; } static void viaExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, - int dstX, int dstY, int width, int height) + int dstX, int dstY, int width, int height) { ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; VIAPtr pVia = VIAPTR(pScrn); @@ -2158,21 +2092,21 @@ viaExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, CARD32 col; if (pVia->maskP) { - viaPixelARGB8888(pVia->maskFormat, pVia->maskP, &col); - v3d->setTexBlendCol(v3d, 0, pVia->componentAlpha, col); + viaPixelARGB8888(pVia->maskFormat, pVia->maskP, &col); + v3d->setTexBlendCol(v3d, 0, pVia->componentAlpha, col); } if (pVia->srcP) { - viaPixelARGB8888(pVia->srcFormat, pVia->srcP, &col); - v3d->setDrawing(v3d, 0x0c, 0xFFFFFFFF, col & 0x00FFFFFF, col >> 24); - srcX = maskX; - srcY = maskY; + viaPixelARGB8888(pVia->srcFormat, pVia->srcP, &col); + v3d->setDrawing(v3d, 0x0c, 0xFFFFFFFF, col & 0x00FFFFFF, col >> 24); + srcX = maskX; + srcY = maskY; } if (pVia->maskP || pVia->srcP) - v3d->emitState(v3d, &pVia->cb, viaCheckUpload(pScrn, v3d)); + v3d->emitState(v3d, &pVia->cb, viaCheckUpload(pScrn, v3d)); - v3d->emitQuad(v3d, &pVia->cb, dstX, dstY, srcX, srcY, maskX, maskY, width, - height); + v3d->emitQuad(v3d, &pVia->cb, dstX, dstY, srcX, srcY, maskX, maskY, + width, height); } #if (EXA_VERSION_MAJOR >= 2) @@ -2187,7 +2121,7 @@ viaInitExa(ScreenPtr pScreen) memset(pExa, 0, sizeof(*pExa)); if (!pExa) - return NULL; + return NULL; pExa->exa_major = EXA_VERSION_MAJOR; pExa->exa_minor = EXA_VERSION_MINOR; @@ -2196,8 +2130,8 @@ viaInitExa(ScreenPtr pScreen) pExa->offScreenBase = pScrn->virtualY * pVia->Bpl; pExa->pixmapOffsetAlign = 32; pExa->pixmapPitchAlign = 16; - pExa->flags = EXA_OFFSCREEN_PIXMAPS | - (pVia->nPOT[1] ? 0 : EXA_OFFSCREEN_ALIGN_POT); + pExa->flags = EXA_OFFSCREEN_PIXMAPS | + (pVia->nPOT[1] ? 0 : EXA_OFFSCREEN_ALIGN_POT); pExa->maxX = 2047; pExa->maxY = 2047; pExa->WaitMarker = viaAccelWaitMarker; @@ -2212,39 +2146,38 @@ viaInitExa(ScreenPtr pScreen) #ifdef XF86DRI if (pVia->directRenderingEnabled) { #ifdef linux - if ((pVia->drmVerMajor > 2) || - ((pVia->drmVerMajor == 2) && (pVia->drmVerMinor >= 7))) { - pExa->DownloadFromScreen = viaExaDownloadFromScreen; - } + if ((pVia->drmVerMajor > 2) || + ((pVia->drmVerMajor == 2) && (pVia->drmVerMinor >= 7))) { + pExa->DownloadFromScreen = viaExaDownloadFromScreen; + } #endif /* linux */ - switch (pVia->Chipset) { - case VIA_K8M800: - case VIA_KM400: - pExa->UploadToScreen = viaExaTexUploadToScreen; - break; - default: - pExa->UploadToScreen = NULL; - break; - } + switch (pVia->Chipset) { + case VIA_K8M800: + case VIA_KM400: + pExa->UploadToScreen = viaExaTexUploadToScreen; + break; + default: + pExa->UploadToScreen = NULL; + break; + } } #endif /* XF86DRI */ pExa->UploadToScratch = viaExaUploadToScratch; if (!pVia->noComposite) { - pExa->CheckComposite = viaExaCheckComposite; - pExa->PrepareComposite = viaExaPrepareComposite; - pExa->Composite = viaExaComposite; - pExa->DoneComposite = viaExaDoneSolidCopy; + pExa->CheckComposite = viaExaCheckComposite; + pExa->PrepareComposite = viaExaPrepareComposite; + pExa->Composite = viaExaComposite; + pExa->DoneComposite = viaExaDoneSolidCopy; } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[EXA] Disabling EXA accelerated composite.\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[EXA] Disabling EXA accelerated composite.\n"); } - if (!exaDriverInit(pScreen, pExa)) { - xfree(pExa); - return NULL; + xfree(pExa); + return NULL; } viaInit3DState(&pVia->v3d); @@ -2254,9 +2187,8 @@ viaInitExa(ScreenPtr pScreen) #else /* - * Init EXA. Alignments are 2D engine constraints. + * Initialize EXA. Alignments are 2D engine constraints. */ - static ExaDriverPtr viaInitExa(ScreenPtr pScreen) { @@ -2265,7 +2197,7 @@ viaInitExa(ScreenPtr pScreen) ExaDriverPtr pExa = (ExaDriverPtr) xnfcalloc(sizeof(ExaDriverRec), 1); if (!pExa) - return NULL; + return NULL; pExa->card.memoryBase = pVia->FBBase; pExa->card.memorySize = pVia->FBFreeEnd; @@ -2273,7 +2205,7 @@ viaInitExa(ScreenPtr pScreen) pExa->card.pixmapOffsetAlign = 32; pExa->card.pixmapPitchAlign = 16; pExa->card.flags = EXA_OFFSCREEN_PIXMAPS | - (pVia->nPOT[1] ? 0 : EXA_OFFSCREEN_ALIGN_POT); + (pVia->nPOT[1] ? 0 : EXA_OFFSCREEN_ALIGN_POT); pExa->card.maxX = 2047; pExa->card.maxY = 2047; @@ -2289,33 +2221,33 @@ viaInitExa(ScreenPtr pScreen) #ifdef XF86DRI if (pVia->directRenderingEnabled) { #ifdef linux - if ((pVia->drmVerMajor > 2) || - ((pVia->drmVerMajor == 2) && (pVia->drmVerMinor >= 7))) { - if (pVia->Chipset != VIA_K8M800) - pExa->accel.UploadToScreen = viaExaUploadToScreen; - pExa->accel.DownloadFromScreen = viaExaDownloadFromScreen; - } + if ((pVia->drmVerMajor > 2) || + ((pVia->drmVerMajor == 2) && (pVia->drmVerMinor >= 7))) { + if (pVia->Chipset != VIA_K8M800) + pExa->accel.UploadToScreen = viaExaUploadToScreen; + pExa->accel.DownloadFromScreen = viaExaDownloadFromScreen; + } #endif /* linux */ - if (pVia->Chipset == VIA_K8M800) - pExa->accel.UploadToScreen = viaExaTexUploadToScreen; + if (pVia->Chipset == VIA_K8M800) + pExa->accel.UploadToScreen = viaExaTexUploadToScreen; } #endif /* XF86DRI */ pExa->accel.UploadToScratch = viaExaUploadToScratch; if (!pVia->noComposite) { - pExa->accel.CheckComposite = viaExaCheckComposite; - pExa->accel.PrepareComposite = viaExaPrepareComposite; - pExa->accel.Composite = viaExaComposite; - pExa->accel.DoneComposite = viaExaDoneSolidCopy; + pExa->accel.CheckComposite = viaExaCheckComposite; + pExa->accel.PrepareComposite = viaExaPrepareComposite; + pExa->accel.Composite = viaExaComposite; + pExa->accel.DoneComposite = viaExaDoneSolidCopy; } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[EXA] Disabling EXA accelerated composite.\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[EXA] Disabling EXA accelerated composite.\n"); } if (!exaDriverInit(pScreen, pExa)) { - xfree(pExa); - return NULL; + xfree(pExa); + return NULL; } viaInit3DState(&pVia->v3d); @@ -2326,10 +2258,9 @@ viaInitExa(ScreenPtr pScreen) #endif /* VIA_HAVE_EXA */ /* - * Acceleration init function. Sets up offscreen memory disposition, initializes engines - * and acceleration method. + * Acceleration initializatuon function. Sets up offscreen memory disposition, + * and initializes engines and acceleration method. */ - Bool viaInitAccel(ScreenPtr pScreen) { @@ -2340,23 +2271,19 @@ viaInitAccel(ScreenPtr pScreen) Bool nPOTSupported; pVia->VQStart = 0; - if (((pVia->FBFreeEnd - pVia->FBFreeStart) >= VIA_VQ_SIZE) && - pVia->VQEnable) { + if (((pVia->FBFreeEnd - pVia->FBFreeStart) >= VIA_VQ_SIZE) + && pVia->VQEnable) { pVia->VQStart = pVia->FBFreeEnd - VIA_VQ_SIZE; pVia->VQEnd = pVia->VQStart + VIA_VQ_SIZE - 1; pVia->FBFreeEnd -= VIA_VQ_SIZE; } - if (pVia->cursor->isHWCursorEnabled) { + if (pVia->cursor->isHWCursorEnabled) viaCursorSetFB(pScrn); - } viaInitialize2DEngine(pScrn); - /* - * Sync marker space. - */ - + /* Sync marker space. */ pVia->FBFreeEnd -= 32; pVia->markerOffset = (pVia->FBFreeEnd + 31) & ~31; pVia->markerBuf = (CARD32 *) ((char *)pVia->FBBase + pVia->markerOffset); @@ -2372,9 +2299,9 @@ viaInitAccel(ScreenPtr pScreen) nPOTSupported = TRUE; #ifdef XF86DRI - nPOTSupported = (!pVia->directRenderingEnabled) || - (pVia->drmVerMajor > 2) || - ((pVia->drmVerMajor == 2) && (pVia->drmVerMinor >= 11)); + nPOTSupported = ((!pVia->directRenderingEnabled) || + (pVia->drmVerMajor > 2) || + ((pVia->drmVerMajor == 2) && (pVia->drmVerMinor >= 11))); #endif pVia->nPOT[0] = nPOTSupported; pVia->nPOT[1] = nPOTSupported; @@ -2386,31 +2313,31 @@ viaInitAccel(ScreenPtr pScreen) pVia->scratchAddr = NULL; #endif /* XF86DRI */ if (pVia->useEXA) { - pVia->exaDriverPtr = viaInitExa(pScreen); - if (!pVia->exaDriverPtr) { + pVia->exaDriverPtr = viaInitExa(pScreen); + if (!pVia->exaDriverPtr) { - /* - * Docs recommend turning off also Xv here, but we handle this - * case with the old linear offscreen FB manager through - * VIAInitLinear. - */ + /* + * Docs recommend turning off also Xv here, but we handle this + * case with the old linear offscreen FB manager through + * VIAInitLinear. + */ - pVia->NoAccel = TRUE; - return FALSE; - } + pVia->NoAccel = TRUE; + return FALSE; + } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[EXA] Trying to enable EXA acceleration.\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[EXA] Trying to enable EXA acceleration.\n"); - pVia->driSize = (pVia->FBFreeEnd - pVia->FBFreeStart) / 2; + pVia->driSize = (pVia->FBFreeEnd - pVia->FBFreeStart) / 2; - if ((pVia->driSize > (pVia->maxDriSize * 1024)) - && pVia->maxDriSize > 0) - pVia->driSize = pVia->maxDriSize * 1024; + if ((pVia->driSize > (pVia->maxDriSize * 1024)) + && pVia->maxDriSize > 0) + pVia->driSize = pVia->maxDriSize * 1024; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[EXA] Enabled EXA acceleration.\n"); - return TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[EXA] Enabled EXA acceleration.\n"); + return TRUE; } #endif /* VIA_HAVE_EXA */ @@ -2426,15 +2353,15 @@ viaInitAccel(ScreenPtr pScreen) #ifdef XF86DRI if (pVia->directRenderingEnabled) { - pVia->driSize = (pVia->FBFreeEnd - pVia->FBFreeStart) / 2; - maxY = pScrn->virtualY + (pVia->driSize / pVia->Bpl); + pVia->driSize = (pVia->FBFreeEnd - pVia->FBFreeStart) / 2; + maxY = pScrn->virtualY + (pVia->driSize / pVia->Bpl); } else #endif { - maxY = pVia->FBFreeEnd / pVia->Bpl; + maxY = pVia->FBFreeEnd / pVia->Bpl; } if (maxY > 4 * pScrn->virtualY) - maxY = 4 * pScrn->virtualY; + maxY = 4 * pScrn->virtualY; pVia->FBFreeStart = (maxY + 1) * pVia->Bpl; @@ -2444,11 +2371,11 @@ viaInitAccel(ScreenPtr pScreen) pVia->driSize = (pVia->FBFreeEnd - pVia->FBFreeStart - pVia->Bpl); if ((pVia->driSize > (pVia->maxDriSize * 1024)) && pVia->maxDriSize > 0) - pVia->driSize = pVia->maxDriSize * 1024; + pVia->driSize = pVia->maxDriSize * 1024; DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Using %d lines for offscreen memory.\n", - AvailFBArea.y2 - pScrn->virtualY)); + "Using %d lines for offscreen memory.\n", + AvailFBArea.y2 - pScrn->virtualY)); return viaInitXAA(pScreen); } @@ -2456,7 +2383,6 @@ viaInitAccel(ScreenPtr pScreen) /* * Free the used acceleration resources. */ - void viaExitAccel(ScreenPtr pScreen) { @@ -2469,39 +2395,38 @@ viaExitAccel(ScreenPtr pScreen) #ifdef VIA_HAVE_EXA if (pVia->useEXA) { #ifdef XF86DRI - if (pVia->directRenderingEnabled) { - if (pVia->texAddr) { - drmCommandWrite(pVia->drmFD, DRM_VIA_FREEMEM, - &pVia->texAGPBuffer, sizeof(drm_via_mem_t)); - pVia->texAddr = NULL; - } - if (pVia->scratchAddr && !pVia->IsPCI && - ((unsigned long)pVia->scratchAddr - - (unsigned long)pVia->agpMappedAddr == - pVia->scratchOffset)) { - drmCommandWrite(pVia->drmFD, DRM_VIA_FREEMEM, - &pVia->scratchAGPBuffer, sizeof(drm_via_mem_t)); - pVia->scratchAddr = NULL; - } - } - if (pVia->dBounce) - xfree(pVia->dBounce); + if (pVia->directRenderingEnabled) { + if (pVia->texAddr) { + drmCommandWrite(pVia->drmFD, DRM_VIA_FREEMEM, + &pVia->texAGPBuffer, sizeof(drm_via_mem_t)); + pVia->texAddr = NULL; + } + if (pVia->scratchAddr && !pVia->IsPCI && + ((unsigned long)pVia->scratchAddr - + (unsigned long)pVia->agpMappedAddr == pVia->scratchOffset)) { + drmCommandWrite(pVia->drmFD, DRM_VIA_FREEMEM, + &pVia->scratchAGPBuffer, sizeof(drm_via_mem_t)); + pVia->scratchAddr = NULL; + } + } + if (pVia->dBounce) + xfree(pVia->dBounce); #endif /* XF86DRI */ - if (pVia->scratchAddr) { - exaOffscreenFree(pScreen, pVia->scratchFBBuffer); - pVia->scratchAddr = NULL; - } - if (pVia->exaDriverPtr) { - exaDriverFini(pScreen); - } - xfree(pVia->exaDriverPtr); - pVia->exaDriverPtr = NULL; - return; + if (pVia->scratchAddr) { + exaOffscreenFree(pScreen, pVia->scratchFBBuffer); + pVia->scratchAddr = NULL; + } + if (pVia->exaDriverPtr) { + exaDriverFini(pScreen); + } + xfree(pVia->exaDriverPtr); + pVia->exaDriverPtr = NULL; + return; } #endif /* VIA_HAVE_EXA */ if (pVia->AccelInfoRec) { - XAADestroyInfoRec(pVia->AccelInfoRec); - pVia->AccelInfoRec = NULL; + XAADestroyInfoRec(pVia->AccelInfoRec); + pVia->AccelInfoRec = NULL; } } @@ -2510,7 +2435,6 @@ viaExitAccel(ScreenPtr pScreen) * and EXA scratch area. The scratch area resides primarily in AGP memory, * but reverts to FB if AGP is not available. */ - void viaFinishInitAccel(ScreenPtr pScreen) { @@ -2523,92 +2447,87 @@ viaFinishInitAccel(ScreenPtr pScreen) if (pVia->directRenderingEnabled && pVia->useEXA) { - pVia->dBounce = xcalloc(VIA_DMA_DL_SIZE * 2, 1); + pVia->dBounce = xcalloc(VIA_DMA_DL_SIZE * 2, 1); - if (!pVia->IsPCI) { + if (!pVia->IsPCI) { - /* - * Allocate upload and scratch space. - */ + /* Allocate upload and scratch space. */ #if (EXA_VERSION_MAJOR >= 2) - if (pVia->exaDriverPtr->UploadToScreen == viaExaTexUploadToScreen) { + if (pVia->exaDriverPtr->UploadToScreen == viaExaTexUploadToScreen) { #else - if (pVia->exaDriverPtr->accel.UploadToScreen == - viaExaTexUploadToScreen) { + if (pVia->exaDriverPtr->accel.UploadToScreen == + viaExaTexUploadToScreen) { #endif - size = VIA_AGP_UPL_SIZE * 2 + 32; - pVia->texAGPBuffer.context = 1; - pVia->texAGPBuffer.size = size; - pVia->texAGPBuffer.type = VIA_MEM_AGP; - ret = - drmCommandWriteRead(pVia->drmFD, DRM_VIA_ALLOCMEM, - &pVia->texAGPBuffer, sizeof(drm_via_mem_t)); - - if (ret || size != pVia->texAGPBuffer.size) { - pVia->texAGPBuffer.size = 0; - } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Allocated %u kiB of AGP memory for system to frame-buffer transfer.\n", - size / 1024); - pVia->texOffset = (pVia->texAGPBuffer.offset + 31) & ~31; - pVia->texAddr = - (char *)pVia->agpMappedAddr + pVia->texOffset; - } - - } - - size = pVia->exaScratchSize * 1024 + 32; - pVia->scratchAGPBuffer.context = 1; - pVia->scratchAGPBuffer.size = size; - pVia->scratchAGPBuffer.type = VIA_MEM_AGP; - ret = - drmCommandWriteRead(pVia->drmFD, DRM_VIA_ALLOCMEM, - &pVia->scratchAGPBuffer, sizeof(drm_via_mem_t)); - if (ret || size != pVia->scratchAGPBuffer.size) { - pVia->scratchAGPBuffer.size = 0; - } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Allocated %u kiB of AGP memory for EXA scratch area.\n", - size / 1024); - pVia->scratchOffset = - (pVia->scratchAGPBuffer.offset + 31) & ~31; - pVia->scratchAddr = - (char *)pVia->agpMappedAddr + pVia->scratchOffset; - } - - } + size = VIA_AGP_UPL_SIZE * 2 + 32; + pVia->texAGPBuffer.context = 1; + pVia->texAGPBuffer.size = size; + pVia->texAGPBuffer.type = VIA_MEM_AGP; + ret = drmCommandWriteRead(pVia->drmFD, DRM_VIA_ALLOCMEM, + &pVia->texAGPBuffer, + sizeof(drm_via_mem_t)); + + if (ret || size != pVia->texAGPBuffer.size) { + pVia->texAGPBuffer.size = 0; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Allocated %u kiB of AGP memory for " + "system-to-framebuffer transfer.\n", + size / 1024); + pVia->texOffset = (pVia->texAGPBuffer.offset + 31) & ~31; + pVia->texAddr = + (char *)pVia->agpMappedAddr + pVia->texOffset; + } + } + + size = pVia->exaScratchSize * 1024 + 32; + pVia->scratchAGPBuffer.context = 1; + pVia->scratchAGPBuffer.size = size; + pVia->scratchAGPBuffer.type = VIA_MEM_AGP; + ret = drmCommandWriteRead(pVia->drmFD, DRM_VIA_ALLOCMEM, + &pVia->scratchAGPBuffer, + sizeof(drm_via_mem_t)); + if (ret || size != pVia->scratchAGPBuffer.size) { + pVia->scratchAGPBuffer.size = 0; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Allocated %u kiB of AGP memory for " + "EXA scratch area.\n", size / 1024); + pVia->scratchOffset = + (pVia->scratchAGPBuffer.offset + 31) & ~31; + pVia->scratchAddr = + (char *)pVia->agpMappedAddr + pVia->scratchOffset; + } + } } #endif /* XF86DRI */ if (!pVia->scratchAddr && pVia->useEXA) { - pVia->scratchFBBuffer = - exaOffscreenAlloc(pScreen, pVia->exaScratchSize * 1024, - 32, TRUE, NULL, NULL); - if (pVia->scratchFBBuffer) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Allocated %u kiB of framebuffer memory for EXA scratch area.\n", - pVia->exaScratchSize); - pVia->scratchOffset = pVia->scratchFBBuffer->offset; - pVia->scratchAddr = (char *)pVia->FBBase + pVia->scratchOffset; - } - + pVia->scratchFBBuffer = + exaOffscreenAlloc(pScreen, pVia->exaScratchSize * 1024, + 32, TRUE, NULL, NULL); + if (pVia->scratchFBBuffer) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Allocated %u kiB of framebuffer memory for " + "EXA scratch area.\n", pVia->exaScratchSize); + pVia->scratchOffset = pVia->scratchFBBuffer->offset; + pVia->scratchAddr = (char *)pVia->FBBase + pVia->scratchOffset; + } } #endif /* VIA_HAVE_EXA */ if (Success != viaSetupCBuffer(pScrn, &pVia->cb, 0)) { - pVia->NoAccel = TRUE; - viaExitAccel(pScreen); - return; + pVia->NoAccel = TRUE; + viaExitAccel(pScreen); + return; } } /* - * DGA accelerated functions go here and let them be independent of acceleration - * method. + * DGA accelerated functions go here and let them be independent of + * acceleration method. */ - void viaAccelBlitRect(ScrnInfoPtr pScrn, int srcx, int srcy, int w, int h, - int dstx, int dsty) + int dstx, int dsty) { VIAPtr pVia = VIAPTR(pScrn); ViaTwodContext *tdc = &pVia->td; @@ -2618,75 +2537,75 @@ viaAccelBlitRect(ScrnInfoPtr pScrn, int srcx, int srcy, int w, int h, RING_VARS; if (!w || !h) - return; + return; if (!pVia->NoAccel) { - int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; - int ydir = (srcy < dsty) ? -1 : 1; - CARD32 cmd = VIA_GEC_BLT | VIAACCELCOPYROP(GXcopy); + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; + CARD32 cmd = VIA_GEC_BLT | VIAACCELCOPYROP(GXcopy); - if (xdir < 0) - cmd |= VIA_GEC_DECX; - if (ydir < 0) - cmd |= VIA_GEC_DECY; + if (xdir < 0) + cmd |= VIA_GEC_DECX; + if (ydir < 0) + cmd |= VIA_GEC_DECY; - viaAccelSetMode(pScrn->bitsPerPixel, tdc); - viaAccelTransparentHelper(tdc, cb, 0x0, 0x0, FALSE); - viaAccelCopyHelper(cb, srcx, 0, dstx, 0, w, h, srcOffset, dstOffset, - tdc->mode, pVia->Bpl, pVia->Bpl, cmd); - pVia->accelMarker = viaAccelMarkSync(pScrn->pScreen); - ADVANCE_RING; + viaAccelSetMode(pScrn->bitsPerPixel, tdc); + viaAccelTransparentHelper(tdc, cb, 0x0, 0x0, FALSE); + viaAccelCopyHelper(cb, srcx, 0, dstx, 0, w, h, srcOffset, dstOffset, + tdc->mode, pVia->Bpl, pVia->Bpl, cmd); + pVia->accelMarker = viaAccelMarkSync(pScrn->pScreen); + ADVANCE_RING; } } void viaAccelFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, - unsigned long color) + unsigned long color) { VIAPtr pVia = VIAPTR(pScrn); unsigned dstBase = pScrn->fbOffset + y * pVia->Bpl; ViaTwodContext *tdc = &pVia->td; CARD32 cmd = VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | - VIAACCELPATTERNROP(GXcopy); + VIAACCELPATTERNROP(GXcopy); RING_VARS; if (!w || !h) - return; + return; if (!pVia->NoAccel) { - viaAccelSetMode(pScrn->bitsPerPixel, tdc); - viaAccelTransparentHelper(tdc, cb, 0x0, 0x0, FALSE); - viaAccelSolidHelper(cb, x, 0, w, h, dstBase, tdc->mode, - pVia->Bpl, color, cmd); - pVia->accelMarker = viaAccelMarkSync(pScrn->pScreen); - ADVANCE_RING; + viaAccelSetMode(pScrn->bitsPerPixel, tdc); + viaAccelTransparentHelper(tdc, cb, 0x0, 0x0, FALSE); + viaAccelSolidHelper(cb, x, 0, w, h, dstBase, tdc->mode, + pVia->Bpl, color, cmd); + pVia->accelMarker = viaAccelMarkSync(pScrn->pScreen); + ADVANCE_RING; } } void viaAccelFillPixmap(ScrnInfoPtr pScrn, - unsigned long offset, - unsigned long pitch, - int depth, int x, int y, int w, int h, unsigned long color) + unsigned long offset, + unsigned long pitch, + int depth, int x, int y, int w, int h, unsigned long color) { VIAPtr pVia = VIAPTR(pScrn); unsigned dstBase = offset + y * pitch; ViaTwodContext *tdc = &pVia->td; CARD32 cmd = VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | - VIAACCELPATTERNROP(GXcopy); + VIAACCELPATTERNROP(GXcopy); RING_VARS; if (!w || !h) - return; + return; if (!pVia->NoAccel) { - viaAccelSetMode(depth, tdc); - viaAccelTransparentHelper(tdc, cb, 0x0, 0x0, FALSE); - viaAccelSolidHelper(cb, x, 0, w, h, dstBase, tdc->mode, - pitch, color, cmd); - pVia->accelMarker = viaAccelMarkSync(pScrn->pScreen); - ADVANCE_RING; + viaAccelSetMode(depth, tdc); + viaAccelTransparentHelper(tdc, cb, 0x0, 0x0, FALSE); + viaAccelSolidHelper(cb, x, 0, w, h, dstBase, tdc->mode, + pitch, color, cmd); + pVia->accelMarker = viaAccelMarkSync(pScrn->pScreen); + ADVANCE_RING; } } @@ -2700,12 +2619,13 @@ viaAccelSyncMarker(ScrnInfoPtr pScrn) void viaAccelTextureBlit(ScrnInfoPtr pScrn, unsigned long srcOffset, - unsigned srcPitch, unsigned w, unsigned h, unsigned srcX, unsigned srcY, - unsigned srcFormat, unsigned long dstOffset, unsigned dstPitch, - unsigned dstX, unsigned dstY, unsigned dstFormat, int rotate) + unsigned srcPitch, unsigned w, unsigned h, unsigned srcX, + unsigned srcY, unsigned srcFormat, unsigned long dstOffset, + unsigned dstPitch, unsigned dstX, unsigned dstY, + unsigned dstFormat, int rotate) { VIAPtr pVia = VIAPTR(pScrn); - unsigned wOrder, hOrder; + CARD32 wOrder, hOrder; Via3DState *v3d = &pVia->v3d; viaOrder(w, &wOrder); @@ -2714,8 +2634,9 @@ viaAccelTextureBlit(ScrnInfoPtr pScrn, unsigned long srcOffset, v3d->setDestination(v3d, dstOffset, dstPitch, dstFormat); v3d->setDrawing(v3d, 0x0c, 0xFFFFFFFF, 0x000000FF, 0x00); v3d->setFlags(v3d, 1, TRUE, TRUE, FALSE); - v3d->setTexture(v3d, 0, srcOffset, srcPitch, TRUE, 1 << wOrder, - 1 << hOrder, srcFormat, via_single, via_single, via_src, FALSE); + v3d->setTexture(v3d, 0, srcOffset, srcPitch, TRUE, + 1 << wOrder, 1 << hOrder, srcFormat, + via_single, via_single, via_src, FALSE); v3d->emitState(v3d, &pVia->cb, viaCheckUpload(pScrn, v3d)); v3d->emitClipRect(v3d, &pVia->cb, dstX, dstY, w, h); v3d->emitQuad(v3d, &pVia->cb, dstX, dstY, srcX, srcY, 0, 0, w, h); diff --git a/src/via_driver.c b/src/via_driver.c index 5852134..e174cd7 100644 --- a/src/via_driver.c +++ b/src/via_driver.c @@ -130,7 +130,6 @@ typedef enum { OPTION_EXA_SCRATCH_SIZE, #endif OPTION_SWCURSOR, - OPTION_HWCURSOR, OPTION_SHADOW_FB, OPTION_ROTATE, OPTION_VIDEORAM, @@ -140,11 +139,9 @@ typedef enum { OPTION_PANELSIZE, OPTION_FORCEPANEL, OPTION_TVDOTCRAWL, - OPTION_TVPROGRESSIVE, OPTION_TVTYPE, OPTION_TVOUTPUT, OPTION_DISABLEVQ, - OPTION_DRIXINERAMA, OPTION_DISABLEIRQ, OPTION_TVDEFLICKER, OPTION_AGP_DMA, @@ -170,7 +167,6 @@ static OptionInfoRec VIAOptions[] = { {OPTION_EXA_NOCOMPOSITE, "ExaNoComposite", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_EXA_SCRATCH_SIZE, "ExaScratchSize", OPTV_INTEGER, {0}, FALSE}, #endif - {OPTION_HWCURSOR, "HWCursor", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_SWCURSOR, "SWCursor", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE}, @@ -183,7 +179,6 @@ static OptionInfoRec VIAOptions[] = { {OPTION_FORCEPANEL, "ForcePanel", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_TVDOTCRAWL, "TVDotCrawl", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_TVDEFLICKER, "TVDeflicker", OPTV_INTEGER, {0}, FALSE}, - {OPTION_TVPROGRESSIVE, "TVProgressive", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_TVTYPE, "TVType", OPTV_ANYSTR, {0}, FALSE}, {OPTION_TVOUTPUT, "TVOutput", OPTV_ANYSTR, {0}, FALSE}, {OPTION_DISABLEVQ, "DisableVQ", OPTV_BOOLEAN, {0}, FALSE}, @@ -445,7 +440,8 @@ VIASetup(pointer module, pointer opts, int *errmaj, int *errmin) #endif /* XFree86LOADER */ -static Bool VIAGetRec(ScrnInfoPtr pScrn) +static Bool +VIAGetRec(ScrnInfoPtr pScrn) { Bool ret ; DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAGetRec\n")); @@ -539,22 +535,22 @@ static void VIAFreeRec(ScrnInfoPtr pScrn) } /* VIAFreeRec */ - -static const OptionInfoRec * VIAAvailableOptions(int chipid, int busid) +static const +OptionInfoRec * VIAAvailableOptions(int chipid, int busid) { - return VIAOptions; - -} /* VIAAvailableOptions */ +} -static void VIAIdentify(int flags) +static void +VIAIdentify(int flags) { xf86PrintChipsets("OPENCHROME", "Driver for VIA Chrome chipsets", VIAChipsets); -} /* VIAIdentify */ +} -static Bool VIAProbe(DriverPtr drv, int flags) +static Bool +VIAProbe(DriverPtr drv, int flags) { GDevPtr *devSections; int *usedChips; @@ -666,7 +662,8 @@ static Bool VIAProbe(DriverPtr drv, int flags) } /* VIAProbe */ #ifdef XF86DRI -static void kickVblank(ScrnInfoPtr pScrn) +static void +kickVblank(ScrnInfoPtr pScrn) { /* * Switching mode will clear registers that make vblank @@ -685,7 +682,8 @@ static void kickVblank(ScrnInfoPtr pScrn) } #endif -static int LookupChipSet(PciChipsets *pset, int chipSet) +static int +LookupChipSet(PciChipsets *pset, int chipSet) { while (pset->numChipset >= 0) { if (pset->numChipset == chipSet) return pset->PCIid; @@ -699,8 +697,7 @@ static int LookupChipID(PciChipsets* pset, int ChipID) { /* Is there a function to do this for me? */ - while (pset->numChipset >= 0) - { + while (pset->numChipset >= 0) { if (pset->PCIid == ChipID) return pset->numChipset; @@ -708,8 +705,7 @@ LookupChipID(PciChipsets* pset, int ChipID) } return -1; - -} /* LookupChipID */ +} static void VIAProbeDDC(ScrnInfoPtr pScrn, int index) @@ -736,8 +732,8 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn) #ifdef VIA_HAVE_EXA pVia->noComposite = FALSE; pVia->exaScratchSize = VIA_SCRATCH_SIZE / 1024; -#endif /* VIA_HAVE_EXA */ - pVia->cursor->isHWCursorEnabled = pVia->shadowFB ? FALSE : TRUE; +#endif + pVia->cursor->isHWCursorEnabled = TRUE; pVia->VQEnable = TRUE; pVia->DRIIrqEnable = TRUE; pVia->agpEnable = TRUE; @@ -755,17 +751,15 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn) #ifdef HAVE_DEBUG pVia->PrintVGARegs = FALSE; #endif - pVia->swov.maxWInterp = 800 ; - pVia->swov.maxHInterp = 600 ; + pVia->swov.maxWInterp = 800; + pVia->swov.maxHInterp = 600; pVia->useLegacyVBE = TRUE; - pVia->UseLegacyModeSwitch = TRUE ; + pVia->UseLegacyModeSwitch = TRUE; - switch (pVia->Chipset) - { + switch (pVia->Chipset) { case VIA_KM400: - /* IRQ is not broken on KM400A */ - /* But test below is not enough to make sure we have a KM400A */ - /* if (pVia->ChipRev < 0x80) */ + /* IRQ is not broken on KM400A, but testing (pVia->ChipRev < 0x80) + is not enough to make sure we have an older, broken KM400. */ pVia->DRIIrqEnable = FALSE; break; case VIA_K8M800: @@ -773,7 +767,7 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn) break; case VIA_P4M900: pVia->useLegacyVBE = FALSE; - /* FIXME: It needs to be tested */ + /* FIXME: this needs to be tested */ pVia->dmaXV = FALSE; /* FIXME: @@ -800,8 +794,8 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn) pVia->UseLegacyModeSwitch = FALSE ; case VIA_PM800: pVia->VideoEngine = VIDEO_ENGINE_CME; - pVia->swov.maxWInterp = 1920 ; - pVia->swov.maxHInterp = 1080 ; + pVia->swov.maxWInterp = 1920; + pVia->swov.maxHInterp = 1080; break; case VIA_P4M890: pVia->VideoEngine = VIDEO_ENGINE_CME; @@ -997,27 +991,25 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags) */ if (pEnt->device->chipset && *pEnt->device->chipset) { + from = X_CONFIG; pScrn->chipset = pEnt->device->chipset; pVia->Chipset = xf86StringToToken(VIAChipsets, pScrn->chipset); - pVia->ChipId = pEnt->device->chipID = LookupChipSet(VIAPciChipsets, pVia->Chipset); - from = X_CONFIG; + pVia->ChipId = LookupChipSet(VIAPciChipsets, pVia->Chipset); } else if (pEnt->device->chipID >= 0) { + from = X_CONFIG; pVia->ChipId = pEnt->device->chipID; pVia->Chipset = LookupChipID(VIAPciChipsets, pVia->ChipId); - pScrn->chipset = (char *)xf86TokenToString(VIAChipsets, - pVia->Chipset); - from = X_CONFIG; + pScrn->chipset = (char *)xf86TokenToString(VIAChipsets, pVia->Chipset); xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n", pEnt->device->chipID); } else { from = X_PROBED; pVia->ChipId = pVia->PciInfo->chipType; pVia->Chipset = LookupChipID(VIAPciChipsets, pVia->ChipId); - pScrn->chipset = (char *)xf86TokenToString(VIAChipsets, - pVia->Chipset); + pScrn->chipset = (char *)xf86TokenToString(VIAChipsets, pVia->Chipset); } - xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset); + xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: %s\n", pScrn->chipset); if (pEnt->device->chipRev >= 0) { pVia->ChipRev = pEnt->device->chipRev; @@ -1085,12 +1077,13 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags) "Probed amount of VideoRAM = %d kB\n", pScrn->videoRam); xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Setting up default chipset options...\n"); + "Setting up default chipset options.\n"); if (!VIASetupDefaultOptions(pScrn)) { VIAFreeRec(pScrn); return FALSE; } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Reading config file...\n"); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, VIAOptions); xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -1176,26 +1169,18 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags) } #endif /* VIA_HAVE_EXA */ - /* - * The SWCursor setting takes priority over HWCursor. The default - * if neither is specified is HW. - */ - - //pVia->hwcursor = pVia->shadowFB ? FALSE : TRUE; + /* Whether to use a software cursor or the default hardware cursor. */ from = X_DEFAULT; - if (xf86GetOptValBool(VIAOptions, OPTION_HWCURSOR, - &pVia->cursor->isHWCursorEnabled)) - from = X_CONFIG; - if (xf86GetOptValBool(VIAOptions, OPTION_SWCURSOR, - &pVia->cursor->isHWCursorEnabled)) { + if (pVia->IsSecondary || pVia->shadowFB) + pVia->cursor->isHWCursorEnabled = FALSE; + else if (xf86GetOptValBool(VIAOptions, OPTION_SWCURSOR, + &pVia->cursor->isHWCursorEnabled)) { pVia->cursor->isHWCursorEnabled = !pVia->cursor->isHWCursorEnabled; from = X_CONFIG; } - if (pVia->IsSecondary) - pVia->cursor->isHWCursorEnabled = FALSE; if (pVia->cursor->isHWCursorEnabled) - xf86DrvMsg(pScrn->scrnIndex, from, "Hardware two-color cursors; " - "software full-color cursors.\n"); + xf86DrvMsg(pScrn->scrnIndex, from, "Using hardware two-color " + "cursors and software full-color cursors.\n"); else xf86DrvMsg(pScrn->scrnIndex, from, "Using software cursors.\n"); @@ -1514,8 +1499,7 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags) if (!xf86LoadSubModule(pScrn, "i2c")) { VIAFreeRec(pScrn); return FALSE; - } - else { + } else { xf86LoaderReqSymLists(i2cSymbols,NULL); ViaI2CInit(pScrn); } @@ -1970,8 +1954,7 @@ VIASave(ScrnInfoPtr pScrn) Regs->SR46 = hwp->readSeq(hwp, 0x46); Regs->SR47 = hwp->readSeq(hwp, 0x47); - switch (pVia->Chipset) - { + switch (pVia->Chipset) { case VIA_CLE266: case VIA_KM400: break; @@ -2087,8 +2070,7 @@ VIARestore(ScrnInfoPtr pScrn) hwp->writeSeq(hwp, 0x46, Regs->SR46); hwp->writeSeq(hwp, 0x47, Regs->SR47); - switch (pVia->Chipset) - { + switch (pVia->Chipset) { case VIA_CLE266: case VIA_KM400: break; @@ -2495,9 +2477,6 @@ VIALoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, } -/* - * - */ static Bool VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { @@ -2850,7 +2829,6 @@ VIACloseScreen(int scrnIndex, ScreenPtr pScreen) #endif /* Wait Hardware Engine idle to exit graphical mode */ viaAccelSync(pScrn); - /* A soft reset Fixes 3D Hang after X restart */ if (pVia->Chipset != VIA_K8M890 && pVia->Chipset != VIA_P4M900) @@ -3057,43 +3035,27 @@ VIAInitialize3DEngine(ScrnInfoPtr pScrn) int i; VIASETREG(VIA_REG_TRANSET, 0x00010000); - for (i = 0; i <= 0x7D; i++) - { VIASETREG(VIA_REG_TRANSPACE, (CARD32) i << 24); - } VIASETREG(VIA_REG_TRANSET, 0x00020000); - for (i = 0; i <= 0x94; i++) - { VIASETREG(VIA_REG_TRANSPACE, (CARD32) i << 24); - } - VIASETREG(VIA_REG_TRANSPACE, 0x82400000); VIASETREG(VIA_REG_TRANSET, 0x01020000); - - for (i = 0; i <= 0x94; i++) - { VIASETREG(VIA_REG_TRANSPACE, (CARD32) i << 24); - } - VIASETREG(VIA_REG_TRANSPACE, 0x82400000); - VIASETREG(VIA_REG_TRANSET, 0xfe020000); + VIASETREG(VIA_REG_TRANSET, 0xfe020000); for (i = 0; i <= 0x03; i++) - { VIASETREG(VIA_REG_TRANSPACE, (CARD32) i << 24); - } VIASETREG(VIA_REG_TRANSET, 0x00030000); - for (i = 0; i <= 0xff; i++) - { VIASETREG(VIA_REG_TRANSPACE, 0); - } + VIASETREG(VIA_REG_TRANSET, 0x00100000); VIASETREG(VIA_REG_TRANSPACE, 0x00333004); VIASETREG(VIA_REG_TRANSPACE, 0x10000002); @@ -3106,9 +3068,9 @@ VIAInitialize3DEngine(ScrnInfoPtr pScrn) VIASETREG(VIA_REG_TRANSET, 0x00fe0000); if (pVia->Chipset == VIA_CLE266 && pVia->ChipRev >= 3) - VIASETREG(VIA_REG_TRANSPACE,0x40008c0f); + VIASETREG(VIA_REG_TRANSPACE,0x40008c0f); else - VIASETREG(VIA_REG_TRANSPACE,0x4000800f); + VIASETREG(VIA_REG_TRANSPACE,0x4000800f); VIASETREG(VIA_REG_TRANSPACE,0x44000000); VIASETREG(VIA_REG_TRANSPACE,0x45080C04); @@ -3117,7 +3079,6 @@ VIAInitialize3DEngine(ScrnInfoPtr pScrn) VIASETREG(VIA_REG_TRANSPACE,0x51000000); VIASETREG(VIA_REG_TRANSPACE,0x52000000); VIASETREG(VIA_REG_TRANSPACE,0x53000000); - VIASETREG(VIA_REG_TRANSET,0x00fe0000); VIASETREG(VIA_REG_TRANSPACE,0x08000001); diff --git a/src/via_driver.h b/src/via_driver.h index bd29b1d..a38558d 100644 --- a/src/via_driver.h +++ b/src/via_driver.h @@ -99,7 +99,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #ifdef USE_NEW_XVABI -#define PATCHLEVEL 900 +#define PATCHLEVEL 901 #else #define PATCHLEVEL 0 #endif diff --git a/src/via_id.c b/src/via_id.c index 89e9a27..13da2b3 100644 --- a/src/via_id.c +++ b/src/via_id.c @@ -167,12 +167,14 @@ static struct ViaCardIdStruct ViaCardId[] = { {"Everex NC1501/NC1503", VIA_P4M900, 0x1509, 0x1E30, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, {"Clevo M660SE", VIA_P4M900, 0x1558, 0x0664, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, {"Neo Endura 540SLe", VIA_P4M900, 0x1558, 0x5408, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, + {"Biostar P4M900M-M7 SE", VIA_P4M900, 0x1565, 0x1207, VIA_DEVICE_CRT}, {"Fujitsu/Siemens Amilo Pro V3515", VIA_P4M900, 0x1734, 0x10CB, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, {"Fujitsu/Siemens Amilo Li1705", VIA_P4M900, 0x1734, 0x10F7, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, /*** CX700 ***/ {"VIA VT8454B", VIA_CX700, 0x0908, 0x1975, VIA_DEVICE_CRT}, /* Evaluation board, reference possibly wrong */ {"VIA VT3324 (CX700)", VIA_CX700, 0x1106, 0x3157, VIA_DEVICE_CRT}, + {"MSI Fuzzy CX700/CX700D", VIA_CX700, 0x1462, 0x8020, VIA_DEVICE_CRT | VIA_DEVICE_LCD | VIA_DEVICE_TV}, {"FIC CE260", VIA_CX700, 0x1509, 0x2D30, VIA_DEVICE_LCD}, /*** P4M890, VN890 ***/ diff --git a/src/via_mode.c b/src/via_mode.c index e9c891e..2321d4c 100644 --- a/src/via_mode.c +++ b/src/via_mode.c @@ -183,7 +183,7 @@ ViaTVInit(ScrnInfoPtr pScrn) || !pBIOSInfo->TVPrintRegs) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "ViaTVInit: TVEncoder was not properly initialised."); + "ViaTVInit: TVEncoder was not properly initialised.\n"); xf86DestroyI2CDevRec(pBIOSInfo->TVI2CDev, TRUE); pBIOSInfo->TVI2CDev = NULL; @@ -336,7 +336,7 @@ ViaOutputsDetect(ScrnInfoPtr pScrn) */ if (pVia->Chipset == VIA_P4M900 && pBIOSInfo->PanelPresent) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Will not try to detect TV encoder."); + "Will not try to detect TV encoder.\n"); } else { /* TV encoder */ if (ViaTVDetect(pScrn) && ViaTVInit(pScrn)) { -- cgit v1.2.3