171d7fec4Smrg/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/nsc_gx1_dga.c,v 1.1 2002/12/10 15:12:23 alanh Exp $ */
271d7fec4Smrg/*
371d7fec4Smrg * $Workfile: nsc_gx1_dga.c $
471d7fec4Smrg * $Revision: 1.1.1.1 $
571d7fec4Smrg * $Author: mrg $
671d7fec4Smrg *
771d7fec4Smrg * File contents: DGA(Direct Acess Graphics mode) is feature of
871d7fec4Smrg *                XFree86 that allows the program to access directly to video
971d7fec4Smrg *                memory on the graphics card.DGA supports the double
1071d7fec4Smrg *                flickering.This file has the functions to support the DGA
1171d7fec4Smrg *                modes.
1271d7fec4Smrg *
1371d7fec4Smrg * Project:       Geode Xfree Frame buffer device driver.
1471d7fec4Smrg *
1571d7fec4Smrg */
1671d7fec4Smrg
1771d7fec4Smrg/*
1871d7fec4Smrg * NSC_LIC_ALTERNATIVE_PREAMBLE
1971d7fec4Smrg *
2071d7fec4Smrg * Revision 1.0
2171d7fec4Smrg *
2271d7fec4Smrg * National Semiconductor Alternative GPL-BSD License
2371d7fec4Smrg *
2471d7fec4Smrg * National Semiconductor Corporation licenses this software
2571d7fec4Smrg * ("Software"):
2671d7fec4Smrg *
2771d7fec4Smrg * National Xfree frame buffer driver
2871d7fec4Smrg *
2971d7fec4Smrg * under one of the two following licenses, depending on how the
3071d7fec4Smrg * Software is received by the Licensee.
3171d7fec4Smrg *
3271d7fec4Smrg * If this Software is received as part of the Linux Framebuffer or
3371d7fec4Smrg * other GPL licensed software, then the GPL license designated
3471d7fec4Smrg * NSC_LIC_GPL applies to this Software; in all other circumstances
3571d7fec4Smrg * then the BSD-style license designated NSC_LIC_BSD shall apply.
3671d7fec4Smrg *
3771d7fec4Smrg * END_NSC_LIC_ALTERNATIVE_PREAMBLE */
3871d7fec4Smrg
3971d7fec4Smrg/* NSC_LIC_BSD
4071d7fec4Smrg *
4171d7fec4Smrg * National Semiconductor Corporation Open Source License for
4271d7fec4Smrg *
4371d7fec4Smrg * National Xfree frame buffer driver
4471d7fec4Smrg *
4571d7fec4Smrg * (BSD License with Export Notice)
4671d7fec4Smrg *
4771d7fec4Smrg * Copyright (c) 1999-2001
4871d7fec4Smrg * National Semiconductor Corporation.
4971d7fec4Smrg * All rights reserved.
5071d7fec4Smrg *
5171d7fec4Smrg * Redistribution and use in source and binary forms, with or without
5271d7fec4Smrg * modification, are permitted provided that the following conditions
5371d7fec4Smrg * are met:
5471d7fec4Smrg *
5571d7fec4Smrg *   * Redistributions of source code must retain the above copyright
5671d7fec4Smrg *     notice, this list of conditions and the following disclaimer.
5771d7fec4Smrg *
5871d7fec4Smrg *   * Redistributions in binary form must reproduce the above
5971d7fec4Smrg *     copyright notice, this list of conditions and the following
6071d7fec4Smrg *     disclaimer in the documentation and/or other materials provided
6171d7fec4Smrg *     with the distribution.
6271d7fec4Smrg *
6371d7fec4Smrg *   * Neither the name of the National Semiconductor Corporation nor
6471d7fec4Smrg *     the names of its contributors may be used to endorse or promote
6571d7fec4Smrg *     products derived from this software without specific prior
6671d7fec4Smrg *     written permission.
6771d7fec4Smrg *
6871d7fec4Smrg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6971d7fec4Smrg * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7071d7fec4Smrg * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
7171d7fec4Smrg * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
7271d7fec4Smrg * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY
7371d7fec4Smrg * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7471d7fec4Smrg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
7571d7fec4Smrg * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
7671d7fec4Smrg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
7771d7fec4Smrg * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE,
7871d7fec4Smrg * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY
7971d7fec4Smrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
8071d7fec4Smrg * OF SUCH DAMAGE.
8171d7fec4Smrg *
8271d7fec4Smrg * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
8371d7fec4Smrg * YOUR JURISDICTION. It is licensee's responsibility to comply with
8471d7fec4Smrg * any export regulations applicable in licensee's jurisdiction. Under
8571d7fec4Smrg * CURRENT (2001) U.S. export regulations this software
8671d7fec4Smrg * is eligible for export from the U.S. and can be downloaded by or
8771d7fec4Smrg * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed
8871d7fec4Smrg * destinations which include Cuba, Iraq, Libya, North Korea, Iran,
8971d7fec4Smrg * Syria, Sudan, Afghanistan and any other country to which the U.S.
9071d7fec4Smrg * has embargoed goods and services.
9171d7fec4Smrg *
9271d7fec4Smrg * END_NSC_LIC_BSD */
9371d7fec4Smrg
9471d7fec4Smrg/* NSC_LIC_GPL
9571d7fec4Smrg *
9671d7fec4Smrg * National Semiconductor Corporation Gnu General Public License for
9771d7fec4Smrg *
9871d7fec4Smrg * National Xfree frame buffer driver
9971d7fec4Smrg *
10071d7fec4Smrg * (GPL License with Export Notice)
10171d7fec4Smrg *
10271d7fec4Smrg * Copyright (c) 1999-2001
10371d7fec4Smrg * National Semiconductor Corporation.
10471d7fec4Smrg * All rights reserved.
10571d7fec4Smrg *
10671d7fec4Smrg * Redistribution and use in source and binary forms, with or without
10771d7fec4Smrg * modification, are permitted under the terms of the GNU General
10871d7fec4Smrg * Public License as published by the Free Software Foundation; either
10971d7fec4Smrg * version 2 of the License, or (at your option) any later version
11071d7fec4Smrg *
11171d7fec4Smrg * In addition to the terms of the GNU General Public License, neither
11271d7fec4Smrg * the name of the National Semiconductor Corporation nor the names of
11371d7fec4Smrg * its contributors may be used to endorse or promote products derived
11471d7fec4Smrg * from this software without specific prior written permission.
11571d7fec4Smrg *
11671d7fec4Smrg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
11771d7fec4Smrg * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
11871d7fec4Smrg * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
11971d7fec4Smrg * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
12071d7fec4Smrg * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY
12171d7fec4Smrg * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
12271d7fec4Smrg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
12371d7fec4Smrg * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
12471d7fec4Smrg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
12571d7fec4Smrg * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE,
12671d7fec4Smrg * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY
12771d7fec4Smrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
12871d7fec4Smrg * OF SUCH DAMAGE. See the GNU General Public License for more details.
12971d7fec4Smrg *
13071d7fec4Smrg * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
13171d7fec4Smrg * YOUR JURISDICTION. It is licensee's responsibility to comply with
13271d7fec4Smrg * any export regulations applicable in licensee's jurisdiction. Under
13371d7fec4Smrg * CURRENT (2001) U.S. export regulations this software
13471d7fec4Smrg * is eligible for export from the U.S. and can be downloaded by or
13571d7fec4Smrg * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed
13671d7fec4Smrg * destinations which include Cuba, Iraq, Libya, North Korea, Iran,
13771d7fec4Smrg * Syria, Sudan, Afghanistan and any other country to which the U.S.
13871d7fec4Smrg * has embargoed goods and services.
13971d7fec4Smrg *
14071d7fec4Smrg * You should have received a copy of the GNU General Public License
14171d7fec4Smrg * along with this file; if not, write to the Free Software Foundation,
14271d7fec4Smrg * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14371d7fec4Smrg *
14471d7fec4Smrg * END_NSC_LIC_GPL */
14571d7fec4Smrg
14671d7fec4Smrg#ifdef HAVE_CONFIG_H
14771d7fec4Smrg#include "config.h"
14871d7fec4Smrg#endif
14971d7fec4Smrg
15071d7fec4Smrg#include "xf86.h"
15171d7fec4Smrg#include "xf86_OSproc.h"
15271d7fec4Smrg#include "xf86Pci.h"
15371d7fec4Smrg#include "xf86PciInfo.h"
15471d7fec4Smrg#include "xaa.h"
15571d7fec4Smrg#include "xaalocal.h"
15671d7fec4Smrg#include "nsc.h"
15771d7fec4Smrg#include "dgaproc.h"
15871d7fec4Smrg
15971d7fec4Smrg/* forward declarations */
16071d7fec4Smrgstatic Bool GX1_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **,
16171d7fec4Smrg				int *, int *, int *);
16271d7fec4Smrgstatic void GX1_CloseFramebuffer(ScrnInfoPtr pScrn);
16371d7fec4Smrgstatic Bool GX1_SetMode(ScrnInfoPtr, DGAModePtr);
16471d7fec4Smrgstatic int GX1_GetViewport(ScrnInfoPtr);
16571d7fec4Smrgstatic void GX1_SetViewport(ScrnInfoPtr, int, int, int);
16671d7fec4Smrgstatic void GX1_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long);
16771d7fec4Smrgstatic void GX1_BlitRect(ScrnInfoPtr, int, int, int, int, int, int);
16871d7fec4Smrg
16971d7fec4Smrgextern void GX1AdjustFrame(int, int, int, int);
17071d7fec4Smrgextern Bool GX1SwitchMode(int, DisplayModePtr, int);
17171d7fec4Smrgextern void GX1AccelSync(ScrnInfoPtr pScreenInfo);
17271d7fec4Smrg
17371d7fec4SmrgBool GX1DGAInit(ScreenPtr pScreen);
17471d7fec4Smrg
17571d7fec4Smrgstatic DGAFunctionRec GeodeDGAFuncs = {
17671d7fec4Smrg   GX1_OpenFramebuffer,
17771d7fec4Smrg   GX1_CloseFramebuffer,
17871d7fec4Smrg   GX1_SetMode,
17971d7fec4Smrg   GX1_SetViewport,
18071d7fec4Smrg   GX1_GetViewport,
18171d7fec4Smrg   GX1AccelSync,
18271d7fec4Smrg   GX1_FillRect,
18371d7fec4Smrg   GX1_BlitRect,
18471d7fec4Smrg   NULL
18571d7fec4Smrg};
18671d7fec4Smrg
18771d7fec4Smrg/*----------------------------------------------------------------------------
18871d7fec4Smrg * GX1DGAInit.
18971d7fec4Smrg *
19071d7fec4Smrg * Description	:This function is used to intiallize the DGA modes and sets the
19171d7fec4Smrg			 	 viewport based on the screen mode.
19271d7fec4Smrg * Parameters.
19371d7fec4Smrg *	pScreeen	:Pointer to screen info structure.
19471d7fec4Smrg *
19571d7fec4Smrg * Returns		:TRUE on success and FALSE on failure.
19671d7fec4Smrg *
19771d7fec4Smrg * Comments		:This function prepares the DGA mode settings for
19871d7fec4Smrg *				 other func reference.
19971d7fec4Smrg *
20071d7fec4Smrg*----------------------------------------------------------------------------
20171d7fec4Smrg*/
20271d7fec4SmrgBool
20371d7fec4SmrgGX1DGAInit(ScreenPtr pScreen)
20471d7fec4Smrg{
20571d7fec4Smrg   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
20671d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
20771d7fec4Smrg   DGAModePtr modes = NULL, newmodes = NULL, currentMode;
20871d7fec4Smrg   DisplayModePtr pMode, firstMode;
20971d7fec4Smrg   int Bpp = pScrn->bitsPerPixel >> 3;
21071d7fec4Smrg   int num = 0;
21171d7fec4Smrg   Bool oneMore;
21271d7fec4Smrg
21371d7fec4Smrg   pMode = firstMode = pScrn->modes;
21471d7fec4Smrg   DEBUGMSG(0, (0, X_NONE, "GX1DGAInit\n"));
21571d7fec4Smrg   while (pMode) {
21671d7fec4Smrg
21771d7fec4Smrg      /* redundant but it can be used in future:if(0). */
21871d7fec4Smrg      if (0) {				/*pScrn->displayWidth != pMode->HDisplay */
21971d7fec4Smrg	 /* memory is allocated for dga to
22071d7fec4Smrg	  *setup the viewport and mode parameters
22171d7fec4Smrg	  */
22271d7fec4Smrg	 newmodes = xrealloc(modes, (num + 2) * sizeof(DGAModeRec));
22371d7fec4Smrg	 oneMore = TRUE;
22471d7fec4Smrg      } else {
22571d7fec4Smrg	 /* one record is allocated here */
22671d7fec4Smrg	 newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec));
22771d7fec4Smrg	 oneMore = FALSE;
22871d7fec4Smrg      }
22971d7fec4Smrg      if (!newmodes) {
23071d7fec4Smrg	 xfree(modes);
23171d7fec4Smrg	 return FALSE;
23271d7fec4Smrg      }
23371d7fec4Smrg      modes = newmodes;
23471d7fec4Smrg
23571d7fec4Smrg    SECOND_PASS:			/* DGA mode flgas and viewport parametrs are set here. */
23671d7fec4Smrg
23771d7fec4Smrg      currentMode = modes + num;
23871d7fec4Smrg      num++;
23971d7fec4Smrg      currentMode->mode = pMode;
24071d7fec4Smrg      currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE;
24171d7fec4Smrg      currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT;
24271d7fec4Smrg      if (pMode->Flags & V_DBLSCAN)
24371d7fec4Smrg	 currentMode->flags |= DGA_DOUBLESCAN;
24471d7fec4Smrg      if (pMode->Flags & V_INTERLACE)
24571d7fec4Smrg	 currentMode->flags |= DGA_INTERLACED;
24671d7fec4Smrg      currentMode->byteOrder = pScrn->imageByteOrder;
24771d7fec4Smrg      currentMode->depth = pScrn->depth;
24871d7fec4Smrg      currentMode->bitsPerPixel = pScrn->bitsPerPixel;
24971d7fec4Smrg      currentMode->red_mask = pScrn->mask.red;
25071d7fec4Smrg      currentMode->green_mask = pScrn->mask.green;
25171d7fec4Smrg      currentMode->blue_mask = pScrn->mask.blue;
25271d7fec4Smrg      currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor;
25371d7fec4Smrg      currentMode->viewportWidth = pMode->HDisplay;
25471d7fec4Smrg      currentMode->viewportHeight = pMode->VDisplay;
25571d7fec4Smrg      currentMode->xViewportStep = 1;
25671d7fec4Smrg      currentMode->yViewportStep = 1;
25771d7fec4Smrg      currentMode->viewportFlags = DGA_FLIP_RETRACE;
25871d7fec4Smrg      currentMode->offset = 0;
25971d7fec4Smrg      currentMode->address = pGeode->FBBase;
26071d7fec4Smrg      if (oneMore) {			/* first one is narrow width */
26171d7fec4Smrg	 currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L;
26271d7fec4Smrg	 currentMode->imageWidth = pMode->HDisplay;
26371d7fec4Smrg	 currentMode->imageHeight = pMode->VDisplay;
26471d7fec4Smrg	 currentMode->pixmapWidth = currentMode->imageWidth;
26571d7fec4Smrg	 currentMode->pixmapHeight = currentMode->imageHeight;
26671d7fec4Smrg	 currentMode->maxViewportX = currentMode->imageWidth -
26771d7fec4Smrg	       currentMode->viewportWidth;
26871d7fec4Smrg	 /* this might need to get clamped to some maximum */
26971d7fec4Smrg	 currentMode->maxViewportY = currentMode->imageHeight -
27071d7fec4Smrg	       currentMode->viewportHeight;
27171d7fec4Smrg	 oneMore = FALSE;
27271d7fec4Smrg	 goto SECOND_PASS;
27371d7fec4Smrg      } else {
27471d7fec4Smrg	 currentMode->bytesPerScanline =
27571d7fec4Smrg	       ((pScrn->displayWidth * Bpp) + 3) & ~3L;
27671d7fec4Smrg	 currentMode->imageWidth = pScrn->displayWidth;
27771d7fec4Smrg	 currentMode->imageHeight = pMode->VDisplay;
27871d7fec4Smrg	 currentMode->pixmapWidth = currentMode->imageWidth;
27971d7fec4Smrg	 currentMode->pixmapHeight = currentMode->imageHeight;
28071d7fec4Smrg	 currentMode->maxViewportX = currentMode->imageWidth -
28171d7fec4Smrg	       currentMode->viewportWidth;
28271d7fec4Smrg	 /* this might need to get clamped to some maximum */
28371d7fec4Smrg	 currentMode->maxViewportY = currentMode->imageHeight -
28471d7fec4Smrg	       currentMode->viewportHeight;
28571d7fec4Smrg      }
28671d7fec4Smrg      pMode = pMode->next;
28771d7fec4Smrg      if (pMode == firstMode)
28871d7fec4Smrg	 break;
28971d7fec4Smrg   }
29071d7fec4Smrg   pGeode->numDGAModes = num;
29171d7fec4Smrg   pGeode->DGAModes = modes;
29271d7fec4Smrg   return DGAInit(pScreen, &GeodeDGAFuncs, modes, num);
29371d7fec4Smrg}
29471d7fec4Smrg
29571d7fec4Smrg/*----------------------------------------------------------------------------
29671d7fec4Smrg * GX1_SetMode.
29771d7fec4Smrg *
29871d7fec4Smrg * Description	:This function is sets into the DGA mode.
29971d7fec4Smrg *.
30071d7fec4Smrg * Parameters.
30171d7fec4Smrg *	pScreeen	:Pointer to screen info structure.
30271d7fec4Smrg *	pMode		:Points to the DGAmode ptr data
30371d7fec4Smrg * Returns		:TRUE on success and FALSE on failure.
30471d7fec4Smrg *
30571d7fec4Smrg * Comments		:none.
30671d7fec4Smrg *
30771d7fec4Smrg *
30871d7fec4Smrg*----------------------------------------------------------------------------
30971d7fec4Smrg*/
31071d7fec4Smrgstatic Bool
31171d7fec4SmrgGX1_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode)
31271d7fec4Smrg{
31371d7fec4Smrg   static int OldDisplayWidth[MAXSCREENS];
31471d7fec4Smrg   int index = pScrn->pScreen->myNum;
31571d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
31671d7fec4Smrg
31771d7fec4Smrg   DEBUGMSG(0, (0, X_NONE, "GX1_SetMode\n"));
31871d7fec4Smrg   if (!pMode) {
31971d7fec4Smrg      /* restore the original mode
32071d7fec4Smrg       * * put the ScreenParameters back
32171d7fec4Smrg       */
32271d7fec4Smrg      pScrn->displayWidth = OldDisplayWidth[index];
32371d7fec4Smrg      GX1SwitchMode(index, pScrn->currentMode, 0);
32471d7fec4Smrg      pGeode->DGAactive = FALSE;
32571d7fec4Smrg   } else {
32671d7fec4Smrg      if (!pGeode->DGAactive) {		/* save the old parameters */
32771d7fec4Smrg	 OldDisplayWidth[index] = pScrn->displayWidth;
32871d7fec4Smrg	 pGeode->DGAactive = TRUE;
32971d7fec4Smrg      }
33071d7fec4Smrg      pScrn->displayWidth = pMode->bytesPerScanline /
33171d7fec4Smrg	    (pMode->bitsPerPixel >> 3);
33271d7fec4Smrg      GX1SwitchMode(index, pMode->mode, 0);
33371d7fec4Smrg   }
33471d7fec4Smrg   /* enable/disable cursor */
33571d7fec4Smrg   if (pGeode->HWCursor) {
33671d7fec4Smrg#if defined(STB_X)
33771d7fec4Smrg      Gal_set_compression_enable(((pGeode->DGAactive) ?
33871d7fec4Smrg				  GAL_COMPRESSION_DISABLE :
33971d7fec4Smrg				  GAL_COMPRESSION_ENABLE));
34071d7fec4Smrg      Gal_set_cursor_enable(!pGeode->DGAactive);
34171d7fec4Smrg#else
34271d7fec4Smrg      gfx_set_cursor_enable(!pGeode->DGAactive);
34371d7fec4Smrg      gfx_set_compression_enable(!pGeode->DGAactive);
34471d7fec4Smrg#endif /* STB_X */
34571d7fec4Smrg   }
34671d7fec4Smrg
34771d7fec4Smrg   return TRUE;
34871d7fec4Smrg}
34971d7fec4Smrg
35071d7fec4Smrg/*----------------------------------------------------------------------------
35171d7fec4Smrg * GX1_GetViewPort.
35271d7fec4Smrg *
35371d7fec4Smrg * Description	:This function is Gets the viewport window memory.
35471d7fec4Smrg *.
35571d7fec4Smrg * Parameters.
35671d7fec4Smrg *	pScrn		:Pointer to screen info structure.
35771d7fec4Smrg *
35871d7fec4Smrg * Returns		:returns the viewport status.
35971d7fec4Smrg *
36071d7fec4Smrg * Comments		:none.
36171d7fec4Smrg *
36271d7fec4Smrg *
36371d7fec4Smrg*----------------------------------------------------------------------------
36471d7fec4Smrg*/
36571d7fec4Smrgstatic int
36671d7fec4SmrgGX1_GetViewport(ScrnInfoPtr pScrn)
36771d7fec4Smrg{
36871d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
36971d7fec4Smrg
37071d7fec4Smrg   return pGeode->DGAViewportStatus;
37171d7fec4Smrg}
37271d7fec4Smrg
37371d7fec4Smrg/*----------------------------------------------------------------------------
37471d7fec4Smrg * GX1_SetViewPort.
37571d7fec4Smrg *
37671d7fec4Smrg * Description	:This function is Gets the viewport window memory.
37771d7fec4Smrg *
37871d7fec4Smrg * Parameters.
37971d7fec4Smrg *	pScrn		:Pointer to screen info structure.
38071d7fec4Smrg		x		:x-cordinate of viewport window
38171d7fec4Smrg *		y		:y-codinate of the viewport window.
38271d7fec4Smrg *	flags		:indicates the viewport to be flipped or not.
38371d7fec4Smrg * Returns		:returns the viewport status  as zero.
38471d7fec4Smrg *
38571d7fec4Smrg * Comments		:none.
38671d7fec4Smrg *
38771d7fec4Smrg*----------------------------------------------------------------------------
38871d7fec4Smrg*/
38971d7fec4Smrgstatic void
39071d7fec4SmrgGX1_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags)
39171d7fec4Smrg{
39271d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
39371d7fec4Smrg
39471d7fec4Smrg   GX1AdjustFrame(pScrn->pScreen->myNum, x, y, flags);
39571d7fec4Smrg   pGeode->DGAViewportStatus = 0;	/*GX1AdjustFrame loops until finished */
39671d7fec4Smrg}
39771d7fec4Smrg
39871d7fec4Smrg/*----------------------------------------------------------------------------
39971d7fec4Smrg * GX1_FillRect.
40071d7fec4Smrg *
40171d7fec4Smrg * Description	:This function is Gets the viewport window memory.
40271d7fec4Smrg *.
40371d7fec4Smrg * Parameters.
40471d7fec4Smrg *	pScrn		:Pointer to screen info structure.
40571d7fec4Smrg *		x		:x-cordinate of viewport window
40671d7fec4Smrg *		y		:y-codinate of the viewport window.
40771d7fec4Smrg *		w		:width of the rectangle
40871d7fec4Smrg *      h		:height of the rectangle.
40971d7fec4Smrg *	color		:color to be filled in rectangle.
41071d7fec4Smrg *
41171d7fec4Smrg * Returns		:returns the viewport status  as zero.
41271d7fec4Smrg *
41371d7fec4Smrg * Comments		:This function is implemented by solidfill routines..
41471d7fec4Smrg *
41571d7fec4Smrg*----------------------------------------------------------------------------
41671d7fec4Smrg*/
41771d7fec4Smrgstatic void
41871d7fec4SmrgGX1_FillRect(ScrnInfoPtr pScrn, int x, int y,
41971d7fec4Smrg	     int w, int h, unsigned long color)
42071d7fec4Smrg{
42171d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
42271d7fec4Smrg
42371d7fec4Smrg   if (pGeode->AccelInfoRec) {
42471d7fec4Smrg      (*pGeode->AccelInfoRec->SetupForSolidFill) (pScrn, color, GXcopy, ~0);
42571d7fec4Smrg      (*pGeode->AccelInfoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h);
42671d7fec4Smrg      SET_SYNC_FLAG(pGeode->AccelInfoRec);
42771d7fec4Smrg   }
42871d7fec4Smrg}
42971d7fec4Smrg
43071d7fec4Smrg/*----------------------------------------------------------------------------
43171d7fec4Smrg * GX1_BlitRect.
43271d7fec4Smrg *
43371d7fec4Smrg * Description	:This function implementing Blit and it moves a
43471d7fec4Smrg *			 	 Rectangular block of data from one location to other
43571d7fec4Smrg *			 	 Location.
43671d7fec4Smrg *
43771d7fec4Smrg * Parameters.
43871d7fec4Smrg *	pScrn		:Pointer to screen info structure.
43971d7fec4Smrg *	srcx		:x-cordinate of the src rectangle
44071d7fec4Smrg *	srcy		:y-codinate of src rectangle.
44171d7fec4Smrg *	  w			:width of the rectangle
44271d7fec4Smrg *    h			:height of the rectangle.
44371d7fec4Smrg *	dstx		:x-cordinate of the dst rectangle.
44471d7fec4Smrg *	dsty		:y -coordinates of the dst rectangle.
44571d7fec4Smrg * Returns		:none.
44671d7fec4Smrg *
44771d7fec4Smrg * Comments		:none
44871d7fec4Smrg *
44971d7fec4Smrg*----------------------------------------------------------------------------
45071d7fec4Smrg*/
45171d7fec4Smrgstatic void
45271d7fec4SmrgGX1_BlitRect(ScrnInfoPtr pScrn, int srcx, int srcy, int w,
45371d7fec4Smrg	     int h, int dstx, int dsty)
45471d7fec4Smrg{
45571d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
45671d7fec4Smrg
45771d7fec4Smrg   if (pGeode->AccelInfoRec) {
45871d7fec4Smrg      int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1;
45971d7fec4Smrg      int ydir = (srcy < dsty) ? -1 : 1;
46071d7fec4Smrg
46171d7fec4Smrg      (*pGeode->AccelInfoRec->SetupForScreenToScreenCopy)
46271d7fec4Smrg	    (pScrn, xdir, ydir, GXcopy, ~0, -1);
46371d7fec4Smrg      (*pGeode->AccelInfoRec->SubsequentScreenToScreenCopy) (pScrn, srcx,
46471d7fec4Smrg							     srcy, dstx, dsty,
46571d7fec4Smrg							     w, h);
46671d7fec4Smrg      SET_SYNC_FLAG(pGeode->AccelInfoRec);
46771d7fec4Smrg   }
46871d7fec4Smrg}
46971d7fec4Smrg
47071d7fec4Smrg/*----------------------------------------------------------------------------
47171d7fec4Smrg * GX1_OpenFramebuffer.
47271d7fec4Smrg *
47371d7fec4Smrg * Description	:This function open the framebuffer driver for DGA.
47471d7fec4Smrg *
47571d7fec4Smrg * Parameters.
47671d7fec4Smrg *	pScrn		:Pointer to screen info structure.
47771d7fec4Smrg *	srcx		:x-cordinate of the src rectangle
47871d7fec4Smrg *	srcy		:y-codinate of src rectangle.
47971d7fec4Smrg *		w		:width of the rectangle
48071d7fec4Smrg *    	h		:height of the rectangle.
48171d7fec4Smrg *	dstx		:x-cordinate of the dst rectangle.
48271d7fec4Smrg *	dsty		:y -coordinates of the dst rectangle.
48371d7fec4Smrg * Returns		:none.
48471d7fec4Smrg *
48571d7fec4Smrg * Comments		:none
48671d7fec4Smrg *
48771d7fec4Smrg*----------------------------------------------------------------------------
48871d7fec4Smrg*/
48971d7fec4Smrgstatic Bool
49071d7fec4SmrgGX1_OpenFramebuffer(ScrnInfoPtr pScrn,
49171d7fec4Smrg		    char **name, unsigned char **mem,
49271d7fec4Smrg		    int *size, int *offset, int *flags)
49371d7fec4Smrg{
49471d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
49571d7fec4Smrg
49671d7fec4Smrg   *name = NULL;			/* no special device */
49771d7fec4Smrg   *mem = (unsigned char *)pGeode->FBLinearAddr;
49871d7fec4Smrg   *size = pGeode->FBSize;
49971d7fec4Smrg   *offset = 0;
50071d7fec4Smrg   *flags = DGA_NEED_ROOT;
50171d7fec4Smrg   return TRUE;
50271d7fec4Smrg}
50371d7fec4Smrg
50471d7fec4Smrgstatic void
50571d7fec4SmrgGX1_CloseFramebuffer(ScrnInfoPtr pScrn)
50671d7fec4Smrg{
50771d7fec4Smrg}
50871d7fec4Smrg
50971d7fec4Smrg/* end of file */
510