Lines Matching full:chip

58 static void amp_voyetra(struct snd_cs46xx *chip, int change);
74 static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip, in snd_cs46xx_codec_read() argument
86 chip->active_ctrl(chip, 1); in snd_cs46xx_codec_read()
100 snd_cs46xx_peekBA0(chip, BA0_ACSDA + offset); in snd_cs46xx_codec_read()
102 tmp = snd_cs46xx_peekBA0(chip, BA0_ACCTL); in snd_cs46xx_codec_read()
104 dev_warn(chip->card->dev, "ACCTL_VFRM not set 0x%x\n", tmp); in snd_cs46xx_codec_read()
105 snd_cs46xx_pokeBA0(chip, BA0_ACCTL, (tmp & (~ACCTL_ESYN)) | ACCTL_VFRM ); in snd_cs46xx_codec_read()
107 tmp = snd_cs46xx_peekBA0(chip, BA0_ACCTL + offset); in snd_cs46xx_codec_read()
108 snd_cs46xx_pokeBA0(chip, BA0_ACCTL, tmp | ACCTL_ESYN | ACCTL_VFRM ); in snd_cs46xx_codec_read()
125 snd_cs46xx_pokeBA0(chip, BA0_ACCAD, reg); in snd_cs46xx_codec_read()
126 snd_cs46xx_pokeBA0(chip, BA0_ACCDA, 0); in snd_cs46xx_codec_read()
128 snd_cs46xx_pokeBA0(chip, BA0_ACCTL,/* clear ACCTL_DCV */ ACCTL_CRW | in snd_cs46xx_codec_read()
131 snd_cs46xx_pokeBA0(chip, BA0_ACCTL, ACCTL_DCV | ACCTL_CRW | in snd_cs46xx_codec_read()
135 snd_cs46xx_pokeBA0(chip, BA0_ACCTL, ACCTL_DCV | ACCTL_TC | in snd_cs46xx_codec_read()
152 if (!(snd_cs46xx_peekBA0(chip, BA0_ACCTL) & ACCTL_DCV)) in snd_cs46xx_codec_read()
156 dev_err(chip->card->dev, in snd_cs46xx_codec_read()
171 if (snd_cs46xx_peekBA0(chip, BA0_ACSTS + offset) & ACSTS_VSTS) in snd_cs46xx_codec_read()
176 dev_err(chip->card->dev, in snd_cs46xx_codec_read()
188 dev_dbg(chip->card->dev, in snd_cs46xx_codec_read()
190 snd_cs46xx_peekBA0(chip, BA0_ACSDA), in snd_cs46xx_codec_read()
191 snd_cs46xx_peekBA0(chip, BA0_ACCAD)); in snd_cs46xx_codec_read()
194 //snd_cs46xx_peekBA0(chip, BA0_ACCAD); in snd_cs46xx_codec_read()
195 result = snd_cs46xx_peekBA0(chip, BA0_ACSDA + offset); in snd_cs46xx_codec_read()
197 chip->active_ctrl(chip, -1); in snd_cs46xx_codec_read()
204 struct snd_cs46xx *chip = ac97->private_data; in snd_cs46xx_ac97_read() local
212 val = snd_cs46xx_codec_read(chip, reg, codec_index); in snd_cs46xx_ac97_read()
218 static void snd_cs46xx_codec_write(struct snd_cs46xx *chip, in snd_cs46xx_codec_write() argument
229 chip->active_ctrl(chip, 1); in snd_cs46xx_codec_write()
251 snd_cs46xx_pokeBA0(chip, BA0_ACCAD , reg); in snd_cs46xx_codec_write()
252 snd_cs46xx_pokeBA0(chip, BA0_ACCDA , val); in snd_cs46xx_codec_write()
253 snd_cs46xx_peekBA0(chip, BA0_ACCTL); in snd_cs46xx_codec_write()
256 snd_cs46xx_pokeBA0(chip, BA0_ACCTL, /* clear ACCTL_DCV */ ACCTL_VFRM | in snd_cs46xx_codec_write()
258 snd_cs46xx_pokeBA0(chip, BA0_ACCTL, ACCTL_DCV | ACCTL_VFRM | in snd_cs46xx_codec_write()
261 snd_cs46xx_pokeBA0(chip, BA0_ACCTL, ACCTL_DCV | ACCTL_TC | in snd_cs46xx_codec_write()
274 if (!(snd_cs46xx_peekBA0(chip, BA0_ACCTL) & ACCTL_DCV)) { in snd_cs46xx_codec_write()
278 dev_err(chip->card->dev, in snd_cs46xx_codec_write()
282 chip->active_ctrl(chip, -1); in snd_cs46xx_codec_write()
289 struct snd_cs46xx *chip = ac97->private_data; in snd_cs46xx_ac97_write() local
296 snd_cs46xx_codec_write(chip, reg, val, codec_index); in snd_cs46xx_ac97_write()
301 * Chip initialization
304 int snd_cs46xx_download(struct snd_cs46xx *chip, in snd_cs46xx_download() argument
315 dst = chip->region.idx[bank+1].remap_addr + offset; in snd_cs46xx_download()
382 static int load_firmware(struct snd_cs46xx *chip, in load_firmware() argument
394 err = request_firmware(&fw, fw_path, &chip->pci->dev); in load_firmware()
468 int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip, in snd_cs46xx_clear_BA1() argument
478 dst = chip->region.idx[bank+1].remap_addr + offset; in snd_cs46xx_clear_BA1()
501 static int load_firmware(struct snd_cs46xx *chip) in load_firmware() argument
506 err = request_firmware(&fw, "cs46xx/ba1", &chip->pci->dev); in load_firmware()
509 if (fw->size != sizeof(*chip->ba1)) { in load_firmware()
514 chip->ba1 = vmalloc(sizeof(*chip->ba1)); in load_firmware()
515 if (!chip->ba1) { in load_firmware()
520 memcpy_le32(chip->ba1, fw->data, sizeof(*chip->ba1)); in load_firmware()
525 size += chip->ba1->memory[i].size; in load_firmware()
534 int snd_cs46xx_download_image(struct snd_cs46xx *chip) in snd_cs46xx_download_image() argument
538 struct ba1_struct *ba1 = chip->ba1; in snd_cs46xx_download_image()
541 err = snd_cs46xx_download(chip, in snd_cs46xx_download_image()
554 * Chip reset
557 static void snd_cs46xx_reset(struct snd_cs46xx *chip) in snd_cs46xx_reset() argument
564 snd_cs46xx_poke(chip, BA1_SPCR, SPCR_RSTSP); in snd_cs46xx_reset()
569 snd_cs46xx_poke(chip, BA1_SPCR, SPCR_DRQEN); in snd_cs46xx_reset()
575 snd_cs46xx_poke(chip, BA1_DREG, DREG_REGID_TRAP_SELECT + idx); in snd_cs46xx_reset()
576 snd_cs46xx_poke(chip, BA1_TWPR, 0xFFFF); in snd_cs46xx_reset()
578 snd_cs46xx_poke(chip, BA1_DREG, 0); in snd_cs46xx_reset()
583 snd_cs46xx_poke(chip, BA1_FRMT, 0xadf); in snd_cs46xx_reset()
586 static int cs46xx_wait_for_fifo(struct snd_cs46xx * chip,int retry_timeout) in cs46xx_wait_for_fifo() argument
593 status = snd_cs46xx_peekBA0(chip, BA0_SERBST); in cs46xx_wait_for_fifo()
602 dev_err(chip->card->dev, in cs46xx_wait_for_fifo()
610 static void snd_cs46xx_clear_serial_FIFOs(struct snd_cs46xx *chip) in snd_cs46xx_clear_serial_FIFOs() argument
619 tmp = snd_cs46xx_peekBA0(chip, BA0_CLKCR1); in snd_cs46xx_clear_serial_FIFOs()
621 snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, tmp | CLKCR1_SWCE); in snd_cs46xx_clear_serial_FIFOs()
630 snd_cs46xx_pokeBA0(chip, BA0_SERBWP, 0); in snd_cs46xx_clear_serial_FIFOs()
639 if (cs46xx_wait_for_fifo(chip,1)) { in snd_cs46xx_clear_serial_FIFOs()
640 dev_dbg(chip->card->dev, in snd_cs46xx_clear_serial_FIFOs()
645 snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, tmp); in snd_cs46xx_clear_serial_FIFOs()
652 snd_cs46xx_pokeBA0(chip, BA0_SERBAD, idx); in snd_cs46xx_clear_serial_FIFOs()
656 snd_cs46xx_pokeBA0(chip, BA0_SERBCM, SERBCM_WRC); in snd_cs46xx_clear_serial_FIFOs()
663 snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, tmp); in snd_cs46xx_clear_serial_FIFOs()
666 static void snd_cs46xx_proc_start(struct snd_cs46xx *chip) in snd_cs46xx_proc_start() argument
673 snd_cs46xx_poke(chip, BA1_FRMT, 0xadf); in snd_cs46xx_proc_start()
678 snd_cs46xx_poke(chip, BA1_SPCR, SPCR_RUN | SPCR_RUNFR | SPCR_DRQEN); in snd_cs46xx_proc_start()
685 if (!(snd_cs46xx_peek(chip, BA1_SPCR) & SPCR_RUNFR)) in snd_cs46xx_proc_start()
689 if (snd_cs46xx_peek(chip, BA1_SPCR) & SPCR_RUNFR) in snd_cs46xx_proc_start()
690 dev_err(chip->card->dev, "SPCR_RUNFR never reset\n"); in snd_cs46xx_proc_start()
693 static void snd_cs46xx_proc_stop(struct snd_cs46xx *chip) in snd_cs46xx_proc_stop() argument
699 snd_cs46xx_poke(chip, BA1_SPCR, 0); in snd_cs46xx_proc_stop()
708 static void snd_cs46xx_set_play_sample_rate(struct snd_cs46xx *chip, unsigned int rate) in snd_cs46xx_set_play_sample_rate() argument
747 spin_lock_irqsave(&chip->reg_lock, flags); in snd_cs46xx_set_play_sample_rate()
748 snd_cs46xx_poke(chip, BA1_PSRC, in snd_cs46xx_set_play_sample_rate()
750 snd_cs46xx_poke(chip, BA1_PPI, phiIncr); in snd_cs46xx_set_play_sample_rate()
751 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_cs46xx_set_play_sample_rate()
754 static void snd_cs46xx_set_capture_sample_rate(struct snd_cs46xx *chip, unsigned int rate) in snd_cs46xx_set_capture_sample_rate() argument
821 spin_lock_irqsave(&chip->reg_lock, flags); in snd_cs46xx_set_capture_sample_rate()
822 snd_cs46xx_poke(chip, BA1_CSRC, in snd_cs46xx_set_capture_sample_rate()
824 snd_cs46xx_poke(chip, BA1_CCI, coeffIncr); in snd_cs46xx_set_capture_sample_rate()
825 snd_cs46xx_poke(chip, BA1_CD, in snd_cs46xx_set_capture_sample_rate()
827 snd_cs46xx_poke(chip, BA1_CPI, phiIncr); in snd_cs46xx_set_capture_sample_rate()
828 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_cs46xx_set_capture_sample_rate()
851 spin_lock_irqsave(&chip->reg_lock, flags); in snd_cs46xx_set_capture_sample_rate()
852 snd_cs46xx_poke(chip, BA1_CFG1, frameGroupLength); in snd_cs46xx_set_capture_sample_rate()
853 snd_cs46xx_poke(chip, BA1_CFG2, (0x00800000 | frameGroupLength)); in snd_cs46xx_set_capture_sample_rate()
854 snd_cs46xx_poke(chip, BA1_CCST, 0x0000FFFF); in snd_cs46xx_set_capture_sample_rate()
855 snd_cs46xx_poke(chip, BA1_CSPB, ((65536 * rate) / 24000)); in snd_cs46xx_set_capture_sample_rate()
856 snd_cs46xx_poke(chip, (BA1_CSPB + 4), 0x0000FFFF); in snd_cs46xx_set_capture_sample_rate()
857 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_cs46xx_set_capture_sample_rate()
883 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_cp_trans_copy() local
886 chip->capt.hw_buf.area + rec->hw_data, bytes); in snd_cs46xx_cp_trans_copy()
891 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_capture_transfer() local
892 return snd_pcm_indirect_capture_transfer(substream, &chip->capt.pcm_rec, in snd_cs46xx_capture_transfer()
898 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_playback_direct_pointer() local
906 ptr = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 2) << 2); in snd_cs46xx_playback_direct_pointer()
908 ptr = snd_cs46xx_peek(chip, BA1_PBA); in snd_cs46xx_playback_direct_pointer()
916 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_playback_indirect_pointer() local
923 ptr = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 2) << 2); in snd_cs46xx_playback_indirect_pointer()
925 ptr = snd_cs46xx_peek(chip, BA1_PBA); in snd_cs46xx_playback_indirect_pointer()
933 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_capture_direct_pointer() local
934 size_t ptr = snd_cs46xx_peek(chip, BA1_CBA) - chip->capt.hw_buf.addr; in snd_cs46xx_capture_direct_pointer()
935 return ptr >> chip->capt.shift; in snd_cs46xx_capture_direct_pointer()
940 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_capture_indirect_pointer() local
941 size_t ptr = snd_cs46xx_peek(chip, BA1_CBA) - chip->capt.hw_buf.addr; in snd_cs46xx_capture_indirect_pointer()
942 return snd_pcm_indirect_capture_pointer(substream, &chip->capt.pcm_rec, ptr); in snd_cs46xx_capture_indirect_pointer()
948 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_playback_trigger() local
963 snd_cs46xx_poke(chip, (cpcm->pcm_channel->pcm_reader_scb->address + in snd_cs46xx_playback_trigger()
967 cs46xx_dsp_pcm_link(chip,cpcm->pcm_channel); in snd_cs46xx_playback_trigger()
972 spin_lock(&chip->reg_lock); in snd_cs46xx_playback_trigger()
976 tmp = snd_cs46xx_peek(chip, BA1_PCTL); in snd_cs46xx_playback_trigger()
978 snd_cs46xx_poke(chip, BA1_PCTL, chip->play_ctl | tmp); in snd_cs46xx_playback_trigger()
980 spin_unlock(&chip->reg_lock); in snd_cs46xx_playback_trigger()
987 snd_cs46xx_poke(chip, (cpcm->pcm_channel->pcm_reader_scb->address + in snd_cs46xx_playback_trigger()
991 cs46xx_dsp_pcm_unlink(chip,cpcm->pcm_channel); in snd_cs46xx_playback_trigger()
993 spin_lock(&chip->reg_lock); in snd_cs46xx_playback_trigger()
995 tmp = snd_cs46xx_peek(chip, BA1_PCTL); in snd_cs46xx_playback_trigger()
997 snd_cs46xx_poke(chip, BA1_PCTL, tmp); in snd_cs46xx_playback_trigger()
999 spin_unlock(&chip->reg_lock); in snd_cs46xx_playback_trigger()
1013 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_capture_trigger() local
1017 spin_lock(&chip->reg_lock); in snd_cs46xx_capture_trigger()
1021 tmp = snd_cs46xx_peek(chip, BA1_CCTL); in snd_cs46xx_capture_trigger()
1023 snd_cs46xx_poke(chip, BA1_CCTL, chip->capt.ctl | tmp); in snd_cs46xx_capture_trigger()
1027 tmp = snd_cs46xx_peek(chip, BA1_CCTL); in snd_cs46xx_capture_trigger()
1029 snd_cs46xx_poke(chip, BA1_CCTL, tmp); in snd_cs46xx_capture_trigger()
1035 spin_unlock(&chip->reg_lock); in snd_cs46xx_capture_trigger()
1041 static int _cs46xx_adjust_sample_rate (struct snd_cs46xx *chip, struct snd_cs46xx_pcm *cpcm, in _cs46xx_adjust_sample_rate() argument
1047 cpcm->pcm_channel = cs46xx_dsp_create_pcm_channel (chip, sample_rate, in _cs46xx_adjust_sample_rate()
1050 dev_err(chip->card->dev, in _cs46xx_adjust_sample_rate()
1059 cs46xx_dsp_destroy_pcm_channel (chip,cpcm->pcm_channel); in _cs46xx_adjust_sample_rate()
1061 if ( (cpcm->pcm_channel = cs46xx_dsp_create_pcm_channel (chip, sample_rate, cpcm, in _cs46xx_adjust_sample_rate()
1064 dev_err(chip->card->dev, in _cs46xx_adjust_sample_rate()
1069 if (!unlinked) cs46xx_dsp_pcm_link (chip,cpcm->pcm_channel); in _cs46xx_adjust_sample_rate()
1085 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_playback_hw_params() local
1095 mutex_lock(&chip->spos_mutex); in snd_cs46xx_playback_hw_params()
1097 if (_cs46xx_adjust_sample_rate (chip,cpcm,sample_rate)) { in snd_cs46xx_playback_hw_params()
1098 mutex_unlock(&chip->spos_mutex); in snd_cs46xx_playback_hw_params()
1104 mutex_unlock(&chip->spos_mutex); in snd_cs46xx_playback_hw_params()
1109 if (cs46xx_dsp_pcm_channel_set_period (chip,cpcm->pcm_channel,period_size)) { in snd_cs46xx_playback_hw_params()
1110 mutex_unlock(&chip->spos_mutex); in snd_cs46xx_playback_hw_params()
1114 dev_dbg(chip->card->dev, in snd_cs46xx_playback_hw_params()
1152 mutex_unlock(&chip->spos_mutex); in snd_cs46xx_playback_hw_params()
1176 mutex_unlock(&chip->spos_mutex); in snd_cs46xx_playback_hw_params()
1184 /*struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);*/ in snd_cs46xx_playback_hw_free()
1208 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_playback_prepare() local
1218 pfie = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 1) << 2 ); in snd_cs46xx_playback_prepare()
1222 pfie = snd_cs46xx_peek(chip, BA1_PFIE); in snd_cs46xx_playback_prepare()
1254 tmp = snd_cs46xx_peek(chip, (cpcm->pcm_channel->pcm_reader_scb->address) << 2); in snd_cs46xx_playback_prepare()
1258 snd_cs46xx_poke(chip, (cpcm->pcm_channel->pcm_reader_scb->address) << 2, tmp); in snd_cs46xx_playback_prepare()
1261 …snd_cs46xx_poke(chip, (cpcm->pcm_channel->pcm_reader_scb->address + 1) << 2, pfie | cpcm->pcm_chan… in snd_cs46xx_playback_prepare()
1263 snd_cs46xx_poke(chip, BA1_PBA, cpcm->hw_buf.addr); in snd_cs46xx_playback_prepare()
1264 tmp = snd_cs46xx_peek(chip, BA1_PDTC); in snd_cs46xx_playback_prepare()
1267 snd_cs46xx_poke(chip, BA1_PDTC, tmp); in snd_cs46xx_playback_prepare()
1268 snd_cs46xx_poke(chip, BA1_PFIE, pfie); in snd_cs46xx_playback_prepare()
1269 snd_cs46xx_set_play_sample_rate(chip, runtime->rate); in snd_cs46xx_playback_prepare()
1278 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_capture_hw_params() local
1283 cs46xx_dsp_pcm_ostream_set_period (chip, params_period_bytes(hw_params)); in snd_cs46xx_capture_hw_params()
1286 if (runtime->dma_area != chip->capt.hw_buf.area) in snd_cs46xx_capture_hw_params()
1288 runtime->dma_area = chip->capt.hw_buf.area; in snd_cs46xx_capture_hw_params()
1289 runtime->dma_addr = chip->capt.hw_buf.addr; in snd_cs46xx_capture_hw_params()
1290 runtime->dma_bytes = chip->capt.hw_buf.bytes; in snd_cs46xx_capture_hw_params()
1293 if (runtime->dma_area == chip->capt.hw_buf.area) { in snd_cs46xx_capture_hw_params()
1308 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_capture_hw_free() local
1311 if (runtime->dma_area != chip->capt.hw_buf.area) in snd_cs46xx_capture_hw_free()
1322 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_capture_prepare() local
1325 snd_cs46xx_poke(chip, BA1_CBA, chip->capt.hw_buf.addr); in snd_cs46xx_capture_prepare()
1326 chip->capt.shift = 2; in snd_cs46xx_capture_prepare()
1327 memset(&chip->capt.pcm_rec, 0, sizeof(chip->capt.pcm_rec)); in snd_cs46xx_capture_prepare()
1328 chip->capt.pcm_rec.sw_buffer_size = snd_pcm_lib_buffer_bytes(substream); in snd_cs46xx_capture_prepare()
1329 chip->capt.pcm_rec.hw_buffer_size = runtime->period_size * CS46XX_FRAGS << 2; in snd_cs46xx_capture_prepare()
1330 snd_cs46xx_set_capture_sample_rate(chip, runtime->rate); in snd_cs46xx_capture_prepare()
1337 struct snd_cs46xx *chip = dev_id; in snd_cs46xx_interrupt() local
1340 struct dsp_spos_instance * ins = chip->dsp_spos_instance; in snd_cs46xx_interrupt()
1349 status1 = snd_cs46xx_peekBA0(chip, BA0_HISR); in snd_cs46xx_interrupt()
1351 snd_cs46xx_pokeBA0(chip, BA0_HICR, HICR_CHGM | HICR_IEV); in snd_cs46xx_interrupt()
1356 status2 = snd_cs46xx_peekBA0(chip, BA0_HSR0); in snd_cs46xx_interrupt()
1362 if (chip->capt.substream) in snd_cs46xx_interrupt()
1363 snd_pcm_period_elapsed(chip->capt.substream); in snd_cs46xx_interrupt()
1387 if ((status1 & HISR_VC0) && chip->playback_pcm) { in snd_cs46xx_interrupt()
1388 if (chip->playback_pcm->substream) in snd_cs46xx_interrupt()
1389 snd_pcm_period_elapsed(chip->playback_pcm->substream); in snd_cs46xx_interrupt()
1391 if ((status1 & HISR_VC1) && chip->pcm) { in snd_cs46xx_interrupt()
1392 if (chip->capt.substream) in snd_cs46xx_interrupt()
1393 snd_pcm_period_elapsed(chip->capt.substream); in snd_cs46xx_interrupt()
1397 if ((status1 & HISR_MIDI) && chip->rmidi) { in snd_cs46xx_interrupt()
1400 spin_lock(&chip->reg_lock); in snd_cs46xx_interrupt()
1401 while ((snd_cs46xx_peekBA0(chip, BA0_MIDSR) & MIDSR_RBE) == 0) { in snd_cs46xx_interrupt()
1402 c = snd_cs46xx_peekBA0(chip, BA0_MIDRP); in snd_cs46xx_interrupt()
1403 if ((chip->midcr & MIDCR_RIE) == 0) in snd_cs46xx_interrupt()
1405 snd_rawmidi_receive(chip->midi_input, &c, 1); in snd_cs46xx_interrupt()
1407 while ((snd_cs46xx_peekBA0(chip, BA0_MIDSR) & MIDSR_TBF) == 0) { in snd_cs46xx_interrupt()
1408 if ((chip->midcr & MIDCR_TIE) == 0) in snd_cs46xx_interrupt()
1410 if (snd_rawmidi_transmit(chip->midi_output, &c, 1) != 1) { in snd_cs46xx_interrupt()
1411 chip->midcr &= ~MIDCR_TIE; in snd_cs46xx_interrupt()
1412 snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); in snd_cs46xx_interrupt()
1415 snd_cs46xx_pokeBA0(chip, BA0_MIDWP, c); in snd_cs46xx_interrupt()
1417 spin_unlock(&chip->reg_lock); in snd_cs46xx_interrupt()
1422 snd_cs46xx_pokeBA0(chip, BA0_HICR, HICR_CHGM | HICR_IEV); in snd_cs46xx_interrupt()
1490 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in _cs46xx_playback_open_channel() local
1497 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), in _cs46xx_playback_open_channel()
1509 mutex_lock(&chip->spos_mutex); in _cs46xx_playback_open_channel()
1518 mutex_unlock(&chip->spos_mutex); in _cs46xx_playback_open_channel()
1520 chip->playback_pcm = cpcm; /* HACK */ in _cs46xx_playback_open_channel()
1523 if (chip->accept_valid) in _cs46xx_playback_open_channel()
1525 chip->active_ctrl(chip, 1); in _cs46xx_playback_open_channel()
1551 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_playback_open_iec958() local
1553 dev_dbg(chip->card->dev, "open raw iec958 channel\n"); in snd_cs46xx_playback_open_iec958()
1555 mutex_lock(&chip->spos_mutex); in snd_cs46xx_playback_open_iec958()
1556 cs46xx_iec958_pre_open (chip); in snd_cs46xx_playback_open_iec958()
1557 mutex_unlock(&chip->spos_mutex); in snd_cs46xx_playback_open_iec958()
1567 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_playback_close_iec958() local
1569 dev_dbg(chip->card->dev, "close raw iec958 channel\n"); in snd_cs46xx_playback_close_iec958()
1573 mutex_lock(&chip->spos_mutex); in snd_cs46xx_playback_close_iec958()
1574 cs46xx_iec958_post_close (chip); in snd_cs46xx_playback_close_iec958()
1575 mutex_unlock(&chip->spos_mutex); in snd_cs46xx_playback_close_iec958()
1583 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_capture_open() local
1585 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), in snd_cs46xx_capture_open()
1586 PAGE_SIZE, &chip->capt.hw_buf) < 0) in snd_cs46xx_capture_open()
1588 chip->capt.substream = substream; in snd_cs46xx_capture_open()
1591 if (chip->accept_valid) in snd_cs46xx_capture_open()
1594 chip->active_ctrl(chip, 1); in snd_cs46xx_capture_open()
1606 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_playback_close() local
1616 mutex_lock(&chip->spos_mutex); in snd_cs46xx_playback_close()
1618 cs46xx_dsp_destroy_pcm_channel(chip,cpcm->pcm_channel); in snd_cs46xx_playback_close()
1621 mutex_unlock(&chip->spos_mutex); in snd_cs46xx_playback_close()
1623 chip->playback_pcm = NULL; in snd_cs46xx_playback_close()
1628 chip->active_ctrl(chip, -1); in snd_cs46xx_playback_close()
1635 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); in snd_cs46xx_capture_close() local
1637 chip->capt.substream = NULL; in snd_cs46xx_capture_close()
1638 snd_dma_free_pages(&chip->capt.hw_buf); in snd_cs46xx_capture_close()
1639 chip->active_ctrl(chip, -1); in snd_cs46xx_capture_close()
1768 int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device) in snd_cs46xx_pcm() argument
1773 if ((err = snd_pcm_new(chip->card, "CS46xx", device, MAX_PLAYBACK_CHANNELS, 1, &pcm)) < 0) in snd_cs46xx_pcm()
1776 pcm->private_data = chip; in snd_cs46xx_pcm()
1784 chip->pcm = pcm; in snd_cs46xx_pcm()
1787 snd_dma_pci_data(chip->pci), 64*1024, 256*1024); in snd_cs46xx_pcm()
1794 int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device) in snd_cs46xx_pcm_rear() argument
1799 if ((err = snd_pcm_new(chip->card, "CS46xx - Rear", device, MAX_PLAYBACK_CHANNELS, 0, &pcm)) < 0) in snd_cs46xx_pcm_rear()
1802 pcm->private_data = chip; in snd_cs46xx_pcm_rear()
1809 chip->pcm_rear = pcm; in snd_cs46xx_pcm_rear()
1812 snd_dma_pci_data(chip->pci), 64*1024, 256*1024); in snd_cs46xx_pcm_rear()
1817 int snd_cs46xx_pcm_center_lfe(struct snd_cs46xx *chip, int device) in snd_cs46xx_pcm_center_lfe() argument
1822 …if ((err = snd_pcm_new(chip->card, "CS46xx - Center LFE", device, MAX_PLAYBACK_CHANNELS, 0, &pcm))… in snd_cs46xx_pcm_center_lfe()
1825 pcm->private_data = chip; in snd_cs46xx_pcm_center_lfe()
1832 chip->pcm_center_lfe = pcm; in snd_cs46xx_pcm_center_lfe()
1835 snd_dma_pci_data(chip->pci), 64*1024, 256*1024); in snd_cs46xx_pcm_center_lfe()
1840 int snd_cs46xx_pcm_iec958(struct snd_cs46xx *chip, int device) in snd_cs46xx_pcm_iec958() argument
1845 if ((err = snd_pcm_new(chip->card, "CS46xx - IEC958", device, 1, 0, &pcm)) < 0) in snd_cs46xx_pcm_iec958()
1848 pcm->private_data = chip; in snd_cs46xx_pcm_iec958()
1855 chip->pcm_iec958 = pcm; in snd_cs46xx_pcm_iec958()
1858 snd_dma_pci_data(chip->pci), 64*1024, 256*1024); in snd_cs46xx_pcm_iec958()
1869 struct snd_cs46xx *chip = bus->private_data; in snd_cs46xx_mixer_free_ac97_bus() local
1871 chip->ac97_bus = NULL; in snd_cs46xx_mixer_free_ac97_bus()
1876 struct snd_cs46xx *chip = ac97->private_data; in snd_cs46xx_mixer_free_ac97() local
1878 if (snd_BUG_ON(ac97 != chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] && in snd_cs46xx_mixer_free_ac97()
1879 ac97 != chip->ac97[CS46XX_SECONDARY_CODEC_INDEX])) in snd_cs46xx_mixer_free_ac97()
1882 if (ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]) { in snd_cs46xx_mixer_free_ac97()
1883 chip->ac97[CS46XX_PRIMARY_CODEC_INDEX] = NULL; in snd_cs46xx_mixer_free_ac97()
1884 chip->eapd_switch = NULL; in snd_cs46xx_mixer_free_ac97()
1887 chip->ac97[CS46XX_SECONDARY_CODEC_INDEX] = NULL; in snd_cs46xx_mixer_free_ac97()
1902 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_vol_get() local
1904 unsigned int val = snd_cs46xx_peek(chip, reg); in snd_cs46xx_vol_get()
1912 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_vol_put() local
1916 unsigned int old = snd_cs46xx_peek(chip, reg); in snd_cs46xx_vol_put()
1920 snd_cs46xx_poke(chip, reg, val); in snd_cs46xx_vol_put()
1930 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_vol_dac_get() local
1932 ucontrol->value.integer.value[0] = chip->dsp_spos_instance->dac_volume_left; in snd_cs46xx_vol_dac_get()
1933 ucontrol->value.integer.value[1] = chip->dsp_spos_instance->dac_volume_right; in snd_cs46xx_vol_dac_get()
1940 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_vol_dac_put() local
1943 if (chip->dsp_spos_instance->dac_volume_right != ucontrol->value.integer.value[0] || in snd_cs46xx_vol_dac_put()
1944 chip->dsp_spos_instance->dac_volume_left != ucontrol->value.integer.value[1]) { in snd_cs46xx_vol_dac_put()
1945 cs46xx_dsp_set_dac_volume(chip, in snd_cs46xx_vol_dac_put()
1957 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol);
1959 ucontrol->value.integer.value[0] = chip->dsp_spos_instance->spdif_input_volume_left;
1960 ucontrol->value.integer.value[1] = chip->dsp_spos_instance->spdif_input_volume_right;
1966 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol);
1969 if (chip->dsp_spos_instance->spdif_input_volume_left != ucontrol->value.integer.value[0] ||
1970 chip->dsp_spos_instance->spdif_input_volume_right!= ucontrol->value.integer.value[1]) {
1971 cs46xx_dsp_set_iec958_volume (chip,
1986 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_iec958_get() local
1990 …ucontrol->value.integer.value[0] = (chip->dsp_spos_instance->spdif_status_out & DSP_SPDIF_STATUS_O… in snd_cs46xx_iec958_get()
1992 ucontrol->value.integer.value[0] = chip->dsp_spos_instance->spdif_status_in; in snd_cs46xx_iec958_get()
2000 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_iec958_put() local
2005 mutex_lock(&chip->spos_mutex); in snd_cs46xx_iec958_put()
2006 change = (chip->dsp_spos_instance->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED); in snd_cs46xx_iec958_put()
2008 cs46xx_dsp_enable_spdif_out(chip); in snd_cs46xx_iec958_put()
2010 cs46xx_dsp_disable_spdif_out(chip); in snd_cs46xx_iec958_put()
2012 res = (change != (chip->dsp_spos_instance->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED)); in snd_cs46xx_iec958_put()
2013 mutex_unlock(&chip->spos_mutex); in snd_cs46xx_iec958_put()
2016 change = chip->dsp_spos_instance->spdif_status_in; in snd_cs46xx_iec958_put()
2018 cs46xx_dsp_enable_spdif_in(chip); in snd_cs46xx_iec958_put()
2022 cs46xx_dsp_disable_spdif_in(chip); in snd_cs46xx_iec958_put()
2024 res = (change != chip->dsp_spos_instance->spdif_status_in); in snd_cs46xx_iec958_put()
2037 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_adc_capture_get() local
2038 struct dsp_spos_instance * ins = chip->dsp_spos_instance; in snd_cs46xx_adc_capture_get()
2051 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_adc_capture_put() local
2052 struct dsp_spos_instance * ins = chip->dsp_spos_instance; in snd_cs46xx_adc_capture_put()
2056 cs46xx_dsp_enable_adc_capture(chip); in snd_cs46xx_adc_capture_put()
2059 cs46xx_dsp_disable_adc_capture(chip); in snd_cs46xx_adc_capture_put()
2068 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_pcm_capture_get() local
2069 struct dsp_spos_instance * ins = chip->dsp_spos_instance; in snd_cs46xx_pcm_capture_get()
2083 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_pcm_capture_put() local
2084 struct dsp_spos_instance * ins = chip->dsp_spos_instance; in snd_cs46xx_pcm_capture_put()
2088 cs46xx_dsp_enable_pcm_capture(chip); in snd_cs46xx_pcm_capture_put()
2091 cs46xx_dsp_disable_pcm_capture(chip); in snd_cs46xx_pcm_capture_put()
2101 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_herc_spdif_select_get() local
2103 int val1 = snd_cs46xx_peekBA0(chip, BA0_EGPIODR); in snd_herc_spdif_select_get()
2119 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_herc_spdif_select_put() local
2120 int val1 = snd_cs46xx_peekBA0(chip, BA0_EGPIODR); in snd_herc_spdif_select_put()
2121 int val2 = snd_cs46xx_peekBA0(chip, BA0_EGPIOPTR); in snd_herc_spdif_select_put()
2125 snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, in snd_herc_spdif_select_put()
2127 snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, in snd_herc_spdif_select_put()
2131 snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, val1 & ~EGPIODR_GPOE0); /* disable */ in snd_herc_spdif_select_put()
2132 snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, val2 & ~EGPIOPTR_GPPT0); /* disable */ in snd_herc_spdif_select_put()
2137 return (val1 != (int)snd_cs46xx_peekBA0(chip, BA0_EGPIODR)); in snd_herc_spdif_select_put()
2151 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_spdif_default_get() local
2152 struct dsp_spos_instance * ins = chip->dsp_spos_instance; in snd_cs46xx_spdif_default_get()
2154 mutex_lock(&chip->spos_mutex); in snd_cs46xx_spdif_default_get()
2159 mutex_unlock(&chip->spos_mutex); in snd_cs46xx_spdif_default_get()
2167 struct snd_cs46xx * chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_spdif_default_put() local
2168 struct dsp_spos_instance * ins = chip->dsp_spos_instance; in snd_cs46xx_spdif_default_put()
2172 mutex_lock(&chip->spos_mutex); in snd_cs46xx_spdif_default_put()
2184 cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV,val); in snd_cs46xx_spdif_default_put()
2186 mutex_unlock(&chip->spos_mutex); in snd_cs46xx_spdif_default_put()
2204 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_spdif_stream_get() local
2205 struct dsp_spos_instance * ins = chip->dsp_spos_instance; in snd_cs46xx_spdif_stream_get()
2207 mutex_lock(&chip->spos_mutex); in snd_cs46xx_spdif_stream_get()
2212 mutex_unlock(&chip->spos_mutex); in snd_cs46xx_spdif_stream_get()
2220 struct snd_cs46xx * chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_spdif_stream_put() local
2221 struct dsp_spos_instance * ins = chip->dsp_spos_instance; in snd_cs46xx_spdif_stream_put()
2225 mutex_lock(&chip->spos_mutex); in snd_cs46xx_spdif_stream_put()
2237 cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV,val); in snd_cs46xx_spdif_stream_put()
2239 mutex_unlock(&chip->spos_mutex); in snd_cs46xx_spdif_stream_put()
2346 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_front_dup_get() local
2348 val = snd_ac97_read(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX], AC97_CSR_ACMODE); in snd_cs46xx_front_dup_get()
2356 struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); in snd_cs46xx_front_dup_put() local
2357 return snd_ac97_update_bits(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX], in snd_cs46xx_front_dup_put()
2434 static int cs46xx_detect_codec(struct snd_cs46xx *chip, int codec) in cs46xx_detect_codec() argument
2440 ac97.private_data = chip; in cs46xx_detect_codec()
2443 if (chip->amplifier_ctrl == amp_voyetra) in cs46xx_detect_codec()
2447 snd_cs46xx_codec_write(chip, AC97_RESET, 0, codec); in cs46xx_detect_codec()
2449 if (snd_cs46xx_codec_read(chip, AC97_RESET, codec) & 0x8000) { in cs46xx_detect_codec()
2450 dev_dbg(chip->card->dev, in cs46xx_detect_codec()
2456 snd_cs46xx_codec_write(chip, AC97_MASTER, 0x8000, codec); in cs46xx_detect_codec()
2458 if (snd_cs46xx_codec_read(chip, AC97_MASTER, codec) == 0x8000) { in cs46xx_detect_codec()
2459 err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97[codec]); in cs46xx_detect_codec()
2464 dev_dbg(chip->card->dev, "codec %d detection timeout\n", codec); in cs46xx_detect_codec()
2468 int snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device) in snd_cs46xx_mixer() argument
2470 struct snd_card *card = chip->card; in snd_cs46xx_mixer()
2483 chip->nr_ac97_codecs = 0; in snd_cs46xx_mixer()
2484 dev_dbg(chip->card->dev, "detecting primary codec\n"); in snd_cs46xx_mixer()
2485 if ((err = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus)) < 0) in snd_cs46xx_mixer()
2487 chip->ac97_bus->private_free = snd_cs46xx_mixer_free_ac97_bus; in snd_cs46xx_mixer()
2489 if (cs46xx_detect_codec(chip, CS46XX_PRIMARY_CODEC_INDEX) < 0) in snd_cs46xx_mixer()
2491 chip->nr_ac97_codecs = 1; in snd_cs46xx_mixer()
2494 dev_dbg(chip->card->dev, "detecting secondary codec\n"); in snd_cs46xx_mixer()
2496 if (! cs46xx_detect_codec(chip, CS46XX_SECONDARY_CODEC_INDEX)) in snd_cs46xx_mixer()
2497 chip->nr_ac97_codecs = 2; in snd_cs46xx_mixer()
2503 kctl = snd_ctl_new1(&snd_cs46xx_controls[idx], chip); in snd_cs46xx_mixer()
2514 chip->eapd_switch = snd_ctl_find_id(chip->card, &id); in snd_cs46xx_mixer()
2517 if (chip->nr_ac97_codecs == 1) { in snd_cs46xx_mixer()
2518 unsigned int id2 = chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]->id & 0xffff; in snd_cs46xx_mixer()
2520 err = snd_ctl_add(card, snd_ctl_new1(&snd_cs46xx_front_dup_ctl, chip)); in snd_cs46xx_mixer()
2523 snd_ac97_write_cache(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX], in snd_cs46xx_mixer()
2528 if (chip->mixer_init) { in snd_cs46xx_mixer()
2529 dev_dbg(chip->card->dev, "calling chip->mixer_init(chip);\n"); in snd_cs46xx_mixer()
2530 chip->mixer_init(chip); in snd_cs46xx_mixer()
2535 chip->amplifier_ctrl(chip, 1); in snd_cs46xx_mixer()
2544 static void snd_cs46xx_midi_reset(struct snd_cs46xx *chip) in snd_cs46xx_midi_reset() argument
2546 snd_cs46xx_pokeBA0(chip, BA0_MIDCR, MIDCR_MRST); in snd_cs46xx_midi_reset()
2548 snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); in snd_cs46xx_midi_reset()
2553 struct snd_cs46xx *chip = substream->rmidi->private_data; in snd_cs46xx_midi_input_open() local
2555 chip->active_ctrl(chip, 1); in snd_cs46xx_midi_input_open()
2556 spin_lock_irq(&chip->reg_lock); in snd_cs46xx_midi_input_open()
2557 chip->uartm |= CS46XX_MODE_INPUT; in snd_cs46xx_midi_input_open()
2558 chip->midcr |= MIDCR_RXE; in snd_cs46xx_midi_input_open()
2559 chip->midi_input = substream; in snd_cs46xx_midi_input_open()
2560 if (!(chip->uartm & CS46XX_MODE_OUTPUT)) { in snd_cs46xx_midi_input_open()
2561 snd_cs46xx_midi_reset(chip); in snd_cs46xx_midi_input_open()
2563 snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); in snd_cs46xx_midi_input_open()
2565 spin_unlock_irq(&chip->reg_lock); in snd_cs46xx_midi_input_open()
2571 struct snd_cs46xx *chip = substream->rmidi->private_data; in snd_cs46xx_midi_input_close() local
2573 spin_lock_irq(&chip->reg_lock); in snd_cs46xx_midi_input_close()
2574 chip->midcr &= ~(MIDCR_RXE | MIDCR_RIE); in snd_cs46xx_midi_input_close()
2575 chip->midi_input = NULL; in snd_cs46xx_midi_input_close()
2576 if (!(chip->uartm & CS46XX_MODE_OUTPUT)) { in snd_cs46xx_midi_input_close()
2577 snd_cs46xx_midi_reset(chip); in snd_cs46xx_midi_input_close()
2579 snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); in snd_cs46xx_midi_input_close()
2581 chip->uartm &= ~CS46XX_MODE_INPUT; in snd_cs46xx_midi_input_close()
2582 spin_unlock_irq(&chip->reg_lock); in snd_cs46xx_midi_input_close()
2583 chip->active_ctrl(chip, -1); in snd_cs46xx_midi_input_close()
2589 struct snd_cs46xx *chip = substream->rmidi->private_data; in snd_cs46xx_midi_output_open() local
2591 chip->active_ctrl(chip, 1); in snd_cs46xx_midi_output_open()
2593 spin_lock_irq(&chip->reg_lock); in snd_cs46xx_midi_output_open()
2594 chip->uartm |= CS46XX_MODE_OUTPUT; in snd_cs46xx_midi_output_open()
2595 chip->midcr |= MIDCR_TXE; in snd_cs46xx_midi_output_open()
2596 chip->midi_output = substream; in snd_cs46xx_midi_output_open()
2597 if (!(chip->uartm & CS46XX_MODE_INPUT)) { in snd_cs46xx_midi_output_open()
2598 snd_cs46xx_midi_reset(chip); in snd_cs46xx_midi_output_open()
2600 snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); in snd_cs46xx_midi_output_open()
2602 spin_unlock_irq(&chip->reg_lock); in snd_cs46xx_midi_output_open()
2608 struct snd_cs46xx *chip = substream->rmidi->private_data; in snd_cs46xx_midi_output_close() local
2610 spin_lock_irq(&chip->reg_lock); in snd_cs46xx_midi_output_close()
2611 chip->midcr &= ~(MIDCR_TXE | MIDCR_TIE); in snd_cs46xx_midi_output_close()
2612 chip->midi_output = NULL; in snd_cs46xx_midi_output_close()
2613 if (!(chip->uartm & CS46XX_MODE_INPUT)) { in snd_cs46xx_midi_output_close()
2614 snd_cs46xx_midi_reset(chip); in snd_cs46xx_midi_output_close()
2616 snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); in snd_cs46xx_midi_output_close()
2618 chip->uartm &= ~CS46XX_MODE_OUTPUT; in snd_cs46xx_midi_output_close()
2619 spin_unlock_irq(&chip->reg_lock); in snd_cs46xx_midi_output_close()
2620 chip->active_ctrl(chip, -1); in snd_cs46xx_midi_output_close()
2627 struct snd_cs46xx *chip = substream->rmidi->private_data; in snd_cs46xx_midi_input_trigger() local
2629 spin_lock_irqsave(&chip->reg_lock, flags); in snd_cs46xx_midi_input_trigger()
2631 if ((chip->midcr & MIDCR_RIE) == 0) { in snd_cs46xx_midi_input_trigger()
2632 chip->midcr |= MIDCR_RIE; in snd_cs46xx_midi_input_trigger()
2633 snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); in snd_cs46xx_midi_input_trigger()
2636 if (chip->midcr & MIDCR_RIE) { in snd_cs46xx_midi_input_trigger()
2637 chip->midcr &= ~MIDCR_RIE; in snd_cs46xx_midi_input_trigger()
2638 snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); in snd_cs46xx_midi_input_trigger()
2641 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_cs46xx_midi_input_trigger()
2647 struct snd_cs46xx *chip = substream->rmidi->private_data; in snd_cs46xx_midi_output_trigger() local
2650 spin_lock_irqsave(&chip->reg_lock, flags); in snd_cs46xx_midi_output_trigger()
2652 if ((chip->midcr & MIDCR_TIE) == 0) { in snd_cs46xx_midi_output_trigger()
2653 chip->midcr |= MIDCR_TIE; in snd_cs46xx_midi_output_trigger()
2655 while ((chip->midcr & MIDCR_TIE) && in snd_cs46xx_midi_output_trigger()
2656 (snd_cs46xx_peekBA0(chip, BA0_MIDSR) & MIDSR_TBF) == 0) { in snd_cs46xx_midi_output_trigger()
2658 chip->midcr &= ~MIDCR_TIE; in snd_cs46xx_midi_output_trigger()
2660 snd_cs46xx_pokeBA0(chip, BA0_MIDWP, byte); in snd_cs46xx_midi_output_trigger()
2663 snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); in snd_cs46xx_midi_output_trigger()
2666 if (chip->midcr & MIDCR_TIE) { in snd_cs46xx_midi_output_trigger()
2667 chip->midcr &= ~MIDCR_TIE; in snd_cs46xx_midi_output_trigger()
2668 snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); in snd_cs46xx_midi_output_trigger()
2671 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_cs46xx_midi_output_trigger()
2688 int snd_cs46xx_midi(struct snd_cs46xx *chip, int device) in snd_cs46xx_midi() argument
2693 if ((err = snd_rawmidi_new(chip->card, "CS46XX", device, 1, 1, &rmidi)) < 0) in snd_cs46xx_midi()
2699 rmidi->private_data = chip; in snd_cs46xx_midi()
2700 chip->rmidi = rmidi; in snd_cs46xx_midi()
2713 struct snd_cs46xx *chip = gameport_get_port_data(gameport); in snd_cs46xx_gameport_trigger() local
2715 if (snd_BUG_ON(!chip)) in snd_cs46xx_gameport_trigger()
2717 snd_cs46xx_pokeBA0(chip, BA0_JSPT, 0xFF); //outb(gameport->io, 0xFF); in snd_cs46xx_gameport_trigger()
2722 struct snd_cs46xx *chip = gameport_get_port_data(gameport); in snd_cs46xx_gameport_read() local
2724 if (snd_BUG_ON(!chip)) in snd_cs46xx_gameport_read()
2726 return snd_cs46xx_peekBA0(chip, BA0_JSPT); //inb(gameport->io); in snd_cs46xx_gameport_read()
2731 struct snd_cs46xx *chip = gameport_get_port_data(gameport); in snd_cs46xx_gameport_cooked_read() local
2734 if (snd_BUG_ON(!chip)) in snd_cs46xx_gameport_cooked_read()
2737 js1 = snd_cs46xx_peekBA0(chip, BA0_JSC1); in snd_cs46xx_gameport_cooked_read()
2738 js2 = snd_cs46xx_peekBA0(chip, BA0_JSC2); in snd_cs46xx_gameport_cooked_read()
2739 jst = snd_cs46xx_peekBA0(chip, BA0_JSPT); in snd_cs46xx_gameport_cooked_read()
2766 int snd_cs46xx_gameport(struct snd_cs46xx *chip) in snd_cs46xx_gameport() argument
2770 chip->gameport = gp = gameport_allocate_port(); in snd_cs46xx_gameport()
2772 dev_err(chip->card->dev, in snd_cs46xx_gameport()
2778 gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci)); in snd_cs46xx_gameport()
2779 gameport_set_dev_parent(gp, &chip->pci->dev); in snd_cs46xx_gameport()
2780 gameport_set_port_data(gp, chip); in snd_cs46xx_gameport()
2787 snd_cs46xx_pokeBA0(chip, BA0_JSIO, 0xFF); // ? in snd_cs46xx_gameport()
2788 snd_cs46xx_pokeBA0(chip, BA0_JSCTL, JSCTL_SP_MEDIUM_SLOW); in snd_cs46xx_gameport()
2795 static inline void snd_cs46xx_remove_gameport(struct snd_cs46xx *chip) in snd_cs46xx_remove_gameport() argument
2797 if (chip->gameport) { in snd_cs46xx_remove_gameport()
2798 gameport_unregister_port(chip->gameport); in snd_cs46xx_remove_gameport()
2799 chip->gameport = NULL; in snd_cs46xx_remove_gameport()
2803 int snd_cs46xx_gameport(struct snd_cs46xx *chip) { return -ENOSYS; } in snd_cs46xx_gameport() argument
2804 static inline void snd_cs46xx_remove_gameport(struct snd_cs46xx *chip) { } in snd_cs46xx_remove_gameport() argument
2828 static int snd_cs46xx_proc_init(struct snd_card *card, struct snd_cs46xx *chip) in snd_cs46xx_proc_init() argument
2834 struct snd_cs46xx_region *region = &chip->region.idx[idx]; in snd_cs46xx_proc_init()
2837 entry->private_data = chip; in snd_cs46xx_proc_init()
2844 cs46xx_dsp_proc_init(card, chip); in snd_cs46xx_proc_init()
2849 static int snd_cs46xx_proc_done(struct snd_cs46xx *chip) in snd_cs46xx_proc_done() argument
2852 cs46xx_dsp_proc_done(chip); in snd_cs46xx_proc_done()
2857 #define snd_cs46xx_proc_init(card, chip) argument
2858 #define snd_cs46xx_proc_done(chip) argument
2864 static void snd_cs46xx_hw_stop(struct snd_cs46xx *chip) in snd_cs46xx_hw_stop() argument
2868 tmp = snd_cs46xx_peek(chip, BA1_PFIE); in snd_cs46xx_hw_stop()
2871 snd_cs46xx_poke(chip, BA1_PFIE, tmp); /* playback interrupt disable */ in snd_cs46xx_hw_stop()
2873 tmp = snd_cs46xx_peek(chip, BA1_CIE); in snd_cs46xx_hw_stop()
2876 snd_cs46xx_poke(chip, BA1_CIE, tmp); /* capture interrupt disable */ in snd_cs46xx_hw_stop()
2881 tmp = snd_cs46xx_peek(chip, BA1_PCTL); in snd_cs46xx_hw_stop()
2882 snd_cs46xx_poke(chip, BA1_PCTL, tmp & 0x0000ffff); in snd_cs46xx_hw_stop()
2887 tmp = snd_cs46xx_peek(chip, BA1_CCTL); in snd_cs46xx_hw_stop()
2888 snd_cs46xx_poke(chip, BA1_CCTL, tmp & 0xffff0000); in snd_cs46xx_hw_stop()
2893 snd_cs46xx_reset(chip); in snd_cs46xx_hw_stop()
2895 snd_cs46xx_proc_stop(chip); in snd_cs46xx_hw_stop()
2900 snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, 0); in snd_cs46xx_hw_stop()
2906 tmp = snd_cs46xx_peekBA0(chip, BA0_CLKCR1) & ~CLKCR1_SWCE; in snd_cs46xx_hw_stop()
2907 snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, tmp); in snd_cs46xx_hw_stop()
2911 static int snd_cs46xx_free(struct snd_cs46xx *chip) in snd_cs46xx_free() argument
2915 if (snd_BUG_ON(!chip)) in snd_cs46xx_free()
2918 if (chip->active_ctrl) in snd_cs46xx_free()
2919 chip->active_ctrl(chip, 1); in snd_cs46xx_free()
2921 snd_cs46xx_remove_gameport(chip); in snd_cs46xx_free()
2923 if (chip->amplifier_ctrl) in snd_cs46xx_free()
2924 chip->amplifier_ctrl(chip, -chip->amplifier); /* force to off */ in snd_cs46xx_free()
2926 snd_cs46xx_proc_done(chip); in snd_cs46xx_free()
2928 if (chip->region.idx[0].resource) in snd_cs46xx_free()
2929 snd_cs46xx_hw_stop(chip); in snd_cs46xx_free()
2931 if (chip->irq >= 0) in snd_cs46xx_free()
2932 free_irq(chip->irq, chip); in snd_cs46xx_free()
2934 if (chip->active_ctrl) in snd_cs46xx_free()
2935 chip->active_ctrl(chip, -chip->amplifier); in snd_cs46xx_free()
2938 struct snd_cs46xx_region *region = &chip->region.idx[idx]; in snd_cs46xx_free()
2945 if (chip->dsp_spos_instance) { in snd_cs46xx_free()
2946 cs46xx_dsp_spos_destroy(chip); in snd_cs46xx_free()
2947 chip->dsp_spos_instance = NULL; in snd_cs46xx_free()
2950 free_module_desc(chip->modules[idx]); in snd_cs46xx_free()
2952 vfree(chip->ba1); in snd_cs46xx_free()
2956 kfree(chip->saved_regs); in snd_cs46xx_free()
2959 pci_disable_device(chip->pci); in snd_cs46xx_free()
2960 kfree(chip); in snd_cs46xx_free()
2966 struct snd_cs46xx *chip = device->device_data; in snd_cs46xx_dev_free() local
2967 return snd_cs46xx_free(chip); in snd_cs46xx_dev_free()
2971 * initialize chip
2973 static int snd_cs46xx_chip_init(struct snd_cs46xx *chip) in snd_cs46xx_chip_init() argument
2982 snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, 0); in snd_cs46xx_chip_init()
2983 snd_cs46xx_pokeBA0(chip, BA0_SERMC1, 0); in snd_cs46xx_chip_init()
2990 snd_cs46xx_pokeBA0(chip, BA0_SERACC, SERACC_HSP | SERACC_CHIP_TYPE_2_0 | in snd_cs46xx_chip_init()
2992 /* snd_cs46xx_pokeBA0(chip, BA0_SERACC, SERACC_HSP | SERACC_CHIP_TYPE_2_0); */ /* 2.00 codec */ in snd_cs46xx_chip_init()
2994 snd_cs46xx_pokeBA0(chip, BA0_SERACC, SERACC_HSP | SERACC_CHIP_TYPE_1_03); /* 1.03 codec */ in snd_cs46xx_chip_init()
3003 snd_cs46xx_pokeBA0(chip, BA0_ACCTL, 0); in snd_cs46xx_chip_init()
3005 snd_cs46xx_pokeBA0(chip, BA0_ACCTL2, 0); in snd_cs46xx_chip_init()
3008 snd_cs46xx_pokeBA0(chip, BA0_ACCTL, ACCTL_RSTN); in snd_cs46xx_chip_init()
3010 snd_cs46xx_pokeBA0(chip, BA0_ACCTL2, ACCTL_RSTN); in snd_cs46xx_chip_init()
3018 snd_cs46xx_pokeBA0(chip, BA0_ACCTL, ACCTL_ESYN | ACCTL_RSTN); in snd_cs46xx_chip_init()
3020 snd_cs46xx_pokeBA0(chip, BA0_ACCTL2, ACCTL_ESYN | ACCTL_RSTN); in snd_cs46xx_chip_init()
3034 snd_cs46xx_pokeBA0(chip, BA0_SERMC1, SERMC1_PTC_AC97); in snd_cs46xx_chip_init()
3041 snd_cs46xx_pokeBA0(chip, BA0_PLLCC, PLLCC_LPF_1050_2780_KHZ | PLLCC_CDR_73_104_MHZ); in snd_cs46xx_chip_init()
3042 snd_cs46xx_pokeBA0(chip, BA0_PLLM, 0x3a); in snd_cs46xx_chip_init()
3043 snd_cs46xx_pokeBA0(chip, BA0_CLKCR2, CLKCR2_PDIVS_8); in snd_cs46xx_chip_init()
3048 snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, CLKCR1_PLLP); in snd_cs46xx_chip_init()
3058 snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, CLKCR1_PLLP | CLKCR1_SWCE); in snd_cs46xx_chip_init()
3063 snd_cs46xx_pokeBA0(chip, BA0_SERBCF, SERBCF_HBP); in snd_cs46xx_chip_init()
3068 snd_cs46xx_clear_serial_FIFOs(chip); in snd_cs46xx_chip_init()
3073 /* snd_cs46xx_pokeBA0(chip, BA0_SERBSP, 0); */ in snd_cs46xx_chip_init()
3079 snd_cs46xx_pokeBA0(chip, BA0_SERC1, SERC1_SO1F_AC97 | SERC1_SO1EN); in snd_cs46xx_chip_init()
3080 snd_cs46xx_pokeBA0(chip, BA0_SERC2, SERC2_SI1F_AC97 | SERC1_SO1EN); in snd_cs46xx_chip_init()
3081 snd_cs46xx_pokeBA0(chip, BA0_SERMC1, SERMC1_PTC_AC97 | SERMC1_MSPE); in snd_cs46xx_chip_init()
3085 snd_cs46xx_pokeBA0(chip, BA0_SERC7, SERC7_ASDI2EN); in snd_cs46xx_chip_init()
3086 snd_cs46xx_pokeBA0(chip, BA0_SERC3, 0); in snd_cs46xx_chip_init()
3087 snd_cs46xx_pokeBA0(chip, BA0_SERC4, 0); in snd_cs46xx_chip_init()
3088 snd_cs46xx_pokeBA0(chip, BA0_SERC5, 0); in snd_cs46xx_chip_init()
3089 snd_cs46xx_pokeBA0(chip, BA0_SERC6, 1); in snd_cs46xx_chip_init()
3104 if (snd_cs46xx_peekBA0(chip, BA0_ACSTS) & ACSTS_CRDY) in snd_cs46xx_chip_init()
3110 dev_err(chip->card->dev, in snd_cs46xx_chip_init()
3112 dev_err(chip->card->dev, in snd_cs46xx_chip_init()
3123 if (snd_cs46xx_peekBA0(chip, BA0_ACSTS2) & ACSTS_CRDY) in snd_cs46xx_chip_init()
3130 if (!(snd_cs46xx_peekBA0(chip, BA0_ACSTS2) & ACSTS_CRDY)) in snd_cs46xx_chip_init()
3131 dev_dbg(chip->card->dev, in snd_cs46xx_chip_init()
3140 snd_cs46xx_pokeBA0(chip, BA0_ACCTL, ACCTL_VFRM | ACCTL_ESYN | ACCTL_RSTN); in snd_cs46xx_chip_init()
3142 snd_cs46xx_pokeBA0(chip, BA0_ACCTL2, ACCTL_VFRM | ACCTL_ESYN | ACCTL_RSTN); in snd_cs46xx_chip_init()
3156 …if ((snd_cs46xx_peekBA0(chip, BA0_ACISV) & (ACISV_ISV3 | ACISV_ISV4)) == (ACISV_ISV3 | ACISV_ISV4)) in snd_cs46xx_chip_init()
3162 dev_err(chip->card->dev, in snd_cs46xx_chip_init()
3170 dev_err(chip->card->dev, "never read ISV3 & ISV4 from AC'97\n"); in snd_cs46xx_chip_init()
3171 dev_err(chip->card->dev, in snd_cs46xx_chip_init()
3173 dev_err(chip->card->dev, in snd_cs46xx_chip_init()
3175 dev_err(chip->card->dev, in snd_cs46xx_chip_init()
3187 snd_cs46xx_pokeBA0(chip, BA0_ACOSV, ACOSV_SLV3 | ACOSV_SLV4); in snd_cs46xx_chip_init()
3194 /* snd_cs46xx_pokeBA0(chip, BA0_AC97_POWERDOWN, 0x300); */ in snd_cs46xx_chip_init()
3200 /* tmp = snd_cs46xx_peekBA0(chip, BA0_CLKCR1) & ~CLKCR1_SWCE; */ in snd_cs46xx_chip_init()
3201 /* snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, tmp); */ in snd_cs46xx_chip_init()
3210 static void cs46xx_enable_stream_irqs(struct snd_cs46xx *chip) in cs46xx_enable_stream_irqs() argument
3214 snd_cs46xx_pokeBA0(chip, BA0_HICR, HICR_IEV | HICR_CHGM); in cs46xx_enable_stream_irqs()
3216 tmp = snd_cs46xx_peek(chip, BA1_PFIE); in cs46xx_enable_stream_irqs()
3218 snd_cs46xx_poke(chip, BA1_PFIE, tmp); /* playback interrupt enable */ in cs46xx_enable_stream_irqs()
3220 tmp = snd_cs46xx_peek(chip, BA1_CIE); in cs46xx_enable_stream_irqs()
3223 snd_cs46xx_poke(chip, BA1_CIE, tmp); /* capture interrupt enable */ in cs46xx_enable_stream_irqs()
3226 int snd_cs46xx_start_dsp(struct snd_cs46xx *chip) in snd_cs46xx_start_dsp() argument
3237 snd_cs46xx_reset(chip); in snd_cs46xx_start_dsp()
3243 err = load_firmware(chip, &chip->modules[i], module_names[i]); in snd_cs46xx_start_dsp()
3245 dev_err(chip->card->dev, "firmware load error [%s]\n", in snd_cs46xx_start_dsp()
3249 err = cs46xx_dsp_load_module(chip, chip->modules[i]); in snd_cs46xx_start_dsp()
3251 dev_err(chip->card->dev, "image download error [%s]\n", in snd_cs46xx_start_dsp()
3257 if (cs46xx_dsp_scb_and_task_init(chip) < 0) in snd_cs46xx_start_dsp()
3260 err = load_firmware(chip); in snd_cs46xx_start_dsp()
3265 err = snd_cs46xx_download_image(chip); in snd_cs46xx_start_dsp()
3267 dev_err(chip->card->dev, "image download error\n"); in snd_cs46xx_start_dsp()
3274 tmp = snd_cs46xx_peek(chip, BA1_PCTL); in snd_cs46xx_start_dsp()
3275 chip->play_ctl = tmp & 0xffff0000; in snd_cs46xx_start_dsp()
3276 snd_cs46xx_poke(chip, BA1_PCTL, tmp & 0x0000ffff); in snd_cs46xx_start_dsp()
3282 tmp = snd_cs46xx_peek(chip, BA1_CCTL); in snd_cs46xx_start_dsp()
3283 chip->capt.ctl = tmp & 0x0000ffff; in snd_cs46xx_start_dsp()
3284 snd_cs46xx_poke(chip, BA1_CCTL, tmp & 0xffff0000); in snd_cs46xx_start_dsp()
3288 snd_cs46xx_set_play_sample_rate(chip, 8000); in snd_cs46xx_start_dsp()
3289 snd_cs46xx_set_capture_sample_rate(chip, 8000); in snd_cs46xx_start_dsp()
3291 snd_cs46xx_proc_start(chip); in snd_cs46xx_start_dsp()
3293 cs46xx_enable_stream_irqs(chip); in snd_cs46xx_start_dsp()
3297 snd_cs46xx_poke(chip, BA1_PVOL, 0x80008000); in snd_cs46xx_start_dsp()
3298 snd_cs46xx_poke(chip, BA1_CVOL, 0x80008000); in snd_cs46xx_start_dsp()
3309 static void amp_none(struct snd_cs46xx *chip, int change) in amp_none() argument
3314 static int voyetra_setup_eapd_slot(struct snd_cs46xx *chip) in voyetra_setup_eapd_slot() argument
3320 dev_dbg(chip->card->dev, "cs46xx_setup_eapd_slot()+\n"); in voyetra_setup_eapd_slot()
3326 tmp = snd_cs46xx_peekBA0(chip, BA0_CLKCR1); in voyetra_setup_eapd_slot()
3329 snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, tmp | CLKCR1_SWCE); in voyetra_setup_eapd_slot()
3334 * Clear PRA. The Bonzo chip will be used for GPIO not for modem in voyetra_setup_eapd_slot()
3337 if(chip->nr_ac97_codecs != 2) { in voyetra_setup_eapd_slot()
3338 dev_err(chip->card->dev, in voyetra_setup_eapd_slot()
3343 modem_power = snd_cs46xx_codec_read (chip, in voyetra_setup_eapd_slot()
3348 snd_cs46xx_codec_write(chip, in voyetra_setup_eapd_slot()
3355 pin_config = snd_cs46xx_codec_read (chip, in voyetra_setup_eapd_slot()
3360 snd_cs46xx_codec_write(chip, in voyetra_setup_eapd_slot()
3368 logic_type = snd_cs46xx_codec_read(chip, AC97_GPIO_POLARITY, in voyetra_setup_eapd_slot()
3372 snd_cs46xx_codec_write (chip, AC97_GPIO_POLARITY, logic_type, in voyetra_setup_eapd_slot()
3375 valid_slots = snd_cs46xx_peekBA0(chip, BA0_ACOSV); in voyetra_setup_eapd_slot()
3377 snd_cs46xx_pokeBA0(chip, BA0_ACOSV, valid_slots); in voyetra_setup_eapd_slot()
3379 if ( cs46xx_wait_for_fifo(chip,1) ) { in voyetra_setup_eapd_slot()
3380 dev_dbg(chip->card->dev, "FIFO is busy\n"); in voyetra_setup_eapd_slot()
3395 snd_cs46xx_pokeBA0(chip, BA0_SERBWP, 0x1800); in voyetra_setup_eapd_slot()
3400 if ( cs46xx_wait_for_fifo(chip,200) ) { in voyetra_setup_eapd_slot()
3401 dev_dbg(chip->card->dev, in voyetra_setup_eapd_slot()
3411 snd_cs46xx_pokeBA0(chip, BA0_SERBAD, idx); in voyetra_setup_eapd_slot()
3416 snd_cs46xx_pokeBA0(chip, BA0_SERBCM, SERBCM_WRC); in voyetra_setup_eapd_slot()
3420 cs46xx_wait_for_fifo(chip,200); in voyetra_setup_eapd_slot()
3427 snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, tmp); in voyetra_setup_eapd_slot()
3437 static void amp_voyetra(struct snd_cs46xx *chip, int change) in amp_voyetra() argument
3443 int old = chip->amplifier; in amp_voyetra()
3447 chip->amplifier += change; in amp_voyetra()
3448 oval = snd_cs46xx_codec_read(chip, AC97_POWERDOWN, in amp_voyetra()
3451 if (chip->amplifier) { in amp_voyetra()
3459 snd_cs46xx_codec_write(chip, AC97_POWERDOWN, val, in amp_voyetra()
3461 if (chip->eapd_switch) in amp_voyetra()
3462 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in amp_voyetra()
3463 &chip->eapd_switch->id); in amp_voyetra()
3467 if (chip->amplifier && !old) { in amp_voyetra()
3468 voyetra_setup_eapd_slot(chip); in amp_voyetra()
3473 static void hercules_init(struct snd_cs46xx *chip) in hercules_init() argument
3476 snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, EGPIODR_GPOE0); in hercules_init()
3477 snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, EGPIODR_GPOE0); in hercules_init()
3484 static void amp_hercules(struct snd_cs46xx *chip, int change) in amp_hercules() argument
3486 int old = chip->amplifier; in amp_hercules()
3487 int val1 = snd_cs46xx_peekBA0(chip, BA0_EGPIODR); in amp_hercules()
3488 int val2 = snd_cs46xx_peekBA0(chip, BA0_EGPIOPTR); in amp_hercules()
3490 chip->amplifier += change; in amp_hercules()
3491 if (chip->amplifier && !old) { in amp_hercules()
3492 dev_dbg(chip->card->dev, "Hercules amplifier ON\n"); in amp_hercules()
3494 snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, in amp_hercules()
3496 snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, in amp_hercules()
3498 } else if (old && !chip->amplifier) { in amp_hercules()
3499 dev_dbg(chip->card->dev, "Hercules amplifier OFF\n"); in amp_hercules()
3500 snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, val1 & ~EGPIODR_GPOE2); /* disable */ in amp_hercules()
3501 snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, val2 & ~EGPIOPTR_GPPT2); /* disable */ in amp_hercules()
3505 static void voyetra_mixer_init (struct snd_cs46xx *chip) in voyetra_mixer_init() argument
3507 dev_dbg(chip->card->dev, "initializing Voyetra mixer\n"); in voyetra_mixer_init()
3510 snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, EGPIODR_GPOE0); in voyetra_mixer_init()
3511 snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, EGPIODR_GPOE0); in voyetra_mixer_init()
3514 static void hercules_mixer_init (struct snd_cs46xx *chip) in hercules_mixer_init() argument
3519 struct snd_card *card = chip->card; in hercules_mixer_init()
3523 hercules_init(chip); in hercules_mixer_init()
3525 dev_dbg(chip->card->dev, "initializing Hercules mixer\n"); in hercules_mixer_init()
3528 if (chip->in_suspend) in hercules_mixer_init()
3534 kctl = snd_ctl_new1(&snd_hercules_controls[idx], chip); in hercules_mixer_init()
3551 static void amp_voyetra_4294(struct snd_cs46xx *chip, int change)
3553 chip->amplifier += change;
3555 if (chip->amplifier) {
3557 snd_cs46xx_codec_write(chip, 0x4C,
3558 snd_cs46xx_codec_read(chip, 0x4C) & 0xFE7F);
3559 snd_cs46xx_codec_write(chip, 0x4E,
3560 snd_cs46xx_codec_read(chip, 0x4E) | 0x0180);
3562 snd_cs46xx_codec_write(chip, 0x54,
3563 snd_cs46xx_codec_read(chip, 0x54) & ~0x0180);
3565 snd_cs46xx_codec_write(chip, 0x54,
3566 snd_cs46xx_codec_read(chip, 0x54) | 0x0180);
3574 * whenever we need to beat on the chip.
3581 static void clkrun_hack(struct snd_cs46xx *chip, int change) in clkrun_hack() argument
3585 if (!chip->acpi_port) in clkrun_hack()
3588 chip->amplifier += change; in clkrun_hack()
3591 nval = control = inw(chip->acpi_port + 0x10); in clkrun_hack()
3594 if (! chip->amplifier) in clkrun_hack()
3599 outw(nval, chip->acpi_port + 0x10); in clkrun_hack()
3606 static void clkrun_init(struct snd_cs46xx *chip) in clkrun_init() argument
3611 chip->acpi_port = 0; in clkrun_init()
3620 chip->acpi_port = pp << 8; in clkrun_init()
3765 struct snd_cs46xx *chip = card->private_data; in snd_cs46xx_suspend() local
3769 chip->in_suspend = 1; in snd_cs46xx_suspend()
3770 // chip->ac97_powerdown = snd_cs46xx_codec_read(chip, AC97_POWER_CONTROL); in snd_cs46xx_suspend()
3771 // chip->ac97_general_purpose = snd_cs46xx_codec_read(chip, BA0_AC97_GENERAL_PURPOSE); in snd_cs46xx_suspend()
3773 snd_ac97_suspend(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); in snd_cs46xx_suspend()
3774 snd_ac97_suspend(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); in snd_cs46xx_suspend()
3778 chip->saved_regs[i] = snd_cs46xx_peekBA0(chip, saved_regs[i]); in snd_cs46xx_suspend()
3780 amp_saved = chip->amplifier; in snd_cs46xx_suspend()
3782 chip->amplifier_ctrl(chip, -chip->amplifier); in snd_cs46xx_suspend()
3783 snd_cs46xx_hw_stop(chip); in snd_cs46xx_suspend()
3785 chip->active_ctrl(chip, -chip->amplifier); in snd_cs46xx_suspend()
3786 chip->amplifier = amp_saved; /* restore the status */ in snd_cs46xx_suspend()
3793 struct snd_cs46xx *chip = card->private_data; in snd_cs46xx_resume() local
3800 amp_saved = chip->amplifier; in snd_cs46xx_resume()
3801 chip->amplifier = 0; in snd_cs46xx_resume()
3802 chip->active_ctrl(chip, 1); /* force to on */ in snd_cs46xx_resume()
3804 snd_cs46xx_chip_init(chip); in snd_cs46xx_resume()
3806 snd_cs46xx_reset(chip); in snd_cs46xx_resume()
3808 cs46xx_dsp_resume(chip); in snd_cs46xx_resume()
3811 snd_cs46xx_pokeBA0(chip, saved_regs[i], chip->saved_regs[i]); in snd_cs46xx_resume()
3813 snd_cs46xx_download_image(chip); in snd_cs46xx_resume()
3817 snd_cs46xx_codec_write(chip, BA0_AC97_GENERAL_PURPOSE, in snd_cs46xx_resume()
3818 chip->ac97_general_purpose); in snd_cs46xx_resume()
3819 snd_cs46xx_codec_write(chip, AC97_POWER_CONTROL, in snd_cs46xx_resume()
3820 chip->ac97_powerdown); in snd_cs46xx_resume()
3822 snd_cs46xx_codec_write(chip, BA0_AC97_POWERDOWN, in snd_cs46xx_resume()
3823 chip->ac97_powerdown); in snd_cs46xx_resume()
3827 snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); in snd_cs46xx_resume()
3828 snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); in snd_cs46xx_resume()
3833 tmp = snd_cs46xx_peek(chip, BA1_CCTL); in snd_cs46xx_resume()
3834 chip->capt.ctl = tmp & 0x0000ffff; in snd_cs46xx_resume()
3835 snd_cs46xx_poke(chip, BA1_CCTL, tmp & 0xffff0000); in snd_cs46xx_resume()
3840 snd_cs46xx_set_play_sample_rate(chip, 8000); in snd_cs46xx_resume()
3841 snd_cs46xx_set_capture_sample_rate(chip, 8000); in snd_cs46xx_resume()
3842 snd_cs46xx_proc_start(chip); in snd_cs46xx_resume()
3844 cs46xx_enable_stream_irqs(chip); in snd_cs46xx_resume()
3847 chip->amplifier_ctrl(chip, 1); /* turn amp on */ in snd_cs46xx_resume()
3849 chip->active_ctrl(chip, -1); /* disable CLKRUN */ in snd_cs46xx_resume()
3850 chip->amplifier = amp_saved; in snd_cs46xx_resume()
3851 chip->in_suspend = 0; in snd_cs46xx_resume()
3868 struct snd_cs46xx *chip; in snd_cs46xx_create() local
3883 chip = kzalloc(sizeof(*chip), GFP_KERNEL); in snd_cs46xx_create()
3884 if (chip == NULL) { in snd_cs46xx_create()
3888 spin_lock_init(&chip->reg_lock); in snd_cs46xx_create()
3890 mutex_init(&chip->spos_mutex); in snd_cs46xx_create()
3892 chip->card = card; in snd_cs46xx_create()
3893 chip->pci = pci; in snd_cs46xx_create()
3894 chip->irq = -1; in snd_cs46xx_create()
3895 chip->ba0_addr = pci_resource_start(pci, 0); in snd_cs46xx_create()
3896 chip->ba1_addr = pci_resource_start(pci, 1); in snd_cs46xx_create()
3897 if (chip->ba0_addr == 0 || chip->ba0_addr == (unsigned long)~0 || in snd_cs46xx_create()
3898 chip->ba1_addr == 0 || chip->ba1_addr == (unsigned long)~0) { in snd_cs46xx_create()
3899 dev_err(chip->card->dev, in snd_cs46xx_create()
3901 chip->ba0_addr, chip->ba1_addr); in snd_cs46xx_create()
3902 snd_cs46xx_free(chip); in snd_cs46xx_create()
3906 region = &chip->region.name.ba0; in snd_cs46xx_create()
3908 region->base = chip->ba0_addr; in snd_cs46xx_create()
3911 region = &chip->region.name.data0; in snd_cs46xx_create()
3913 region->base = chip->ba1_addr + BA1_SP_DMEM0; in snd_cs46xx_create()
3916 region = &chip->region.name.data1; in snd_cs46xx_create()
3918 region->base = chip->ba1_addr + BA1_SP_DMEM1; in snd_cs46xx_create()
3921 region = &chip->region.name.pmem; in snd_cs46xx_create()
3923 region->base = chip->ba1_addr + BA1_SP_PMEM; in snd_cs46xx_create()
3926 region = &chip->region.name.reg; in snd_cs46xx_create()
3928 region->base = chip->ba1_addr + BA1_SP_REG; in snd_cs46xx_create()
3937 dev_dbg(chip->card->dev, "hack for %s enabled\n", in snd_cs46xx_create()
3940 chip->amplifier_ctrl = cp->amp; in snd_cs46xx_create()
3941 chip->active_ctrl = cp->active; in snd_cs46xx_create()
3942 chip->mixer_init = cp->mixer_init; in snd_cs46xx_create()
3945 cp->init(chip); in snd_cs46xx_create()
3951 dev_info(chip->card->dev, in snd_cs46xx_create()
3953 chip->amplifier_ctrl = amp_voyetra; in snd_cs46xx_create()
3957 dev_info(chip->card->dev, in snd_cs46xx_create()
3959 chip->active_ctrl = clkrun_hack; in snd_cs46xx_create()
3960 clkrun_init(chip); in snd_cs46xx_create()
3963 if (chip->amplifier_ctrl == NULL) in snd_cs46xx_create()
3964 chip->amplifier_ctrl = amp_none; in snd_cs46xx_create()
3965 if (chip->active_ctrl == NULL) in snd_cs46xx_create()
3966 chip->active_ctrl = amp_none; in snd_cs46xx_create()
3968 chip->active_ctrl(chip, 1); /* enable CLKRUN */ in snd_cs46xx_create()
3973 region = &chip->region.idx[idx]; in snd_cs46xx_create()
3976 dev_err(chip->card->dev, in snd_cs46xx_create()
3979 snd_cs46xx_free(chip); in snd_cs46xx_create()
3984 dev_err(chip->card->dev, in snd_cs46xx_create()
3986 snd_cs46xx_free(chip); in snd_cs46xx_create()
3992 KBUILD_MODNAME, chip)) { in snd_cs46xx_create()
3993 dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_cs46xx_create()
3994 snd_cs46xx_free(chip); in snd_cs46xx_create()
3997 chip->irq = pci->irq; in snd_cs46xx_create()
4000 chip->dsp_spos_instance = cs46xx_dsp_spos_create(chip); in snd_cs46xx_create()
4001 if (chip->dsp_spos_instance == NULL) { in snd_cs46xx_create()
4002 snd_cs46xx_free(chip); in snd_cs46xx_create()
4007 err = snd_cs46xx_chip_init(chip); in snd_cs46xx_create()
4009 snd_cs46xx_free(chip); in snd_cs46xx_create()
4013 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { in snd_cs46xx_create()
4014 snd_cs46xx_free(chip); in snd_cs46xx_create()
4018 snd_cs46xx_proc_init(card, chip); in snd_cs46xx_create()
4021 chip->saved_regs = kmalloc_array(ARRAY_SIZE(saved_regs), in snd_cs46xx_create()
4022 sizeof(*chip->saved_regs), in snd_cs46xx_create()
4024 if (!chip->saved_regs) { in snd_cs46xx_create()
4025 snd_cs46xx_free(chip); in snd_cs46xx_create()
4030 chip->active_ctrl(chip, -1); /* disable CLKRUN */ in snd_cs46xx_create()
4032 *rchip = chip; in snd_cs46xx_create()