Lines Matching refs:codec

142 #define ALI_REG(codec, x) ((codec)->port + x)
181 struct snd_ali *codec;
267 static inline unsigned int snd_ali_5451_peek(struct snd_ali *codec,
270 return (unsigned int)inl(ALI_REG(codec, port));
273 static inline void snd_ali_5451_poke(struct snd_ali *codec,
277 outl((unsigned int)val, ALI_REG(codec, port));
280 static int snd_ali_codec_ready(struct snd_ali *codec,
289 res = snd_ali_5451_peek(codec,port);
297 snd_ali_5451_poke(codec, port, res & ~0x8000);
298 dev_dbg(codec->card->dev, "ali_codec_ready: codec is not ready.\n ");
302 static int snd_ali_stimer_ready(struct snd_ali *codec)
307 dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER);
311 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);
319 dev_err(codec->card->dev, "ali_stimer_read: stimer is not ready.\n");
323 static void snd_ali_codec_poke(struct snd_ali *codec,int secondary,
331 dev_err(codec->card->dev,
336 port = codec->chregs.regs.ac97write;
338 if (snd_ali_codec_ready(codec, port) < 0)
340 if (snd_ali_stimer_ready(codec) < 0)
347 if (codec->revision == ALI_5451_V02)
350 snd_ali_5451_poke(codec, port, dwVal);
355 static unsigned short snd_ali_codec_peek(struct snd_ali *codec,
363 dev_err(codec->card->dev,
368 port = codec->chregs.regs.ac97read;
370 if (snd_ali_codec_ready(codec, port) < 0)
372 if (snd_ali_stimer_ready(codec) < 0)
380 snd_ali_5451_poke(codec, port, dwVal);
382 if (snd_ali_stimer_ready(codec) < 0)
384 if (snd_ali_codec_ready(codec, port) < 0)
387 return (snd_ali_5451_peek(codec, port) & 0xffff0000) >> 16;
394 struct snd_ali *codec = ac97->private_data;
396 dev_dbg(codec->card->dev, "codec_write: reg=%xh data=%xh.\n", reg, val);
399 ALI_REG(codec, ALI_AC97_GPIO));
402 snd_ali_codec_poke(codec, ac97->num, reg, val);
410 struct snd_ali *codec = ac97->private_data;
412 dev_dbg(codec->card->dev, "codec_read reg=%xh.\n", reg);
413 return snd_ali_codec_peek(codec, ac97->num, reg);
420 static int snd_ali_reset_5451(struct snd_ali *codec)
426 pci_dev = codec->pci_m1533;
436 pci_dev = codec->pci;
446 wReg = snd_ali_codec_peek(codec, 0, AC97_POWERDOWN);
452 /* non-fatal if you have a non PM capable codec */
453 /* dev_warn(codec->card->dev, "ali5451: reset time out\n"); */
461 static void snd_ali_enable_special_channel(struct snd_ali *codec,
466 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
468 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
471 static void snd_ali_disable_special_channel(struct snd_ali *codec,
476 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
478 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
481 static void snd_ali_enable_address_interrupt(struct snd_ali *codec)
485 gc = inl(ALI_REG(codec, ALI_GC_CIR));
488 outl( gc, ALI_REG(codec, ALI_GC_CIR));
491 static void snd_ali_disable_address_interrupt(struct snd_ali *codec)
495 gc = inl(ALI_REG(codec, ALI_GC_CIR));
498 outl(gc, ALI_REG(codec, ALI_GC_CIR));
501 static void snd_ali_disable_voice_irq(struct snd_ali *codec,
505 struct snd_ali_channel_control *pchregs = &(codec->chregs);
507 dev_dbg(codec->card->dev, "disable_voice_irq channel=%d\n", channel);
510 pchregs->data.ainten = inl(ALI_REG(codec, pchregs->regs.ainten));
512 outl(pchregs->data.ainten, ALI_REG(codec, pchregs->regs.ainten));
515 static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel)
519 if (codec->synth.chcnt >= ALI_CHANNELS){
520 dev_err(codec->card->dev,
525 if (!(codec->synth.chmap & (1 << idx))) {
526 codec->synth.chmap |= 1 << idx;
527 codec->synth.chcnt++;
528 dev_dbg(codec->card->dev, "alloc_pcm_channel no. %d.\n", idx);
534 static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
539 dev_dbg(codec->card->dev,
544 if (codec->spdif_support &&
545 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
551 result = snd_ali_alloc_pcm_channel(codec, idx);
555 dev_err(codec->card->dev,
562 if (codec->spdif_support &&
563 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
566 result = snd_ali_alloc_pcm_channel(codec, idx);
570 dev_err(codec->card->dev,
575 result = snd_ali_alloc_pcm_channel(codec, idx);
579 dev_err(codec->card->dev, "ali_find_free_channel: no free channels.\n");
583 static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel)
587 dev_dbg(codec->card->dev, "free_channel_pcm channel=%d\n", channel);
592 if (!(codec->synth.chmap & (1 << idx))) {
593 dev_err(codec->card->dev,
598 codec->synth.chmap &= ~(1 << idx);
599 codec->synth.chcnt--;
603 static void snd_ali_stop_voice(struct snd_ali *codec, unsigned int channel)
607 dev_dbg(codec->card->dev, "stop_voice: channel=%d\n", channel);
608 outl(mask, ALI_REG(codec, codec->chregs.regs.stop));
615 static void snd_ali_delay(struct snd_ali *codec,int interval)
619 begintimer = inl(ALI_REG(codec, ALI_STIMER));
620 currenttimer = inl(ALI_REG(codec, ALI_STIMER));
623 if (snd_ali_stimer_ready(codec) < 0)
625 currenttimer = inl(ALI_REG(codec, ALI_STIMER));
630 static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
636 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL + 1));
638 outb(bval, ALI_REG(codec, ALI_SPDIF_CTRL + 1));
642 snd_ali_delay(codec, 6);
643 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL + 1));
648 dev_err(codec->card->dev, "ali_detect_spdif_rate: timeout!\n");
653 snd_ali_delay(codec, 6);
654 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1));
663 dev_err(codec->card->dev, "ali_detect_spdif_rate: timeout!\n");
668 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2));
671 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2));
673 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3)) & 0xf0;
674 outb(bval | 0x02, ALI_REG(codec, ALI_SPDIF_CS + 3));
676 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2));
679 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2));
681 bval = inb(ALI_REG(codec,ALI_SPDIF_CS + 3)) & 0xf0;
682 outb(bval | 0x03, ALI_REG(codec, ALI_SPDIF_CS + 3));
686 static unsigned int snd_ali_get_spdif_in_rate(struct snd_ali *codec)
691 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
694 outb(bval, ALI_REG(codec, ALI_SPDIF_CTRL));
696 snd_ali_detect_spdif_rate(codec);
698 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3));
711 static void snd_ali_enable_spdif_in(struct snd_ali *codec)
715 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
717 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
719 dwVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
721 outb(dwVal, ALI_REG(codec, ALI_SPDIF_CTRL));
723 snd_ali_enable_special_channel(codec, ALI_SPDIF_IN_CHANNEL);
726 static void snd_ali_disable_spdif_in(struct snd_ali *codec)
730 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
732 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
734 snd_ali_disable_special_channel(codec, ALI_SPDIF_IN_CHANNEL);
738 static void snd_ali_set_spdif_out_rate(struct snd_ali *codec, unsigned int rate)
749 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
753 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL));
754 outb(dwRate | 0x20, ALI_REG(codec, ALI_SPDIF_CS + 2));
757 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL));
758 outw(rate | 0x10, ALI_REG(codec, ALI_SPDIF_CS + 2));
761 static void snd_ali_enable_spdif_out(struct snd_ali *codec)
767 pci_dev = codec->pci_m1533;
782 bVal = inb(ALI_REG(codec, ALI_SCTRL));
783 outb(bVal | ALI_SPDIF_OUT_ENABLE, ALI_REG(codec, ALI_SCTRL));
785 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
786 outb(bVal & ALI_SPDIF_OUT_CH_STATUS, ALI_REG(codec, ALI_SPDIF_CTRL));
788 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
790 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
791 snd_ali_disable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
794 static void snd_ali_enable_spdif_chnout(struct snd_ali *codec)
798 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
800 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
802 wVal = inw(ALI_REG(codec, ALI_SPDIF_CS));
807 outw(wVal, ALI_REG(codec, ALI_SPDIF_CS));
809 snd_ali_enable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
812 static void snd_ali_disable_spdif_chnout(struct snd_ali *codec)
816 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
818 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
820 snd_ali_enable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
823 static void snd_ali_disable_spdif_out(struct snd_ali *codec)
827 bVal = inb(ALI_REG(codec, ALI_SCTRL));
828 outb(bVal & ~ALI_SPDIF_OUT_ENABLE, ALI_REG(codec, ALI_SCTRL));
830 snd_ali_disable_spdif_chnout(codec);
833 static void snd_ali_update_ptr(struct snd_ali *codec, int channel)
839 pchregs = &(codec->chregs);
848 pvoice = &codec->synth.voices[channel];
851 spin_lock(&codec->reg_lock);
856 dev_dbg(codec->card->dev,
858 inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2)),
859 (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask);
860 spin_unlock(&codec->reg_lock);
862 spin_lock(&codec->reg_lock);
864 snd_ali_stop_voice(codec, channel);
865 snd_ali_disable_voice_irq(codec, channel);
867 } else if (codec->synth.voices[channel].synth) {
869 } else if (codec->synth.voices[channel].midi) {
873 snd_ali_stop_voice(codec, channel);
874 snd_ali_disable_voice_irq(codec, channel);
876 spin_unlock(&codec->reg_lock);
877 outl(mask,ALI_REG(codec,pchregs->regs.aint));
883 struct snd_ali *codec = dev_id;
888 if (codec == NULL || !codec->hw_initialized)
891 audio_int = inl(ALI_REG(codec, ALI_MISCINT));
895 pchregs = &(codec->chregs);
898 pchregs->data.aint = inl(ALI_REG(codec, pchregs->regs.aint));
900 snd_ali_update_ptr(codec, channel);
903 ALI_REG(codec, ALI_MISCINT));
909 static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec,
915 dev_dbg(codec->card->dev, "alloc_voice: type=%d rec=%d\n", type, rec);
917 spin_lock_irq(&codec->voice_alloc);
919 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) :
920 snd_ali_find_free_channel(codec,rec);
922 dev_err(codec->card->dev, "ali_alloc_voice: err.\n");
923 spin_unlock_irq(&codec->voice_alloc);
926 pvoice = &(codec->synth.voices[idx]);
927 pvoice->codec = codec;
931 spin_unlock_irq(&codec->voice_alloc);
934 spin_unlock_irq(&codec->voice_alloc);
939 static void snd_ali_free_voice(struct snd_ali * codec,
945 dev_dbg(codec->card->dev, "free_voice: channel=%d\n", pvoice->number);
948 snd_ali_clear_voices(codec, pvoice->number, pvoice->number);
949 spin_lock_irq(&codec->voice_alloc);
955 snd_ali_free_channel_pcm(codec, pvoice->number);
958 spin_unlock_irq(&codec->voice_alloc);
964 static void snd_ali_clear_voices(struct snd_ali *codec,
971 snd_ali_stop_voice(codec, i);
972 snd_ali_disable_voice_irq(codec, i);
976 static void snd_ali_write_voice_regs(struct snd_ali *codec,
991 outb((unsigned char)(Channel & 0x001f), ALI_REG(codec, ALI_GC_CIR));
1002 outb(Channel, ALI_REG(codec, ALI_GC_CIR));
1004 outl(ctlcmds[0], ALI_REG(codec, ALI_CSO_ALPHA_FMS));
1005 outl(ctlcmds[1], ALI_REG(codec, ALI_LBA));
1006 outl(ctlcmds[2], ALI_REG(codec, ALI_ESO_DELTA));
1007 outl(ctlcmds[3], ALI_REG(codec, ALI_GVSEL_PAN_VOC_CTRL_EC));
1009 outl(0x30000000, ALI_REG(codec, ALI_EBUF1)); /* Still Mode */
1010 outl(0x30000000, ALI_REG(codec, ALI_EBUF2)); /* Still Mode */
1071 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1093 if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) {
1115 spin_lock(&codec->reg_lock);
1117 outl(what, ALI_REG(codec, ALI_STOP));
1118 val = inl(ALI_REG(codec, ALI_AINTEN));
1123 outl(val, ALI_REG(codec, ALI_AINTEN));
1125 outl(what, ALI_REG(codec, ALI_START));
1126 dev_dbg(codec->card->dev, "trigger: what=%xh whati=%xh\n", what, whati);
1127 spin_unlock(&codec->reg_lock);
1135 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1145 evoice = snd_ali_alloc_voice(codec,
1155 snd_ali_free_voice(codec, evoice);
1165 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1171 snd_ali_free_voice(codec, evoice);
1179 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1193 dev_dbg(codec->card->dev, "playback_prepare ...\n");
1195 spin_lock_irq(&codec->reg_lock);
1202 snd_ali_disable_special_channel(codec, pvoice->number);
1203 else if (codec->spdif_support &&
1204 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
1207 snd_ali_set_spdif_out_rate(codec, runtime->rate);
1220 dev_dbg(codec->card->dev, "playback_prepare: eso=%xh count=%xh\n",
1232 dev_dbg(codec->card->dev, "playback_prepare:\n");
1233 dev_dbg(codec->card->dev,
1236 snd_ali_write_voice_regs(codec,
1252 snd_ali_write_voice_regs(codec,
1265 spin_unlock_irq(&codec->reg_lock);
1272 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1285 spin_lock_irq(&codec->reg_lock);
1287 dev_dbg(codec->card->dev, "ali_prepare...\n");
1289 snd_ali_enable_special_channel(codec,pvoice->number);
1300 spin_unlock_irq(&codec->reg_lock);
1301 if (codec->revision != ALI_5451_V02)
1304 rate = snd_ali_get_spdif_in_rate(codec);
1306 dev_warn(codec->card->dev,
1310 spin_lock_irq(&codec->reg_lock);
1311 bValue = inb(ALI_REG(codec,ALI_SPDIF_CTRL));
1313 outb(bValue,ALI_REG(codec,ALI_SPDIF_CTRL));
1314 dev_warn(codec->card->dev,
1339 snd_ali_write_voice_regs( codec,
1352 spin_unlock_irq(&codec->reg_lock);
1361 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1366 spin_lock(&codec->reg_lock);
1368 spin_unlock(&codec->reg_lock);
1371 outb(pvoice->number, ALI_REG(codec, ALI_GC_CIR));
1372 cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2));
1373 spin_unlock(&codec->reg_lock);
1374 dev_dbg(codec->card->dev, "playback pointer returned cso=%xh.\n", cso);
1383 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1388 spin_lock(&codec->reg_lock);
1390 spin_unlock(&codec->reg_lock);
1393 outb(pvoice->number, ALI_REG(codec, ALI_GC_CIR));
1394 cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2));
1395 spin_unlock(&codec->reg_lock);
1454 snd_ali_free_voice(pvoice->codec, pvoice);
1460 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1464 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec,
1497 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1500 snd_ali_disable_special_channel(codec,pvoice->number);
1618 struct snd_ali *codec = pcm->private_data;
1619 codec->pcm[pcm->device] = NULL;
1623 static int snd_ali_pcm(struct snd_ali *codec, int device,
1629 err = snd_pcm_new(codec->card, desc->name, device,
1632 dev_err(codec->card->dev,
1636 pcm->private_data = codec;
1646 &codec->pci->dev, 64*1024, 128*1024);
1652 codec->pcm[0] = pcm;
1672 static int snd_ali_build_pcms(struct snd_ali *codec)
1675 for (i = 0; i < codec->num_of_codecs && i < ARRAY_SIZE(ali_pcms); i++) {
1676 err = snd_ali_pcm(codec, i, &ali_pcms[i]);
1694 struct snd_ali *codec = kcontrol->private_data;
1699 spin_lock_irq(&codec->reg_lock);
1702 spdif_enable = (codec->spdif_mask & 0x02) ? 1 : 0;
1705 spdif_enable = ((codec->spdif_mask & 0x02) &&
1706 (codec->spdif_mask & 0x04)) ? 1 : 0;
1709 spdif_enable = (codec->spdif_mask & 0x01) ? 1 : 0;
1715 spin_unlock_irq(&codec->reg_lock);
1722 struct snd_ali *codec = kcontrol->private_data;
1727 spin_lock_irq(&codec->reg_lock);
1730 change = (codec->spdif_mask & 0x02) ? 1 : 0;
1734 codec->spdif_mask |= 0x02;
1735 snd_ali_enable_spdif_out(codec);
1737 codec->spdif_mask &= ~(0x02);
1738 codec->spdif_mask &= ~(0x04);
1739 snd_ali_disable_spdif_out(codec);
1744 change = (codec->spdif_mask & 0x04) ? 1 : 0;
1746 if (change && (codec->spdif_mask & 0x02)) {
1748 codec->spdif_mask |= 0x04;
1749 snd_ali_enable_spdif_chnout(codec);
1751 codec->spdif_mask &= ~(0x04);
1752 snd_ali_disable_spdif_chnout(codec);
1757 change = (codec->spdif_mask & 0x01) ? 1 : 0;
1761 codec->spdif_mask |= 0x01;
1762 snd_ali_enable_spdif_in(codec);
1764 codec->spdif_mask &= ~(0x01);
1765 snd_ali_disable_spdif_in(codec);
1772 spin_unlock_irq(&codec->reg_lock);
1787 static int snd_ali_mixer(struct snd_ali *codec)
1797 err = snd_ac97_bus(codec->card, 0, &ops, codec, &codec->ac97_bus);
1802 ac97.private_data = codec;
1804 for (i = 0; i < codec->num_of_codecs; i++) {
1806 err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i]);
1808 dev_err(codec->card->dev,
1812 codec->num_of_codecs = 1;
1817 if (codec->spdif_support) {
1819 err = snd_ctl_add(codec->card,
1820 snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec));
1918 static int snd_ali_free(struct snd_ali * codec)
1920 if (codec->hw_initialized)
1921 snd_ali_disable_address_interrupt(codec);
1922 if (codec->irq >= 0)
1923 free_irq(codec->irq, codec);
1924 if (codec->port)
1925 pci_release_regions(codec->pci);
1926 pci_disable_device(codec->pci);
1928 kfree(codec->image);
1930 pci_dev_put(codec->pci_m1533);
1931 pci_dev_put(codec->pci_m7101);
1932 kfree(codec);
1936 static int snd_ali_chip_init(struct snd_ali *codec)
1942 dev_dbg(codec->card->dev, "chip initializing ...\n");
1944 if (snd_ali_reset_5451(codec)) {
1945 dev_err(codec->card->dev, "ali_chip_init: reset 5451 error.\n");
1949 if (codec->revision == ALI_5451_V02) {
1950 pci_dev = codec->pci_m1533;
1955 pci_dev = codec->pci_m7101;
1961 pci_read_config_dword(codec->pci, 0x44, &legacy);
1964 pci_write_config_dword(codec->pci, 0x44, legacy);
1966 outl(0x80000001, ALI_REG(codec, ALI_GLOBAL_CONTROL));
1967 outl(0x00000000, ALI_REG(codec, ALI_AINTEN));
1968 outl(0xffffffff, ALI_REG(codec, ALI_AINT));
1969 outl(0x00000000, ALI_REG(codec, ALI_VOLUME));
1970 outb(0x10, ALI_REG(codec, ALI_MPUR2));
1972 codec->ac97_ext_id = snd_ali_codec_peek(codec, 0, AC97_EXTENDED_ID);
1973 codec->ac97_ext_status = snd_ali_codec_peek(codec, 0,
1975 if (codec->spdif_support) {
1976 snd_ali_enable_spdif_out(codec);
1977 codec->spdif_mask = 0x00000002;
1980 codec->num_of_codecs = 1;
1982 /* secondary codec - modem */
1983 if (inl(ALI_REG(codec, ALI_SCTRL)) & ALI_SCTRL_CODEC2_READY) {
1984 codec->num_of_codecs++;
1985 outl(inl(ALI_REG(codec, ALI_SCTRL)) |
1988 ALI_REG(codec, ALI_SCTRL));
1991 dev_dbg(codec->card->dev, "chip initialize succeed.\n");
2000 struct snd_ali *codec = entry->private_data;
2003 snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i)));
2006 static void snd_ali_proc_init(struct snd_ali *codec)
2008 snd_card_ro_proc_new(codec->card, "ali5451", codec, snd_ali_proc_read);
2011 static int snd_ali_resources(struct snd_ali *codec)
2015 dev_dbg(codec->card->dev, "resources allocation ...\n");
2016 err = pci_request_regions(codec->pci, "ALI 5451");
2019 codec->port = pci_resource_start(codec->pci, 0);
2021 if (request_irq(codec->pci->irq, snd_ali_card_interrupt,
2022 IRQF_SHARED, KBUILD_MODNAME, codec)) {
2023 dev_err(codec->card->dev, "Unable to request irq.\n");
2026 codec->irq = codec->pci->irq;
2027 codec->card->sync_irq = codec->irq;
2028 dev_dbg(codec->card->dev, "resources allocated.\n");
2033 struct snd_ali *codec = device->device_data;
2034 snd_ali_free(codec);
2044 struct snd_ali *codec;
2068 codec = kzalloc(sizeof(*codec), GFP_KERNEL);
2069 if (!codec) {
2074 spin_lock_init(&codec->reg_lock);
2075 spin_lock_init(&codec->voice_alloc);
2077 codec->card = card;
2078 codec->pci = pci;
2079 codec->irq = -1;
2080 codec->revision = pci->revision;
2081 codec->spdif_support = spdif_support;
2096 if (snd_ali_resources(codec)) {
2097 snd_ali_free(codec);
2101 codec->synth.chmap = 0;
2102 codec->synth.chcnt = 0;
2103 codec->spdif_mask = 0;
2104 codec->synth.synthcount = 0;
2106 if (codec->revision == ALI_5451_V02)
2107 codec->chregs.regs.ac97read = ALI_AC97_WRITE;
2109 codec->chregs.regs.ac97read = ALI_AC97_READ;
2110 codec->chregs.regs.ac97write = ALI_AC97_WRITE;
2112 codec->chregs.regs.start = ALI_START;
2113 codec->chregs.regs.stop = ALI_STOP;
2114 codec->chregs.regs.aint = ALI_AINT;
2115 codec->chregs.regs.ainten = ALI_AINTEN;
2117 codec->chregs.data.start = 0x00;
2118 codec->chregs.data.stop = 0x00;
2119 codec->chregs.data.aint = 0x00;
2120 codec->chregs.data.ainten = 0x00;
2123 codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL);
2124 if (!codec->pci_m1533) {
2126 snd_ali_free(codec);
2130 codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL);
2131 if (!codec->pci_m7101 && codec->revision == ALI_5451_V02) {
2133 snd_ali_free(codec);
2138 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops);
2140 snd_ali_free(codec);
2146 codec->synth.voices[i].number = i;
2148 err = snd_ali_chip_init(codec);
2155 codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL);
2156 if (!codec->image)
2160 snd_ali_enable_address_interrupt(codec);
2161 codec->hw_initialized = 1;
2163 *r_ali = codec;
2172 struct snd_ali *codec;
2181 err = snd_ali_create(card, pci, pcm_channels, spdif, &codec);
2184 card->private_data = codec;
2187 err = snd_ali_mixer(codec);
2192 err = snd_ali_build_pcms(codec);
2196 snd_ali_proc_init(codec);
2202 card->shortname, codec->port, codec->irq);