Lines Matching full:codec

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