Home | History | Annotate | Line # | Download | only in pci
tga_conf.c revision 1.5
      1 /* $NetBSD: tga_conf.c,v 1.5 2001/11/13 07:48:49 lukem 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.5 2001/11/13 07:48:49 lukem Exp $");
     32 
     33 #include <sys/param.h>
     34 #include <sys/device.h>
     35 
     36 #include <dev/pci/pcivar.h>
     37 #include <dev/pci/tgareg.h>
     38 #include <dev/pci/tgavar.h>
     39 
     40 #include <dev/ic/bt485var.h>
     41 #include <dev/ic/bt463var.h>
     42 
     43 #undef KB
     44 #define KB		* 1024
     45 #undef MB
     46 #define	MB		* 1024 * 1024
     47 
     48 static const struct tga_conf tga_configs[TGA_TYPE_UNKNOWN] = {
     49 	/* TGA_TYPE_T8_01 */
     50 	{
     51 		"T8-01",
     52 		bt485_funcs,
     53 		8,
     54 		4 MB,
     55 		2 KB,
     56 		1,	{  2 MB,     0 },	{ 1 MB,    0 },
     57 		0,	{     0,     0 },	{    0,    0 },
     58 	},
     59 	/* TGA_TYPE_T8_02 */
     60 	{
     61 		"T8-02",
     62 		bt485_funcs,
     63 		8,
     64 		4 MB,
     65 		4 KB,
     66 		1,	{  2 MB,     0 },	{ 2 MB,    0 },
     67 		0,	{     0,     0 },	{    0,    0 },
     68 	},
     69 	/* TGA_TYPE_T8_22 */
     70 	{
     71 		"T8-22",
     72 		bt485_funcs,
     73 		8,
     74 		8 MB,
     75 		4 KB,
     76 		1,	{  4 MB,     0 },	{ 2 MB,    0 },
     77 		1,	{  6 MB,     0 },	{ 2 MB,    0 },
     78 	},
     79 	/* TGA_TYPE_T8_44 */
     80 	{
     81 		"T8-44",
     82 		bt485_funcs,
     83 		8,
     84 		16 MB,
     85 		4 KB,
     86 		2,	{  8 MB, 12 MB },	{ 2 MB, 2 MB },
     87 		2,	{ 10 MB, 14 MB },	{ 2 MB, 2 MB },
     88 	},
     89 	/* TGA_TYPE_T32_04 */
     90 	{
     91 		"T32-04",
     92 		bt463_funcs,
     93 		32,
     94 		16 MB,
     95 		8 KB,
     96 		1,	{  8 MB,     0 },	{ 4 MB,    0 },
     97 		0,	{     0,     0 },	{    0,    0 },
     98 	},
     99 	/* TGA_TYPE_T32_08 */
    100 	{
    101 		"T32-08",
    102 		bt463_funcs,
    103 		32,
    104 		16 MB,
    105 		16 KB,
    106 		1,	{  8 MB,    0 },	{ 8 MB,    0 },
    107 		0,	{     0,    0 },	{    0,    0 },
    108 	},
    109 	/* TGA_TYPE_T32_88 */
    110 	{
    111 		"T32-88",
    112 		bt463_funcs,
    113 		32,
    114 		32 MB,
    115 		16 KB,
    116 		1,	{ 16 MB,    0 },	{ 8 MB,    0 },
    117 		1,	{ 24 MB,    0 },	{ 8 MB,    0 },
    118 	},
    119 };
    120 
    121 #undef KB
    122 #undef MB
    123 
    124 int
    125 tga_identify(dc)
    126 	struct tga_devconfig *dc;
    127 {
    128 	int type;
    129 	int gder;
    130 	int deep, addrmask, wide;
    131 
    132 	gder = TGARREG(dc, TGA_REG_GDER);
    133 
    134 	deep = (gder & 0x1) != 0; /* XXX */
    135 	addrmask = (gder >> 2) & 0x7; /* XXX */
    136 	wide = (gder & 0x200) == 0; /* XXX */
    137 
    138 
    139 	type = TGA_TYPE_UNKNOWN;
    140 
    141 	if (!deep) {
    142 		/* 8bpp frame buffer */
    143 
    144 		if (addrmask == 0x0) {
    145 			/* 4MB core map; T8-01 or T8-02 */
    146 
    147 			if (!wide)
    148 				type = TGA_TYPE_T8_01;
    149 			else
    150 				type = TGA_TYPE_T8_02;
    151 		} else if (addrmask == 0x1) {
    152 			/* 8MB core map; T8-22 */
    153 
    154 			if (wide)			/* sanity */
    155 				type = TGA_TYPE_T8_22;
    156 		} else if (addrmask == 0x3) {
    157 			/* 16MB core map; T8-44 */
    158 
    159 			if (wide)			/* sanity */
    160 				type = TGA_TYPE_T8_44;
    161 		}
    162 	} else {
    163 		/* 32bpp frame buffer */
    164 
    165 		if (addrmask == 0x3) {
    166 			/* 16MB core map; T32-04 or T32-08 */
    167 
    168 			if (!wide)
    169 				type = TGA_TYPE_T32_04;
    170 			else
    171 				type = TGA_TYPE_T32_08;
    172 		} else if (addrmask == 0x7) {
    173 			/* 32MB core map; T32-88 */
    174 
    175 			if (wide)			/* sanity */
    176 				type = TGA_TYPE_T32_88;
    177 		}
    178 	}
    179 
    180 	return (type);
    181 }
    182 
    183 const struct tga_conf *
    184 tga_getconf(type)
    185 	int type;
    186 {
    187 
    188 	if (type >= 0 && type < TGA_TYPE_UNKNOWN)
    189 		return &tga_configs[type];
    190 
    191 	return (NULL);
    192 }
    193 
    194