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