Lines Matching refs:chip
39 int snd_vx_check_reg_bit(struct vx_core *chip, int reg, int mask, int bit, int time) in snd_vx_check_reg_bit() argument
51 if ((snd_vx_inb(chip, reg) & mask) == bit) in snd_vx_check_reg_bit()
55 …eck_reg_bit: timeout, reg=%s, mask=0x%x, val=0x%x\n", reg_names[reg], mask, snd_vx_inb(chip, reg)); in snd_vx_check_reg_bit()
69 static int vx_send_irq_dsp(struct vx_core *chip, int num) in vx_send_irq_dsp() argument
74 if (snd_vx_check_reg_bit(chip, VX_CVR, CVR_HC, 0, 200) < 0) in vx_send_irq_dsp()
78 if (vx_has_new_dsp(chip)) in vx_send_irq_dsp()
80 vx_outb(chip, CVR, (nirq >> 1) | CVR_HC); in vx_send_irq_dsp()
90 static int vx_reset_chk(struct vx_core *chip) in vx_reset_chk() argument
93 if (vx_send_irq_dsp(chip, IRQ_RESET_CHK) < 0) in vx_reset_chk()
96 if (vx_check_isr(chip, ISR_CHK, 0, 200) < 0) in vx_reset_chk()
109 static int vx_transfer_end(struct vx_core *chip, int cmd) in vx_transfer_end() argument
113 if ((err = vx_reset_chk(chip)) < 0) in vx_transfer_end()
117 if ((err = vx_send_irq_dsp(chip, cmd)) < 0) in vx_transfer_end()
121 if ((err = vx_wait_isr_bit(chip, ISR_CHK)) < 0) in vx_transfer_end()
125 if ((err = vx_inb(chip, ISR)) & ISR_ERR) { in vx_transfer_end()
126 if ((err = vx_wait_for_rx_full(chip)) < 0) { in vx_transfer_end()
130 err = vx_inb(chip, RXH) << 16; in vx_transfer_end()
131 err |= vx_inb(chip, RXM) << 8; in vx_transfer_end()
132 err |= vx_inb(chip, RXL); in vx_transfer_end()
147 static int vx_read_status(struct vx_core *chip, struct vx_rmh *rmh) in vx_read_status() argument
158 err = vx_wait_for_rx_full(chip); in vx_read_status()
163 val = vx_inb(chip, RXH) << 16; in vx_read_status()
164 val |= vx_inb(chip, RXM) << 8; in vx_read_status()
165 val |= vx_inb(chip, RXL); in vx_read_status()
200 err = vx_send_irq_dsp(chip, IRQ_MESS_WRITE_NEXT); in vx_read_status()
204 err = vx_wait_for_rx_full(chip); in vx_read_status()
207 rmh->Stat[i] = vx_inb(chip, RXH) << 16; in vx_read_status()
208 rmh->Stat[i] |= vx_inb(chip, RXM) << 8; in vx_read_status()
209 rmh->Stat[i] |= vx_inb(chip, RXL); in vx_read_status()
212 return vx_transfer_end(chip, IRQ_MESS_WRITE_END); in vx_read_status()
228 int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh) in vx_send_msg_nolock() argument
232 if (chip->chip_status & VX_STAT_IS_STALE) in vx_send_msg_nolock()
235 if ((err = vx_reset_chk(chip)) < 0) { in vx_send_msg_nolock()
257 if ((err = vx_wait_isr_bit(chip, ISR_TX_EMPTY)) < 0) { in vx_send_msg_nolock()
263 vx_outb(chip, TXH, (rmh->Cmd[0] >> 16) & 0xff); in vx_send_msg_nolock()
264 vx_outb(chip, TXM, (rmh->Cmd[0] >> 8) & 0xff); in vx_send_msg_nolock()
265 vx_outb(chip, TXL, rmh->Cmd[0] & 0xff); in vx_send_msg_nolock()
268 if ((err = vx_send_irq_dsp(chip, IRQ_MESSAGE)) < 0) { in vx_send_msg_nolock()
274 if ((err = vx_wait_isr_bit(chip, ISR_CHK)) < 0) in vx_send_msg_nolock()
278 if (vx_inb(chip, ISR) & ISR_ERR) { in vx_send_msg_nolock()
279 if ((err = vx_wait_for_rx_full(chip)) < 0) { in vx_send_msg_nolock()
283 err = vx_inb(chip, RXH) << 16; in vx_send_msg_nolock()
284 err |= vx_inb(chip, RXM) << 8; in vx_send_msg_nolock()
285 err |= vx_inb(chip, RXL); in vx_send_msg_nolock()
295 if ((err = vx_wait_isr_bit(chip, ISR_TX_READY)) < 0) { in vx_send_msg_nolock()
301 vx_outb(chip, TXH, (rmh->Cmd[i] >> 16) & 0xff); in vx_send_msg_nolock()
302 vx_outb(chip, TXM, (rmh->Cmd[i] >> 8) & 0xff); in vx_send_msg_nolock()
303 vx_outb(chip, TXL, rmh->Cmd[i] & 0xff); in vx_send_msg_nolock()
306 if ((err = vx_send_irq_dsp(chip, IRQ_MESS_READ_NEXT)) < 0) { in vx_send_msg_nolock()
312 if ((err = vx_wait_isr_bit(chip, ISR_TX_READY)) < 0) { in vx_send_msg_nolock()
317 err = vx_transfer_end(chip, IRQ_MESS_READ_END); in vx_send_msg_nolock()
322 return vx_read_status(chip, rmh); in vx_send_msg_nolock()
333 int vx_send_msg(struct vx_core *chip, struct vx_rmh *rmh) in vx_send_msg() argument
337 mutex_lock(&chip->lock); in vx_send_msg()
338 err = vx_send_msg_nolock(chip, rmh); in vx_send_msg()
339 mutex_unlock(&chip->lock); in vx_send_msg()
355 int vx_send_rih_nolock(struct vx_core *chip, int cmd) in vx_send_rih_nolock() argument
359 if (chip->chip_status & VX_STAT_IS_STALE) in vx_send_rih_nolock()
365 if ((err = vx_reset_chk(chip)) < 0) in vx_send_rih_nolock()
368 if ((err = vx_send_irq_dsp(chip, cmd)) < 0) in vx_send_rih_nolock()
371 if ((err = vx_wait_isr_bit(chip, ISR_CHK)) < 0) in vx_send_rih_nolock()
374 if (vx_inb(chip, ISR) & ISR_ERR) { in vx_send_rih_nolock()
375 if ((err = vx_wait_for_rx_full(chip)) < 0) in vx_send_rih_nolock()
377 err = vx_inb(chip, RXH) << 16; in vx_send_rih_nolock()
378 err |= vx_inb(chip, RXM) << 8; in vx_send_rih_nolock()
379 err |= vx_inb(chip, RXL); in vx_send_rih_nolock()
392 int vx_send_rih(struct vx_core *chip, int cmd) in vx_send_rih() argument
396 mutex_lock(&chip->lock); in vx_send_rih()
397 err = vx_send_rih_nolock(chip, cmd); in vx_send_rih()
398 mutex_unlock(&chip->lock); in vx_send_rih()
409 int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *boot) in snd_vx_load_boot_image() argument
412 int no_fillup = vx_has_new_dsp(chip); in snd_vx_load_boot_image()
429 vx_reset_dsp(chip); in snd_vx_load_boot_image()
438 if (vx_wait_isr_bit(chip, ISR_TX_EMPTY) < 0) { in snd_vx_load_boot_image()
442 vx_outb(chip, TXH, 0); in snd_vx_load_boot_image()
443 vx_outb(chip, TXM, 0); in snd_vx_load_boot_image()
444 vx_outb(chip, TXL, 0); in snd_vx_load_boot_image()
447 if (vx_wait_isr_bit(chip, ISR_TX_EMPTY) < 0) { in snd_vx_load_boot_image()
451 vx_outb(chip, TXH, image[0]); in snd_vx_load_boot_image()
452 vx_outb(chip, TXM, image[1]); in snd_vx_load_boot_image()
453 vx_outb(chip, TXL, image[2]); in snd_vx_load_boot_image()
466 static int vx_test_irq_src(struct vx_core *chip, unsigned int *ret) in vx_test_irq_src() argument
470 vx_init_rmh(&chip->irq_rmh, CMD_TEST_IT); in vx_test_irq_src()
471 mutex_lock(&chip->lock); in vx_test_irq_src()
472 err = vx_send_msg_nolock(chip, &chip->irq_rmh); in vx_test_irq_src()
476 *ret = chip->irq_rmh.Stat[0]; in vx_test_irq_src()
477 mutex_unlock(&chip->lock); in vx_test_irq_src()
487 struct vx_core *chip = dev; in snd_vx_threaded_irq_handler() local
490 if (chip->chip_status & VX_STAT_IS_STALE) in snd_vx_threaded_irq_handler()
493 if (vx_test_irq_src(chip, &events) < 0) in snd_vx_threaded_irq_handler()
520 vx_change_frequency(chip); in snd_vx_threaded_irq_handler()
523 vx_pcm_update_intr(chip, events); in snd_vx_threaded_irq_handler()
535 struct vx_core *chip = dev; in snd_vx_irq_handler() local
537 if (! (chip->chip_status & VX_STAT_CHIP_INIT) || in snd_vx_irq_handler()
538 (chip->chip_status & VX_STAT_IS_STALE)) in snd_vx_irq_handler()
540 if (! vx_test_and_ack(chip)) in snd_vx_irq_handler()
549 static void vx_reset_board(struct vx_core *chip, int cold_reset) in vx_reset_board() argument
551 if (snd_BUG_ON(!chip->ops->reset_board)) in vx_reset_board()
555 chip->audio_source = VX_AUDIO_SRC_LINE; in vx_reset_board()
557 chip->audio_source_target = chip->audio_source; in vx_reset_board()
558 chip->clock_source = INTERNAL_QUARTZ; in vx_reset_board()
559 chip->clock_mode = VX_CLOCK_MODE_AUTO; in vx_reset_board()
560 chip->freq = 48000; in vx_reset_board()
561 chip->uer_detected = VX_UER_MODE_NOT_PRESENT; in vx_reset_board()
562 chip->uer_bits = SNDRV_PCM_DEFAULT_CON_SPDIF; in vx_reset_board()
565 chip->ops->reset_board(chip, cold_reset); in vx_reset_board()
567 vx_reset_codec(chip, cold_reset); in vx_reset_board()
569 vx_set_internal_clock(chip, chip->freq); in vx_reset_board()
572 vx_reset_dsp(chip); in vx_reset_board()
574 if (vx_is_pcmcia(chip)) { in vx_reset_board()
576 vx_test_and_ack(chip); in vx_reset_board()
577 vx_validate_irq(chip, 1); in vx_reset_board()
581 vx_set_iec958_status(chip, chip->uer_bits); in vx_reset_board()
591 struct vx_core *chip = entry->private_data; in vx_proc_read() local
598 snd_iprintf(buffer, "%s\n", chip->card->longname); in vx_proc_read()
600 (chip->chip_status & VX_STAT_XILINX_LOADED) ? "Loaded" : "No"); in vx_proc_read()
602 (chip->chip_status & VX_STAT_DEVICE_INIT) ? "Yes" : "No"); in vx_proc_read()
604 if (chip->audio_info & VX_AUDIO_INFO_REAL_TIME) in vx_proc_read()
606 if (chip->audio_info & VX_AUDIO_INFO_OFFLINE) in vx_proc_read()
608 if (chip->audio_info & VX_AUDIO_INFO_MPEG1) in vx_proc_read()
610 if (chip->audio_info & VX_AUDIO_INFO_MPEG2) in vx_proc_read()
612 if (chip->audio_info & VX_AUDIO_INFO_LINEAR_8) in vx_proc_read()
614 if (chip->audio_info & VX_AUDIO_INFO_LINEAR_16) in vx_proc_read()
616 if (chip->audio_info & VX_AUDIO_INFO_LINEAR_24) in vx_proc_read()
619 snd_iprintf(buffer, "Input Source: %s\n", vx_is_pcmcia(chip) ? in vx_proc_read()
620 audio_src_vxp[chip->audio_source] : in vx_proc_read()
621 audio_src_vx2[chip->audio_source]); in vx_proc_read()
622 snd_iprintf(buffer, "Clock Mode: %s\n", clock_mode[chip->clock_mode]); in vx_proc_read()
623 snd_iprintf(buffer, "Clock Source: %s\n", clock_src[chip->clock_source]); in vx_proc_read()
624 snd_iprintf(buffer, "Frequency: %d\n", chip->freq); in vx_proc_read()
625 snd_iprintf(buffer, "Detected Frequency: %d\n", chip->freq_detected); in vx_proc_read()
626 snd_iprintf(buffer, "Detected UER type: %s\n", uer_type[chip->uer_detected]); in vx_proc_read()
628 chip->ibl.min_size, chip->ibl.max_size, chip->ibl.size, in vx_proc_read()
629 chip->ibl.granularity); in vx_proc_read()
632 static void vx_proc_init(struct vx_core *chip) in vx_proc_init() argument
634 snd_card_ro_proc_new(chip->card, "vx-status", chip, vx_proc_read); in vx_proc_init()
643 int snd_vx_dsp_boot(struct vx_core *chip, const struct firmware *boot) in snd_vx_dsp_boot() argument
646 int cold_reset = !(chip->chip_status & VX_STAT_DEVICE_INIT); in snd_vx_dsp_boot()
648 vx_reset_board(chip, cold_reset); in snd_vx_dsp_boot()
649 vx_validate_irq(chip, 0); in snd_vx_dsp_boot()
651 if ((err = snd_vx_load_boot_image(chip, boot)) < 0) in snd_vx_dsp_boot()
665 int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp) in snd_vx_dsp_load() argument
675 vx_toggle_dac_mute(chip, 1); in snd_vx_dsp_load()
681 if ((err = vx_wait_isr_bit(chip, ISR_TX_EMPTY)) < 0) { in snd_vx_dsp_load()
689 vx_outb(chip, TXH, *cptr++); in snd_vx_dsp_load()
692 vx_outb(chip, TXM, *cptr++); in snd_vx_dsp_load()
695 vx_outb(chip, TXL, *cptr++); in snd_vx_dsp_load()
701 if ((err = vx_wait_isr_bit(chip, ISR_CHK)) < 0) in snd_vx_dsp_load()
704 vx_toggle_dac_mute(chip, 0); in snd_vx_dsp_load()
706 vx_test_and_ack(chip); in snd_vx_dsp_load()
707 vx_validate_irq(chip, 1); in snd_vx_dsp_load()
718 int snd_vx_suspend(struct vx_core *chip) in snd_vx_suspend() argument
720 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); in snd_vx_suspend()
721 chip->chip_status |= VX_STAT_IN_SUSPEND; in snd_vx_suspend()
731 int snd_vx_resume(struct vx_core *chip) in snd_vx_resume() argument
735 chip->chip_status &= ~VX_STAT_CHIP_INIT; in snd_vx_resume()
738 if (! chip->firmware[i]) in snd_vx_resume()
740 err = chip->ops->load_dsp(chip, i, chip->firmware[i]); in snd_vx_resume()
747 chip->chip_status |= VX_STAT_CHIP_INIT; in snd_vx_resume()
748 chip->chip_status &= ~VX_STAT_IN_SUSPEND; in snd_vx_resume()
750 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); in snd_vx_resume()
774 struct vx_core *chip; in snd_vx_create() local
779 chip = kzalloc(sizeof(*chip) + extra_size, GFP_KERNEL); in snd_vx_create()
780 if (! chip) in snd_vx_create()
782 mutex_init(&chip->lock); in snd_vx_create()
783 chip->irq = -1; in snd_vx_create()
784 chip->hw = hw; in snd_vx_create()
785 chip->type = hw->type; in snd_vx_create()
786 chip->ops = ops; in snd_vx_create()
787 mutex_init(&chip->mixer_mutex); in snd_vx_create()
789 chip->card = card; in snd_vx_create()
790 card->private_data = chip; in snd_vx_create()
794 vx_proc_init(chip); in snd_vx_create()
796 return chip; in snd_vx_create()