171d7fec4Smrg/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/nsc_gx2_dga.c,v 1.1 2002/12/10 15:12:24 alanh Exp $ */
271d7fec4Smrg/*
371d7fec4Smrg * $Workfile: nsc_gx2_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 */
16071d7fec4SmrgBool GX2DGAInit(ScreenPtr pScreen);
16171d7fec4Smrgstatic Bool GX2_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **,
16271d7fec4Smrg				int *, int *, int *);
16371d7fec4Smrgstatic void GX2_CloseFramebuffer(ScrnInfoPtr pScrn);
16471d7fec4Smrgstatic Bool GX2_SetMode(ScrnInfoPtr, DGAModePtr);
16571d7fec4Smrgstatic int GX2_GetViewport(ScrnInfoPtr);
16671d7fec4Smrgstatic void GX2_SetViewport(ScrnInfoPtr, int, int, int);
16771d7fec4Smrgstatic void GX2_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long);
16871d7fec4Smrgstatic void GX2_BlitRect(ScrnInfoPtr, int, int, int, int, int, int);
16971d7fec4Smrg
17071d7fec4Smrgextern void GX2AdjustFrame(int, int, int, int);
17171d7fec4Smrgextern Bool GX2SwitchMode(int, DisplayModePtr, int);
17271d7fec4Smrgextern void GX2AccelSync(ScrnInfoPtr pScreenInfo);
17371d7fec4Smrg
17471d7fec4Smrgstatic DGAFunctionRec GX2DGAFuncs = {
17571d7fec4Smrg   GX2_OpenFramebuffer,
17671d7fec4Smrg   GX2_CloseFramebuffer,
17771d7fec4Smrg   GX2_SetMode,
17871d7fec4Smrg   GX2_SetViewport,
17971d7fec4Smrg   GX2_GetViewport,
18071d7fec4Smrg   GX2AccelSync,
18171d7fec4Smrg   GX2_FillRect,
18271d7fec4Smrg   GX2_BlitRect,
18371d7fec4Smrg   NULL
18471d7fec4Smrg};
18571d7fec4Smrg
18671d7fec4Smrg/*----------------------------------------------------------------------------
18771d7fec4Smrg * GX2DGAInit.
18871d7fec4Smrg *
18971d7fec4Smrg * Description	:This function is used to intiallize the DGA modes and sets the
19071d7fec4Smrg			 	 viewport based on the screen mode.
19171d7fec4Smrg * Parameters.
19271d7fec4Smrg *	pScreeen	:Pointer to screen info structure.
19371d7fec4Smrg *
19471d7fec4Smrg * Returns		:TRUE on success and FALSE on failure.
19571d7fec4Smrg *
19671d7fec4Smrg * Comments		:This function prepares the DGA mode settings for
19771d7fec4Smrg *				 other func reference.
19871d7fec4Smrg *
19971d7fec4Smrg*----------------------------------------------------------------------------
20071d7fec4Smrg*/
20171d7fec4SmrgBool
20271d7fec4SmrgGX2DGAInit(ScreenPtr pScreen)
20371d7fec4Smrg{
20471d7fec4Smrg   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
20571d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
20671d7fec4Smrg   DGAModePtr modes = NULL, newmodes = NULL, currentMode;
20771d7fec4Smrg   DisplayModePtr pMode, firstMode;
20871d7fec4Smrg   int Bpp = pScrn->bitsPerPixel >> 3;
20971d7fec4Smrg   int num = 0;
21071d7fec4Smrg   Bool oneMore;
21171d7fec4Smrg
21271d7fec4Smrg   pMode = firstMode = pScrn->modes;
21371d7fec4Smrg   DEBUGMSG(0, (0, X_NONE, "GX2DGAInit %d\n", Bpp));
21471d7fec4Smrg   while (pMode) {
21571d7fec4Smrg
21671d7fec4Smrg      /* redundant but it can be used in future:if(0). */
21771d7fec4Smrg      if (0) {				/*pScrn->displayWidth != pMode->HDisplay */
21871d7fec4Smrg	 /* memory is allocated for dga to
21971d7fec4Smrg	  *setup the viewport and mode parameters
22071d7fec4Smrg	  */
22171d7fec4Smrg	 newmodes = xrealloc(modes, (num + 2) * sizeof(DGAModeRec));
22271d7fec4Smrg	 oneMore = TRUE;
22371d7fec4Smrg      } else {
22471d7fec4Smrg	 /* one record is allocated here */
22571d7fec4Smrg	 newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec));
22671d7fec4Smrg	 oneMore = FALSE;
22771d7fec4Smrg      }
22871d7fec4Smrg      if (!newmodes) {
22971d7fec4Smrg	 xfree(modes);
23071d7fec4Smrg	 return FALSE;
23171d7fec4Smrg      }
23271d7fec4Smrg      modes = newmodes;
23371d7fec4Smrg
23471d7fec4Smrg    SECOND_PASS:			/* DGA mode flgas and viewport parametrs are set here. */
23571d7fec4Smrg
23671d7fec4Smrg      currentMode = modes + num;
23771d7fec4Smrg      num++;
23871d7fec4Smrg      currentMode->mode = pMode;
23971d7fec4Smrg      currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE;
24071d7fec4Smrg      currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT;
24171d7fec4Smrg      if (pMode->Flags & V_DBLSCAN)
24271d7fec4Smrg	 currentMode->flags |= DGA_DOUBLESCAN;
24371d7fec4Smrg      if (pMode->Flags & V_INTERLACE)
24471d7fec4Smrg	 currentMode->flags |= DGA_INTERLACED;
24571d7fec4Smrg      currentMode->byteOrder = pScrn->imageByteOrder;
24671d7fec4Smrg      currentMode->depth = pScrn->depth;
24771d7fec4Smrg      currentMode->bitsPerPixel = pScrn->bitsPerPixel;
24871d7fec4Smrg      currentMode->red_mask = pScrn->mask.red;
24971d7fec4Smrg      currentMode->green_mask = pScrn->mask.green;
25071d7fec4Smrg      currentMode->blue_mask = pScrn->mask.blue;
25171d7fec4Smrg      currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor;
25271d7fec4Smrg      currentMode->viewportWidth = pMode->HDisplay;
25371d7fec4Smrg      currentMode->viewportHeight = pMode->VDisplay;
25471d7fec4Smrg      currentMode->xViewportStep = 1;
25571d7fec4Smrg      currentMode->yViewportStep = 1;
25671d7fec4Smrg      currentMode->viewportFlags = DGA_FLIP_RETRACE;
25771d7fec4Smrg      currentMode->offset = 0;
25871d7fec4Smrg      currentMode->address = pGeode->FBBase;
25971d7fec4Smrg      if (oneMore) {			/* first one is narrow width */
26071d7fec4Smrg	 currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L;
26171d7fec4Smrg	 currentMode->imageWidth = pMode->HDisplay;
26271d7fec4Smrg	 currentMode->imageHeight = pMode->VDisplay;
26371d7fec4Smrg	 currentMode->pixmapWidth = currentMode->imageWidth;
26471d7fec4Smrg	 currentMode->pixmapHeight = currentMode->imageHeight;
26571d7fec4Smrg	 currentMode->maxViewportX = currentMode->imageWidth -
26671d7fec4Smrg	       currentMode->viewportWidth;
26771d7fec4Smrg	 /* this might need to get clamped to some maximum */
26871d7fec4Smrg	 currentMode->maxViewportY = currentMode->imageHeight -
26971d7fec4Smrg	       currentMode->viewportHeight;
27071d7fec4Smrg	 oneMore = FALSE;
27171d7fec4Smrg	 goto SECOND_PASS;
27271d7fec4Smrg      } else {
27371d7fec4Smrg	 currentMode->bytesPerScanline =
27471d7fec4Smrg	       ((pScrn->displayWidth * Bpp) + 3) & ~3L;
27571d7fec4Smrg	 currentMode->imageWidth = pScrn->displayWidth;
27671d7fec4Smrg	 currentMode->imageHeight = pMode->VDisplay;
27771d7fec4Smrg	 currentMode->pixmapWidth = currentMode->imageWidth;
27871d7fec4Smrg	 currentMode->pixmapHeight = currentMode->imageHeight;
27971d7fec4Smrg	 currentMode->maxViewportX = currentMode->imageWidth -
28071d7fec4Smrg	       currentMode->viewportWidth;
28171d7fec4Smrg	 /* this might need to get clamped to some maximum */
28271d7fec4Smrg	 currentMode->maxViewportY = currentMode->imageHeight -
28371d7fec4Smrg	       currentMode->viewportHeight;
28471d7fec4Smrg      }
28571d7fec4Smrg      pMode = pMode->next;
28671d7fec4Smrg      if (pMode == firstMode)
28771d7fec4Smrg	 break;
28871d7fec4Smrg   }
28971d7fec4Smrg   pGeode->numDGAModes = num;
29071d7fec4Smrg   pGeode->DGAModes = modes;
29171d7fec4Smrg   return DGAInit(pScreen, &GX2DGAFuncs, modes, num);
29271d7fec4Smrg}
29371d7fec4Smrg
29471d7fec4Smrg/*----------------------------------------------------------------------------
29571d7fec4Smrg * GX2_SetMode.
29671d7fec4Smrg *
29771d7fec4Smrg * Description	:This function is sets into the DGA mode.
29871d7fec4Smrg *.
29971d7fec4Smrg * Parameters.
30071d7fec4Smrg *	pScreeen	:Pointer to screen info structure.
30171d7fec4Smrg *	pMode		:Points to the DGAmode ptr data
30271d7fec4Smrg * Returns		:TRUE on success and FALSE on failure.
30371d7fec4Smrg *
30471d7fec4Smrg * Comments		:none.
30571d7fec4Smrg *
30671d7fec4Smrg *
30771d7fec4Smrg*----------------------------------------------------------------------------
30871d7fec4Smrg*/
30971d7fec4Smrgstatic Bool
31071d7fec4SmrgGX2_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode)
31171d7fec4Smrg{
31271d7fec4Smrg   static int OldDisplayWidth[MAXSCREENS];
31371d7fec4Smrg   int index = pScrn->pScreen->myNum;
31471d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
31571d7fec4Smrg
31671d7fec4Smrg   DEBUGMSG(0, (0, X_NONE, "GX2_SetMode\n"));
31771d7fec4Smrg   if (!pMode) {
31871d7fec4Smrg      /* restore the original mode
31971d7fec4Smrg       * * put the ScreenParameters back
32071d7fec4Smrg       */
32171d7fec4Smrg      pScrn->displayWidth = OldDisplayWidth[index];
32271d7fec4Smrg      DEBUGMSG(0,
32371d7fec4Smrg	       (0, X_NONE, "GX2_SetMode !pMode %d\n", pScrn->displayWidth));
32471d7fec4Smrg      GX2SwitchMode(index, pScrn->currentMode, 0);
32571d7fec4Smrg      pGeode->DGAactive = FALSE;
32671d7fec4Smrg   } else {
32771d7fec4Smrg      if (!pGeode->DGAactive) {		/* save the old parameters */
32871d7fec4Smrg	 OldDisplayWidth[index] = pScrn->displayWidth;
32971d7fec4Smrg	 pGeode->DGAactive = TRUE;
33071d7fec4Smrg	 DEBUGMSG(0,
33171d7fec4Smrg		  (0, X_NONE, "GX2_SetMode pMode+ NA %d\n",
33271d7fec4Smrg		   pScrn->displayWidth));
33371d7fec4Smrg      }
33471d7fec4Smrg      pScrn->displayWidth = pMode->bytesPerScanline /
33571d7fec4Smrg	    (pMode->bitsPerPixel >> 3);
33671d7fec4Smrg      DEBUGMSG(0,
33771d7fec4Smrg	       (0, X_NONE, "GX2_SetMode pMode+  %d\n", pScrn->displayWidth));
33871d7fec4Smrg      GX2SwitchMode(index, pMode->mode, 0);
33971d7fec4Smrg   }
34071d7fec4Smrg   /* enable/disable Compression */
34171d7fec4Smrg   if (pGeode->Compression) {
34271d7fec4Smrg      GFX(set_compression_enable(!pGeode->DGAactive));
34371d7fec4Smrg   }
34471d7fec4Smrg
34571d7fec4Smrg   /* enable/disable cursor */
34671d7fec4Smrg   if (pGeode->HWCursor) {
34771d7fec4Smrg      GFX(set_cursor_enable(!pGeode->DGAactive));
34871d7fec4Smrg   }
34971d7fec4Smrg
35071d7fec4Smrg   return TRUE;
35171d7fec4Smrg}
35271d7fec4Smrg
35371d7fec4Smrg/*----------------------------------------------------------------------------
35471d7fec4Smrg * GX2_GetViewPort.
35571d7fec4Smrg *
35671d7fec4Smrg * Description	:This function is Gets the viewport window memory.
35771d7fec4Smrg *.
35871d7fec4Smrg * Parameters.
35971d7fec4Smrg *	pScrn		:Pointer to screen info structure.
36071d7fec4Smrg *
36171d7fec4Smrg * Returns		:returns the viewport status.
36271d7fec4Smrg *
36371d7fec4Smrg * Comments		:none.
36471d7fec4Smrg *
36571d7fec4Smrg *
36671d7fec4Smrg*----------------------------------------------------------------------------
36771d7fec4Smrg*/
36871d7fec4Smrgstatic int
36971d7fec4SmrgGX2_GetViewport(ScrnInfoPtr pScrn)
37071d7fec4Smrg{
37171d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
37271d7fec4Smrg
37371d7fec4Smrg   return pGeode->DGAViewportStatus;
37471d7fec4Smrg}
37571d7fec4Smrg
37671d7fec4Smrg/*----------------------------------------------------------------------------
37771d7fec4Smrg * GX2_SetViewPort.
37871d7fec4Smrg *
37971d7fec4Smrg * Description	:This function is Gets the viewport window memory.
38071d7fec4Smrg *
38171d7fec4Smrg * Parameters.
38271d7fec4Smrg *	pScrn		:Pointer to screen info structure.
38371d7fec4Smrg		x		:x-cordinate of viewport window
38471d7fec4Smrg *		y		:y-codinate of the viewport window.
38571d7fec4Smrg *	flags		:indicates the viewport to be flipped or not.
38671d7fec4Smrg * Returns		:returns the viewport status  as zero.
38771d7fec4Smrg *
38871d7fec4Smrg * Comments		:none.
38971d7fec4Smrg *
39071d7fec4Smrg*----------------------------------------------------------------------------
39171d7fec4Smrg*/
39271d7fec4Smrgstatic void
39371d7fec4SmrgGX2_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags)
39471d7fec4Smrg{
39571d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
39671d7fec4Smrg
39771d7fec4Smrg   GX2AdjustFrame(pScrn->pScreen->myNum, x, y, flags);
39871d7fec4Smrg   pGeode->DGAViewportStatus = 0;	/*GX2AdjustFrame loops until finished */
39971d7fec4Smrg}
40071d7fec4Smrg
40171d7fec4Smrg/*----------------------------------------------------------------------------
40271d7fec4Smrg * GX2_FillRect.
40371d7fec4Smrg *
40471d7fec4Smrg * Description	:This function is Gets the viewport window memory.
40571d7fec4Smrg *.
40671d7fec4Smrg * Parameters.
40771d7fec4Smrg *	pScrn		:Pointer to screen info structure.
40871d7fec4Smrg *		x		:x-cordinate of viewport window
40971d7fec4Smrg *		y		:y-codinate of the viewport window.
41071d7fec4Smrg *		w		:width of the rectangle
41171d7fec4Smrg *      h		:height of the rectangle.
41271d7fec4Smrg *	color		:color to be filled in rectangle.
41371d7fec4Smrg *
41471d7fec4Smrg * Returns		:returns the viewport status  as zero.
41571d7fec4Smrg *
41671d7fec4Smrg * Comments		:This function is implemented by solidfill routines..
41771d7fec4Smrg *
41871d7fec4Smrg*----------------------------------------------------------------------------
41971d7fec4Smrg*/
42071d7fec4Smrgstatic void
42171d7fec4SmrgGX2_FillRect(ScrnInfoPtr pScrn, int x, int y,
42271d7fec4Smrg	     int w, int h, unsigned long color)
42371d7fec4Smrg{
42471d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
42571d7fec4Smrg
42671d7fec4Smrg   if (pGeode->AccelInfoRec) {
42771d7fec4Smrg      (*pGeode->AccelInfoRec->SetupForSolidFill) (pScrn, color, GXcopy, ~0);
42871d7fec4Smrg      (*pGeode->AccelInfoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h);
42971d7fec4Smrg      SET_SYNC_FLAG(pGeode->AccelInfoRec);
43071d7fec4Smrg   }
43171d7fec4Smrg}
43271d7fec4Smrg
43371d7fec4Smrg/*----------------------------------------------------------------------------
43471d7fec4Smrg * GX2_BlitRect.
43571d7fec4Smrg *
43671d7fec4Smrg * Description	:This function implementing Blit and it moves a
43771d7fec4Smrg *			 	 Rectangular block of data from one location to other
43871d7fec4Smrg *			 	 Location.
43971d7fec4Smrg *
44071d7fec4Smrg * Parameters.
44171d7fec4Smrg *	pScrn		:Pointer to screen info structure.
44271d7fec4Smrg *	srcx		:x-cordinate of the src rectangle
44371d7fec4Smrg *	srcy		:y-codinate of src rectangle.
44471d7fec4Smrg *	  w			:width of the rectangle
44571d7fec4Smrg *    h			:height of the rectangle.
44671d7fec4Smrg *	dstx		:x-cordinate of the dst rectangle.
44771d7fec4Smrg *	dsty		:y -coordinates of the dst rectangle.
44871d7fec4Smrg * Returns		:none.
44971d7fec4Smrg *
45071d7fec4Smrg * Comments		:none
45171d7fec4Smrg *
45271d7fec4Smrg*----------------------------------------------------------------------------
45371d7fec4Smrg*/
45471d7fec4Smrgstatic void
45571d7fec4SmrgGX2_BlitRect(ScrnInfoPtr pScrn,
45671d7fec4Smrg	     int srcx, int srcy, int w, int h, int dstx, int dsty)
45771d7fec4Smrg{
45871d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
45971d7fec4Smrg
46071d7fec4Smrg   if (pGeode->AccelInfoRec) {
46171d7fec4Smrg      int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1;
46271d7fec4Smrg      int ydir = (srcy < dsty) ? -1 : 1;
46371d7fec4Smrg
46471d7fec4Smrg      (*pGeode->AccelInfoRec->SetupForScreenToScreenCopy)
46571d7fec4Smrg	    (pScrn, xdir, ydir, GXcopy, ~0, -1);
46671d7fec4Smrg      (*pGeode->AccelInfoRec->SubsequentScreenToScreenCopy) (pScrn, srcx,
46771d7fec4Smrg							     srcy, dstx, dsty,
46871d7fec4Smrg							     w, h);
46971d7fec4Smrg      SET_SYNC_FLAG(pGeode->AccelInfoRec);
47071d7fec4Smrg   }
47171d7fec4Smrg}
47271d7fec4Smrg
47371d7fec4Smrg/*----------------------------------------------------------------------------
47471d7fec4Smrg * GX2_OpenFramebuffer.
47571d7fec4Smrg *
47671d7fec4Smrg * Description	:This function open the framebuffer driver for DGA.
47771d7fec4Smrg *
47871d7fec4Smrg * Parameters.
47971d7fec4Smrg *	pScrn		:Pointer to screen info structure.
48071d7fec4Smrg *	srcx		:x-cordinate of the src rectangle
48171d7fec4Smrg *	srcy		:y-codinate of src rectangle.
48271d7fec4Smrg *		w		:width of the rectangle
48371d7fec4Smrg *    	h		:height of the rectangle.
48471d7fec4Smrg *	dstx		:x-cordinate of the dst rectangle.
48571d7fec4Smrg *	dsty		:y -coordinates of the dst rectangle.
48671d7fec4Smrg * Returns		:none.
48771d7fec4Smrg *
48871d7fec4Smrg * Comments		:none
48971d7fec4Smrg *
49071d7fec4Smrg*----------------------------------------------------------------------------
49171d7fec4Smrg*/
49271d7fec4Smrgstatic Bool
49371d7fec4SmrgGX2_OpenFramebuffer(ScrnInfoPtr pScrn,
49471d7fec4Smrg		    char **name, unsigned char **mem,
49571d7fec4Smrg		    int *size, int *offset, int *flags)
49671d7fec4Smrg{
49771d7fec4Smrg   GeodePtr pGeode = GEODEPTR(pScrn);
49871d7fec4Smrg
49971d7fec4Smrg   *name = NULL;			/* no special device */
50071d7fec4Smrg   *mem = (unsigned char *)pGeode->FBLinearAddr;
50171d7fec4Smrg   *size = pGeode->FBSize;
50271d7fec4Smrg   *offset = 0;
50371d7fec4Smrg   *flags = DGA_NEED_ROOT;
50471d7fec4Smrg   return TRUE;
50571d7fec4Smrg}
50671d7fec4Smrg
50771d7fec4Smrgstatic void
50871d7fec4SmrgGX2_CloseFramebuffer(ScrnInfoPtr pScrn)
50971d7fec4Smrg{
51071d7fec4Smrg}
51171d7fec4Smrg
51271d7fec4Smrg/* end of file */
513