Index: alsa-kernel/pci/atiixp_modem.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/atiixp_modem.c,v retrieving revision 1.4 diff -u -b -B -r1.4 atiixp_modem.c --- alsa-kernel/pci/atiixp_modem.c 15 Jul 2004 15:25:22 -0000 1.4 +++ alsa-kernel/pci/atiixp_modem.c 25 Jul 2004 14:39:59 -0000 @@ -246,7 +246,7 @@ int irq; ac97_bus_t *ac97_bus; - ac97_t *ac97[NUM_ATI_CODECS]; + ac97_t *mc97; spinlock_t reg_lock; spinlock_t ac97_lock; @@ -674,7 +674,6 @@ atiixp_t *chip = snd_pcm_substream_chip(substream); atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data; unsigned int reg = 0; - int i; snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL); @@ -684,12 +683,7 @@ spin_lock(&chip->reg_lock); /* hook off/on: via GPIO_OUT */ - for (i = 0; i < NUM_ATI_CODECS; i++) { - if (chip->ac97[i]) { - reg = snd_ac97_read(chip->ac97[i], AC97_GPIO_STATUS); - break; - } - } + reg = snd_ac97_read(chip->mc97, AC97_GPIO_STATUS); if(cmd == SNDRV_PCM_TRIGGER_START) reg |= AC97_GPIO_LINE1_OH; else @@ -805,7 +799,6 @@ atiixp_t *chip = snd_pcm_substream_chip(substream); atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data; int err; - int i; err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); if (err < 0) @@ -820,12 +813,8 @@ return err; /* set up modem rate */ - for (i = 0; i < NUM_ATI_CODECS; i++) { - if (! chip->ac97[i]) - continue; - snd_ac97_write(chip->ac97[i], AC97_LINE1_RATE, params_rate(hw_params)); - snd_ac97_write(chip->ac97[i], AC97_LINE1_LEVEL, 0); - } + snd_ac97_write(chip->mc97, AC97_LINE1_RATE, params_rate(hw_params)); + snd_ac97_write(chip->mc97, AC97_LINE1_LEVEL, 0); return err; } @@ -1065,7 +1054,7 @@ ac97_bus_t *pbus; ac97_template_t ac97; int i, err; - int codec_count; + int codec_num; static ac97_bus_ops_t ops = { .write = snd_atiixp_ac97_write, .read = snd_atiixp_ac97_read, @@ -1084,25 +1073,26 @@ pbus->clock = clock; chip->ac97_bus = pbus; - codec_count = 0; + codec_num = -1; for (i = 0; i < NUM_ATI_CODECS; i++) { if (chip->codec_not_ready_bits & codec_skip[i]) - continue; + break; + codec_num = i; + } + + if(codec_num == -1) { + snd_printk(KERN_ERR "atiixp: no codec available\n"); + return -ENODEV; + } + memset(&ac97, 0, sizeof(ac97)); ac97.private_data = chip; ac97.pci = chip->pci; - ac97.num = i; + ac97.num = codec_num; ac97.scaps = AC97_SCAP_SKIP_AUDIO; - if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) { - chip->ac97[i] = NULL; /* to be sure */ - snd_printdd("atiixp: codec %d not available for modem\n", i); - continue; - } - codec_count++; - } - - if (! codec_count) { - snd_printk(KERN_ERR "atiixp: no codec available\n"); + if ((err = snd_ac97_mixer(pbus, &ac97, &chip->mc97)) < 0) { + chip->mc97 = NULL; /* to be sure */ + snd_printdd("atiixp: codec %d not available for modem\n",codec_num); return -ENODEV; } @@ -1124,9 +1114,8 @@ for (i = 0; i < NUM_ATI_PCMDEVS; i++) if (chip->pcmdevs[i]) snd_pcm_suspend_all(chip->pcmdevs[i]); - for (i = 0; i < NUM_ATI_CODECS; i++) - if (chip->ac97[i]) - snd_ac97_suspend(chip->ac97[i]); + if (chip->mc97) + snd_ac97_suspend(chip->mc97); snd_atiixp_aclink_down(chip); snd_atiixp_chip_stop(chip); @@ -1139,7 +1128,6 @@ static int snd_atiixp_resume(snd_card_t *card, unsigned int state) { atiixp_t *chip = card->pm_private_data; - int i; pci_enable_device(chip->pci); pci_set_power_state(chip->pci, 0); @@ -1147,9 +1135,8 @@ snd_atiixp_aclink_reset(chip); snd_atiixp_chip_start(chip); - for (i = 0; i < NUM_ATI_CODECS; i++) - if (chip->ac97[i]) - snd_ac97_resume(chip->ac97[i]); + if (chip->mc97) + snd_ac97_resume(chip->mc97); snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0;