• Home
  • Raw
  • Download

Lines Matching +full:ec +full:- +full:codec

7  *    --
10 * --
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #include <linux/dma-mapping.h>
156 #define ALI_REG(codec, x) ((codec)->port + x) argument
195 struct snd_ali *codec; member
200 int count; /* runtime->period_size */
202 /* --- */
281 static inline unsigned int snd_ali_5451_peek(struct snd_ali *codec, in snd_ali_5451_peek() argument
284 return (unsigned int)inl(ALI_REG(codec, port)); in snd_ali_5451_peek()
287 static inline void snd_ali_5451_poke(struct snd_ali *codec, in snd_ali_5451_poke() argument
291 outl((unsigned int)val, ALI_REG(codec, port)); in snd_ali_5451_poke()
294 static int snd_ali_codec_ready(struct snd_ali *codec, in snd_ali_codec_ready() argument
303 res = snd_ali_5451_peek(codec,port); in snd_ali_codec_ready()
311 snd_ali_5451_poke(codec, port, res & ~0x8000); in snd_ali_codec_ready()
312 dev_dbg(codec->card->dev, "ali_codec_ready: codec is not ready.\n "); in snd_ali_codec_ready()
313 return -EIO; in snd_ali_codec_ready()
316 static int snd_ali_stimer_ready(struct snd_ali *codec) in snd_ali_stimer_ready() argument
321 dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER); in snd_ali_stimer_ready()
325 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); in snd_ali_stimer_ready()
333 dev_err(codec->card->dev, "ali_stimer_read: stimer is not ready.\n"); in snd_ali_stimer_ready()
334 return -EIO; in snd_ali_stimer_ready()
337 static void snd_ali_codec_poke(struct snd_ali *codec,int secondary, in snd_ali_codec_poke() argument
345 dev_err(codec->card->dev, in snd_ali_codec_poke()
350 port = codec->chregs.regs.ac97write; in snd_ali_codec_poke()
352 if (snd_ali_codec_ready(codec, port) < 0) in snd_ali_codec_poke()
354 if (snd_ali_stimer_ready(codec) < 0) in snd_ali_codec_poke()
361 if (codec->revision == ALI_5451_V02) in snd_ali_codec_poke()
364 snd_ali_5451_poke(codec, port, dwVal); in snd_ali_codec_poke()
369 static unsigned short snd_ali_codec_peek(struct snd_ali *codec, in snd_ali_codec_peek() argument
377 dev_err(codec->card->dev, in snd_ali_codec_peek()
382 port = codec->chregs.regs.ac97read; in snd_ali_codec_peek()
384 if (snd_ali_codec_ready(codec, port) < 0) in snd_ali_codec_peek()
386 if (snd_ali_stimer_ready(codec) < 0) in snd_ali_codec_peek()
394 snd_ali_5451_poke(codec, port, dwVal); in snd_ali_codec_peek()
396 if (snd_ali_stimer_ready(codec) < 0) in snd_ali_codec_peek()
398 if (snd_ali_codec_ready(codec, port) < 0) in snd_ali_codec_peek()
401 return (snd_ali_5451_peek(codec, port) & 0xffff0000) >> 16; in snd_ali_codec_peek()
408 struct snd_ali *codec = ac97->private_data; in snd_ali_codec_write() local
410 dev_dbg(codec->card->dev, "codec_write: reg=%xh data=%xh.\n", reg, val); in snd_ali_codec_write()
413 ALI_REG(codec, ALI_AC97_GPIO)); in snd_ali_codec_write()
416 snd_ali_codec_poke(codec, ac97->num, reg, val); in snd_ali_codec_write()
424 struct snd_ali *codec = ac97->private_data; in snd_ali_codec_read() local
426 dev_dbg(codec->card->dev, "codec_read reg=%xh.\n", reg); in snd_ali_codec_read()
427 return snd_ali_codec_peek(codec, ac97->num, reg); in snd_ali_codec_read()
434 static int snd_ali_reset_5451(struct snd_ali *codec) in snd_ali_reset_5451() argument
440 pci_dev = codec->pci_m1533; in snd_ali_reset_5451()
450 pci_dev = codec->pci; in snd_ali_reset_5451()
459 while(wCount--) { in snd_ali_reset_5451()
460 wReg = snd_ali_codec_peek(codec, 0, AC97_POWERDOWN); in snd_ali_reset_5451()
466 /* non-fatal if you have a non PM capable codec */ in snd_ali_reset_5451()
467 /* dev_warn(codec->card->dev, "ali5451: reset time out\n"); */ in snd_ali_reset_5451()
475 static void snd_ali_enable_special_channel(struct snd_ali *codec, in snd_ali_enable_special_channel() argument
480 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_enable_special_channel()
482 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_enable_special_channel()
485 static void snd_ali_disable_special_channel(struct snd_ali *codec, in snd_ali_disable_special_channel() argument
490 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_disable_special_channel()
492 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_disable_special_channel()
495 static void snd_ali_enable_address_interrupt(struct snd_ali *codec) in snd_ali_enable_address_interrupt() argument
499 gc = inl(ALI_REG(codec, ALI_GC_CIR)); in snd_ali_enable_address_interrupt()
502 outl( gc, ALI_REG(codec, ALI_GC_CIR)); in snd_ali_enable_address_interrupt()
505 static void snd_ali_disable_address_interrupt(struct snd_ali *codec) in snd_ali_disable_address_interrupt() argument
509 gc = inl(ALI_REG(codec, ALI_GC_CIR)); in snd_ali_disable_address_interrupt()
512 outl(gc, ALI_REG(codec, ALI_GC_CIR)); in snd_ali_disable_address_interrupt()
515 static void snd_ali_disable_voice_irq(struct snd_ali *codec, in snd_ali_disable_voice_irq() argument
519 struct snd_ali_channel_control *pchregs = &(codec->chregs); in snd_ali_disable_voice_irq()
521 dev_dbg(codec->card->dev, "disable_voice_irq channel=%d\n", channel); in snd_ali_disable_voice_irq()
524 pchregs->data.ainten = inl(ALI_REG(codec, pchregs->regs.ainten)); in snd_ali_disable_voice_irq()
525 pchregs->data.ainten &= ~mask; in snd_ali_disable_voice_irq()
526 outl(pchregs->data.ainten, ALI_REG(codec, pchregs->regs.ainten)); in snd_ali_disable_voice_irq()
529 static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel) in snd_ali_alloc_pcm_channel() argument
533 if (codec->synth.chcnt >= ALI_CHANNELS){ in snd_ali_alloc_pcm_channel()
534 dev_err(codec->card->dev, in snd_ali_alloc_pcm_channel()
536 return -1; in snd_ali_alloc_pcm_channel()
539 if (!(codec->synth.chmap & (1 << idx))) { in snd_ali_alloc_pcm_channel()
540 codec->synth.chmap |= 1 << idx; in snd_ali_alloc_pcm_channel()
541 codec->synth.chcnt++; in snd_ali_alloc_pcm_channel()
542 dev_dbg(codec->card->dev, "alloc_pcm_channel no. %d.\n", idx); in snd_ali_alloc_pcm_channel()
545 return -1; in snd_ali_alloc_pcm_channel()
548 static int snd_ali_find_free_channel(struct snd_ali * codec, int rec) in snd_ali_find_free_channel() argument
551 int result = -1; in snd_ali_find_free_channel()
553 dev_dbg(codec->card->dev, in snd_ali_find_free_channel()
558 if (codec->spdif_support && in snd_ali_find_free_channel()
559 (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()
571 return -1; in snd_ali_find_free_channel()
576 if (codec->spdif_support && in snd_ali_find_free_channel()
577 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) & in snd_ali_find_free_channel()
580 result = snd_ali_alloc_pcm_channel(codec, idx); in snd_ali_find_free_channel()
584 dev_err(codec->card->dev, in snd_ali_find_free_channel()
589 result = snd_ali_alloc_pcm_channel(codec, idx); in snd_ali_find_free_channel()
593 dev_err(codec->card->dev, "ali_find_free_channel: no free channels.\n"); in snd_ali_find_free_channel()
594 return -1; in snd_ali_find_free_channel()
597 static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel) in snd_ali_free_channel_pcm() argument
601 dev_dbg(codec->card->dev, "free_channel_pcm channel=%d\n", channel); in snd_ali_free_channel_pcm()
606 if (!(codec->synth.chmap & (1 << idx))) { in snd_ali_free_channel_pcm()
607 dev_err(codec->card->dev, in snd_ali_free_channel_pcm()
612 codec->synth.chmap &= ~(1 << idx); in snd_ali_free_channel_pcm()
613 codec->synth.chcnt--; in snd_ali_free_channel_pcm()
617 static void snd_ali_stop_voice(struct snd_ali *codec, unsigned int channel) in snd_ali_stop_voice() argument
621 dev_dbg(codec->card->dev, "stop_voice: channel=%d\n", channel); in snd_ali_stop_voice()
622 outl(mask, ALI_REG(codec, codec->chregs.regs.stop)); in snd_ali_stop_voice()
629 static void snd_ali_delay(struct snd_ali *codec,int interval) in snd_ali_delay() argument
633 begintimer = inl(ALI_REG(codec, ALI_STIMER)); in snd_ali_delay()
634 currenttimer = inl(ALI_REG(codec, ALI_STIMER)); in snd_ali_delay()
637 if (snd_ali_stimer_ready(codec) < 0) in snd_ali_delay()
639 currenttimer = inl(ALI_REG(codec, ALI_STIMER)); in snd_ali_delay()
644 static void snd_ali_detect_spdif_rate(struct snd_ali *codec) in snd_ali_detect_spdif_rate() argument
650 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL + 1)); in snd_ali_detect_spdif_rate()
652 outb(bval, ALI_REG(codec, ALI_SPDIF_CTRL + 1)); in snd_ali_detect_spdif_rate()
656 snd_ali_delay(codec, 6); in snd_ali_detect_spdif_rate()
657 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 snd_ali_delay(codec, 6); in snd_ali_detect_spdif_rate()
668 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1)); in snd_ali_detect_spdif_rate()
677 dev_err(codec->card->dev, "ali_detect_spdif_rate: timeout!\n"); in snd_ali_detect_spdif_rate()
682 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2)); in snd_ali_detect_spdif_rate()
685 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2)); in snd_ali_detect_spdif_rate()
687 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3)) & 0xf0; in snd_ali_detect_spdif_rate()
688 outb(bval | 0x02, ALI_REG(codec, ALI_SPDIF_CS + 3)); in snd_ali_detect_spdif_rate()
690 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2)); in snd_ali_detect_spdif_rate()
693 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2)); in snd_ali_detect_spdif_rate()
695 bval = inb(ALI_REG(codec,ALI_SPDIF_CS + 3)) & 0xf0; in snd_ali_detect_spdif_rate()
696 outb(bval | 0x03, ALI_REG(codec, ALI_SPDIF_CS + 3)); in snd_ali_detect_spdif_rate()
700 static unsigned int snd_ali_get_spdif_in_rate(struct snd_ali *codec) in snd_ali_get_spdif_in_rate() argument
705 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL)); in snd_ali_get_spdif_in_rate()
708 outb(bval, ALI_REG(codec, ALI_SPDIF_CTRL)); in snd_ali_get_spdif_in_rate()
710 snd_ali_detect_spdif_rate(codec); in snd_ali_get_spdif_in_rate()
712 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3)); in snd_ali_get_spdif_in_rate()
725 static void snd_ali_enable_spdif_in(struct snd_ali *codec) in snd_ali_enable_spdif_in() argument
729 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_enable_spdif_in()
731 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_enable_spdif_in()
733 dwVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL)); in snd_ali_enable_spdif_in()
735 outb(dwVal, ALI_REG(codec, ALI_SPDIF_CTRL)); in snd_ali_enable_spdif_in()
737 snd_ali_enable_special_channel(codec, ALI_SPDIF_IN_CHANNEL); in snd_ali_enable_spdif_in()
740 static void snd_ali_disable_spdif_in(struct snd_ali *codec) in snd_ali_disable_spdif_in() argument
744 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_disable_spdif_in()
746 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_disable_spdif_in()
748 snd_ali_disable_special_channel(codec, ALI_SPDIF_IN_CHANNEL); in snd_ali_disable_spdif_in()
752 static void snd_ali_set_spdif_out_rate(struct snd_ali *codec, unsigned int rate) in snd_ali_set_spdif_out_rate() argument
763 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL)); in snd_ali_set_spdif_out_rate()
767 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL)); in snd_ali_set_spdif_out_rate()
768 outb(dwRate | 0x20, ALI_REG(codec, ALI_SPDIF_CS + 2)); in snd_ali_set_spdif_out_rate()
771 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL)); in snd_ali_set_spdif_out_rate()
772 outw(rate | 0x10, ALI_REG(codec, ALI_SPDIF_CS + 2)); in snd_ali_set_spdif_out_rate()
775 static void snd_ali_enable_spdif_out(struct snd_ali *codec) in snd_ali_enable_spdif_out() argument
781 pci_dev = codec->pci_m1533; in snd_ali_enable_spdif_out()
796 bVal = inb(ALI_REG(codec, ALI_SCTRL)); in snd_ali_enable_spdif_out()
797 outb(bVal | ALI_SPDIF_OUT_ENABLE, ALI_REG(codec, ALI_SCTRL)); in snd_ali_enable_spdif_out()
799 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL)); in snd_ali_enable_spdif_out()
800 outb(bVal & ALI_SPDIF_OUT_CH_STATUS, ALI_REG(codec, ALI_SPDIF_CTRL)); in snd_ali_enable_spdif_out()
802 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_enable_spdif_out()
804 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_enable_spdif_out()
805 snd_ali_disable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL); in snd_ali_enable_spdif_out()
808 static void snd_ali_enable_spdif_chnout(struct snd_ali *codec) in snd_ali_enable_spdif_chnout() argument
812 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_enable_spdif_chnout()
814 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_enable_spdif_chnout()
816 wVal = inw(ALI_REG(codec, ALI_SPDIF_CS)); in snd_ali_enable_spdif_chnout()
821 outw(wVal, ALI_REG(codec, ALI_SPDIF_CS)); in snd_ali_enable_spdif_chnout()
823 snd_ali_enable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL); in snd_ali_enable_spdif_chnout()
826 static void snd_ali_disable_spdif_chnout(struct snd_ali *codec) in snd_ali_disable_spdif_chnout() argument
830 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_disable_spdif_chnout()
832 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_disable_spdif_chnout()
834 snd_ali_enable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL); in snd_ali_disable_spdif_chnout()
837 static void snd_ali_disable_spdif_out(struct snd_ali *codec) in snd_ali_disable_spdif_out() argument
841 bVal = inb(ALI_REG(codec, ALI_SCTRL)); in snd_ali_disable_spdif_out()
842 outb(bVal & ~ALI_SPDIF_OUT_ENABLE, ALI_REG(codec, ALI_SCTRL)); in snd_ali_disable_spdif_out()
844 snd_ali_disable_spdif_chnout(codec); in snd_ali_disable_spdif_out()
847 static void snd_ali_update_ptr(struct snd_ali *codec, int channel) in snd_ali_update_ptr() argument
853 pchregs = &(codec->chregs); in snd_ali_update_ptr()
856 old = pchregs->data.aint; in snd_ali_update_ptr()
862 pvoice = &codec->synth.voices[channel]; in snd_ali_update_ptr()
865 spin_lock(&codec->reg_lock); in snd_ali_update_ptr()
867 if (pvoice->pcm && pvoice->substream) { in snd_ali_update_ptr()
869 if (pvoice->running) { in snd_ali_update_ptr()
870 dev_dbg(codec->card->dev, in snd_ali_update_ptr()
872 inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2)), in snd_ali_update_ptr()
873 (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask); in snd_ali_update_ptr()
874 spin_unlock(&codec->reg_lock); in snd_ali_update_ptr()
875 snd_pcm_period_elapsed(pvoice->substream); in snd_ali_update_ptr()
876 spin_lock(&codec->reg_lock); in snd_ali_update_ptr()
878 snd_ali_stop_voice(codec, channel); in snd_ali_update_ptr()
879 snd_ali_disable_voice_irq(codec, channel); in snd_ali_update_ptr()
881 } else if (codec->synth.voices[channel].synth) { in snd_ali_update_ptr()
883 } else if (codec->synth.voices[channel].midi) { in snd_ali_update_ptr()
887 snd_ali_stop_voice(codec, channel); in snd_ali_update_ptr()
888 snd_ali_disable_voice_irq(codec, channel); in snd_ali_update_ptr()
890 spin_unlock(&codec->reg_lock); in snd_ali_update_ptr()
891 outl(mask,ALI_REG(codec,pchregs->regs.aint)); in snd_ali_update_ptr()
892 pchregs->data.aint = old & (~mask); in snd_ali_update_ptr()
897 struct snd_ali *codec = dev_id; in snd_ali_card_interrupt() local
902 if (codec == NULL || !codec->hw_initialized) in snd_ali_card_interrupt()
905 audio_int = inl(ALI_REG(codec, ALI_MISCINT)); in snd_ali_card_interrupt()
909 pchregs = &(codec->chregs); in snd_ali_card_interrupt()
912 pchregs->data.aint = inl(ALI_REG(codec, pchregs->regs.aint)); in snd_ali_card_interrupt()
914 snd_ali_update_ptr(codec, channel); in snd_ali_card_interrupt()
917 ALI_REG(codec, ALI_MISCINT)); in snd_ali_card_interrupt()
923 static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec, in snd_ali_alloc_voice() argument
929 dev_dbg(codec->card->dev, "alloc_voice: type=%d rec=%d\n", type, rec); in snd_ali_alloc_voice()
931 spin_lock_irq(&codec->voice_alloc); in snd_ali_alloc_voice()
933 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) : in snd_ali_alloc_voice()
934 snd_ali_find_free_channel(codec,rec); in snd_ali_alloc_voice()
936 dev_err(codec->card->dev, "ali_alloc_voice: err.\n"); in snd_ali_alloc_voice()
937 spin_unlock_irq(&codec->voice_alloc); in snd_ali_alloc_voice()
940 pvoice = &(codec->synth.voices[idx]); in snd_ali_alloc_voice()
941 pvoice->codec = codec; in snd_ali_alloc_voice()
942 pvoice->use = 1; in snd_ali_alloc_voice()
943 pvoice->pcm = 1; in snd_ali_alloc_voice()
944 pvoice->mode = rec; in snd_ali_alloc_voice()
945 spin_unlock_irq(&codec->voice_alloc); in snd_ali_alloc_voice()
948 spin_unlock_irq(&codec->voice_alloc); in snd_ali_alloc_voice()
953 static void snd_ali_free_voice(struct snd_ali * codec, in snd_ali_free_voice() argument
959 dev_dbg(codec->card->dev, "free_voice: channel=%d\n", pvoice->number); in snd_ali_free_voice()
960 if (!pvoice->use) in snd_ali_free_voice()
962 snd_ali_clear_voices(codec, pvoice->number, pvoice->number); in snd_ali_free_voice()
963 spin_lock_irq(&codec->voice_alloc); in snd_ali_free_voice()
964 private_free = pvoice->private_free; in snd_ali_free_voice()
965 private_data = pvoice->private_data; in snd_ali_free_voice()
966 pvoice->private_free = NULL; in snd_ali_free_voice()
967 pvoice->private_data = NULL; in snd_ali_free_voice()
968 if (pvoice->pcm) in snd_ali_free_voice()
969 snd_ali_free_channel_pcm(codec, pvoice->number); in snd_ali_free_voice()
970 pvoice->use = pvoice->pcm = pvoice->synth = 0; in snd_ali_free_voice()
971 pvoice->substream = NULL; in snd_ali_free_voice()
972 spin_unlock_irq(&codec->voice_alloc); in snd_ali_free_voice()
978 static void snd_ali_clear_voices(struct snd_ali *codec, in snd_ali_clear_voices() argument
985 snd_ali_stop_voice(codec, i); in snd_ali_clear_voices()
986 snd_ali_disable_voice_irq(codec, i); in snd_ali_clear_voices()
990 static void snd_ali_write_voice_regs(struct snd_ali *codec, in snd_ali_write_voice_regs() argument
1001 unsigned int EC) in snd_ali_write_voice_regs() argument
1005 outb((unsigned char)(Channel & 0x001f), ALI_REG(codec, ALI_GC_CIR)); in snd_ali_write_voice_regs()
1014 (EC & 0x00000fff); in snd_ali_write_voice_regs()
1016 outb(Channel, ALI_REG(codec, ALI_GC_CIR)); in snd_ali_write_voice_regs()
1018 outl(ctlcmds[0], ALI_REG(codec, ALI_CSO_ALPHA_FMS)); in snd_ali_write_voice_regs()
1019 outl(ctlcmds[1], ALI_REG(codec, ALI_LBA)); in snd_ali_write_voice_regs()
1020 outl(ctlcmds[2], ALI_REG(codec, ALI_ESO_DELTA)); in snd_ali_write_voice_regs()
1021 outl(ctlcmds[3], ALI_REG(codec, ALI_GVSEL_PAN_VOC_CTRL_EC)); in snd_ali_write_voice_regs()
1023 outl(0x30000000, ALI_REG(codec, ALI_EBUF1)); /* Still Mode */ in snd_ali_write_voice_regs()
1024 outl(0x30000000, ALI_REG(codec, ALI_EBUF2)); /* Still Mode */ in snd_ali_write_voice_regs()
1062 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ali_control_mode()
1065 CTRL default: 8-bit (unsigned) mono, loop mode enabled in snd_ali_control_mode()
1068 if (snd_pcm_format_width(runtime->format) == 16) in snd_ali_control_mode()
1069 CTRL |= 0x00000008; /* 16-bit data */ in snd_ali_control_mode()
1070 if (!snd_pcm_format_unsigned(runtime->format)) in snd_ali_control_mode()
1072 if (runtime->channels > 1) in snd_ali_control_mode()
1085 struct snd_ali *codec = snd_pcm_substream_chip(substream); in snd_ali_trigger() local
1102 return -EINVAL; in snd_ali_trigger()
1107 if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) { in snd_ali_trigger()
1108 pvoice = s->runtime->private_data; in snd_ali_trigger()
1109 evoice = pvoice->extra; in snd_ali_trigger()
1110 what |= 1 << (pvoice->number & 0x1f); in snd_ali_trigger()
1112 whati |= 1 << (pvoice->number & 0x1f); in snd_ali_trigger()
1114 whati |= 1 << (evoice->number & 0x1f); in snd_ali_trigger()
1115 what |= 1 << (evoice->number & 0x1f); in snd_ali_trigger()
1118 pvoice->running = 1; in snd_ali_trigger()
1120 evoice->running = 1; in snd_ali_trigger()
1122 pvoice->running = 0; in snd_ali_trigger()
1124 evoice->running = 0; in snd_ali_trigger()
1127 if (pvoice->mode) in snd_ali_trigger()
1131 spin_lock(&codec->reg_lock); in snd_ali_trigger()
1133 outl(what, ALI_REG(codec, ALI_STOP)); in snd_ali_trigger()
1134 val = inl(ALI_REG(codec, ALI_AINTEN)); in snd_ali_trigger()
1139 outl(val, ALI_REG(codec, ALI_AINTEN)); in snd_ali_trigger()
1141 outl(what, ALI_REG(codec, ALI_START)); in snd_ali_trigger()
1142 dev_dbg(codec->card->dev, "trigger: what=%xh whati=%xh\n", what, whati); in snd_ali_trigger()
1143 spin_unlock(&codec->reg_lock); in snd_ali_trigger()
1151 struct snd_ali *codec = snd_pcm_substream_chip(substream); in snd_ali_playback_hw_params() local
1152 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ali_playback_hw_params()
1153 struct snd_ali_voice *pvoice = runtime->private_data; in snd_ali_playback_hw_params()
1154 struct snd_ali_voice *evoice = pvoice->extra; in snd_ali_playback_hw_params()
1167 evoice = snd_ali_alloc_voice(codec, in snd_ali_playback_hw_params()
1169 0, -1); in snd_ali_playback_hw_params()
1171 return -ENOMEM; in snd_ali_playback_hw_params()
1172 pvoice->extra = evoice; in snd_ali_playback_hw_params()
1173 evoice->substream = substream; in snd_ali_playback_hw_params()
1177 snd_ali_free_voice(codec, evoice); in snd_ali_playback_hw_params()
1178 pvoice->extra = evoice = NULL; in snd_ali_playback_hw_params()
1187 struct snd_ali *codec = snd_pcm_substream_chip(substream); in snd_ali_playback_hw_free() local
1188 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ali_playback_hw_free()
1189 struct snd_ali_voice *pvoice = runtime->private_data; in snd_ali_playback_hw_free()
1190 struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL; in snd_ali_playback_hw_free()
1194 snd_ali_free_voice(codec, evoice); in snd_ali_playback_hw_free()
1195 pvoice->extra = NULL; in snd_ali_playback_hw_free()
1214 struct snd_ali *codec = snd_pcm_substream_chip(substream); in snd_ali_playback_prepare() local
1215 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ali_playback_prepare()
1216 struct snd_ali_voice *pvoice = runtime->private_data; in snd_ali_playback_prepare()
1217 struct snd_ali_voice *evoice = pvoice->extra; in snd_ali_playback_prepare()
1226 unsigned int EC; in snd_ali_playback_prepare() local
1228 dev_dbg(codec->card->dev, "playback_prepare ...\n"); in snd_ali_playback_prepare()
1230 spin_lock_irq(&codec->reg_lock); in snd_ali_playback_prepare()
1233 Delta = snd_ali_convert_rate(runtime->rate, 0); in snd_ali_playback_prepare()
1235 if (pvoice->number == ALI_SPDIF_IN_CHANNEL || in snd_ali_playback_prepare()
1236 pvoice->number == ALI_PCM_IN_CHANNEL) in snd_ali_playback_prepare()
1237 snd_ali_disable_special_channel(codec, pvoice->number); in snd_ali_playback_prepare()
1238 else if (codec->spdif_support && in snd_ali_playback_prepare()
1239 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) & in snd_ali_playback_prepare()
1241 && pvoice->number == ALI_SPDIF_OUT_CHANNEL) { in snd_ali_playback_prepare()
1242 snd_ali_set_spdif_out_rate(codec, runtime->rate); in snd_ali_playback_prepare()
1247 LBA = runtime->dma_addr; in snd_ali_playback_prepare()
1250 pvoice->count = runtime->period_size; in snd_ali_playback_prepare()
1253 pvoice->eso = runtime->buffer_size; in snd_ali_playback_prepare()
1255 dev_dbg(codec->card->dev, "playback_prepare: eso=%xh count=%xh\n", in snd_ali_playback_prepare()
1256 pvoice->eso, pvoice->count); in snd_ali_playback_prepare()
1259 ESO = pvoice->eso -1; in snd_ali_playback_prepare()
1266 EC = 0; in snd_ali_playback_prepare()
1267 dev_dbg(codec->card->dev, "playback_prepare:\n"); in snd_ali_playback_prepare()
1268 dev_dbg(codec->card->dev, in snd_ali_playback_prepare()
1270 pvoice->number,runtime->rate,Delta,GVSEL,PAN,CTRL); in snd_ali_playback_prepare()
1271 snd_ali_write_voice_regs(codec, in snd_ali_playback_prepare()
1272 pvoice->number, in snd_ali_playback_prepare()
1282 EC); in snd_ali_playback_prepare()
1284 evoice->count = pvoice->count; in snd_ali_playback_prepare()
1285 evoice->eso = pvoice->count << 1; in snd_ali_playback_prepare()
1286 ESO = evoice->eso - 1; in snd_ali_playback_prepare()
1287 snd_ali_write_voice_regs(codec, in snd_ali_playback_prepare()
1288 evoice->number, in snd_ali_playback_prepare()
1298 EC); in snd_ali_playback_prepare()
1300 spin_unlock_irq(&codec->reg_lock); in snd_ali_playback_prepare()
1307 struct snd_ali *codec = snd_pcm_substream_chip(substream); in snd_ali_prepare() local
1308 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ali_prepare()
1309 struct snd_ali_voice *pvoice = runtime->private_data; in snd_ali_prepare()
1317 unsigned int EC; in snd_ali_prepare() local
1320 spin_lock_irq(&codec->reg_lock); in snd_ali_prepare()
1322 dev_dbg(codec->card->dev, "ali_prepare...\n"); in snd_ali_prepare()
1324 snd_ali_enable_special_channel(codec,pvoice->number); in snd_ali_prepare()
1326 Delta = (pvoice->number == ALI_MODEM_IN_CHANNEL || in snd_ali_prepare()
1327 pvoice->number == ALI_MODEM_OUT_CHANNEL) ? in snd_ali_prepare()
1328 0x1000 : snd_ali_convert_rate(runtime->rate, pvoice->mode); in snd_ali_prepare()
1331 if (pvoice->number == ALI_SPDIF_IN_CHANNEL) { in snd_ali_prepare()
1335 spin_unlock_irq(&codec->reg_lock); in snd_ali_prepare()
1336 if (codec->revision != ALI_5451_V02) in snd_ali_prepare()
1337 return -1; in snd_ali_prepare()
1339 rate = snd_ali_get_spdif_in_rate(codec); in snd_ali_prepare()
1341 dev_warn(codec->card->dev, in snd_ali_prepare()
1345 spin_lock_irq(&codec->reg_lock); in snd_ali_prepare()
1346 bValue = inb(ALI_REG(codec,ALI_SPDIF_CTRL)); in snd_ali_prepare()
1348 outb(bValue,ALI_REG(codec,ALI_SPDIF_CTRL)); in snd_ali_prepare()
1349 dev_warn(codec->card->dev, in snd_ali_prepare()
1354 Delta = ((rate << 12) / runtime->rate) & 0x00ffff; in snd_ali_prepare()
1358 pvoice->eso = runtime->buffer_size; in snd_ali_prepare()
1361 pvoice->count = runtime->period_size; in snd_ali_prepare()
1364 LBA = runtime->dma_addr; in snd_ali_prepare()
1367 ESO = pvoice->eso - 1; in snd_ali_prepare()
1372 EC = 0; in snd_ali_prepare()
1374 snd_ali_write_voice_regs( codec, in snd_ali_prepare()
1375 pvoice->number, in snd_ali_prepare()
1385 EC); in snd_ali_prepare()
1387 spin_unlock_irq(&codec->reg_lock); in snd_ali_prepare()
1396 struct snd_ali *codec = snd_pcm_substream_chip(substream); in snd_ali_playback_pointer() local
1397 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ali_playback_pointer()
1398 struct snd_ali_voice *pvoice = runtime->private_data; in snd_ali_playback_pointer()
1401 spin_lock(&codec->reg_lock); in snd_ali_playback_pointer()
1402 if (!pvoice->running) { in snd_ali_playback_pointer()
1403 spin_unlock(&codec->reg_lock); in snd_ali_playback_pointer()
1406 outb(pvoice->number, ALI_REG(codec, ALI_GC_CIR)); in snd_ali_playback_pointer()
1407 cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2)); in snd_ali_playback_pointer()
1408 spin_unlock(&codec->reg_lock); in snd_ali_playback_pointer()
1409 dev_dbg(codec->card->dev, "playback pointer returned cso=%xh.\n", cso); in snd_ali_playback_pointer()
1411 cso %= runtime->buffer_size; in snd_ali_playback_pointer()
1418 struct snd_ali *codec = snd_pcm_substream_chip(substream); in snd_ali_pointer() local
1419 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ali_pointer()
1420 struct snd_ali_voice *pvoice = runtime->private_data; in snd_ali_pointer()
1423 spin_lock(&codec->reg_lock); in snd_ali_pointer()
1424 if (!pvoice->running) { in snd_ali_pointer()
1425 spin_unlock(&codec->reg_lock); in snd_ali_pointer()
1428 outb(pvoice->number, ALI_REG(codec, ALI_GC_CIR)); in snd_ali_pointer()
1429 cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2)); in snd_ali_pointer()
1430 spin_unlock(&codec->reg_lock); in snd_ali_pointer()
1432 cso %= runtime->buffer_size; in snd_ali_pointer()
1486 struct snd_ali_voice *pvoice = runtime->private_data; in snd_ali_pcm_free_substream()
1489 snd_ali_free_voice(pvoice->codec, pvoice); in snd_ali_pcm_free_substream()
1495 struct snd_ali *codec = snd_pcm_substream_chip(substream); in snd_ali_open() local
1496 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ali_open()
1499 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec, in snd_ali_open()
1502 return -EAGAIN; in snd_ali_open()
1504 pvoice->substream = substream; in snd_ali_open()
1505 runtime->private_data = pvoice; in snd_ali_open()
1506 runtime->private_free = snd_ali_pcm_free_substream; in snd_ali_open()
1508 runtime->hw = *phw; in snd_ali_open()
1517 return snd_ali_open(substream, 0, -1, &snd_ali_playback); in snd_ali_playback_open()
1522 return snd_ali_open(substream, 1, -1, &snd_ali_capture); in snd_ali_capture_open()
1532 struct snd_ali *codec = snd_pcm_substream_chip(substream); in snd_ali_close() local
1533 struct snd_ali_voice *pvoice = substream->runtime->private_data; in snd_ali_close()
1535 snd_ali_disable_special_channel(codec,pvoice->number); in snd_ali_close()
1570 unsigned int modem_num = chip->num_of_codecs - 1; in snd_ali_modem_hw_params()
1571 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE, in snd_ali_modem_hw_params()
1573 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0); in snd_ali_modem_hw_params()
1612 return snd_pcm_hw_constraint_list(substream->runtime, 0, in snd_ali_modem_open()
1661 struct snd_ali *codec = pcm->private_data; in snd_ali_pcm_free() local
1662 codec->pcm[pcm->device] = NULL; in snd_ali_pcm_free()
1666 static int snd_ali_pcm(struct snd_ali *codec, int device, in snd_ali_pcm() argument
1672 err = snd_pcm_new(codec->card, desc->name, device, in snd_ali_pcm()
1673 desc->playback_num, desc->capture_num, &pcm); in snd_ali_pcm()
1675 dev_err(codec->card->dev, in snd_ali_pcm()
1679 pcm->private_data = codec; in snd_ali_pcm()
1680 pcm->private_free = snd_ali_pcm_free; in snd_ali_pcm()
1681 if (desc->playback_ops) in snd_ali_pcm()
1683 desc->playback_ops); in snd_ali_pcm()
1684 if (desc->capture_ops) in snd_ali_pcm()
1686 desc->capture_ops); in snd_ali_pcm()
1689 snd_dma_pci_data(codec->pci), in snd_ali_pcm()
1692 pcm->info_flags = 0; in snd_ali_pcm()
1693 pcm->dev_class = desc->class; in snd_ali_pcm()
1694 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; in snd_ali_pcm()
1695 strcpy(pcm->name, desc->name); in snd_ali_pcm()
1696 codec->pcm[0] = pcm; in snd_ali_pcm()
1716 static int snd_ali_build_pcms(struct snd_ali *codec) in snd_ali_build_pcms() argument
1719 for (i = 0; i < codec->num_of_codecs && i < ARRAY_SIZE(ali_pcms); i++) { in snd_ali_build_pcms()
1720 err = snd_ali_pcm(codec, i, &ali_pcms[i]); in snd_ali_build_pcms()
1738 struct snd_ali *codec = kcontrol->private_data; in snd_ali5451_spdif_get() local
1741 spdif_enable = ucontrol->value.integer.value[0] ? 1 : 0; in snd_ali5451_spdif_get()
1743 spin_lock_irq(&codec->reg_lock); in snd_ali5451_spdif_get()
1744 switch (kcontrol->private_value) { in snd_ali5451_spdif_get()
1746 spdif_enable = (codec->spdif_mask & 0x02) ? 1 : 0; in snd_ali5451_spdif_get()
1749 spdif_enable = ((codec->spdif_mask & 0x02) && in snd_ali5451_spdif_get()
1750 (codec->spdif_mask & 0x04)) ? 1 : 0; in snd_ali5451_spdif_get()
1753 spdif_enable = (codec->spdif_mask & 0x01) ? 1 : 0; in snd_ali5451_spdif_get()
1758 ucontrol->value.integer.value[0] = spdif_enable; in snd_ali5451_spdif_get()
1759 spin_unlock_irq(&codec->reg_lock); in snd_ali5451_spdif_get()
1766 struct snd_ali *codec = kcontrol->private_data; in snd_ali5451_spdif_put() local
1769 spdif_enable = ucontrol->value.integer.value[0] ? 1 : 0; in snd_ali5451_spdif_put()
1771 spin_lock_irq(&codec->reg_lock); in snd_ali5451_spdif_put()
1772 switch (kcontrol->private_value) { in snd_ali5451_spdif_put()
1774 change = (codec->spdif_mask & 0x02) ? 1 : 0; in snd_ali5451_spdif_put()
1778 codec->spdif_mask |= 0x02; in snd_ali5451_spdif_put()
1779 snd_ali_enable_spdif_out(codec); in snd_ali5451_spdif_put()
1781 codec->spdif_mask &= ~(0x02); in snd_ali5451_spdif_put()
1782 codec->spdif_mask &= ~(0x04); in snd_ali5451_spdif_put()
1783 snd_ali_disable_spdif_out(codec); in snd_ali5451_spdif_put()
1788 change = (codec->spdif_mask & 0x04) ? 1 : 0; in snd_ali5451_spdif_put()
1790 if (change && (codec->spdif_mask & 0x02)) { in snd_ali5451_spdif_put()
1792 codec->spdif_mask |= 0x04; in snd_ali5451_spdif_put()
1793 snd_ali_enable_spdif_chnout(codec); in snd_ali5451_spdif_put()
1795 codec->spdif_mask &= ~(0x04); in snd_ali5451_spdif_put()
1796 snd_ali_disable_spdif_chnout(codec); in snd_ali5451_spdif_put()
1801 change = (codec->spdif_mask & 0x01) ? 1 : 0; in snd_ali5451_spdif_put()
1805 codec->spdif_mask |= 0x01; in snd_ali5451_spdif_put()
1806 snd_ali_enable_spdif_in(codec); in snd_ali5451_spdif_put()
1808 codec->spdif_mask &= ~(0x01); in snd_ali5451_spdif_put()
1809 snd_ali_disable_spdif_in(codec); in snd_ali5451_spdif_put()
1816 spin_unlock_irq(&codec->reg_lock); in snd_ali5451_spdif_put()
1831 static int snd_ali_mixer(struct snd_ali *codec) in snd_ali_mixer() argument
1841 err = snd_ac97_bus(codec->card, 0, &ops, codec, &codec->ac97_bus); in snd_ali_mixer()
1846 ac97.private_data = codec; in snd_ali_mixer()
1848 for (i = 0; i < codec->num_of_codecs; i++) { in snd_ali_mixer()
1850 err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i]); in snd_ali_mixer()
1852 dev_err(codec->card->dev, in snd_ali_mixer()
1856 codec->num_of_codecs = 1; in snd_ali_mixer()
1861 if (codec->spdif_support) { in snd_ali_mixer()
1863 err = snd_ctl_add(codec->card, in snd_ali_mixer()
1864 snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec)); in snd_ali_mixer()
1876 struct snd_ali *chip = card->private_data; in ali_suspend()
1880 im = chip->image; in ali_suspend()
1885 for (i = 0; i < chip->num_of_codecs; i++) { in ali_suspend()
1886 snd_pcm_suspend_all(chip->pcm[i]); in ali_suspend()
1887 snd_ac97_suspend(chip->ac97[i]); in ali_suspend()
1890 spin_lock_irq(&chip->reg_lock); in ali_suspend()
1892 im->regs[ALI_MISCINT >> 2] = inl(ALI_REG(chip, ALI_MISCINT)); in ali_suspend()
1893 /* im->regs[ALI_START >> 2] = inl(ALI_REG(chip, ALI_START)); */ in ali_suspend()
1894 im->regs[ALI_STOP >> 2] = inl(ALI_REG(chip, ALI_STOP)); in ali_suspend()
1902 im->regs[i] = inl(ALI_REG(chip, i*4)); in ali_suspend()
1908 im->channel_regs[i][j] = inl(ALI_REG(chip, j*4 + 0xe0)); in ali_suspend()
1914 spin_unlock_irq(&chip->reg_lock); in ali_suspend()
1921 struct snd_ali *chip = card->private_data; in ali_resume()
1925 im = chip->image; in ali_resume()
1929 spin_lock_irq(&chip->reg_lock); in ali_resume()
1934 outl(im->channel_regs[i][j], ALI_REG(chip, j*4 + 0xe0)); in ali_resume()
1941 outl(im->regs[i], ALI_REG(chip, i*4)); in ali_resume()
1945 outl(im->regs[ALI_START >> 2], ALI_REG(chip, ALI_START)); in ali_resume()
1947 outl(im->regs[ALI_MISCINT >> 2], ALI_REG(chip, ALI_MISCINT)); in ali_resume()
1949 spin_unlock_irq(&chip->reg_lock); in ali_resume()
1951 for (i = 0 ; i < chip->num_of_codecs; i++) in ali_resume()
1952 snd_ac97_resume(chip->ac97[i]); in ali_resume()
1964 static int snd_ali_free(struct snd_ali * codec) in snd_ali_free() argument
1966 if (codec->hw_initialized) in snd_ali_free()
1967 snd_ali_disable_address_interrupt(codec); in snd_ali_free()
1968 if (codec->irq >= 0) in snd_ali_free()
1969 free_irq(codec->irq, codec); in snd_ali_free()
1970 if (codec->port) in snd_ali_free()
1971 pci_release_regions(codec->pci); in snd_ali_free()
1972 pci_disable_device(codec->pci); in snd_ali_free()
1974 kfree(codec->image); in snd_ali_free()
1976 pci_dev_put(codec->pci_m1533); in snd_ali_free()
1977 pci_dev_put(codec->pci_m7101); in snd_ali_free()
1978 kfree(codec); in snd_ali_free()
1982 static int snd_ali_chip_init(struct snd_ali *codec) in snd_ali_chip_init() argument
1988 dev_dbg(codec->card->dev, "chip initializing ...\n"); in snd_ali_chip_init()
1990 if (snd_ali_reset_5451(codec)) { in snd_ali_chip_init()
1991 dev_err(codec->card->dev, "ali_chip_init: reset 5451 error.\n"); in snd_ali_chip_init()
1992 return -1; in snd_ali_chip_init()
1995 if (codec->revision == ALI_5451_V02) { in snd_ali_chip_init()
1996 pci_dev = codec->pci_m1533; in snd_ali_chip_init()
2001 pci_dev = codec->pci_m7101; in snd_ali_chip_init()
2007 pci_read_config_dword(codec->pci, 0x44, &legacy); in snd_ali_chip_init()
2010 pci_write_config_dword(codec->pci, 0x44, legacy); in snd_ali_chip_init()
2012 outl(0x80000001, ALI_REG(codec, ALI_GLOBAL_CONTROL)); in snd_ali_chip_init()
2013 outl(0x00000000, ALI_REG(codec, ALI_AINTEN)); in snd_ali_chip_init()
2014 outl(0xffffffff, ALI_REG(codec, ALI_AINT)); in snd_ali_chip_init()
2015 outl(0x00000000, ALI_REG(codec, ALI_VOLUME)); in snd_ali_chip_init()
2016 outb(0x10, ALI_REG(codec, ALI_MPUR2)); in snd_ali_chip_init()
2018 codec->ac97_ext_id = snd_ali_codec_peek(codec, 0, AC97_EXTENDED_ID); in snd_ali_chip_init()
2019 codec->ac97_ext_status = snd_ali_codec_peek(codec, 0, in snd_ali_chip_init()
2021 if (codec->spdif_support) { in snd_ali_chip_init()
2022 snd_ali_enable_spdif_out(codec); in snd_ali_chip_init()
2023 codec->spdif_mask = 0x00000002; in snd_ali_chip_init()
2026 codec->num_of_codecs = 1; in snd_ali_chip_init()
2028 /* secondary codec - modem */ in snd_ali_chip_init()
2029 if (inl(ALI_REG(codec, ALI_SCTRL)) & ALI_SCTRL_CODEC2_READY) { in snd_ali_chip_init()
2030 codec->num_of_codecs++; in snd_ali_chip_init()
2031 outl(inl(ALI_REG(codec, ALI_SCTRL)) | in snd_ali_chip_init()
2034 ALI_REG(codec, ALI_SCTRL)); in snd_ali_chip_init()
2037 dev_dbg(codec->card->dev, "chip initialize succeed.\n"); in snd_ali_chip_init()
2046 struct snd_ali *codec = entry->private_data; in snd_ali_proc_read() local
2049 snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i))); in snd_ali_proc_read()
2052 static void snd_ali_proc_init(struct snd_ali *codec) in snd_ali_proc_init() argument
2055 if (!snd_card_proc_new(codec->card, "ali5451", &entry)) in snd_ali_proc_init()
2056 snd_info_set_text_ops(entry, codec, snd_ali_proc_read); in snd_ali_proc_init()
2059 static int snd_ali_resources(struct snd_ali *codec) in snd_ali_resources() argument
2063 dev_dbg(codec->card->dev, "resources allocation ...\n"); in snd_ali_resources()
2064 err = pci_request_regions(codec->pci, "ALI 5451"); in snd_ali_resources()
2067 codec->port = pci_resource_start(codec->pci, 0); in snd_ali_resources()
2069 if (request_irq(codec->pci->irq, snd_ali_card_interrupt, in snd_ali_resources()
2070 IRQF_SHARED, KBUILD_MODNAME, codec)) { in snd_ali_resources()
2071 dev_err(codec->card->dev, "Unable to request irq.\n"); in snd_ali_resources()
2072 return -EBUSY; in snd_ali_resources()
2074 codec->irq = codec->pci->irq; in snd_ali_resources()
2075 dev_dbg(codec->card->dev, "resources allocated.\n"); in snd_ali_resources()
2080 struct snd_ali *codec = device->device_data; in snd_ali_dev_free() local
2081 snd_ali_free(codec); in snd_ali_dev_free()
2091 struct snd_ali *codec; in snd_ali_create() local
2100 dev_dbg(card->dev, "creating ...\n"); in snd_ali_create()
2107 if (dma_set_mask(&pci->dev, DMA_BIT_MASK(31)) < 0 || in snd_ali_create()
2108 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(31)) < 0) { in snd_ali_create()
2109 dev_err(card->dev, in snd_ali_create()
2112 return -ENXIO; in snd_ali_create()
2115 codec = kzalloc(sizeof(*codec), GFP_KERNEL); in snd_ali_create()
2116 if (!codec) { in snd_ali_create()
2118 return -ENOMEM; in snd_ali_create()
2121 spin_lock_init(&codec->reg_lock); in snd_ali_create()
2122 spin_lock_init(&codec->voice_alloc); in snd_ali_create()
2124 codec->card = card; in snd_ali_create()
2125 codec->pci = pci; in snd_ali_create()
2126 codec->irq = -1; in snd_ali_create()
2127 codec->revision = pci->revision; in snd_ali_create()
2128 codec->spdif_support = spdif_support; in snd_ali_create()
2143 if (snd_ali_resources(codec)) { in snd_ali_create()
2144 snd_ali_free(codec); in snd_ali_create()
2145 return -EBUSY; in snd_ali_create()
2148 synchronize_irq(pci->irq); in snd_ali_create()
2150 codec->synth.chmap = 0; in snd_ali_create()
2151 codec->synth.chcnt = 0; in snd_ali_create()
2152 codec->spdif_mask = 0; in snd_ali_create()
2153 codec->synth.synthcount = 0; in snd_ali_create()
2155 if (codec->revision == ALI_5451_V02) in snd_ali_create()
2156 codec->chregs.regs.ac97read = ALI_AC97_WRITE; in snd_ali_create()
2158 codec->chregs.regs.ac97read = ALI_AC97_READ; in snd_ali_create()
2159 codec->chregs.regs.ac97write = ALI_AC97_WRITE; in snd_ali_create()
2161 codec->chregs.regs.start = ALI_START; in snd_ali_create()
2162 codec->chregs.regs.stop = ALI_STOP; in snd_ali_create()
2163 codec->chregs.regs.aint = ALI_AINT; in snd_ali_create()
2164 codec->chregs.regs.ainten = ALI_AINTEN; in snd_ali_create()
2166 codec->chregs.data.start = 0x00; in snd_ali_create()
2167 codec->chregs.data.stop = 0x00; in snd_ali_create()
2168 codec->chregs.data.aint = 0x00; in snd_ali_create()
2169 codec->chregs.data.ainten = 0x00; in snd_ali_create()
2172 codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL); in snd_ali_create()
2173 if (!codec->pci_m1533) { in snd_ali_create()
2174 dev_err(card->dev, "cannot find ALi 1533 chip.\n"); in snd_ali_create()
2175 snd_ali_free(codec); in snd_ali_create()
2176 return -ENODEV; in snd_ali_create()
2179 codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL); in snd_ali_create()
2180 if (!codec->pci_m7101 && codec->revision == ALI_5451_V02) { in snd_ali_create()
2181 dev_err(card->dev, "cannot find ALi 7101 chip.\n"); in snd_ali_create()
2182 snd_ali_free(codec); in snd_ali_create()
2183 return -ENODEV; in snd_ali_create()
2186 dev_dbg(card->dev, "snd_device_new is called.\n"); in snd_ali_create()
2187 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops); in snd_ali_create()
2189 snd_ali_free(codec); in snd_ali_create()
2195 codec->synth.voices[i].number = i; in snd_ali_create()
2197 err = snd_ali_chip_init(codec); in snd_ali_create()
2199 dev_err(card->dev, "ali create: chip init error.\n"); in snd_ali_create()
2204 codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL); in snd_ali_create()
2205 if (!codec->image) in snd_ali_create()
2206 dev_warn(card->dev, "can't allocate apm buffer\n"); in snd_ali_create()
2209 snd_ali_enable_address_interrupt(codec); in snd_ali_create()
2210 codec->hw_initialized = 1; in snd_ali_create()
2212 *r_ali = codec; in snd_ali_create()
2213 dev_dbg(card->dev, "created.\n"); in snd_ali_create()
2221 struct snd_ali *codec; in snd_ali_probe() local
2224 dev_dbg(&pci->dev, "probe ...\n"); in snd_ali_probe()
2226 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card); in snd_ali_probe()
2230 err = snd_ali_create(card, pci, pcm_channels, spdif, &codec); in snd_ali_probe()
2233 card->private_data = codec; in snd_ali_probe()
2235 dev_dbg(&pci->dev, "mixer building ...\n"); in snd_ali_probe()
2236 err = snd_ali_mixer(codec); in snd_ali_probe()
2240 dev_dbg(&pci->dev, "pcm building ...\n"); in snd_ali_probe()
2241 err = snd_ali_build_pcms(codec); in snd_ali_probe()
2245 snd_ali_proc_init(codec); in snd_ali_probe()
2247 strcpy(card->driver, "ALI5451"); in snd_ali_probe()
2248 strcpy(card->shortname, "ALI 5451"); in snd_ali_probe()
2250 sprintf(card->longname, "%s at 0x%lx, irq %i", in snd_ali_probe()
2251 card->shortname, codec->port, codec->irq); in snd_ali_probe()
2253 dev_dbg(&pci->dev, "register card.\n"); in snd_ali_probe()