171d7fec4Smrg/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/gfx/vga_gu1.c,v 1.1 2002/12/10 15:12:27 alanh Exp $ */
271d7fec4Smrg/*
371d7fec4Smrg * $Workfile: vga_gu1.c $
471d7fec4Smrg *
571d7fec4Smrg * This file contains routines to set modes using the VGA registers.
671d7fec4Smrg * Since this file is for the first generation graphics unit, it interfaces
771d7fec4Smrg * to SoftVGA registers.  It works for both VSA1 and VSA2.
871d7fec4Smrg *
971d7fec4Smrg * NSC_LIC_ALTERNATIVE_PREAMBLE
1071d7fec4Smrg *
1171d7fec4Smrg * Revision 1.0
1271d7fec4Smrg *
1371d7fec4Smrg * National Semiconductor Alternative GPL-BSD License
1471d7fec4Smrg *
1571d7fec4Smrg * National Semiconductor Corporation licenses this software
1671d7fec4Smrg * ("Software"):
1771d7fec4Smrg *
1871d7fec4Smrg *      Durango
1971d7fec4Smrg *
2071d7fec4Smrg * under one of the two following licenses, depending on how the
2171d7fec4Smrg * Software is received by the Licensee.
2271d7fec4Smrg *
2371d7fec4Smrg * If this Software is received as part of the Linux Framebuffer or
2471d7fec4Smrg * other GPL licensed software, then the GPL license designated
2571d7fec4Smrg * NSC_LIC_GPL applies to this Software; in all other circumstances
2671d7fec4Smrg * then the BSD-style license designated NSC_LIC_BSD shall apply.
2771d7fec4Smrg *
2871d7fec4Smrg * END_NSC_LIC_ALTERNATIVE_PREAMBLE */
2971d7fec4Smrg
3071d7fec4Smrg/* NSC_LIC_BSD
3171d7fec4Smrg *
3271d7fec4Smrg * National Semiconductor Corporation Open Source License for Durango
3371d7fec4Smrg *
3471d7fec4Smrg * (BSD License with Export Notice)
3571d7fec4Smrg *
3671d7fec4Smrg * Copyright (c) 1999-2001
3771d7fec4Smrg * National Semiconductor Corporation.
3871d7fec4Smrg * All rights reserved.
3971d7fec4Smrg *
4071d7fec4Smrg * Redistribution and use in source and binary forms, with or without
4171d7fec4Smrg * modification, are permitted provided that the following conditions
4271d7fec4Smrg * are met:
4371d7fec4Smrg *
4471d7fec4Smrg *   * Redistributions of source code must retain the above copyright
4571d7fec4Smrg *     notice, this list of conditions and the following disclaimer.
4671d7fec4Smrg *
4771d7fec4Smrg *   * Redistributions in binary form must reproduce the above
4871d7fec4Smrg *     copyright notice, this list of conditions and the following
4971d7fec4Smrg *     disclaimer in the documentation and/or other materials provided
5071d7fec4Smrg *     with the distribution.
5171d7fec4Smrg *
5271d7fec4Smrg *   * Neither the name of the National Semiconductor Corporation nor
5371d7fec4Smrg *     the names of its contributors may be used to endorse or promote
5471d7fec4Smrg *     products derived from this software without specific prior
5571d7fec4Smrg *     written permission.
5671d7fec4Smrg *
5771d7fec4Smrg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5871d7fec4Smrg * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5971d7fec4Smrg * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
6071d7fec4Smrg * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
6171d7fec4Smrg * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY
6271d7fec4Smrg * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6371d7fec4Smrg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
6471d7fec4Smrg * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
6571d7fec4Smrg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
6671d7fec4Smrg * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE,
6771d7fec4Smrg * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY
6871d7fec4Smrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
6971d7fec4Smrg * OF SUCH DAMAGE.
7071d7fec4Smrg *
7171d7fec4Smrg * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
7271d7fec4Smrg * YOUR JURISDICTION. It is licensee's responsibility to comply with
7371d7fec4Smrg * any export regulations applicable in licensee's jurisdiction. Under
7471d7fec4Smrg * CURRENT (2001) U.S. export regulations this software
7571d7fec4Smrg * is eligible for export from the U.S. and can be downloaded by or
7671d7fec4Smrg * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed
7771d7fec4Smrg * destinations which include Cuba, Iraq, Libya, North Korea, Iran,
7871d7fec4Smrg * Syria, Sudan, Afghanistan and any other country to which the U.S.
7971d7fec4Smrg * has embargoed goods and services.
8071d7fec4Smrg *
8171d7fec4Smrg * END_NSC_LIC_BSD */
8271d7fec4Smrg
8371d7fec4Smrg/* NSC_LIC_GPL
8471d7fec4Smrg *
8571d7fec4Smrg * National Semiconductor Corporation Gnu General Public License for Durango
8671d7fec4Smrg *
8771d7fec4Smrg * (GPL License with Export Notice)
8871d7fec4Smrg *
8971d7fec4Smrg * Copyright (c) 1999-2001
9071d7fec4Smrg * National Semiconductor Corporation.
9171d7fec4Smrg * All rights reserved.
9271d7fec4Smrg *
9371d7fec4Smrg * Redistribution and use in source and binary forms, with or without
9471d7fec4Smrg * modification, are permitted under the terms of the GNU General
9571d7fec4Smrg * Public License as published by the Free Software Foundation; either
9671d7fec4Smrg * version 2 of the License, or (at your option) any later version
9771d7fec4Smrg *
9871d7fec4Smrg * In addition to the terms of the GNU General Public License, neither
9971d7fec4Smrg * the name of the National Semiconductor Corporation nor the names of
10071d7fec4Smrg * its contributors may be used to endorse or promote products derived
10171d7fec4Smrg * from this software without specific prior written permission.
10271d7fec4Smrg *
10371d7fec4Smrg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
10471d7fec4Smrg * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
10571d7fec4Smrg * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
10671d7fec4Smrg * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
10771d7fec4Smrg * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY
10871d7fec4Smrg * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
10971d7fec4Smrg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
11071d7fec4Smrg * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
11171d7fec4Smrg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
11271d7fec4Smrg * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE,
11371d7fec4Smrg * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY
11471d7fec4Smrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
11571d7fec4Smrg * OF SUCH DAMAGE. See the GNU General Public License for more details.
11671d7fec4Smrg *
11771d7fec4Smrg * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
11871d7fec4Smrg * YOUR JURISDICTION. It is licensee's responsibility to comply with
11971d7fec4Smrg * any export regulations applicable in licensee's jurisdiction. Under
12071d7fec4Smrg * CURRENT (2001) U.S. export regulations this software
12171d7fec4Smrg * is eligible for export from the U.S. and can be downloaded by or
12271d7fec4Smrg * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed
12371d7fec4Smrg * destinations which include Cuba, Iraq, Libya, North Korea, Iran,
12471d7fec4Smrg * Syria, Sudan, Afghanistan and any other country to which the U.S.
12571d7fec4Smrg * has embargoed goods and services.
12671d7fec4Smrg *
12771d7fec4Smrg * You should have received a copy of the GNU General Public License
12871d7fec4Smrg * along with this file; if not, write to the Free Software Foundation,
12971d7fec4Smrg * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13071d7fec4Smrg *
13171d7fec4Smrg * END_NSC_LIC_GPL */
13271d7fec4Smrg
13371d7fec4Smrg/* SoftVGA Extended CRTC register indices and bit definitions */
13471d7fec4Smrg
13571d7fec4Smrg#define CRTC_EXTENDED_REGISTER_LOCK		0x30
13671d7fec4Smrg#define CRTC_MODE_SWITCH_CONTROL		0x3F
13771d7fec4Smrg
13871d7fec4Smrg/* BIT DEFINITIONS */
13971d7fec4Smrg
14071d7fec4Smrg#define CRTC_BIT_16BPP					0x01
14171d7fec4Smrg#define CRTC_BIT_555					0x02
14271d7fec4Smrg
14371d7fec4Smrg/* LOCAL ROUTINE DEFINITIONS */
14471d7fec4Smrg
14571d7fec4Smrgint gu1_detect_vsa2(void);
14671d7fec4Smrg
14771d7fec4Smrg/*---------------------------------*/
14871d7fec4Smrg/*  MODE TABLES FOR VGA REGISTERS  */
14971d7fec4Smrg/*---------------------------------*/
15071d7fec4Smrg
15171d7fec4Smrg/* FOR SoftVGA, the CRTC_EXTENDED_ADDRESS_CONTROL (0x43) is always equal to
15271d7fec4Smrg * 0x03 for a packed linear frame buffer organization.  The
15371d7fec4Smrg * CRTC_EXTENDED_DAC_CONTROL (0x4B) is always equal to 0x03 to work with
15471d7fec4Smrg * older versions of VSA1 (that needed to specify 8 or 16 bit bus to an
15571d7fec4Smrg * external RAMDAC.  This is not used in VSA2.  The clock frequency is
15671d7fec4Smrg * specified in register 0x4D if clock control (0x4C) is set to 0x80.
15771d7fec4Smrg * Higher resolutions (1280x1024) use the CRTC_EXTENDED_VERTICAL_TIMING
15871d7fec4Smrg * register (index 0x41).
15971d7fec4Smrg */
16071d7fec4Smrg
16171d7fec4Smrggfx_vga_struct gfx_vga_modes[] = {
16271d7fec4Smrg/*------------------------------------------------------------------------------*/
16371d7fec4Smrg   {640, 480, 60,			/* 640x480 */
16471d7fec4Smrg    25,					/* 25 MHz clock = 60 Hz refresh rate */
16571d7fec4Smrg    0xE3,				/* miscOutput register */
16671d7fec4Smrg    {0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E,	/* standard CRTC */
16771d7fec4Smrg     0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16871d7fec4Smrg     0xEA, 0x0C, 0xDF, 0x50, 0x00, 0xE7, 0x04, 0xE3, 0xFF},
16971d7fec4Smrg    {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,	/* extended CRTC */
17071d7fec4Smrg     0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00}},
17171d7fec4Smrg/*------------------------------------------------------------------------------*/
17271d7fec4Smrg   {640, 480, 72,			/* 640x480 */
17371d7fec4Smrg    29,					/* 29 MHz clock = 72 Hz refresh rate */
17471d7fec4Smrg    0xE3,				/* miscOutput register */
17571d7fec4Smrg    {0x63, 0x4f, 0x50, 0x86, 0x55, 0x99, 0x06, 0x3e,	/* standard CRTC */
17671d7fec4Smrg     0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17771d7fec4Smrg     0xe9, 0x0c, 0xdf, 0x00, 0x00, 0xe7, 0x00, 0xe3, 0xff},
17871d7fec4Smrg    {0x6D, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01, 0x00,	/* extended CRTC */
17971d7fec4Smrg     0x00, 0x00, 0x01, 0x08, 0x80, 0x1F, 0x00, 0x4B}},
18071d7fec4Smrg/*------------------------------------------------------------------------------*/
18171d7fec4Smrg   {640, 480, 75,			/* 640x480 */
18271d7fec4Smrg    31,					/* 31.5 MHz clock = 75 Hz refresh rate */
18371d7fec4Smrg    0xE3,				/* miscOutput register */
18471d7fec4Smrg    {0x64, 0x4F, 0x4F, 0x88, 0x54, 0x9B, 0xF2, 0x1F,	/* standard CRTC */
18571d7fec4Smrg     0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18671d7fec4Smrg     0xE1, 0x04, 0xDF, 0x50, 0x00, 0xDF, 0xF3, 0xE3, 0xFF},
18771d7fec4Smrg    {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,	/* extended CRTC */
18871d7fec4Smrg     0x00, 0x00, 0x00, 0x03, 0x80, 0x1F, 0x00, 0x00}},
18971d7fec4Smrg/*------------------------------------------------------------------------------*/
19071d7fec4Smrg   {800, 600, 60,			/* 800x600 */
19171d7fec4Smrg    40,					/* 40 MHz clock = 60 Hz refresh rate */
19271d7fec4Smrg    0x23,				/* miscOutput register */
19371d7fec4Smrg    {0x7F, 0x63, 0x64, 0x82, 0x6B, 0x1B, 0x72, 0xF0,	/* standard CRTC */
19471d7fec4Smrg     0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19571d7fec4Smrg     0x59, 0x0D, 0x57, 0x64, 0x00, 0x57, 0x73, 0xE3, 0xFF},
19671d7fec4Smrg    {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,	/* extended CRTC */
19771d7fec4Smrg     0x00, 0x00, 0x00, 0x03, 0x80, 0x28, 0x00, 0x00}},
19871d7fec4Smrg/*------------------------------------------------------------------------------*/
19971d7fec4Smrg   {800, 600, 72,			/* 800x600 */
20071d7fec4Smrg    47,					/* 47 MHz clock = 72 Hz refresh rate */
20171d7fec4Smrg    0x2B,				/* miscOutput register */
20271d7fec4Smrg    {0x7D, 0x63, 0x63, 0x81, 0x6D, 0x1B, 0x98, 0xF0,	/* standard CRTC */
20371d7fec4Smrg     0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20471d7fec4Smrg     0x7D, 0x03, 0x57, 0x00, 0x00, 0x57, 0x9A, 0xE3, 0xFF},
20571d7fec4Smrg    {0x6F, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01, 0x00,	/* extended CRTC */
20671d7fec4Smrg     0x00, 0x00, 0x01, 0x08, 0x80, 0x32, 0x00, 0x4B}},
20771d7fec4Smrg/*------------------------------------------------------------------------------*/
20871d7fec4Smrg   {800, 600, 75,			/* 800x600 */
20971d7fec4Smrg    49,					/* 49.5 MHz clock = 75 Hz refresh rate */
21071d7fec4Smrg    0x23,				/* miscOutput register */
21171d7fec4Smrg    {0x7F, 0x63, 0x63, 0x83, 0x68, 0x11, 0x6F, 0xF0,	/* standard CRTC */
21271d7fec4Smrg     0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21371d7fec4Smrg     0x59, 0x1C, 0x57, 0x64, 0x00, 0x57, 0x70, 0xE3, 0xFF},
21471d7fec4Smrg    {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,	/* extended CRTC */
21571d7fec4Smrg     0x00, 0x00, 0x00, 0x03, 0x80, 0x31, 0x00, 0x00}},
21671d7fec4Smrg/*------------------------------------------------------------------------------*/
21771d7fec4Smrg   {1024, 768, 60,			/* 1024x768 */
21871d7fec4Smrg    65,					/* 65 MHz clock = 60 Hz refresh rate */
21971d7fec4Smrg    0xE3,				/* miscOutput register */
22071d7fec4Smrg    {0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xF5,	/* standard CRTC */
22171d7fec4Smrg     0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22271d7fec4Smrg     0x04, 0x0A, 0xFF, 0x80, 0x00, 0xFF, 0x25, 0xE3, 0xFF},
22371d7fec4Smrg    {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,	/* extended CRTC */
22471d7fec4Smrg     0x00, 0x00, 0x00, 0x03, 0x80, 0x41, 0x00, 0x00}},
22571d7fec4Smrg/*------------------------------------------------------------------------------*/
22671d7fec4Smrg   {1024, 768, 70,			/* 1024x768 */
22771d7fec4Smrg    76,					/* 76 MHz clock = 70 Hz refresh rate */
22871d7fec4Smrg    0x2B,				/* miscOutput register */
22971d7fec4Smrg    {0xA1, 0x7F, 0x7F, 0x85, 0x85, 0x95, 0x24, 0xF5,	/* standard CRTC */
23071d7fec4Smrg     0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23171d7fec4Smrg     0x03, 0x09, 0xFF, 0x00, 0x00, 0xFF, 0x26, 0xE3, 0xFF},
23271d7fec4Smrg    {0x62, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01, 0x00,	/* extended CRTC */
23371d7fec4Smrg     0x00, 0x00, 0x01, 0x02, 0x80, 0x4B, 0x00, 0x4B}},
23471d7fec4Smrg/*------------------------------------------------------------------------------*/
23571d7fec4Smrg   {1024, 768, 75,			/* 1024x768 */
23671d7fec4Smrg    79,					/* 79 MHz clock = 75 Hz refresh rate */
23771d7fec4Smrg    0xE3,				/* miscOutput register */
23871d7fec4Smrg    {0x9F, 0x7F, 0x7F, 0x83, 0x84, 0x8F, 0x1E, 0xF5,	/* standard CRTC */
23971d7fec4Smrg     0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24071d7fec4Smrg     0x01, 0x04, 0xFF, 0x80, 0x00, 0xFF, 0x1F, 0xE3, 0xFF},
24171d7fec4Smrg    {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,	/* extended CRTC */
24271d7fec4Smrg     0x00, 0x00, 0x00, 0x03, 0x80, 0x4F, 0x00, 0x00}},
24371d7fec4Smrg/*------------------------------------------------------------------------------*/
24471d7fec4Smrg   {1280, 1024, 60,			/* 1280x1024 */
24571d7fec4Smrg    108,				/* 108 MHz clock = 60 Hz refresh rate */
24671d7fec4Smrg    0x23,				/* miscOutput register */
24771d7fec4Smrg    {0xCF, 0x9F, 0xA0, 0x92, 0xAA, 0x19, 0x28, 0x52,	/* standard CRTC */
24871d7fec4Smrg     0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24971d7fec4Smrg     0x01, 0x04, 0xFF, 0xA0, 0x00, 0x00, 0x29, 0xE3, 0xFF},
25071d7fec4Smrg    {0x00, 0x51, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,	/* extended CRTC */
25171d7fec4Smrg     0x00, 0x00, 0x00, 0x03, 0x80, 0x6C, 0x00, 0x00}},
25271d7fec4Smrg/*------------------------------------------------------------------------------*/
25371d7fec4Smrg   {1280, 1024, 75,			/* 1280x1024 */
25471d7fec4Smrg    135,				/* 135 MHz clock = 75 Hz refresh rate */
25571d7fec4Smrg    0x23,				/* miscOutput register */
25671d7fec4Smrg    {0xCE, 0x9F, 0x9F, 0x92, 0xA4, 0x15, 0x28, 0x52,	/* standard CRTC */
25771d7fec4Smrg     0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25871d7fec4Smrg     0x01, 0x04, 0xFF, 0xA0, 0x00, 0x00, 0x29, 0xE3, 0xFF},
25971d7fec4Smrg    {0x00, 0x51, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,	/* extended CRTC */
26071d7fec4Smrg     0x00, 0x00, 0x00, 0x03, 0x80, 0x87, 0x00, 0x00}},
26171d7fec4Smrg/*------------------------------------------------------------------------------*/
26271d7fec4Smrg   {1280, 1024, 85,			/* 1280x1024 */
26371d7fec4Smrg    159,				/* 159 MHz clock = 85 Hz refresh rate */
26471d7fec4Smrg    0x2B,				/* miscOutput register */
26571d7fec4Smrg    {0xD3, 0x9F, 0xA0, 0x98, 0xA8, 0x9C, 0x2E, 0x5A,	/* standard CRTC */
26671d7fec4Smrg     0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26771d7fec4Smrg     0x01, 0x04, 0xFF, 0x00, 0x00, 0xFF, 0x30, 0xE3, 0xFF},
26871d7fec4Smrg    {0x6B, 0x41, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00,	/* extended CRTC */
26971d7fec4Smrg     0x00, 0x00, 0x01, 0x00, 0x80, 0x9D, 0x00, 0x4B}},
27071d7fec4Smrg
27171d7fec4Smrg/*------------------------------------------------------------------------------*/
27271d7fec4Smrg};
27371d7fec4Smrg
27471d7fec4Smrg#define GFX_VGA_MODES sizeof(gfx_vga_modes)/sizeof(gfx_vga_struct)
27571d7fec4Smrg
27671d7fec4Smrg/*-----------------------------------------------------------------------------
27771d7fec4Smrg * gfx_get_softvga_active
27871d7fec4Smrg *
27971d7fec4Smrg * This returns the active status of SoftVGA
28071d7fec4Smrg *-----------------------------------------------------------------------------
28171d7fec4Smrg */
28271d7fec4Smrgint
28371d7fec4Smrggfx_get_softvga_active(void)
28471d7fec4Smrg{
28571d7fec4Smrg   unsigned short crtcindex, crtcdata;
28671d7fec4Smrg
28771d7fec4Smrg   if (gu1_detect_vsa2())
28871d7fec4Smrg      return (gfx_get_vsa2_softvga_enable());
28971d7fec4Smrg
29071d7fec4Smrg   crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4;
29171d7fec4Smrg   crtcdata = crtcindex + 1;
29271d7fec4Smrg
29371d7fec4Smrg   OUTB(crtcindex, CRTC_MODE_SWITCH_CONTROL);
29471d7fec4Smrg   return (INB(crtcdata) & 0x1);
29571d7fec4Smrg}
29671d7fec4Smrg
29771d7fec4Smrg/*-----------------------------------------------------------------------------
29871d7fec4Smrg * gfx_vga_test_pci
29971d7fec4Smrg *
30071d7fec4Smrg * This routine looks for the VGA PCI header.  It checks to see that bit 1
30171d7fec4Smrg * of the command register is writable to know that SoftVGA is trapping
30271d7fec4Smrg * the PCI config cuscles.  If SoftVGA is not emulating the header, the
30371d7fec4Smrg * hardware will still respond with the proper device ID, etc.
30471d7fec4Smrg *
30571d7fec4Smrg * We need to know that SoftVGA is really there so that we can set the
30671d7fec4Smrg * command register and have the proper effect (enable trapping of VGA).
30771d7fec4Smrg * Otherwise, if we enable VGA via the PCI header, trapping really won't be
30871d7fec4Smrg * enabled and the VGA register writes will go out to the external card.
30971d7fec4Smrg *-----------------------------------------------------------------------------
31071d7fec4Smrg */
31171d7fec4Smrgint
31271d7fec4Smrggfx_vga_test_pci(void)
31371d7fec4Smrg{
31471d7fec4Smrg   int softvga = 1;
31571d7fec4Smrg   unsigned long value;
31671d7fec4Smrg
31771d7fec4Smrg   value = gfx_pci_config_read(0x80009400);
31871d7fec4Smrg   if ((value & 0x0000FFFF) != 0x1078)
31971d7fec4Smrg      softvga = 0;
32071d7fec4Smrg   else {
32171d7fec4Smrg      value = gfx_pci_config_read(0x80009404);
32271d7fec4Smrg      gfx_pci_config_write(0x80009404, value | 0x02);
32371d7fec4Smrg      if (!(gfx_pci_config_read(0x80009404) & 0x02))
32471d7fec4Smrg	 softvga = 0;
32571d7fec4Smrg      gfx_pci_config_write(0x80009404, value);
32671d7fec4Smrg   }
32771d7fec4Smrg   return (softvga);
32871d7fec4Smrg}
32971d7fec4Smrg
33071d7fec4Smrg/*-----------------------------------------------------------------------------
33171d7fec4Smrg * gfx_vga_get_pci_command
33271d7fec4Smrg *
33371d7fec4Smrg * This routine returns the value of the PCI command register.
33471d7fec4Smrg *-----------------------------------------------------------------------------
33571d7fec4Smrg */
33671d7fec4Smrgunsigned char
33771d7fec4Smrggfx_vga_get_pci_command(void)
33871d7fec4Smrg{
33971d7fec4Smrg   unsigned long value;
34071d7fec4Smrg
34171d7fec4Smrg   value = gfx_pci_config_read(0x80009404);
34271d7fec4Smrg   return ((unsigned char)value);
34371d7fec4Smrg}
34471d7fec4Smrg
34571d7fec4Smrg/*-----------------------------------------------------------------------------
34671d7fec4Smrg * gfx_vga_set_pci_command
34771d7fec4Smrg *
34871d7fec4Smrg * This routine writes the value of the PCI command register.  It is used
34971d7fec4Smrg * to enable or disable SoftVGA.
35071d7fec4Smrg *
35171d7fec4Smrg *    Bit 0: Enable VGA IO
35271d7fec4Smrg *    Bit 1: Enable VGA memory
35371d7fec4Smrg *-----------------------------------------------------------------------------
35471d7fec4Smrg */
35571d7fec4Smrgint
35671d7fec4Smrggfx_vga_set_pci_command(unsigned char command)
35771d7fec4Smrg{
35871d7fec4Smrg   unsigned long value;
35971d7fec4Smrg
36071d7fec4Smrg   value = gfx_pci_config_read(0x80009404) & 0xFFFFFF00;
36171d7fec4Smrg   value |= (unsigned long)command;
36271d7fec4Smrg   gfx_pci_config_write(0x80009404, value);
36371d7fec4Smrg   return (GFX_STATUS_OK);
36471d7fec4Smrg}
36571d7fec4Smrg
36671d7fec4Smrg/*-----------------------------------------------------------------------------
36771d7fec4Smrg * gfx_vga_seq_reset
36871d7fec4Smrg *
36971d7fec4Smrg * This routine enables or disables SoftVGA.  It is used to make SoftVGA
37071d7fec4Smrg * "be quiet" and not interfere with any of the direct hardware access from
37171d7fec4Smrg * Durango.  For VSA1, the sequencer is reset to stop text redraws.  VSA2 may
37271d7fec4Smrg * provide a better way to have SoftVGA sit in the background.
37371d7fec4Smrg *-----------------------------------------------------------------------------
37471d7fec4Smrg */
37571d7fec4Smrgint
37671d7fec4Smrggfx_vga_seq_reset(int reset)
37771d7fec4Smrg{
37871d7fec4Smrg   OUTB(0x3C4, 0);
37971d7fec4Smrg   OUTB(0x3C5, (unsigned char)(reset ? 0x00 : 0x03));
38071d7fec4Smrg   return (GFX_STATUS_OK);
38171d7fec4Smrg}
38271d7fec4Smrg
38371d7fec4Smrg/*-----------------------------------------------------------------------------
38471d7fec4Smrg * gfx_vga_set_graphics_bits
38571d7fec4Smrg *
38671d7fec4Smrg * This routine sets the standard VGA sequencer, graphics controller, and
38771d7fec4Smrg * attribute registers to appropriate values for a graphics mode (packed,
38871d7fec4Smrg * 8 BPP or greater).  This is also known as "VESA" modes.  The timings for
38971d7fec4Smrg * a particular mode are handled by the CRTC registers, which are set by
39071d7fec4Smrg * the "gfx_vga_restore" routine.   Most OSs that use VGA to set modes save
39171d7fec4Smrg * and restore the standard VGA registers themselves, which is why these
39271d7fec4Smrg * registers are not part of the save/restore paradigm.
39371d7fec4Smrg *-----------------------------------------------------------------------------
39471d7fec4Smrg */
39571d7fec4Smrgint
39671d7fec4Smrggfx_vga_set_graphics_bits(void)
39771d7fec4Smrg{
39871d7fec4Smrg   /* SET GRAPHICS BIT IN GRAPHICS CONTROLLER REG 0x06 */
39971d7fec4Smrg
40071d7fec4Smrg   OUTB(0x3CE, 0x06);
40171d7fec4Smrg   OUTB(0x3CF, 0x01);
40271d7fec4Smrg
40371d7fec4Smrg   /* SET GRAPHICS BIT IN ATTRIBUTE CONTROLLER REG 0x10 */
40471d7fec4Smrg
40571d7fec4Smrg   INB(0x3BA);				/* Reset flip-flop */
40671d7fec4Smrg   INB(0x3DA);
40771d7fec4Smrg   OUTB(0x3C0, 0x10);
40871d7fec4Smrg   OUTB(0x3C0, 0x01);
40971d7fec4Smrg   return (GFX_STATUS_OK);
41071d7fec4Smrg}
41171d7fec4Smrg
41271d7fec4Smrg/*-----------------------------------------------------------------------------
41371d7fec4Smrg * gfx_vga_mode
41471d7fec4Smrg *
41571d7fec4Smrg * This routine searches the VGA mode table for a match of the specified
41671d7fec4Smrg * mode and then fills in the VGA structure with the associated VGA register
41771d7fec4Smrg * values.  The "gfx_vga_restore" routine can then be called to actually
41871d7fec4Smrg * set the mode.
41971d7fec4Smrg *-----------------------------------------------------------------------------
42071d7fec4Smrg */
42171d7fec4Smrgint
42271d7fec4Smrggfx_vga_mode(gfx_vga_struct * vga, int xres, int yres, int bpp, int hz)
42371d7fec4Smrg{
42471d7fec4Smrg   unsigned int i;
42571d7fec4Smrg   unsigned short pitch;
42671d7fec4Smrg
42771d7fec4Smrg   for (i = 0; i < GFX_VGA_MODES; i++) {
42871d7fec4Smrg      if ((gfx_vga_modes[i].xsize == xres) &&
42971d7fec4Smrg	  (gfx_vga_modes[i].ysize == yres) && (gfx_vga_modes[i].hz == hz)) {
43071d7fec4Smrg	 /* COPY ENTIRE STRUCTURE FROM THE TABLE */
43171d7fec4Smrg
43271d7fec4Smrg	 *vga = gfx_vga_modes[i];
43371d7fec4Smrg
43471d7fec4Smrg	 /* SET PITCH TO 1K OR 2K */
43571d7fec4Smrg	 /* CRTC_EXTENDED_OFFSET index is 0x45, so offset = 0x05 */
43671d7fec4Smrg
43771d7fec4Smrg	 pitch = (unsigned short)xres;
43871d7fec4Smrg	 if (bpp > 8)
43971d7fec4Smrg	    pitch <<= 1;
44071d7fec4Smrg	 if (pitch <= 1024)
44171d7fec4Smrg	    pitch = 1024 >> 3;
44271d7fec4Smrg	 else
44371d7fec4Smrg	    pitch = 2048 >> 3;
44471d7fec4Smrg	 vga->stdCRTCregs[0x13] = (unsigned char)pitch;
44571d7fec4Smrg	 vga->extCRTCregs[0x05] = (unsigned char)((pitch >> 8) & 0x03);
44671d7fec4Smrg
44771d7fec4Smrg	 /* SET PROPER COLOR DEPTH VALUE */
44871d7fec4Smrg	 /* CRTC_EXTENDED_COLOR_CONTROL index is 0x46, so offset = 0x06 */
44971d7fec4Smrg
45071d7fec4Smrg	 switch (bpp) {
45171d7fec4Smrg	 case 15:
45271d7fec4Smrg	    vga->extCRTCregs[0x06] = CRTC_BIT_16BPP | CRTC_BIT_555;
45371d7fec4Smrg	    break;
45471d7fec4Smrg	 case 16:
45571d7fec4Smrg	    vga->extCRTCregs[0x06] = CRTC_BIT_16BPP;
45671d7fec4Smrg	    break;
45771d7fec4Smrg	 default:
45871d7fec4Smrg	    vga->extCRTCregs[0x06] = 0;
45971d7fec4Smrg	    break;
46071d7fec4Smrg	 }
46171d7fec4Smrg	 return (GFX_STATUS_OK);
46271d7fec4Smrg      }
46371d7fec4Smrg   }
46471d7fec4Smrg   return (GFX_STATUS_UNSUPPORTED);
46571d7fec4Smrg}
46671d7fec4Smrg
46771d7fec4Smrg/*-----------------------------------------------------------------------------
46871d7fec4Smrg * gfx_vga_pitch
46971d7fec4Smrg *
47071d7fec4Smrg * This routine updates the VGA regisers in the specified VGA structure for
47171d7fec4Smrg * the specified pitch.  It does not program the hardware.
47271d7fec4Smrg *-----------------------------------------------------------------------------
47371d7fec4Smrg */
47471d7fec4Smrgint
47571d7fec4Smrggfx_vga_pitch(gfx_vga_struct * vga, unsigned short pitch)
47671d7fec4Smrg{
47771d7fec4Smrg   pitch >>= 3;
47871d7fec4Smrg   vga->stdCRTCregs[0x13] = (unsigned char)pitch;
47971d7fec4Smrg   vga->extCRTCregs[0x05] = (unsigned char)((pitch >> 8) & 0x03);
48071d7fec4Smrg   return (0);
48171d7fec4Smrg}
48271d7fec4Smrg
48371d7fec4Smrg/*-----------------------------------------------------------------------------
48471d7fec4Smrg * gfx_vga_save
48571d7fec4Smrg *
48671d7fec4Smrg * This routine saves the state of the VGA registers into the specified
48771d7fec4Smrg * structure.  Flags indicate what portions of the register state need to
48871d7fec4Smrg * be saved.
48971d7fec4Smrg *-----------------------------------------------------------------------------
49071d7fec4Smrg */
49171d7fec4Smrgint
49271d7fec4Smrggfx_vga_save(gfx_vga_struct * vga, int flags)
49371d7fec4Smrg{
49471d7fec4Smrg   int i;
49571d7fec4Smrg   unsigned short crtcindex, crtcdata;
49671d7fec4Smrg
49771d7fec4Smrg   crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4;
49871d7fec4Smrg   crtcdata = crtcindex + 1;
49971d7fec4Smrg
50071d7fec4Smrg   /* CHECK MISCELLANEOUS OUTPUT FLAG */
50171d7fec4Smrg
50271d7fec4Smrg   if (flags & GFX_VGA_FLAG_MISC_OUTPUT) {
50371d7fec4Smrg      /* SAVE MISCCELLANEOUS OUTPUT REGISTER */
50471d7fec4Smrg
50571d7fec4Smrg      vga->miscOutput = INB(0x3CC);
50671d7fec4Smrg   }
50771d7fec4Smrg
50871d7fec4Smrg   /* CHECK STANDARD CRTC FLAG */
50971d7fec4Smrg
51071d7fec4Smrg   if (flags & GFX_VGA_FLAG_STD_CRTC) {
51171d7fec4Smrg      /* SAVE STANDARD CRTC REGISTERS */
51271d7fec4Smrg
51371d7fec4Smrg      for (i = 0; i < GFX_STD_CRTC_REGS; i++) {
51471d7fec4Smrg	 OUTB(crtcindex, (unsigned char)i);
51571d7fec4Smrg	 vga->stdCRTCregs[i] = INB(crtcdata);
51671d7fec4Smrg      }
51771d7fec4Smrg   }
51871d7fec4Smrg
51971d7fec4Smrg   /* CHECK EXTENDED CRTC FLAG */
52071d7fec4Smrg
52171d7fec4Smrg   if (flags & GFX_VGA_FLAG_EXT_CRTC) {
52271d7fec4Smrg      /* SAVE EXTENDED CRTC REGISTERS */
52371d7fec4Smrg
52471d7fec4Smrg      for (i = 0; i < GFX_EXT_CRTC_REGS; i++) {
52571d7fec4Smrg	 OUTB(crtcindex, (unsigned char)(0x40 + i));
52671d7fec4Smrg	 vga->extCRTCregs[i] = INB(crtcdata);
52771d7fec4Smrg      }
52871d7fec4Smrg   }
52971d7fec4Smrg   return (0);
53071d7fec4Smrg}
53171d7fec4Smrg
53271d7fec4Smrg/*-----------------------------------------------------------------------------
53371d7fec4Smrg * gfx_vga_clear_extended
53471d7fec4Smrg *
53571d7fec4Smrg * This routine clears the extended SoftVGA register values to have SoftVGA
53671d7fec4Smrg * behave like standard VGA.
53771d7fec4Smrg *-----------------------------------------------------------------------------
53871d7fec4Smrg */
53971d7fec4Smrgvoid
54071d7fec4Smrggfx_vga_clear_extended(void)
54171d7fec4Smrg{
54271d7fec4Smrg   int i;
54371d7fec4Smrg   unsigned short crtcindex, crtcdata;
54471d7fec4Smrg
54571d7fec4Smrg   crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4;
54671d7fec4Smrg   crtcdata = crtcindex + 1;
54771d7fec4Smrg
54871d7fec4Smrg   OUTB(crtcindex, 0x30);
54971d7fec4Smrg   OUTB(crtcdata, 0x57);
55071d7fec4Smrg   OUTB(crtcdata, 0x4C);
55171d7fec4Smrg   for (i = 0x40; i <= 0x4F; i++) {
55271d7fec4Smrg      OUTB(crtcindex, (unsigned char)i);
55371d7fec4Smrg      OUTB(crtcdata, 0);
55471d7fec4Smrg   }
55571d7fec4Smrg   OUTB(crtcindex, 0x30);
55671d7fec4Smrg   OUTB(crtcdata, 0x00);
55771d7fec4Smrg}
55871d7fec4Smrg
55971d7fec4Smrg/*-----------------------------------------------------------------------------
56071d7fec4Smrg * gfx_vga_restore
56171d7fec4Smrg *
56271d7fec4Smrg * This routine restores the state of the VGA registers from the specified
56371d7fec4Smrg * structure.  Flags indicate what portions of the register state need to
56471d7fec4Smrg * be saved.
56571d7fec4Smrg *-----------------------------------------------------------------------------
56671d7fec4Smrg */
56771d7fec4Smrgint
56871d7fec4Smrggfx_vga_restore(gfx_vga_struct * vga, int flags)
56971d7fec4Smrg{
57071d7fec4Smrg   int i;
57171d7fec4Smrg   unsigned short crtcindex, crtcdata;
57271d7fec4Smrg
57371d7fec4Smrg   crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4;
57471d7fec4Smrg   crtcdata = crtcindex + 1;
57571d7fec4Smrg
57671d7fec4Smrg   /* CHECK MISCELLANEOUS OUTPUT FLAG */
57771d7fec4Smrg
57871d7fec4Smrg   if (flags & GFX_VGA_FLAG_MISC_OUTPUT) {
57971d7fec4Smrg      /* RESTORE MISCELLANEOUS OUTPUT REGISTER VALUE */
58071d7fec4Smrg
58171d7fec4Smrg      OUTB(0x3C2, vga->miscOutput);
58271d7fec4Smrg   }
58371d7fec4Smrg
58471d7fec4Smrg   /* CHECK STANDARD CRTC FLAG */
58571d7fec4Smrg
58671d7fec4Smrg   if (flags & GFX_VGA_FLAG_STD_CRTC) {
58771d7fec4Smrg      /* UNLOCK STANDARD CRTC REGISTERS */
58871d7fec4Smrg
58971d7fec4Smrg      OUTB(crtcindex, 0x11);
59071d7fec4Smrg      OUTB(crtcdata, 0);
59171d7fec4Smrg
59271d7fec4Smrg      /* RESTORE STANDARD CRTC REGISTERS */
59371d7fec4Smrg
59471d7fec4Smrg      for (i = 0; i < GFX_STD_CRTC_REGS; i++) {
59571d7fec4Smrg	 OUTB(crtcindex, (unsigned char)i);
59671d7fec4Smrg	 OUTB(crtcdata, vga->stdCRTCregs[i]);
59771d7fec4Smrg      }
59871d7fec4Smrg   }
59971d7fec4Smrg
60071d7fec4Smrg   /* CHECK EXTENDED CRTC FLAG */
60171d7fec4Smrg
60271d7fec4Smrg   if (flags & GFX_VGA_FLAG_EXT_CRTC) {
60371d7fec4Smrg      /* UNLOCK EXTENDED CRTC REGISTERS */
60471d7fec4Smrg
60571d7fec4Smrg      OUTB(crtcindex, 0x30);
60671d7fec4Smrg      OUTB(crtcdata, 0x57);
60771d7fec4Smrg      OUTB(crtcdata, 0x4C);
60871d7fec4Smrg
60971d7fec4Smrg      /* RESTORE EXTENDED CRTC REGISTERS */
61071d7fec4Smrg
61171d7fec4Smrg      for (i = 0; i < GFX_EXT_CRTC_REGS; i++) {
61271d7fec4Smrg	 OUTB(crtcindex, (unsigned char)(0x40 + i));
61371d7fec4Smrg	 OUTB(crtcdata, vga->extCRTCregs[i]);
61471d7fec4Smrg      }
61571d7fec4Smrg
61671d7fec4Smrg      /* LOCK EXTENDED CRTC REGISTERS */
61771d7fec4Smrg
61871d7fec4Smrg      OUTB(crtcindex, 0x30);
61971d7fec4Smrg      OUTB(crtcdata, 0x00);
62071d7fec4Smrg
62171d7fec4Smrg      /* CHECK IF DIRECT FRAME BUFFER MODE (VESA MODE) */
62271d7fec4Smrg
62371d7fec4Smrg      if (vga->extCRTCregs[0x03] & 1) {
62471d7fec4Smrg	 /* SET BORDER COLOR TO BLACK */
62571d7fec4Smrg	 /* This really should be another thing saved/restored, but */
62671d7fec4Smrg	 /* Durango currently doesn't do the attr controller registers. */
62771d7fec4Smrg
62871d7fec4Smrg	 INB(0x3BA);			/* Reset flip-flop */
62971d7fec4Smrg	 INB(0x3DA);
63071d7fec4Smrg	 OUTB(0x3C0, 0x11);
63171d7fec4Smrg	 OUTB(0x3C0, 0x00);
63271d7fec4Smrg      }
63371d7fec4Smrg   }
63471d7fec4Smrg   return (0);
63571d7fec4Smrg}
63671d7fec4Smrg
63771d7fec4Smrg/*-----------------------------------------------------------------------------
63871d7fec4Smrg * gfx_vga_mode_switch
63971d7fec4Smrg *
64071d7fec4Smrg * This routine programs the SoftVGA register to indicate that a mode switch
64171d7fec4Smrg * is in progress.  This results in a cleaner mode switch since SoftVGA will
64271d7fec4Smrg * not validate the hardware with intermediate values.
64371d7fec4Smrg *-----------------------------------------------------------------------------
64471d7fec4Smrg */
64571d7fec4Smrgint
64671d7fec4Smrggfx_vga_mode_switch(int active)
64771d7fec4Smrg{
64871d7fec4Smrg   unsigned short crtcindex, crtcdata;
64971d7fec4Smrg
65071d7fec4Smrg   crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4;
65171d7fec4Smrg   crtcdata = crtcindex + 1;
65271d7fec4Smrg
65371d7fec4Smrg   /* UNLOCK EXTENDED CRTC REGISTERS */
65471d7fec4Smrg
65571d7fec4Smrg   OUTB(crtcindex, CRTC_EXTENDED_REGISTER_LOCK);
65671d7fec4Smrg   OUTB(crtcdata, 0x57);
65771d7fec4Smrg   OUTB(crtcdata, 0x4C);
65871d7fec4Smrg
65971d7fec4Smrg   /* SIGNAL THE BEGINNING OR END OF THE MODE SWITCH */
66071d7fec4Smrg   /* SoftVGA will hold off validating the back end hardware. */
66171d7fec4Smrg
66271d7fec4Smrg   OUTB(crtcindex, CRTC_MODE_SWITCH_CONTROL);
66371d7fec4Smrg   active = active ? 1 : 0;
66471d7fec4Smrg   OUTB(crtcdata, (unsigned char)active);
66571d7fec4Smrg
66671d7fec4Smrg   /* WAIT UNTIL SOFTVGA HAS VALIDATED MODE IF ENDING MODE SWITCH */
66771d7fec4Smrg   /* This is for VSA1 only, where SoftVGA waits until the next */
66871d7fec4Smrg   /* vertical blank to validate the hardware state. */
66971d7fec4Smrg
67071d7fec4Smrg   if ((!active) && (!(gu1_detect_vsa2()))) {
67171d7fec4Smrg      OUTB(crtcindex, 0x33);
67271d7fec4Smrg      while (INB(crtcdata) & 0x80) ;
67371d7fec4Smrg   }
67471d7fec4Smrg
67571d7fec4Smrg   /* LOCK EXTENDED CRTC REGISTERS */
67671d7fec4Smrg
67771d7fec4Smrg   OUTB(crtcindex, CRTC_EXTENDED_REGISTER_LOCK);
67871d7fec4Smrg   OUTB(crtcdata, 0x00);
67971d7fec4Smrg   return (0);
68071d7fec4Smrg}
68171d7fec4Smrg
68271d7fec4Smrg/*-----------------------------------------------------------------------------
68371d7fec4Smrg * gu1_detect_vsa2
68471d7fec4Smrg *
68571d7fec4Smrg * This routine detects if VSA2 is present.  The interface to SoftVGA
68671d7fec4Smrg * changed slightly.
68771d7fec4Smrg *-----------------------------------------------------------------------------
68871d7fec4Smrg */
68971d7fec4Smrgint
69071d7fec4Smrggu1_detect_vsa2(void)
69171d7fec4Smrg{
69271d7fec4Smrg   unsigned short crtcindex, crtcdata;
69371d7fec4Smrg
69471d7fec4Smrg   crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4;
69571d7fec4Smrg   crtcdata = crtcindex + 1;
69671d7fec4Smrg   OUTB(crtcindex, 0x35);
69771d7fec4Smrg   if (INB(crtcdata) != 'C')
69871d7fec4Smrg      return (0);
69971d7fec4Smrg   OUTB(crtcindex, 0x36);
70071d7fec4Smrg   if (INB(crtcdata) != 'X')
70171d7fec4Smrg      return (0);
70271d7fec4Smrg   return (1);
70371d7fec4Smrg}
70471d7fec4Smrg
70571d7fec4Smrg/* END OF FILE */
706