Lines Matching refs:codec

141 #define ALI_REG(codec, x) ((codec)->port + x)
180 struct snd_ali *codec;
266 static inline unsigned int snd_ali_5451_peek(struct snd_ali *codec,
269 return (unsigned int)inl(ALI_REG(codec, port));
272 static inline void snd_ali_5451_poke(struct snd_ali *codec,
276 outl((unsigned int)val, ALI_REG(codec, port));
279 static int snd_ali_codec_ready(struct snd_ali *codec,
288 res = snd_ali_5451_peek(codec,port);
296 snd_ali_5451_poke(codec, port, res & ~0x8000);
297 dev_dbg(codec->card->dev, "ali_codec_ready: codec is not ready.\n ");
301 static int snd_ali_stimer_ready(struct snd_ali *codec)
306 dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER);
310 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);
318 dev_err(codec->card->dev, "ali_stimer_read: stimer is not ready.\n");
322 static void snd_ali_codec_poke(struct snd_ali *codec,int secondary,
330 dev_err(codec->card->dev,
335 port = codec->chregs.regs.ac97write;
337 if (snd_ali_codec_ready(codec, port) < 0)
339 if (snd_ali_stimer_ready(codec) < 0)
346 if (codec->revision == ALI_5451_V02)
349 snd_ali_5451_poke(codec, port, dwVal);
354 static unsigned short snd_ali_codec_peek(struct snd_ali *codec,
362 dev_err(codec->card->dev,
367 port = codec->chregs.regs.ac97read;
369 if (snd_ali_codec_ready(codec, port) < 0)
371 if (snd_ali_stimer_ready(codec) < 0)
379 snd_ali_5451_poke(codec, port, dwVal);
381 if (snd_ali_stimer_ready(codec) < 0)
383 if (snd_ali_codec_ready(codec, port) < 0)
386 return (snd_ali_5451_peek(codec, port) & 0xffff0000) >> 16;
393 struct snd_ali *codec = ac97->private_data;
395 dev_dbg(codec->card->dev, "codec_write: reg=%xh data=%xh.\n", reg, val);
398 ALI_REG(codec, ALI_AC97_GPIO));
401 snd_ali_codec_poke(codec, ac97->num, reg, val);
409 struct snd_ali *codec = ac97->private_data;
411 dev_dbg(codec->card->dev, "codec_read reg=%xh.\n", reg);
412 return snd_ali_codec_peek(codec, ac97->num, reg);
419 static int snd_ali_reset_5451(struct snd_ali *codec)
425 pci_dev = codec->pci_m1533;
435 pci_dev = codec->pci;
445 wReg = snd_ali_codec_peek(codec, 0, AC97_POWERDOWN);
451 /* non-fatal if you have a non PM capable codec */
452 /* dev_warn(codec->card->dev, "ali5451: reset time out\n"); */
460 static void snd_ali_enable_special_channel(struct snd_ali *codec,
465 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
467 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
470 static void snd_ali_disable_special_channel(struct snd_ali *codec,
475 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
477 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
480 static void snd_ali_enable_address_interrupt(struct snd_ali *codec)
484 gc = inl(ALI_REG(codec, ALI_GC_CIR));
487 outl( gc, ALI_REG(codec, ALI_GC_CIR));
490 static void snd_ali_disable_address_interrupt(struct snd_ali *codec)
494 gc = inl(ALI_REG(codec, ALI_GC_CIR));
497 outl(gc, ALI_REG(codec, ALI_GC_CIR));
500 static void snd_ali_disable_voice_irq(struct snd_ali *codec,
504 struct snd_ali_channel_control *pchregs = &(codec->chregs);
506 dev_dbg(codec->card->dev, "disable_voice_irq channel=%d\n", channel);
509 pchregs->data.ainten = inl(ALI_REG(codec, pchregs->regs.ainten));
511 outl(pchregs->data.ainten, ALI_REG(codec, pchregs->regs.ainten));
514 static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel)
518 if (codec->synth.chcnt >= ALI_CHANNELS){
519 dev_err(codec->card->dev,
524 if (!(codec->synth.chmap & (1 << idx))) {
525 codec->synth.chmap |= 1 << idx;
526 codec->synth.chcnt++;
527 dev_dbg(codec->card->dev, "alloc_pcm_channel no. %d.\n", idx);
533 static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
538 dev_dbg(codec->card->dev,
543 if (codec->spdif_support &&
544 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
550 result = snd_ali_alloc_pcm_channel(codec, idx);
554 dev_err(codec->card->dev,
561 if (codec->spdif_support &&
562 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
565 result = snd_ali_alloc_pcm_channel(codec, idx);
569 dev_err(codec->card->dev,
574 result = snd_ali_alloc_pcm_channel(codec, idx);
578 dev_err(codec->card->dev, "ali_find_free_channel: no free channels.\n");
582 static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel)
586 dev_dbg(codec->card->dev, "free_channel_pcm channel=%d\n", channel);
591 if (!(codec->synth.chmap & (1 << idx))) {
592 dev_err(codec->card->dev,
597 codec->synth.chmap &= ~(1 << idx);
598 codec->synth.chcnt--;
602 static void snd_ali_stop_voice(struct snd_ali *codec, unsigned int channel)
606 dev_dbg(codec->card->dev, "stop_voice: channel=%d\n", channel);
607 outl(mask, ALI_REG(codec, codec->chregs.regs.stop));
614 static void snd_ali_delay(struct snd_ali *codec,int interval)
618 begintimer = inl(ALI_REG(codec, ALI_STIMER));
619 currenttimer = inl(ALI_REG(codec, ALI_STIMER));
622 if (snd_ali_stimer_ready(codec) < 0)
624 currenttimer = inl(ALI_REG(codec, ALI_STIMER));
629 static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
635 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL + 1));
637 outb(bval, ALI_REG(codec, ALI_SPDIF_CTRL + 1));
641 snd_ali_delay(codec, 6);
642 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL + 1));
647 dev_err(codec->card->dev, "ali_detect_spdif_rate: timeout!\n");
652 snd_ali_delay(codec, 6);
653 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1));
662 dev_err(codec->card->dev, "ali_detect_spdif_rate: timeout!\n");
667 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2));
670 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2));
672 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3)) & 0xf0;
673 outb(bval | 0x02, ALI_REG(codec, ALI_SPDIF_CS + 3));
675 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2));
678 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2));
680 bval = inb(ALI_REG(codec,ALI_SPDIF_CS + 3)) & 0xf0;
681 outb(bval | 0x03, ALI_REG(codec, ALI_SPDIF_CS + 3));
685 static unsigned int snd_ali_get_spdif_in_rate(struct snd_ali *codec)
690 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
693 outb(bval, ALI_REG(codec, ALI_SPDIF_CTRL));
695 snd_ali_detect_spdif_rate(codec);
697 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3));
710 static void snd_ali_enable_spdif_in(struct snd_ali *codec)
714 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
716 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
718 dwVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
720 outb(dwVal, ALI_REG(codec, ALI_SPDIF_CTRL));
722 snd_ali_enable_special_channel(codec, ALI_SPDIF_IN_CHANNEL);
725 static void snd_ali_disable_spdif_in(struct snd_ali *codec)
729 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
731 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
733 snd_ali_disable_special_channel(codec, ALI_SPDIF_IN_CHANNEL);
737 static void snd_ali_set_spdif_out_rate(struct snd_ali *codec, unsigned int rate)
748 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
752 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL));
753 outb(dwRate | 0x20, ALI_REG(codec, ALI_SPDIF_CS + 2));
756 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL));
757 outw(rate | 0x10, ALI_REG(codec, ALI_SPDIF_CS + 2));
760 static void snd_ali_enable_spdif_out(struct snd_ali *codec)
766 pci_dev = codec->pci_m1533;
781 bVal = inb(ALI_REG(codec, ALI_SCTRL));
782 outb(bVal | ALI_SPDIF_OUT_ENABLE, ALI_REG(codec, ALI_SCTRL));
784 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
785 outb(bVal & ALI_SPDIF_OUT_CH_STATUS, ALI_REG(codec, ALI_SPDIF_CTRL));
787 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
789 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
790 snd_ali_disable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
793 static void snd_ali_enable_spdif_chnout(struct snd_ali *codec)
797 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
799 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
801 wVal = inw(ALI_REG(codec, ALI_SPDIF_CS));
806 outw(wVal, ALI_REG(codec, ALI_SPDIF_CS));
808 snd_ali_enable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
811 static void snd_ali_disable_spdif_chnout(struct snd_ali *codec)
815 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
817 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
819 snd_ali_enable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
822 static void snd_ali_disable_spdif_out(struct snd_ali *codec)
826 bVal = inb(ALI_REG(codec, ALI_SCTRL));
827 outb(bVal & ~ALI_SPDIF_OUT_ENABLE, ALI_REG(codec, ALI_SCTRL));
829 snd_ali_disable_spdif_chnout(codec);
832 static void snd_ali_update_ptr(struct snd_ali *codec, int channel)
838 pchregs = &(codec->chregs);
847 pvoice = &codec->synth.voices[channel];
850 spin_lock(&codec->reg_lock);
855 dev_dbg(codec->card->dev,
857 inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2)),
858 (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask);
859 spin_unlock(&codec->reg_lock);
861 spin_lock(&codec->reg_lock);
863 snd_ali_stop_voice(codec, channel);
864 snd_ali_disable_voice_irq(codec, channel);
866 } else if (codec->synth.voices[channel].synth) {
868 } else if (codec->synth.voices[channel].midi) {
872 snd_ali_stop_voice(codec, channel);
873 snd_ali_disable_voice_irq(codec, channel);
875 spin_unlock(&codec->reg_lock);
876 outl(mask,ALI_REG(codec,pchregs->regs.aint));
882 struct snd_ali *codec = dev_id;
887 if (codec == NULL || !codec->hw_initialized)
890 audio_int = inl(ALI_REG(codec, ALI_MISCINT));
894 pchregs = &(codec->chregs);
897 pchregs->data.aint = inl(ALI_REG(codec, pchregs->regs.aint));
899 snd_ali_update_ptr(codec, channel);
902 ALI_REG(codec, ALI_MISCINT));
908 static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec,
914 dev_dbg(codec->card->dev, "alloc_voice: type=%d rec=%d\n", type, rec);
916 spin_lock_irq(&codec->voice_alloc);
918 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) :
919 snd_ali_find_free_channel(codec,rec);
921 dev_err(codec->card->dev, "ali_alloc_voice: err.\n");
922 spin_unlock_irq(&codec->voice_alloc);
925 pvoice = &(codec->synth.voices[idx]);
926 pvoice->codec = codec;
930 spin_unlock_irq(&codec->voice_alloc);
933 spin_unlock_irq(&codec->voice_alloc);
938 static void snd_ali_free_voice(struct snd_ali * codec,
944 dev_dbg(codec->card->dev, "free_voice: channel=%d\n", pvoice->number);
947 snd_ali_clear_voices(codec, pvoice->number, pvoice->number);
948 spin_lock_irq(&codec->voice_alloc);
954 snd_ali_free_channel_pcm(codec, pvoice->number);
957 spin_unlock_irq(&codec->voice_alloc);
963 static void snd_ali_clear_voices(struct snd_ali *codec,
970 snd_ali_stop_voice(codec, i);
971 snd_ali_disable_voice_irq(codec, i);
975 static void snd_ali_write_voice_regs(struct snd_ali *codec,
990 outb((unsigned char)(Channel & 0x001f), ALI_REG(codec, ALI_GC_CIR));
1001 outb(Channel, ALI_REG(codec, ALI_GC_CIR));
1003 outl(ctlcmds[0], ALI_REG(codec, ALI_CSO_ALPHA_FMS));
1004 outl(ctlcmds[1], ALI_REG(codec, ALI_LBA));
1005 outl(ctlcmds[2], ALI_REG(codec, ALI_ESO_DELTA));
1006 outl(ctlcmds[3], ALI_REG(codec, ALI_GVSEL_PAN_VOC_CTRL_EC));
1008 outl(0x30000000, ALI_REG(codec, ALI_EBUF1)); /* Still Mode */
1009 outl(0x30000000, ALI_REG(codec, ALI_EBUF2)); /* Still Mode */
1070 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1092 if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) {
1114 spin_lock(&codec->reg_lock);
1116 outl(what, ALI_REG(codec, ALI_STOP));
1117 val = inl(ALI_REG(codec, ALI_AINTEN));
1122 outl(val, ALI_REG(codec, ALI_AINTEN));
1124 outl(what, ALI_REG(codec, ALI_START));
1125 dev_dbg(codec->card->dev, "trigger: what=%xh whati=%xh\n", what, whati);
1126 spin_unlock(&codec->reg_lock);
1134 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1144 evoice = snd_ali_alloc_voice(codec,
1154 snd_ali_free_voice(codec, evoice);
1164 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1170 snd_ali_free_voice(codec, evoice);
1178 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1192 dev_dbg(codec->card->dev, "playback_prepare ...\n");
1194 spin_lock_irq(&codec->reg_lock);
1201 snd_ali_disable_special_channel(codec, pvoice->number);
1202 else if (codec->spdif_support &&
1203 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
1206 snd_ali_set_spdif_out_rate(codec, runtime->rate);
1219 dev_dbg(codec->card->dev, "playback_prepare: eso=%xh count=%xh\n",
1231 dev_dbg(codec->card->dev, "playback_prepare:\n");
1232 dev_dbg(codec->card->dev,
1235 snd_ali_write_voice_regs(codec,
1251 snd_ali_write_voice_regs(codec,
1264 spin_unlock_irq(&codec->reg_lock);
1271 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1284 spin_lock_irq(&codec->reg_lock);
1286 dev_dbg(codec->card->dev, "ali_prepare...\n");
1288 snd_ali_enable_special_channel(codec,pvoice->number);
1299 spin_unlock_irq(&codec->reg_lock);
1300 if (codec->revision != ALI_5451_V02)
1303 rate = snd_ali_get_spdif_in_rate(codec);
1305 dev_warn(codec->card->dev,
1309 spin_lock_irq(&codec->reg_lock);
1310 bValue = inb(ALI_REG(codec,ALI_SPDIF_CTRL));
1312 outb(bValue,ALI_REG(codec,ALI_SPDIF_CTRL));
1313 dev_warn(codec->card->dev,
1338 snd_ali_write_voice_regs( codec,
1351 spin_unlock_irq(&codec->reg_lock);
1360 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1365 spin_lock(&codec->reg_lock);
1367 spin_unlock(&codec->reg_lock);
1370 outb(pvoice->number, ALI_REG(codec, ALI_GC_CIR));
1371 cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2));
1372 spin_unlock(&codec->reg_lock);
1373 dev_dbg(codec->card->dev, "playback pointer returned cso=%xh.\n", cso);
1382 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1387 spin_lock(&codec->reg_lock);
1389 spin_unlock(&codec->reg_lock);
1392 outb(pvoice->number, ALI_REG(codec, ALI_GC_CIR));
1393 cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2));
1394 spin_unlock(&codec->reg_lock);
1453 snd_ali_free_voice(pvoice->codec, pvoice);
1459 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1463 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec,
1496 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1499 snd_ali_disable_special_channel(codec,pvoice->number);
1617 struct snd_ali *codec = pcm->private_data;
1618 codec->pcm[pcm->device] = NULL;
1622 static int snd_ali_pcm(struct snd_ali *codec, int device,
1628 err = snd_pcm_new(codec->card, desc->name, device,
1631 dev_err(codec->card->dev,
1635 pcm->private_data = codec;
1645 &codec->pci->dev, 64*1024, 128*1024);
1651 codec->pcm[0] = pcm;
1671 static int snd_ali_build_pcms(struct snd_ali *codec)
1674 for (i = 0; i < codec->num_of_codecs && i < ARRAY_SIZE(ali_pcms); i++) {
1675 err = snd_ali_pcm(codec, i, &ali_pcms[i]);
1693 struct snd_ali *codec = kcontrol->private_data;
1698 spin_lock_irq(&codec->reg_lock);
1701 spdif_enable = (codec->spdif_mask & 0x02) ? 1 : 0;
1704 spdif_enable = ((codec->spdif_mask & 0x02) &&
1705 (codec->spdif_mask & 0x04)) ? 1 : 0;
1708 spdif_enable = (codec->spdif_mask & 0x01) ? 1 : 0;
1714 spin_unlock_irq(&codec->reg_lock);
1721 struct snd_ali *codec = kcontrol->private_data;
1726 spin_lock_irq(&codec->reg_lock);
1729 change = (codec->spdif_mask & 0x02) ? 1 : 0;
1733 codec->spdif_mask |= 0x02;
1734 snd_ali_enable_spdif_out(codec);
1736 codec->spdif_mask &= ~(0x02);
1737 codec->spdif_mask &= ~(0x04);
1738 snd_ali_disable_spdif_out(codec);
1743 change = (codec->spdif_mask & 0x04) ? 1 : 0;
1745 if (change && (codec->spdif_mask & 0x02)) {
1747 codec->spdif_mask |= 0x04;
1748 snd_ali_enable_spdif_chnout(codec);
1750 codec->spdif_mask &= ~(0x04);
1751 snd_ali_disable_spdif_chnout(codec);
1756 change = (codec->spdif_mask & 0x01) ? 1 : 0;
1760 codec->spdif_mask |= 0x01;
1761 snd_ali_enable_spdif_in(codec);
1763 codec->spdif_mask &= ~(0x01);
1764 snd_ali_disable_spdif_in(codec);
1771 spin_unlock_irq(&codec->reg_lock);
1786 static int snd_ali_mixer(struct snd_ali *codec)
1796 err = snd_ac97_bus(codec->card, 0, &ops, codec, &codec->ac97_bus);
1801 ac97.private_data = codec;
1803 for (i = 0; i < codec->num_of_codecs; i++) {
1805 err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i]);
1807 dev_err(codec->card->dev,
1811 codec->num_of_codecs = 1;
1816 if (codec->spdif_support) {
1818 err = snd_ctl_add(codec->card,
1819 snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec));
1919 struct snd_ali *codec = card->private_data;
1921 if (codec->hw_initialized)
1922 snd_ali_disable_address_interrupt(codec);
1923 pci_dev_put(codec->pci_m1533);
1924 pci_dev_put(codec->pci_m7101);
1927 static int snd_ali_chip_init(struct snd_ali *codec)
1933 dev_dbg(codec->card->dev, "chip initializing ...\n");
1935 if (snd_ali_reset_5451(codec)) {
1936 dev_err(codec->card->dev, "ali_chip_init: reset 5451 error.\n");
1940 if (codec->revision == ALI_5451_V02) {
1941 pci_dev = codec->pci_m1533;
1946 pci_dev = codec->pci_m7101;
1952 pci_read_config_dword(codec->pci, 0x44, &legacy);
1955 pci_write_config_dword(codec->pci, 0x44, legacy);
1957 outl(0x80000001, ALI_REG(codec, ALI_GLOBAL_CONTROL));
1958 outl(0x00000000, ALI_REG(codec, ALI_AINTEN));
1959 outl(0xffffffff, ALI_REG(codec, ALI_AINT));
1960 outl(0x00000000, ALI_REG(codec, ALI_VOLUME));
1961 outb(0x10, ALI_REG(codec, ALI_MPUR2));
1963 codec->ac97_ext_id = snd_ali_codec_peek(codec, 0, AC97_EXTENDED_ID);
1964 codec->ac97_ext_status = snd_ali_codec_peek(codec, 0,
1966 if (codec->spdif_support) {
1967 snd_ali_enable_spdif_out(codec);
1968 codec->spdif_mask = 0x00000002;
1971 codec->num_of_codecs = 1;
1973 /* secondary codec - modem */
1974 if (inl(ALI_REG(codec, ALI_SCTRL)) & ALI_SCTRL_CODEC2_READY) {
1975 codec->num_of_codecs++;
1976 outl(inl(ALI_REG(codec, ALI_SCTRL)) |
1979 ALI_REG(codec, ALI_SCTRL));
1982 dev_dbg(codec->card->dev, "chip initialize succeed.\n");
1991 struct snd_ali *codec = entry->private_data;
1994 snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i)));
1997 static void snd_ali_proc_init(struct snd_ali *codec)
1999 snd_card_ro_proc_new(codec->card, "ali5451", codec, snd_ali_proc_read);
2002 static int snd_ali_resources(struct snd_ali *codec)
2006 dev_dbg(codec->card->dev, "resources allocation ...\n");
2007 err = pci_request_regions(codec->pci, "ALI 5451");
2010 codec->port = pci_resource_start(codec->pci, 0);
2012 if (devm_request_irq(&codec->pci->dev, codec->pci->irq,
2014 IRQF_SHARED, KBUILD_MODNAME, codec)) {
2015 dev_err(codec->card->dev, "Unable to request irq.\n");
2018 codec->irq = codec->pci->irq;
2019 codec->card->sync_irq = codec->irq;
2020 dev_dbg(codec->card->dev, "resources allocated.\n");
2029 struct snd_ali *codec = card->private_data;
2046 spin_lock_init(&codec->reg_lock);
2047 spin_lock_init(&codec->voice_alloc);
2049 codec->card = card;
2050 codec->pci = pci;
2051 codec->irq = -1;
2052 codec->revision = pci->revision;
2053 codec->spdif_support = spdif_support;
2067 if (snd_ali_resources(codec))
2071 codec->synth.chmap = 0;
2072 codec->synth.chcnt = 0;
2073 codec->spdif_mask = 0;
2074 codec->synth.synthcount = 0;
2076 if (codec->revision == ALI_5451_V02)
2077 codec->chregs.regs.ac97read = ALI_AC97_WRITE;
2079 codec->chregs.regs.ac97read = ALI_AC97_READ;
2080 codec->chregs.regs.ac97write = ALI_AC97_WRITE;
2082 codec->chregs.regs.start = ALI_START;
2083 codec->chregs.regs.stop = ALI_STOP;
2084 codec->chregs.regs.aint = ALI_AINT;
2085 codec->chregs.regs.ainten = ALI_AINTEN;
2087 codec->chregs.data.start = 0x00;
2088 codec->chregs.data.stop = 0x00;
2089 codec->chregs.data.aint = 0x00;
2090 codec->chregs.data.ainten = 0x00;
2093 codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL);
2094 if (!codec->pci_m1533) {
2099 codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL);
2100 if (!codec->pci_m7101 && codec->revision == ALI_5451_V02) {
2107 codec->synth.voices[i].number = i;
2109 err = snd_ali_chip_init(codec);
2116 codec->image = devm_kmalloc(&pci->dev, sizeof(*codec->image),
2118 if (!codec->image)
2122 snd_ali_enable_address_interrupt(codec);
2123 codec->hw_initialized = 1;
2131 struct snd_ali *codec;
2137 sizeof(*codec), &card);
2140 codec = card->private_data;
2147 err = snd_ali_mixer(codec);
2152 err = snd_ali_build_pcms(codec);
2156 snd_ali_proc_init(codec);
2162 card->shortname, codec->port, codec->irq);