Lines Matching full:codec

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