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 dev_dbg(chip->card->dev, in snd_vx_check_reg_bit()
57 reg_names[reg], mask, snd_vx_inb(chip, reg)); in snd_vx_check_reg_bit()
71 static int vx_send_irq_dsp(struct vx_core *chip, int num) in vx_send_irq_dsp() argument
76 if (snd_vx_check_reg_bit(chip, VX_CVR, CVR_HC, 0, 200) < 0) in vx_send_irq_dsp()
80 if (vx_has_new_dsp(chip)) in vx_send_irq_dsp()
82 vx_outb(chip, CVR, (nirq >> 1) | CVR_HC); in vx_send_irq_dsp()
92 static int vx_reset_chk(struct vx_core *chip) in vx_reset_chk() argument
95 if (vx_send_irq_dsp(chip, IRQ_RESET_CHK) < 0) in vx_reset_chk()
98 if (vx_check_isr(chip, ISR_CHK, 0, 200) < 0) in vx_reset_chk()
111 static int vx_transfer_end(struct vx_core *chip, int cmd) in vx_transfer_end() argument
115 err = vx_reset_chk(chip); in vx_transfer_end()
120 err = vx_send_irq_dsp(chip, cmd); in vx_transfer_end()
125 err = vx_wait_isr_bit(chip, ISR_CHK); in vx_transfer_end()
130 err = vx_inb(chip, ISR); in vx_transfer_end()
132 err = vx_wait_for_rx_full(chip); in vx_transfer_end()
134 dev_dbg(chip->card->dev, in vx_transfer_end()
138 err = vx_inb(chip, RXH) << 16; in vx_transfer_end()
139 err |= vx_inb(chip, RXM) << 8; in vx_transfer_end()
140 err |= vx_inb(chip, RXL); in vx_transfer_end()
141 dev_dbg(chip->card->dev, "transfer_end: error = 0x%x\n", err); in vx_transfer_end()
155 static int vx_read_status(struct vx_core *chip, struct vx_rmh *rmh) in vx_read_status() argument
166 err = vx_wait_for_rx_full(chip); in vx_read_status()
171 val = vx_inb(chip, RXH) << 16; in vx_read_status()
172 val |= vx_inb(chip, RXM) << 8; in vx_read_status()
173 val |= vx_inb(chip, RXL); in vx_read_status()
208 err = vx_send_irq_dsp(chip, IRQ_MESS_WRITE_NEXT); in vx_read_status()
212 err = vx_wait_for_rx_full(chip); in vx_read_status()
215 rmh->Stat[i] = vx_inb(chip, RXH) << 16; in vx_read_status()
216 rmh->Stat[i] |= vx_inb(chip, RXM) << 8; in vx_read_status()
217 rmh->Stat[i] |= vx_inb(chip, RXL); in vx_read_status()
220 return vx_transfer_end(chip, IRQ_MESS_WRITE_END); in vx_read_status()
236 int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh) in vx_send_msg_nolock() argument
240 if (chip->chip_status & VX_STAT_IS_STALE) in vx_send_msg_nolock()
243 err = vx_reset_chk(chip); in vx_send_msg_nolock()
245 dev_dbg(chip->card->dev, "vx_send_msg: vx_reset_chk error\n"); in vx_send_msg_nolock()
256 err = vx_wait_isr_bit(chip, ISR_TX_EMPTY); in vx_send_msg_nolock()
258 dev_dbg(chip->card->dev, "vx_send_msg: wait tx empty error\n"); 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 err = vx_send_irq_dsp(chip, IRQ_MESSAGE); in vx_send_msg_nolock()
270 dev_dbg(chip->card->dev, in vx_send_msg_nolock()
276 err = vx_wait_isr_bit(chip, ISR_CHK); in vx_send_msg_nolock()
281 if (vx_inb(chip, ISR) & ISR_ERR) { in vx_send_msg_nolock()
282 err = vx_wait_for_rx_full(chip); in vx_send_msg_nolock()
284 dev_dbg(chip->card->dev, in vx_send_msg_nolock()
288 err = vx_inb(chip, RXH) << 16; in vx_send_msg_nolock()
289 err |= vx_inb(chip, RXM) << 8; in vx_send_msg_nolock()
290 err |= vx_inb(chip, RXL); in vx_send_msg_nolock()
291 dev_dbg(chip->card->dev, in vx_send_msg_nolock()
301 err = vx_wait_isr_bit(chip, ISR_TX_READY); in vx_send_msg_nolock()
303 dev_dbg(chip->card->dev, in vx_send_msg_nolock()
309 vx_outb(chip, TXH, (rmh->Cmd[i] >> 16) & 0xff); in vx_send_msg_nolock()
310 vx_outb(chip, TXM, (rmh->Cmd[i] >> 8) & 0xff); in vx_send_msg_nolock()
311 vx_outb(chip, TXL, rmh->Cmd[i] & 0xff); in vx_send_msg_nolock()
314 err = vx_send_irq_dsp(chip, IRQ_MESS_READ_NEXT); in vx_send_msg_nolock()
316 dev_dbg(chip->card->dev, in vx_send_msg_nolock()
322 err = vx_wait_isr_bit(chip, ISR_TX_READY); in vx_send_msg_nolock()
324 dev_dbg(chip->card->dev, in vx_send_msg_nolock()
329 err = vx_transfer_end(chip, IRQ_MESS_READ_END); in vx_send_msg_nolock()
334 return vx_read_status(chip, rmh); in vx_send_msg_nolock()
345 int vx_send_msg(struct vx_core *chip, struct vx_rmh *rmh) in vx_send_msg() argument
349 mutex_lock(&chip->lock); in vx_send_msg()
350 err = vx_send_msg_nolock(chip, rmh); in vx_send_msg()
351 mutex_unlock(&chip->lock); in vx_send_msg()
367 int vx_send_rih_nolock(struct vx_core *chip, int cmd) in vx_send_rih_nolock() argument
371 if (chip->chip_status & VX_STAT_IS_STALE) in vx_send_rih_nolock()
374 err = vx_reset_chk(chip); in vx_send_rih_nolock()
378 err = vx_send_irq_dsp(chip, cmd); in vx_send_rih_nolock()
382 err = vx_wait_isr_bit(chip, ISR_CHK); in vx_send_rih_nolock()
386 if (vx_inb(chip, ISR) & ISR_ERR) { in vx_send_rih_nolock()
387 err = vx_wait_for_rx_full(chip); in vx_send_rih_nolock()
390 err = vx_inb(chip, RXH) << 16; in vx_send_rih_nolock()
391 err |= vx_inb(chip, RXM) << 8; in vx_send_rih_nolock()
392 err |= vx_inb(chip, RXL); in vx_send_rih_nolock()
405 int vx_send_rih(struct vx_core *chip, int cmd) in vx_send_rih() argument
409 mutex_lock(&chip->lock); in vx_send_rih()
410 err = vx_send_rih_nolock(chip, cmd); in vx_send_rih()
411 mutex_unlock(&chip->lock); in vx_send_rih()
422 int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *boot) in snd_vx_load_boot_image() argument
425 int no_fillup = vx_has_new_dsp(chip); in snd_vx_load_boot_image()
442 vx_reset_dsp(chip); in snd_vx_load_boot_image()
451 if (vx_wait_isr_bit(chip, ISR_TX_EMPTY) < 0) { in snd_vx_load_boot_image()
452 dev_err(chip->card->dev, "dsp boot failed at %d\n", i); in snd_vx_load_boot_image()
455 vx_outb(chip, TXH, 0); in snd_vx_load_boot_image()
456 vx_outb(chip, TXM, 0); in snd_vx_load_boot_image()
457 vx_outb(chip, TXL, 0); in snd_vx_load_boot_image()
460 if (vx_wait_isr_bit(chip, ISR_TX_EMPTY) < 0) { in snd_vx_load_boot_image()
461 dev_err(chip->card->dev, "dsp boot failed at %d\n", i); in snd_vx_load_boot_image()
464 vx_outb(chip, TXH, image[0]); in snd_vx_load_boot_image()
465 vx_outb(chip, TXM, image[1]); in snd_vx_load_boot_image()
466 vx_outb(chip, TXL, image[2]); in snd_vx_load_boot_image()
479 static int vx_test_irq_src(struct vx_core *chip, unsigned int *ret) in vx_test_irq_src() argument
483 vx_init_rmh(&chip->irq_rmh, CMD_TEST_IT); in vx_test_irq_src()
484 mutex_lock(&chip->lock); in vx_test_irq_src()
485 err = vx_send_msg_nolock(chip, &chip->irq_rmh); in vx_test_irq_src()
489 *ret = chip->irq_rmh.Stat[0]; in vx_test_irq_src()
490 mutex_unlock(&chip->lock); in vx_test_irq_src()
500 struct vx_core *chip = dev; in snd_vx_threaded_irq_handler() local
503 if (chip->chip_status & VX_STAT_IS_STALE) in snd_vx_threaded_irq_handler()
506 if (vx_test_irq_src(chip, &events) < 0) in snd_vx_threaded_irq_handler()
514 dev_err(chip->card->dev, "vx_core: fatal DSP error!!\n"); in snd_vx_threaded_irq_handler()
527 vx_change_frequency(chip); in snd_vx_threaded_irq_handler()
530 vx_pcm_update_intr(chip, events); in snd_vx_threaded_irq_handler()
542 struct vx_core *chip = dev; in snd_vx_irq_handler() local
544 if (! (chip->chip_status & VX_STAT_CHIP_INIT) || in snd_vx_irq_handler()
545 (chip->chip_status & VX_STAT_IS_STALE)) in snd_vx_irq_handler()
547 if (! vx_test_and_ack(chip)) in snd_vx_irq_handler()
556 static void vx_reset_board(struct vx_core *chip, int cold_reset) in vx_reset_board() argument
558 if (snd_BUG_ON(!chip->ops->reset_board)) in vx_reset_board()
562 chip->audio_source = VX_AUDIO_SRC_LINE; in vx_reset_board()
564 chip->audio_source_target = chip->audio_source; in vx_reset_board()
565 chip->clock_source = INTERNAL_QUARTZ; in vx_reset_board()
566 chip->clock_mode = VX_CLOCK_MODE_AUTO; in vx_reset_board()
567 chip->freq = 48000; in vx_reset_board()
568 chip->uer_detected = VX_UER_MODE_NOT_PRESENT; in vx_reset_board()
569 chip->uer_bits = SNDRV_PCM_DEFAULT_CON_SPDIF; in vx_reset_board()
572 chip->ops->reset_board(chip, cold_reset); in vx_reset_board()
574 vx_reset_codec(chip, cold_reset); in vx_reset_board()
576 vx_set_internal_clock(chip, chip->freq); in vx_reset_board()
579 vx_reset_dsp(chip); in vx_reset_board()
581 if (vx_is_pcmcia(chip)) { in vx_reset_board()
583 vx_test_and_ack(chip); in vx_reset_board()
584 vx_validate_irq(chip, 1); in vx_reset_board()
588 vx_set_iec958_status(chip, chip->uer_bits); in vx_reset_board()
598 struct vx_core *chip = entry->private_data; in vx_proc_read() local
605 snd_iprintf(buffer, "%s\n", chip->card->longname); in vx_proc_read()
607 (chip->chip_status & VX_STAT_XILINX_LOADED) ? "Loaded" : "No"); in vx_proc_read()
609 (chip->chip_status & VX_STAT_DEVICE_INIT) ? "Yes" : "No"); in vx_proc_read()
611 if (chip->audio_info & VX_AUDIO_INFO_REAL_TIME) in vx_proc_read()
613 if (chip->audio_info & VX_AUDIO_INFO_OFFLINE) in vx_proc_read()
615 if (chip->audio_info & VX_AUDIO_INFO_MPEG1) in vx_proc_read()
617 if (chip->audio_info & VX_AUDIO_INFO_MPEG2) in vx_proc_read()
619 if (chip->audio_info & VX_AUDIO_INFO_LINEAR_8) in vx_proc_read()
621 if (chip->audio_info & VX_AUDIO_INFO_LINEAR_16) in vx_proc_read()
623 if (chip->audio_info & VX_AUDIO_INFO_LINEAR_24) in vx_proc_read()
626 snd_iprintf(buffer, "Input Source: %s\n", vx_is_pcmcia(chip) ? in vx_proc_read()
627 audio_src_vxp[chip->audio_source] : in vx_proc_read()
628 audio_src_vx2[chip->audio_source]); in vx_proc_read()
629 snd_iprintf(buffer, "Clock Mode: %s\n", clock_mode[chip->clock_mode]); in vx_proc_read()
630 snd_iprintf(buffer, "Clock Source: %s\n", clock_src[chip->clock_source]); in vx_proc_read()
631 snd_iprintf(buffer, "Frequency: %d\n", chip->freq); in vx_proc_read()
632 snd_iprintf(buffer, "Detected Frequency: %d\n", chip->freq_detected); in vx_proc_read()
633 snd_iprintf(buffer, "Detected UER type: %s\n", uer_type[chip->uer_detected]); in vx_proc_read()
635 chip->ibl.min_size, chip->ibl.max_size, chip->ibl.size, in vx_proc_read()
636 chip->ibl.granularity); in vx_proc_read()
639 static void vx_proc_init(struct vx_core *chip) in vx_proc_init() argument
641 snd_card_ro_proc_new(chip->card, "vx-status", chip, vx_proc_read); in vx_proc_init()
650 int snd_vx_dsp_boot(struct vx_core *chip, const struct firmware *boot) in snd_vx_dsp_boot() argument
653 int cold_reset = !(chip->chip_status & VX_STAT_DEVICE_INIT); in snd_vx_dsp_boot()
655 vx_reset_board(chip, cold_reset); in snd_vx_dsp_boot()
656 vx_validate_irq(chip, 0); in snd_vx_dsp_boot()
658 err = snd_vx_load_boot_image(chip, boot); in snd_vx_dsp_boot()
673 int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp) in snd_vx_dsp_load() argument
683 vx_toggle_dac_mute(chip, 1); in snd_vx_dsp_load()
689 err = vx_wait_isr_bit(chip, ISR_TX_EMPTY); in snd_vx_dsp_load()
691 dev_err(chip->card->dev, in snd_vx_dsp_load()
698 vx_outb(chip, TXH, *cptr++); in snd_vx_dsp_load()
701 vx_outb(chip, TXM, *cptr++); in snd_vx_dsp_load()
704 vx_outb(chip, TXL, *cptr++); in snd_vx_dsp_load()
709 err = vx_wait_isr_bit(chip, ISR_CHK); in snd_vx_dsp_load()
713 vx_toggle_dac_mute(chip, 0); in snd_vx_dsp_load()
715 vx_test_and_ack(chip); in snd_vx_dsp_load()
716 vx_validate_irq(chip, 1); in snd_vx_dsp_load()
727 int snd_vx_suspend(struct vx_core *chip) in snd_vx_suspend() argument
729 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); in snd_vx_suspend()
730 chip->chip_status |= VX_STAT_IN_SUSPEND; in snd_vx_suspend()
740 int snd_vx_resume(struct vx_core *chip) in snd_vx_resume() argument
744 chip->chip_status &= ~VX_STAT_CHIP_INIT; in snd_vx_resume()
747 if (! chip->firmware[i]) in snd_vx_resume()
749 err = chip->ops->load_dsp(chip, i, chip->firmware[i]); in snd_vx_resume()
751 dev_err(chip->card->dev, in snd_vx_resume()
757 chip->chip_status |= VX_STAT_CHIP_INIT; in snd_vx_resume()
758 chip->chip_status &= ~VX_STAT_IN_SUSPEND; in snd_vx_resume()
760 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); in snd_vx_resume()
791 struct vx_core *chip; in snd_vx_create() local
796 chip = devres_alloc(snd_vx_release, sizeof(*chip) + extra_size, in snd_vx_create()
798 if (!chip) in snd_vx_create()
800 mutex_init(&chip->lock); in snd_vx_create()
801 chip->irq = -1; in snd_vx_create()
802 chip->hw = hw; in snd_vx_create()
803 chip->type = hw->type; in snd_vx_create()
804 chip->ops = ops; in snd_vx_create()
805 mutex_init(&chip->mixer_mutex); in snd_vx_create()
807 chip->card = card; in snd_vx_create()
808 card->private_data = chip; in snd_vx_create()
812 vx_proc_init(chip); in snd_vx_create()
814 return chip; in snd_vx_create()