#include <sys/param.h>
#include <sys/device.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/tgareg.h>
#include <dev/pci/tgavar.h>
#include <dev/ic/bt485var.h>
#include <dev/ic/bt463var.h>
#include <dev/ic/ibm561var.h>
#undef KB
#define KB * 1024
#undef MB
#define MB * 1024 * 1024
static const struct tga_conf tga_configs[TGA_TYPE_UNKNOWN] = {
{
"T8-01",
bt485_funcs,
8,
4 MB,
2 KB,
1, { 2 MB, 0 }, { 1 MB, 0 },
0, { 0, 0 }, { 0, 0 },
},
{
"T8-02",
bt485_funcs,
8,
4 MB,
4 KB,
1, { 2 MB, 0 }, { 2 MB, 0 },
0, { 0, 0 }, { 0, 0 },
},
{
"T8-22",
bt485_funcs,
8,
8 MB,
4 KB,
1, { 4 MB, 0 }, { 2 MB, 0 },
1, { 6 MB, 0 }, { 2 MB, 0 },
},
{
"T8-44",
bt485_funcs,
8,
16 MB,
4 KB,
2, { 8 MB, 12 MB }, { 2 MB, 2 MB },
2, { 10 MB, 14 MB }, { 2 MB, 2 MB },
},
{
"T32-04",
bt463_funcs,
32,
16 MB,
8 KB,
1, { 8 MB, 0 }, { 4 MB, 0 },
0, { 0, 0 }, { 0, 0 },
},
{
"T32-08",
bt463_funcs,
32,
16 MB,
16 KB,
1, { 8 MB, 0 }, { 8 MB, 0 },
0, { 0, 0 }, { 0, 0 },
},
{
"T32-88",
bt463_funcs,
32,
32 MB,
16 KB,
1, { 16 MB, 0 }, { 8 MB, 0 },
1, { 24 MB, 0 }, { 8 MB, 0 },
},
{
"PS4d20",
ibm561_funcs,
32,
32 MB,
16 KB,
1, { 16 MB, 0 }, { 8 MB, 0 },
1, { 24 MB, 0 }, { 8 MB, 0 },
},
};
#undef KB
#undef MB
int
tga_identify(struct tga_devconfig *dc)
{
int type;
int gder;
int grev;
int deep, addrmask, wide;
int tga2;
gder = TGARREG(dc, TGA_REG_GDER);
grev = TGARREG(dc, TGA_REG_GREV);
deep = (gder & 0x1) != 0;
addrmask = (gder >> 2) & 0x7;
wide = (gder & 0x200) == 0;
tga2 = (grev & 0x20) != 0;
type = TGA_TYPE_UNKNOWN;
if (!deep) {
if (addrmask == 0x0) {
if (!wide)
type = TGA_TYPE_T8_01;
else
type = TGA_TYPE_T8_02;
} else if (addrmask == 0x1) {
if (wide)
type = TGA_TYPE_T8_22;
} else if (addrmask == 0x3) {
if (wide)
type = TGA_TYPE_T8_44;
}
} else {
if (addrmask == 0x00 && tga2 && wide) {
type = TGA_TYPE_POWERSTORM_4D20;
}
if (addrmask == 0x3) {
if (!wide)
type = TGA_TYPE_T32_04;
else
type = TGA_TYPE_T32_08;
} else if (addrmask == 0x7) {
if (wide && !tga2)
type = TGA_TYPE_T32_88;
}
}
return (type);
}
const struct tga_conf *
tga_getconf(int type)
{
if (type >= 0 && type < TGA_TYPE_UNKNOWN)
return &tga_configs[type];
return (NULL);
}