fail in attach if we seem to have no ac97 codec

This commit is contained in:
Cameron Grant 2000-04-01 22:24:03 +00:00
parent 9bad006e54
commit e620d95952
6 changed files with 14 additions and 8 deletions

View File

@ -635,7 +635,7 @@ au_pci_attach(device_t dev)
codec = ac97_create(dev, au, NULL, au_rdcd, au_wrcd);
if (codec == NULL) goto bad;
mixer_init(d, &ac97_mixer, codec);
if (mixer_init(d, &ac97_mixer, codec) == -1) goto bad;
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,

View File

@ -810,7 +810,8 @@ pcmcsa_attach(device_t dev)
codec = ac97_create(dev, csa, NULL, csa_rdcd, csa_wrcd);
if (codec == NULL)
return (ENXIO);
mixer_init(devinfo, &ac97_mixer, codec);
if (mixer_init(devinfo, &ac97_mixer, codec) == -1)
return (ENXIO);
snprintf(status, SND_STATUSLEN, "at irq %ld", rman_get_start(resp->irq));

View File

@ -776,7 +776,7 @@ es_pci_attach(device_t dev)
/* our init routine does everything for us */
/* set to NULL; flag mixer_init not to run the ac97_init */
/* ac97_mixer.init = NULL; */
mixer_init(d, &ac97_mixer, codec);
if (mixer_init(d, &ac97_mixer, codec) == -1) goto bad;
ct = &es1371_chantemplate;
} else if (pci_get_devid(dev) == ES1370_PCI_ID) {
if (-1 == es1370_init(es)) {

View File

@ -625,7 +625,7 @@ nm_pci_attach(device_t dev)
codec = ac97_create(dev, sc, nm_initcd, nm_rdcd, nm_wrcd);
if (codec == NULL) goto bad;
mixer_init(d, &ac97_mixer, codec);
if (mixer_init(d, &ac97_mixer, codec) == -1) goto bad;
sc->irqid = 0;
sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irqid,

View File

@ -630,7 +630,7 @@ tr_pci_attach(device_t dev)
codec = ac97_create(dev, tr, NULL, tr_rdcd, tr_wrcd);
if (codec == NULL) goto bad;
mixer_init(d, &ac97_mixer, codec);
if (mixer_init(d, &ac97_mixer, codec) == -1) goto bad;
tr->irqid = 0;
tr->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &tr->irqid,

View File

@ -303,7 +303,7 @@ ac97_initmixer(struct ac97_info *codec)
codec->init(codec->devinfo);
wrcd(codec, AC97_REG_POWER, 0);
wrcd(codec, AC97_REG_RESET, 0);
DELAY(10000);
DELAY(100000);
i = rdcd(codec, AC97_REG_RESET);
codec->caps = i & 0x03ff;
@ -311,6 +311,10 @@ ac97_initmixer(struct ac97_info *codec)
id = (rdcd(codec, AC97_REG_ID1) << 16) | rdcd(codec, AC97_REG_ID2);
codec->rev = id & 0x000000ff;
if (id == 0 || id == 0xffffffff) {
device_printf(codec->dev, "ac97 codec invalid or not present (id == %x)\n", id);
return ENODEV;
}
for (i = 0; ac97codecid[i].id; i++)
if (ac97codecid[i].id == id)
@ -333,7 +337,7 @@ ac97_initmixer(struct ac97_info *codec)
wrcd(codec, AC97_MIX_MASTER, 0x00);
if (bootverbose) {
device_printf(codec->dev, "ac97 codec id 0x%8x", id);
device_printf(codec->dev, "ac97 codec id 0x%08x", id);
for (i = 0; ac97codecid[i].id; i++)
if (ac97codecid[i].id == id)
printf(" (%s)", ac97codecid[i].name);
@ -384,7 +388,8 @@ ac97mix_init(snd_mixer *m)
struct ac97_info *codec = mix_getdevinfo(m);
if (codec == NULL)
return -1;
ac97_initmixer(codec);
if (ac97_initmixer(codec))
return -1;
mix_setdevs(m, ac97mixdevs | ((codec->caps & 4)? SOUND_MASK_BASS | SOUND_MASK_TREBLE : 0));
mix_setrecdevs(m, ac97recdevs);
return 0;