Lines Matching full:chip
50 static int snd_pmac_dbdma_alloc(struct snd_pmac *chip, struct pmac_dbdma *rec, int size) in snd_pmac_dbdma_alloc() argument
54 rec->space = dma_alloc_coherent(&chip->pdev->dev, rsize, in snd_pmac_dbdma_alloc()
66 static void snd_pmac_dbdma_free(struct snd_pmac *chip, struct pmac_dbdma *rec) in snd_pmac_dbdma_free() argument
71 dma_free_coherent(&chip->pdev->dev, rsize, rec->space, rec->dma_base); in snd_pmac_dbdma_free()
84 unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate) in snd_pmac_rate_index() argument
89 if (rate > chip->freq_table[0]) in snd_pmac_rate_index()
92 for (i = 0; i < chip->num_freqs; i++, ok >>= 1) { in snd_pmac_rate_index()
95 if (rate >= chip->freq_table[i]) in snd_pmac_rate_index()
113 static struct pmac_stream *snd_pmac_get_stream(struct snd_pmac *chip, int stream) in snd_pmac_get_stream() argument
117 return &chip->playback; in snd_pmac_get_stream()
119 return &chip->capture; in snd_pmac_get_stream()
138 * set the format and rate to the chip.
141 static void snd_pmac_pcm_set_format(struct snd_pmac *chip) in snd_pmac_pcm_set_format() argument
144 out_le32(&chip->awacs->control, chip->control_mask | (chip->rate_index << 8)); in snd_pmac_pcm_set_format()
145 out_le32(&chip->awacs->byteswap, chip->format == SNDRV_PCM_FORMAT_S16_LE ? 1 : 0); in snd_pmac_pcm_set_format()
146 if (chip->set_format) in snd_pmac_pcm_set_format()
147 chip->set_format(chip); in snd_pmac_pcm_set_format()
179 static int snd_pmac_pcm_prepare(struct snd_pmac *chip, struct pmac_stream *rec, struct snd_pcm_subs… in snd_pmac_pcm_prepare() argument
192 rate_index = snd_pmac_rate_index(chip, rec, runtime->rate); in snd_pmac_pcm_prepare()
195 astr = snd_pmac_get_stream(chip, another_stream(rec->stream)); in snd_pmac_pcm_prepare()
200 chip->rate_index = rate_index; in snd_pmac_pcm_prepare()
201 chip->format = runtime->format; in snd_pmac_pcm_prepare()
209 spin_lock_irq(&chip->reg_lock); in snd_pmac_pcm_prepare()
211 chip->extra_dma.cmds->command = cpu_to_le16(DBDMA_STOP); in snd_pmac_pcm_prepare()
212 snd_pmac_dma_set_command(rec, &chip->extra_dma); in snd_pmac_pcm_prepare()
214 spin_unlock_irq(&chip->reg_lock); in snd_pmac_pcm_prepare()
216 spin_lock_irq(&chip->reg_lock); in snd_pmac_pcm_prepare()
234 spin_unlock_irq(&chip->reg_lock); in snd_pmac_pcm_prepare()
243 static int snd_pmac_pcm_trigger(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_trigger() argument
256 spin_lock(&chip->reg_lock); in snd_pmac_pcm_trigger()
257 snd_pmac_beep_stop(chip); in snd_pmac_pcm_trigger()
258 snd_pmac_pcm_set_format(chip); in snd_pmac_pcm_trigger()
265 spin_unlock(&chip->reg_lock); in snd_pmac_pcm_trigger()
270 spin_lock(&chip->reg_lock); in snd_pmac_pcm_trigger()
275 spin_unlock(&chip->reg_lock); in snd_pmac_pcm_trigger()
289 static snd_pcm_uframes_t snd_pmac_pcm_pointer(struct snd_pmac *chip, in snd_pmac_pcm_pointer() argument
315 struct snd_pmac *chip = snd_pcm_substream_chip(subs); in snd_pmac_playback_prepare() local
316 return snd_pmac_pcm_prepare(chip, &chip->playback, subs); in snd_pmac_playback_prepare()
322 struct snd_pmac *chip = snd_pcm_substream_chip(subs); in snd_pmac_playback_trigger() local
323 return snd_pmac_pcm_trigger(chip, &chip->playback, subs, cmd); in snd_pmac_playback_trigger()
328 struct snd_pmac *chip = snd_pcm_substream_chip(subs); in snd_pmac_playback_pointer() local
329 return snd_pmac_pcm_pointer(chip, &chip->playback, subs); in snd_pmac_playback_pointer()
339 struct snd_pmac *chip = snd_pcm_substream_chip(subs); in snd_pmac_capture_prepare() local
340 return snd_pmac_pcm_prepare(chip, &chip->capture, subs); in snd_pmac_capture_prepare()
346 struct snd_pmac *chip = snd_pcm_substream_chip(subs); in snd_pmac_capture_trigger() local
347 return snd_pmac_pcm_trigger(chip, &chip->capture, subs, cmd); in snd_pmac_capture_trigger()
352 struct snd_pmac *chip = snd_pcm_substream_chip(subs); in snd_pmac_capture_pointer() local
353 return snd_pmac_pcm_pointer(chip, &chip->capture, subs); in snd_pmac_capture_pointer()
427 static void snd_pmac_pcm_update(struct snd_pmac *chip, struct pmac_stream *rec) in snd_pmac_pcm_update() argument
433 spin_lock(&chip->reg_lock); in snd_pmac_pcm_update()
463 spin_unlock(&chip->reg_lock); in snd_pmac_pcm_update()
465 spin_lock(&chip->reg_lock); in snd_pmac_pcm_update()
468 spin_unlock(&chip->reg_lock); in snd_pmac_pcm_update()
519 struct snd_pmac *chip = rule->private;
520 struct pmac_stream *rec = snd_pmac_get_stream(chip, rule->deps[0]);
526 for (i = chip->num_freqs - 1; i >= 0; i--) {
528 freq_table[num_freqs++] = chip->freq_table[i];
538 struct snd_pmac *chip = rule->private;
539 struct pmac_stream *rec = snd_pmac_get_stream(chip, rule->deps[0]);
548 static int snd_pmac_pcm_open(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_open() argument
556 for (i = 0; i < chip->num_freqs; i++) in snd_pmac_pcm_open()
557 if (chip->freqs_ok & (1 << i)) in snd_pmac_pcm_open()
559 snd_pcm_rate_to_rate_bit(chip->freq_table[i]); in snd_pmac_pcm_open()
562 for (i = 0; i < chip->num_freqs; i++) { in snd_pmac_pcm_open()
563 if (chip->freqs_ok & (1 << i)) { in snd_pmac_pcm_open()
564 runtime->hw.rate_max = chip->freq_table[i]; in snd_pmac_pcm_open()
568 for (i = chip->num_freqs - 1; i >= 0; i--) { in snd_pmac_pcm_open()
569 if (chip->freqs_ok & (1 << i)) { in snd_pmac_pcm_open()
570 runtime->hw.rate_min = chip->freq_table[i]; in snd_pmac_pcm_open()
574 runtime->hw.formats = chip->formats_ok; in snd_pmac_pcm_open()
575 if (chip->can_capture) { in snd_pmac_pcm_open()
576 if (! chip->can_duplex) in snd_pmac_pcm_open()
585 snd_pmac_hw_rule_rate, chip, rec->stream, -1); in snd_pmac_pcm_open()
587 snd_pmac_hw_rule_format, chip, rec->stream, -1); in snd_pmac_pcm_open()
597 static int snd_pmac_pcm_close(struct snd_pmac *chip, struct pmac_stream *rec, in snd_pmac_pcm_close() argument
604 astr = snd_pmac_get_stream(chip, another_stream(rec->stream)); in snd_pmac_pcm_close()
609 astr->cur_freqs = chip->freqs_ok; in snd_pmac_pcm_close()
610 astr->cur_formats = chip->formats_ok; in snd_pmac_pcm_close()
617 struct snd_pmac *chip = snd_pcm_substream_chip(subs); in snd_pmac_playback_open() local
620 return snd_pmac_pcm_open(chip, &chip->playback, subs); in snd_pmac_playback_open()
625 struct snd_pmac *chip = snd_pcm_substream_chip(subs); in snd_pmac_capture_open() local
628 return snd_pmac_pcm_open(chip, &chip->capture, subs); in snd_pmac_capture_open()
633 struct snd_pmac *chip = snd_pcm_substream_chip(subs); in snd_pmac_playback_close() local
635 return snd_pmac_pcm_close(chip, &chip->playback, subs); in snd_pmac_playback_close()
640 struct snd_pmac *chip = snd_pcm_substream_chip(subs); in snd_pmac_capture_close() local
642 return snd_pmac_pcm_close(chip, &chip->capture, subs); in snd_pmac_capture_close()
664 int snd_pmac_pcm_new(struct snd_pmac *chip) in snd_pmac_pcm_new() argument
670 if (! chip->can_capture) in snd_pmac_pcm_new()
672 err = snd_pcm_new(chip->card, chip->card->driver, 0, 1, num_captures, &pcm); in snd_pmac_pcm_new()
677 if (chip->can_capture) in snd_pmac_pcm_new()
680 pcm->private_data = chip; in snd_pmac_pcm_new()
682 strcpy(pcm->name, chip->card->shortname); in snd_pmac_pcm_new()
683 chip->pcm = pcm; in snd_pmac_pcm_new()
685 chip->formats_ok = SNDRV_PCM_FMTBIT_S16_BE; in snd_pmac_pcm_new()
686 if (chip->can_byte_swap) in snd_pmac_pcm_new()
687 chip->formats_ok |= SNDRV_PCM_FMTBIT_S16_LE; in snd_pmac_pcm_new()
689 chip->playback.cur_formats = chip->formats_ok; in snd_pmac_pcm_new()
690 chip->capture.cur_formats = chip->formats_ok; in snd_pmac_pcm_new()
691 chip->playback.cur_freqs = chip->freqs_ok; in snd_pmac_pcm_new()
692 chip->capture.cur_freqs = chip->freqs_ok; in snd_pmac_pcm_new()
696 &chip->pdev->dev, in snd_pmac_pcm_new()
703 static void snd_pmac_dbdma_reset(struct snd_pmac *chip) in snd_pmac_dbdma_reset() argument
705 out_le32(&chip->playback.dma->control, (RUN|PAUSE|FLUSH|WAKE|DEAD) << 16); in snd_pmac_dbdma_reset()
706 snd_pmac_wait_ack(&chip->playback); in snd_pmac_dbdma_reset()
707 out_le32(&chip->capture.dma->control, (RUN|PAUSE|FLUSH|WAKE|DEAD) << 16); in snd_pmac_dbdma_reset()
708 snd_pmac_wait_ack(&chip->capture); in snd_pmac_dbdma_reset()
715 void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed) in snd_pmac_beep_dma_start() argument
717 struct pmac_stream *rec = &chip->playback; in snd_pmac_beep_dma_start()
720 chip->extra_dma.cmds->req_count = cpu_to_le16(bytes); in snd_pmac_beep_dma_start()
721 chip->extra_dma.cmds->xfer_status = cpu_to_le16(0); in snd_pmac_beep_dma_start()
722 chip->extra_dma.cmds->cmd_dep = cpu_to_le32(chip->extra_dma.addr); in snd_pmac_beep_dma_start()
723 chip->extra_dma.cmds->phy_addr = cpu_to_le32(addr); in snd_pmac_beep_dma_start()
724 chip->extra_dma.cmds->command = cpu_to_le16(OUTPUT_MORE | BR_ALWAYS); in snd_pmac_beep_dma_start()
725 out_le32(&chip->awacs->control, in snd_pmac_beep_dma_start()
726 (in_le32(&chip->awacs->control) & ~0x1f00) in snd_pmac_beep_dma_start()
728 out_le32(&chip->awacs->byteswap, 0); in snd_pmac_beep_dma_start()
729 snd_pmac_dma_set_command(rec, &chip->extra_dma); in snd_pmac_beep_dma_start()
733 void snd_pmac_beep_dma_stop(struct snd_pmac *chip) in snd_pmac_beep_dma_stop() argument
735 snd_pmac_dma_stop(&chip->playback); in snd_pmac_beep_dma_stop()
736 chip->extra_dma.cmds->command = cpu_to_le16(DBDMA_STOP); in snd_pmac_beep_dma_stop()
737 snd_pmac_pcm_set_format(chip); /* reset format */ in snd_pmac_beep_dma_stop()
747 struct snd_pmac *chip = devid; in snd_pmac_tx_intr() local
748 snd_pmac_pcm_update(chip, &chip->playback); in snd_pmac_tx_intr()
756 struct snd_pmac *chip = devid; in snd_pmac_rx_intr() local
757 snd_pmac_pcm_update(chip, &chip->capture); in snd_pmac_rx_intr()
765 struct snd_pmac *chip = devid; in snd_pmac_ctrl_intr() local
766 int ctrl = in_le32(&chip->awacs->control); in snd_pmac_ctrl_intr()
770 if (chip->update_automute) in snd_pmac_ctrl_intr()
771 chip->update_automute(chip, 1); in snd_pmac_ctrl_intr()
774 int err = (in_le32(&chip->awacs->codec_stat) & MASK_ERRCODE) >> 16; in snd_pmac_ctrl_intr()
775 if (err && chip->model <= PMAC_SCREAMER) in snd_pmac_ctrl_intr()
776 dev_dbg(chip->card->dev, "%s: error %x\n", __func__, err); in snd_pmac_ctrl_intr()
779 out_le32(&chip->awacs->control, ctrl); in snd_pmac_ctrl_intr()
787 static void snd_pmac_sound_feature(struct snd_pmac *chip, int enable) in snd_pmac_sound_feature() argument
790 ppc_md.feature_call(PMAC_FTR_SOUND_CHIP_ENABLE, chip->node, 0, enable); in snd_pmac_sound_feature()
797 static int snd_pmac_free(struct snd_pmac *chip) in snd_pmac_free() argument
800 if (chip->initialized) { in snd_pmac_free()
801 snd_pmac_dbdma_reset(chip); in snd_pmac_free()
803 out_le32(&chip->awacs->control, in_le32(&chip->awacs->control) & 0xfff); in snd_pmac_free()
806 if (chip->node) in snd_pmac_free()
807 snd_pmac_sound_feature(chip, 0); in snd_pmac_free()
810 if (chip->mixer_free) in snd_pmac_free()
811 chip->mixer_free(chip); in snd_pmac_free()
813 snd_pmac_detach_beep(chip); in snd_pmac_free()
816 if (chip->irq >= 0) in snd_pmac_free()
817 free_irq(chip->irq, (void*)chip); in snd_pmac_free()
818 if (chip->tx_irq >= 0) in snd_pmac_free()
819 free_irq(chip->tx_irq, (void*)chip); in snd_pmac_free()
820 if (chip->rx_irq >= 0) in snd_pmac_free()
821 free_irq(chip->rx_irq, (void*)chip); in snd_pmac_free()
822 snd_pmac_dbdma_free(chip, &chip->playback.cmd); in snd_pmac_free()
823 snd_pmac_dbdma_free(chip, &chip->capture.cmd); in snd_pmac_free()
824 snd_pmac_dbdma_free(chip, &chip->extra_dma); in snd_pmac_free()
825 snd_pmac_dbdma_free(chip, &emergency_dbdma); in snd_pmac_free()
826 iounmap(chip->macio_base); in snd_pmac_free()
827 iounmap(chip->latch_base); in snd_pmac_free()
828 iounmap(chip->awacs); in snd_pmac_free()
829 iounmap(chip->playback.dma); in snd_pmac_free()
830 iounmap(chip->capture.dma); in snd_pmac_free()
832 if (chip->node) { in snd_pmac_free()
835 if (chip->requested & (1 << i)) in snd_pmac_free()
836 release_mem_region(chip->rsrc[i].start, in snd_pmac_free()
837 resource_size(&chip->rsrc[i])); in snd_pmac_free()
841 pci_dev_put(chip->pdev); in snd_pmac_free()
842 of_node_put(chip->node); in snd_pmac_free()
843 kfree(chip); in snd_pmac_free()
853 struct snd_pmac *chip = device->device_data; in snd_pmac_dev_free() local
854 return snd_pmac_free(chip); in snd_pmac_dev_free()
862 static void detect_byte_swap(struct snd_pmac *chip) in detect_byte_swap() argument
867 for (mio = chip->node->parent; mio; mio = mio->parent) { in detect_byte_swap()
870 chip->can_byte_swap = 0; in detect_byte_swap()
878 chip->can_byte_swap = 0 ; in detect_byte_swap()
881 chip->can_duplex = 0; in detect_byte_swap()
886 * detect a sound chip
888 static int snd_pmac_detect(struct snd_pmac *chip) in snd_pmac_detect() argument
899 chip->subframe = 0; in snd_pmac_detect()
900 chip->revision = 0; in snd_pmac_detect()
901 chip->freqs_ok = 0xff; /* all ok */ in snd_pmac_detect()
902 chip->model = PMAC_AWACS; in snd_pmac_detect()
903 chip->can_byte_swap = 1; in snd_pmac_detect()
904 chip->can_duplex = 1; in snd_pmac_detect()
905 chip->can_capture = 1; in snd_pmac_detect()
906 chip->num_freqs = ARRAY_SIZE(awacs_freqs); in snd_pmac_detect()
907 chip->freq_table = awacs_freqs; in snd_pmac_detect()
908 chip->pdev = NULL; in snd_pmac_detect()
910 chip->control_mask = MASK_IEPC | MASK_IEE | 0x11; /* default */ in snd_pmac_detect()
915 chip->is_pbook_3400 = 1; in snd_pmac_detect()
918 chip->is_pbook_G3 = 1; in snd_pmac_detect()
919 chip->node = of_find_node_by_name(NULL, "awacs"); in snd_pmac_detect()
920 sound = of_node_get(chip->node); in snd_pmac_detect()
926 if (!chip->node) in snd_pmac_detect()
927 chip->node = of_find_node_by_name(NULL, "davbus"); in snd_pmac_detect()
932 if (! chip->node) { in snd_pmac_detect()
933 chip->node = of_find_node_by_name(NULL, "i2s-a"); in snd_pmac_detect()
934 if (chip->node && chip->node->parent && in snd_pmac_detect()
935 chip->node->parent->parent) { in snd_pmac_detect()
936 if (of_device_is_compatible(chip->node->parent->parent, in snd_pmac_detect()
938 chip->is_k2 = 1; in snd_pmac_detect()
941 if (! chip->node) in snd_pmac_detect()
946 if (sound->parent == chip->node) in snd_pmac_detect()
950 of_node_put(chip->node); in snd_pmac_detect()
951 chip->node = NULL; in snd_pmac_detect()
956 chip->subframe = *prop; in snd_pmac_detect()
961 dev_info(chip->card->dev, in snd_pmac_detect()
964 of_node_put(chip->node); in snd_pmac_detect()
965 chip->node = NULL; in snd_pmac_detect()
970 chip->model = PMAC_SCREAMER; in snd_pmac_detect()
971 // chip->can_byte_swap = 0; /* FIXME: check this */ in snd_pmac_detect()
974 chip->model = PMAC_BURGUNDY; in snd_pmac_detect()
975 chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */ in snd_pmac_detect()
978 chip->model = PMAC_DACA; in snd_pmac_detect()
979 chip->can_capture = 0; /* no capture */ in snd_pmac_detect()
980 chip->can_duplex = 0; in snd_pmac_detect()
981 // chip->can_byte_swap = 0; /* FIXME: check this */ in snd_pmac_detect()
982 chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */ in snd_pmac_detect()
985 chip->model = PMAC_TUMBLER; in snd_pmac_detect()
986 chip->can_capture = of_machine_is_compatible("PowerMac4,2") in snd_pmac_detect()
992 chip->can_duplex = 0; in snd_pmac_detect()
993 // chip->can_byte_swap = 0; /* FIXME: check this */ in snd_pmac_detect()
994 chip->num_freqs = ARRAY_SIZE(tumbler_freqs); in snd_pmac_detect()
995 chip->freq_table = tumbler_freqs; in snd_pmac_detect()
996 chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */ in snd_pmac_detect()
999 chip->model = PMAC_SNAPPER; in snd_pmac_detect()
1000 // chip->can_byte_swap = 0; /* FIXME: check this */ in snd_pmac_detect()
1001 chip->num_freqs = ARRAY_SIZE(tumbler_freqs); in snd_pmac_detect()
1002 chip->freq_table = tumbler_freqs; in snd_pmac_detect()
1003 chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */ in snd_pmac_detect()
1007 chip->device_id = *prop; in snd_pmac_detect()
1009 chip->has_iic = (dn != NULL); in snd_pmac_detect()
1015 macio = macio_find(chip->node, macio_unknown); in snd_pmac_detect()
1017 dev_warn(chip->card->dev, "snd-powermac: can't locate macio !\n"); in snd_pmac_detect()
1024 chip->pdev = pdev; in snd_pmac_detect()
1029 if (chip->pdev == NULL) in snd_pmac_detect()
1030 dev_warn(chip->card->dev, in snd_pmac_detect()
1033 detect_byte_swap(chip); in snd_pmac_detect()
1042 chip->freqs_ok = 0; in snd_pmac_detect()
1048 for (i = 0; i < chip->num_freqs; ++i) { in snd_pmac_detect()
1049 if (r == chip->freq_table[i]) { in snd_pmac_detect()
1050 chip->freqs_ok |= (1 << i); in snd_pmac_detect()
1057 chip->freqs_ok = 1; in snd_pmac_detect()
1071 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in pmac_auto_mute_get() local
1072 ucontrol->value.integer.value[0] = chip->auto_mute; in pmac_auto_mute_get()
1079 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in pmac_auto_mute_put() local
1080 if (ucontrol->value.integer.value[0] != chip->auto_mute) { in pmac_auto_mute_put()
1081 chip->auto_mute = !!ucontrol->value.integer.value[0]; in pmac_auto_mute_put()
1082 if (chip->update_automute) in pmac_auto_mute_put()
1083 chip->update_automute(chip, 1); in pmac_auto_mute_put()
1092 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); in pmac_hp_detect_get() local
1093 if (chip->detect_headphone) in pmac_hp_detect_get()
1094 ucontrol->value.integer.value[0] = chip->detect_headphone(chip); in pmac_hp_detect_get()
1115 int snd_pmac_add_automute(struct snd_pmac *chip) in snd_pmac_add_automute() argument
1118 chip->auto_mute = 1; in snd_pmac_add_automute()
1119 err = snd_ctl_add(chip->card, snd_ctl_new1(&auto_mute_controls[0], chip)); in snd_pmac_add_automute()
1121 dev_err(chip->card->dev, in snd_pmac_add_automute()
1125 chip->hp_detect_ctl = snd_ctl_new1(&auto_mute_controls[1], chip); in snd_pmac_add_automute()
1126 return snd_ctl_add(chip->card, chip->hp_detect_ctl); in snd_pmac_add_automute()
1131 * create and detect a pmac chip record
1135 struct snd_pmac *chip; in snd_pmac_new() local
1146 chip = kzalloc(sizeof(*chip), GFP_KERNEL); in snd_pmac_new()
1147 if (chip == NULL) in snd_pmac_new()
1149 chip->card = card; in snd_pmac_new()
1151 spin_lock_init(&chip->reg_lock); in snd_pmac_new()
1152 chip->irq = chip->tx_irq = chip->rx_irq = -1; in snd_pmac_new()
1154 chip->playback.stream = SNDRV_PCM_STREAM_PLAYBACK; in snd_pmac_new()
1155 chip->capture.stream = SNDRV_PCM_STREAM_CAPTURE; in snd_pmac_new()
1157 err = snd_pmac_detect(chip); in snd_pmac_new()
1161 if (snd_pmac_dbdma_alloc(chip, &chip->playback.cmd, PMAC_MAX_FRAGS + 1) < 0 || in snd_pmac_new()
1162 snd_pmac_dbdma_alloc(chip, &chip->capture.cmd, PMAC_MAX_FRAGS + 1) < 0 || in snd_pmac_new()
1163 snd_pmac_dbdma_alloc(chip, &chip->extra_dma, 2) < 0 || in snd_pmac_new()
1164 snd_pmac_dbdma_alloc(chip, &emergency_dbdma, 2) < 0) { in snd_pmac_new()
1169 np = chip->node; in snd_pmac_new()
1170 chip->requested = 0; in snd_pmac_new()
1171 if (chip->is_k2) { in snd_pmac_new()
1176 &chip->rsrc[i])) { in snd_pmac_new()
1177 dev_err(chip->card->dev, in snd_pmac_new()
1183 if (request_mem_region(chip->rsrc[i].start, in snd_pmac_new()
1184 resource_size(&chip->rsrc[i]), in snd_pmac_new()
1186 dev_err(chip->card->dev, in snd_pmac_new()
1188 i, rnames[i], &chip->rsrc[i]); in snd_pmac_new()
1192 chip->requested |= (1 << i); in snd_pmac_new()
1194 ctrl_addr = chip->rsrc[0].start; in snd_pmac_new()
1195 txdma_addr = chip->rsrc[1].start; in snd_pmac_new()
1202 &chip->rsrc[i])) { in snd_pmac_new()
1203 dev_err(chip->card->dev, in snd_pmac_new()
1209 if (request_mem_region(chip->rsrc[i].start, in snd_pmac_new()
1210 resource_size(&chip->rsrc[i]), in snd_pmac_new()
1212 dev_err(chip->card->dev, in snd_pmac_new()
1214 i, rnames[i], &chip->rsrc[i]); in snd_pmac_new()
1218 chip->requested |= (1 << i); in snd_pmac_new()
1220 ctrl_addr = chip->rsrc[0].start; in snd_pmac_new()
1221 txdma_addr = chip->rsrc[1].start; in snd_pmac_new()
1222 rxdma_addr = chip->rsrc[2].start; in snd_pmac_new()
1225 chip->awacs = ioremap(ctrl_addr, 0x1000); in snd_pmac_new()
1226 chip->playback.dma = ioremap(txdma_addr, 0x100); in snd_pmac_new()
1227 chip->capture.dma = ioremap(rxdma_addr, 0x100); in snd_pmac_new()
1228 if (chip->model <= PMAC_BURGUNDY) { in snd_pmac_new()
1231 "PMac", (void*)chip)) { in snd_pmac_new()
1232 dev_err(chip->card->dev, in snd_pmac_new()
1237 chip->irq = irq; in snd_pmac_new()
1240 if (request_irq(irq, snd_pmac_tx_intr, 0, "PMac Output", (void*)chip)){ in snd_pmac_new()
1241 dev_err(chip->card->dev, "pmac: unable to grab IRQ %d\n", irq); in snd_pmac_new()
1245 chip->tx_irq = irq; in snd_pmac_new()
1247 if (request_irq(irq, snd_pmac_rx_intr, 0, "PMac Input", (void*)chip)) { in snd_pmac_new()
1248 dev_err(chip->card->dev, "pmac: unable to grab IRQ %d\n", irq); in snd_pmac_new()
1252 chip->rx_irq = irq; in snd_pmac_new()
1254 snd_pmac_sound_feature(chip, 1); in snd_pmac_new()
1257 if (chip->model <= PMAC_BURGUNDY) in snd_pmac_new()
1258 out_le32(&chip->awacs->control, chip->control_mask); in snd_pmac_new()
1263 if (chip->is_pbook_3400) { in snd_pmac_new()
1271 chip->latch_base = ioremap (0xf301a000, 0x1000); in snd_pmac_new()
1272 in_8(chip->latch_base + 0x190); in snd_pmac_new()
1273 } else if (chip->is_pbook_G3) { in snd_pmac_new()
1275 for (mio = chip->node->parent; mio; mio = mio->parent) { in snd_pmac_new()
1279 chip->macio_base = in snd_pmac_new()
1292 if (chip->macio_base) in snd_pmac_new()
1293 out_8(chip->macio_base + 0x37, 3); in snd_pmac_new()
1297 snd_pmac_dbdma_reset(chip); in snd_pmac_new()
1299 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); in snd_pmac_new()
1303 *chip_return = chip; in snd_pmac_new()
1307 snd_pmac_free(chip); in snd_pmac_new()
1322 void snd_pmac_suspend(struct snd_pmac *chip) in snd_pmac_suspend() argument
1326 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); in snd_pmac_suspend()
1327 if (chip->suspend) in snd_pmac_suspend()
1328 chip->suspend(chip); in snd_pmac_suspend()
1329 spin_lock_irqsave(&chip->reg_lock, flags); in snd_pmac_suspend()
1330 snd_pmac_beep_stop(chip); in snd_pmac_suspend()
1331 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_pmac_suspend()
1332 if (chip->irq >= 0) in snd_pmac_suspend()
1333 disable_irq(chip->irq); in snd_pmac_suspend()
1334 if (chip->tx_irq >= 0) in snd_pmac_suspend()
1335 disable_irq(chip->tx_irq); in snd_pmac_suspend()
1336 if (chip->rx_irq >= 0) in snd_pmac_suspend()
1337 disable_irq(chip->rx_irq); in snd_pmac_suspend()
1338 snd_pmac_sound_feature(chip, 0); in snd_pmac_suspend()
1341 void snd_pmac_resume(struct snd_pmac *chip) in snd_pmac_resume() argument
1343 snd_pmac_sound_feature(chip, 1); in snd_pmac_resume()
1344 if (chip->resume) in snd_pmac_resume()
1345 chip->resume(chip); in snd_pmac_resume()
1347 if (chip->macio_base && chip->is_pbook_G3) in snd_pmac_resume()
1348 out_8(chip->macio_base + 0x37, 3); in snd_pmac_resume()
1349 else if (chip->is_pbook_3400) in snd_pmac_resume()
1350 in_8(chip->latch_base + 0x190); in snd_pmac_resume()
1352 snd_pmac_pcm_set_format(chip); in snd_pmac_resume()
1354 if (chip->irq >= 0) in snd_pmac_resume()
1355 enable_irq(chip->irq); in snd_pmac_resume()
1356 if (chip->tx_irq >= 0) in snd_pmac_resume()
1357 enable_irq(chip->tx_irq); in snd_pmac_resume()
1358 if (chip->rx_irq >= 0) in snd_pmac_resume()
1359 enable_irq(chip->rx_irq); in snd_pmac_resume()
1361 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); in snd_pmac_resume()