Home | History | Annotate | Line # | Download | only in pci
tga_conf.c revision 1.6
      1 /* $NetBSD: tga_conf.c,v 1.6 2001/12/12 07:50:05 elric Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
      5  * All rights reserved.
      6  *
      7  * Author: Chris G. Demetriou
      8  *
      9  * Permission to use, copy, modify and distribute this software and
     10  * its documentation is hereby granted, provided that both the copyright
     11  * notice and this permission notice appear in all copies of the
     12  * software, derivative works or modified versions, and any portions
     13  * thereof, and that both notices appear in supporting documentation.
     14  *
     15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18  *
     19  * Carnegie Mellon requests users of this software to return to
     20  *
     21  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22  *  School of Computer Science
     23  *  Carnegie Mellon University
     24  *  Pittsburgh PA 15213-3890
     25  *
     26  * any improvements or extensions that they make and grant Carnegie the
     27  * rights to redistribute these changes.
     28  */
     29 
     30 #include <sys/cdefs.h>
     31 __KERNEL_RCSID(0, "$NetBSD: tga_conf.c,v 1.6 2001/12/12 07:50:05 elric Exp $");
     32 
     33 #include <sys/param.h>
     34 #include <sys/systm.h>
     35 #include <sys/device.h>
     36 
     37 #include <dev/pci/pcivar.h>
     38 #include <dev/pci/tgareg.h>
     39 #include <dev/pci/tgavar.h>
     40 
     41 #include <dev/ic/bt485var.h>
     42 #include <dev/ic/bt463var.h>
     43 #include <dev/ic/ibm561var.h>
     44 
     45 #undef KB
     46 #define KB		* 1024
     47 #undef MB
     48 #define	MB		* 1024 * 1024
     49 
     50 static const struct tga_conf tga_configs[TGA_TYPE_UNKNOWN] = {
     51 	/* TGA_TYPE_T8_01 */
     52 	{
     53 		"T8-01",
     54 		bt485_funcs,
     55 		8,
     56 		4 MB,
     57 		2 KB,
     58 		1,	{  2 MB,     0 },	{ 1 MB,    0 },
     59 		0,	{     0,     0 },	{    0,    0 },
     60 	},
     61 	/* TGA_TYPE_T8_02 */
     62 	{
     63 		"T8-02",
     64 		bt485_funcs,
     65 		8,
     66 		4 MB,
     67 		4 KB,
     68 		1,	{  2 MB,     0 },	{ 2 MB,    0 },
     69 		0,	{     0,     0 },	{    0,    0 },
     70 	},
     71 	/* TGA_TYPE_T8_22 */
     72 	{
     73 		"T8-22",
     74 		bt485_funcs,
     75 		8,
     76 		8 MB,
     77 		4 KB,
     78 		1,	{  4 MB,     0 },	{ 2 MB,    0 },
     79 		1,	{  6 MB,     0 },	{ 2 MB,    0 },
     80 	},
     81 	/* TGA_TYPE_T8_44 */
     82 	{
     83 		"T8-44",
     84 		bt485_funcs,
     85 		8,
     86 		16 MB,
     87 		4 KB,
     88 		2,	{  8 MB, 12 MB },	{ 2 MB, 2 MB },
     89 		2,	{ 10 MB, 14 MB },	{ 2 MB, 2 MB },
     90 	},
     91 	/* TGA_TYPE_T32_04 */
     92 	{
     93 		"T32-04",
     94 		bt463_funcs,
     95 		32,
     96 		16 MB,
     97 		8 KB,
     98 		1,	{  8 MB,     0 },	{ 4 MB,    0 },
     99 		0,	{     0,     0 },	{    0,    0 },
    100 	},
    101 	/* TGA_TYPE_T32_08 */
    102 	{
    103 		"T32-08",
    104 		bt463_funcs,
    105 		32,
    106 		16 MB,
    107 		16 KB,
    108 		1,	{  8 MB,    0 },	{ 8 MB,    0 },
    109 		0,	{     0,    0 },	{    0,    0 },
    110 	},
    111 	/* TGA_TYPE_T32_88 */
    112 	{
    113 		"T32-88",
    114 		bt463_funcs,
    115 		32,
    116 		32 MB,
    117 		16 KB,
    118 		1,	{ 16 MB,    0 },	{ 8 MB,    0 },
    119 		1,	{ 24 MB,    0 },	{ 8 MB,    0 },
    120 	},
    121 	/* TGA_TYPE_POWERSTORM_4D20 */
    122 	/* XXX: These numbers may be incorrect */
    123 	{
    124 		"PS4d20",
    125 		ibm561_funcs,
    126 		32,
    127 		32 MB,
    128 		16 KB,
    129 		1,	{ 16 MB,    0 },	{ 8 MB,    0 },
    130 		1,	{ 24 MB,    0 },	{ 8 MB,    0 },
    131 	}
    132 };
    133 
    134 #undef KB
    135 #undef MB
    136 
    137 int
    138 tga_identify(dc)
    139 	struct tga_devconfig *dc;
    140 {
    141 	int type;
    142 	int gder;
    143 	int grev;
    144 	int deep, addrmask, wide;
    145 	int tga2;
    146 
    147 	gder = TGARREG(dc, TGA_REG_GDER);
    148 	grev = TGARREG(dc, TGA_REG_GREV);
    149 
    150 	deep = (gder & 0x1) != 0; /* XXX */
    151 	addrmask = (gder >> 2) & 0x7; /* XXX */
    152 	wide = (gder & 0x200) == 0; /* XXX */
    153 	tga2 = (grev & 0x20) != 0;
    154 
    155 	type = TGA_TYPE_UNKNOWN;
    156 
    157 	if (!deep) {
    158 		/* 8bpp frame buffer */
    159 
    160 		if (addrmask == 0x0) {
    161 			/* 4MB core map; T8-01 or T8-02 */
    162 
    163 			if (!wide)
    164 				type = TGA_TYPE_T8_01;
    165 			else
    166 				type = TGA_TYPE_T8_02;
    167 		} else if (addrmask == 0x1) {
    168 			/* 8MB core map; T8-22 */
    169 
    170 			if (wide)			/* sanity */
    171 				type = TGA_TYPE_T8_22;
    172 		} else if (addrmask == 0x3) {
    173 			/* 16MB core map; T8-44 */
    174 
    175 			if (wide)			/* sanity */
    176 				type = TGA_TYPE_T8_44;
    177 		}
    178 	} else {
    179 		/* 32bpp frame buffer */
    180 		if (addrmask == 0x00 && tga2 && wide) {
    181 			/* My PowerStorm 4d20 shows up this way? */
    182 			type = TGA_TYPE_POWERSTORM_4D20;
    183 		}
    184 
    185 		if (addrmask == 0x3) {
    186 			/* 16MB core map; T32-04 or T32-08 */
    187 
    188 			if (!wide)
    189 				type = TGA_TYPE_T32_04;
    190 			else
    191 				type = TGA_TYPE_T32_08;
    192 		} else if (addrmask == 0x7) {
    193 			/* 32MB core map; T32-88 */
    194 
    195 			if (wide && !tga2)			/* sanity */
    196 				type = TGA_TYPE_T32_88;
    197 		}
    198 	}
    199 
    200 	return (type);
    201 }
    202 
    203 const struct tga_conf *
    204 tga_getconf(type)
    205 	int type;
    206 {
    207 
    208 	if (type >= 0 && type < TGA_TYPE_UNKNOWN)
    209 		return &tga_configs[type];
    210 
    211 	return (NULL);
    212 }
    213