Lines Matching +full:chip +full:- +full:to +full:- +full:chip

1 // SPDX-License-Identifier: GPL-2.0-or-later
40 struct snd_vxpocket *chip = to_vxpocket(_chip); in vxp_reg_addr() local
41 return chip->port + vxp_reg_offset[reg]; in vxp_reg_addr()
45 * snd_vx_inb - read a byte from the register
48 static unsigned char vxp_inb(struct vx_core *chip, int offset) in vxp_inb() argument
50 return inb(vxp_reg_addr(chip, offset)); in vxp_inb()
54 * snd_vx_outb - write a byte on the register
56 * @val: the value to write
58 static void vxp_outb(struct vx_core *chip, int offset, unsigned char val) in vxp_outb() argument
60 outb(val, vxp_reg_addr(chip, offset)); in vxp_outb()
64 * redefine macros to call directly
67 #define vx_inb(chip,reg) vxp_inb((struct vx_core *)(chip), VX_##reg) argument
69 #define vx_outb(chip,reg,val) vxp_outb((struct vx_core *)(chip), VX_##reg,val) argument
73 * vx_check_magic - check the magic word on xilinx
77 static int vx_check_magic(struct vx_core *chip) in vx_check_magic() argument
82 c = vx_inb(chip, CDSP); in vx_check_magic()
87 dev_err(chip->card->dev, "cannot find xilinx magic word (%x)\n", c); in vx_check_magic()
88 return -EIO; in vx_check_magic()
93 * vx_reset_dsp - reset the DSP
100 struct snd_vxpocket *chip = to_vxpocket(_chip); in vxp_reset_dsp() local
102 /* set the reset dsp bit to 1 */ in vxp_reset_dsp()
103 vx_outb(chip, CDSP, chip->regCDSP | VXP_CDSP_DSP_RESET_MASK); in vxp_reset_dsp()
104 vx_inb(chip, CDSP); in vxp_reset_dsp()
107 chip->regCDSP &= ~VXP_CDSP_DSP_RESET_MASK; in vxp_reset_dsp()
108 vx_outb(chip, CDSP, chip->regCDSP); in vxp_reset_dsp()
109 vx_inb(chip, CDSP); in vxp_reset_dsp()
118 struct snd_vxpocket *chip = to_vxpocket(_chip); in vxp_reset_codec() local
120 /* Set the reset CODEC bit to 1. */ in vxp_reset_codec()
121 vx_outb(chip, CDSP, chip->regCDSP | VXP_CDSP_CODEC_RESET_MASK); in vxp_reset_codec()
122 vx_inb(chip, CDSP); in vxp_reset_codec()
124 /* Set the reset CODEC bit to 0. */ in vxp_reset_codec()
125 chip->regCDSP &= ~VXP_CDSP_CODEC_RESET_MASK; in vxp_reset_codec()
126 vx_outb(chip, CDSP, chip->regCDSP); in vxp_reset_codec()
127 vx_inb(chip, CDSP); in vxp_reset_codec()
132 * vx_load_xilinx_binary - load the xilinx binary image
137 struct snd_vxpocket *chip = to_vxpocket(_chip); in vxp_load_xilinx_binary() local
144 /* Switch to programmation mode */ in vxp_load_xilinx_binary()
145 chip->regDIALOG |= VXP_DLG_XILINX_REPROG_MASK; in vxp_load_xilinx_binary()
146 vx_outb(chip, DIALOG, chip->regDIALOG); in vxp_load_xilinx_binary()
149 regCSUER = vx_inb(chip, CSUER); in vxp_load_xilinx_binary()
150 regRUER = vx_inb(chip, RUER); in vxp_load_xilinx_binary()
153 vx_outb(chip, ICR, 0); in vxp_load_xilinx_binary()
155 /* Wait for answer HF2 equal to 1 */ in vxp_load_xilinx_binary()
160 vx_outb(chip, ICR, ICR_HF1); in vxp_load_xilinx_binary()
161 image = fw->data; in vxp_load_xilinx_binary()
162 for (i = 0; i < fw->size; i++, image++) { in vxp_load_xilinx_binary()
166 vx_outb(chip, TXL, data); in vxp_load_xilinx_binary()
170 c = vx_inb(chip, RXL); in vxp_load_xilinx_binary()
172 dev_err(_chip->card->dev, in vxp_load_xilinx_binary()
178 vx_outb(chip, ICR, 0); in vxp_load_xilinx_binary()
188 c = (int)vx_inb(chip, RXH) << 16; in vxp_load_xilinx_binary()
189 c |= (int)vx_inb(chip, RXM) << 8; in vxp_load_xilinx_binary()
190 c |= vx_inb(chip, RXL); in vxp_load_xilinx_binary()
192 dev_dbg(_chip->card->dev, in vxp_load_xilinx_binary()
193 "xilinx: dsp size received 0x%x, orig 0x%zx\n", c, fw->size); in vxp_load_xilinx_binary()
195 vx_outb(chip, ICR, ICR_HF0); in vxp_load_xilinx_binary()
205 vx_outb(chip, CSUER, regCSUER); in vxp_load_xilinx_binary()
206 vx_outb(chip, RUER, regRUER); in vxp_load_xilinx_binary()
209 chip->regDIALOG |= VXP_DLG_XILINX_REPROG_MASK; in vxp_load_xilinx_binary()
210 vx_outb(chip, DIALOG, chip->regDIALOG); in vxp_load_xilinx_binary()
211 vx_inb(chip, DIALOG); in vxp_load_xilinx_binary()
213 chip->regDIALOG &= ~VXP_DLG_XILINX_REPROG_MASK; in vxp_load_xilinx_binary()
214 vx_outb(chip, DIALOG, chip->regDIALOG); in vxp_load_xilinx_binary()
215 vx_inb(chip, DIALOG); in vxp_load_xilinx_binary()
224 vx_outb(chip, CSUER, regCSUER); in vxp_load_xilinx_binary()
225 vx_outb(chip, RUER, regRUER); in vxp_load_xilinx_binary()
226 chip->regDIALOG &= ~VXP_DLG_XILINX_REPROG_MASK; in vxp_load_xilinx_binary()
227 vx_outb(chip, DIALOG, chip->regDIALOG); in vxp_load_xilinx_binary()
228 return -EIO; in vxp_load_xilinx_binary()
233 * vxp_load_dsp - load_dsp callback
260 return -EINVAL; in vxp_load_dsp()
266 * vx_test_and_ack - test and acknowledge interrupt
274 struct snd_vxpocket *chip = to_vxpocket(_chip); in vxp_test_and_ack() local
277 if (! (_chip->chip_status & VX_STAT_XILINX_LOADED)) in vxp_test_and_ack()
278 return -ENXIO; in vxp_test_and_ack()
280 if (! (vx_inb(chip, DIALOG) & VXP_DLG_MEMIRQ_MASK)) in vxp_test_and_ack()
281 return -EIO; in vxp_test_and_ack()
285 vx_outb(chip, DIALOG, chip->regDIALOG | VXP_DLG_ACK_MEMIRQ_MASK); in vxp_test_and_ack()
286 /* useless read just to spend some time and maintain in vxp_test_and_ack()
289 vx_inb(chip, DIALOG); in vxp_test_and_ack()
290 vx_outb(chip, DIALOG, chip->regDIALOG & ~VXP_DLG_ACK_MEMIRQ_MASK); in vxp_test_and_ack()
297 * vx_validate_irq - enable/disable IRQ
301 struct snd_vxpocket *chip = to_vxpocket(_chip); in vxp_validate_irq() local
303 /* Set the interrupt enable bit to 1 in CDSP register */ in vxp_validate_irq()
305 chip->regCDSP |= VXP_CDSP_VALID_IRQ_MASK; in vxp_validate_irq()
307 chip->regCDSP &= ~VXP_CDSP_VALID_IRQ_MASK; in vxp_validate_irq()
308 vx_outb(chip, CDSP, chip->regCDSP); in vxp_validate_irq()
312 * vx_setup_pseudo_dma - set up the pseudo dma read/write mode.
317 struct snd_vxpocket *chip = to_vxpocket(_chip); in vx_setup_pseudo_dma() local
320 vx_outb(chip, ICR, do_write ? ICR_TREQ : ICR_RREQ); in vx_setup_pseudo_dma()
321 /* Reset the pseudo-dma register */ in vx_setup_pseudo_dma()
322 vx_inb(chip, ISR); in vx_setup_pseudo_dma()
323 vx_outb(chip, ISR, 0); in vx_setup_pseudo_dma()
325 /* Select DMA in read/write transfer mode and in 16-bit accesses */ in vx_setup_pseudo_dma()
326 chip->regDIALOG |= VXP_DLG_DMA16_SEL_MASK; in vx_setup_pseudo_dma()
327 chip->regDIALOG |= do_write ? VXP_DLG_DMAWRITE_SEL_MASK : VXP_DLG_DMAREAD_SEL_MASK; in vx_setup_pseudo_dma()
328 vx_outb(chip, DIALOG, chip->regDIALOG); in vx_setup_pseudo_dma()
333 * vx_release_pseudo_dma - disable the pseudo-DMA mode
337 struct snd_vxpocket *chip = to_vxpocket(_chip); in vx_release_pseudo_dma() local
339 /* Disable DMA and 16-bit accesses */ in vx_release_pseudo_dma()
340 chip->regDIALOG &= ~(VXP_DLG_DMAWRITE_SEL_MASK| in vx_release_pseudo_dma()
343 vx_outb(chip, DIALOG, chip->regDIALOG); in vx_release_pseudo_dma()
345 vx_outb(chip, ICR, 0); in vx_release_pseudo_dma()
349 * vx_pseudo_dma_write - write bulk data on pseudo-DMA mode
350 * @count: data length to transfer in bytes
352 * data size must be aligned to 6 bytes to ensure the 24bit alignment on DSP.
355 static void vxp_dma_write(struct vx_core *chip, struct snd_pcm_runtime *runtime, in vxp_dma_write() argument
358 long port = vxp_reg_addr(chip, VX_DMA); in vxp_dma_write()
359 int offset = pipe->hw_ptr; in vxp_dma_write()
360 unsigned short *addr = (unsigned short *)(runtime->dma_area + offset); in vxp_dma_write()
362 vx_setup_pseudo_dma(chip, 1); in vxp_dma_write()
363 if (offset + count >= pipe->buffer_bytes) { in vxp_dma_write()
364 int length = pipe->buffer_bytes - offset; in vxp_dma_write()
365 count -= length; in vxp_dma_write()
367 /* Transfer using pseudo-dma. */ in vxp_dma_write()
368 for (; length > 0; length--) { in vxp_dma_write()
372 addr = (unsigned short *)runtime->dma_area; in vxp_dma_write()
373 pipe->hw_ptr = 0; in vxp_dma_write()
375 pipe->hw_ptr += count; in vxp_dma_write()
377 /* Transfer using pseudo-dma. */ in vxp_dma_write()
378 for (; count > 0; count--) { in vxp_dma_write()
382 vx_release_pseudo_dma(chip); in vxp_dma_write()
387 * vx_pseudo_dma_read - read bulk data on pseudo DMA mode
389 * @count: data length to transfer in bytes
391 * the read length must be aligned to 6 bytes, as well as write.
394 static void vxp_dma_read(struct vx_core *chip, struct snd_pcm_runtime *runtime, in vxp_dma_read() argument
397 struct snd_vxpocket *pchip = to_vxpocket(chip); in vxp_dma_read()
398 long port = vxp_reg_addr(chip, VX_DMA); in vxp_dma_read()
399 int offset = pipe->hw_ptr; in vxp_dma_read()
400 unsigned short *addr = (unsigned short *)(runtime->dma_area + offset); in vxp_dma_read()
404 vx_setup_pseudo_dma(chip, 0); in vxp_dma_read()
405 if (offset + count >= pipe->buffer_bytes) { in vxp_dma_read()
406 int length = pipe->buffer_bytes - offset; in vxp_dma_read()
407 count -= length; in vxp_dma_read()
409 /* Transfer using pseudo-dma. */ in vxp_dma_read()
410 for (; length > 0; length--) in vxp_dma_read()
412 addr = (unsigned short *)runtime->dma_area; in vxp_dma_read()
413 pipe->hw_ptr = 0; in vxp_dma_read()
415 pipe->hw_ptr += count; in vxp_dma_read()
417 /* Transfer using pseudo-dma. */ in vxp_dma_read()
418 for (; count > 1; count--) in vxp_dma_read()
421 pchip->regDIALOG &= ~VXP_DLG_DMAREAD_SEL_MASK; in vxp_dma_read()
422 vx_outb(chip, DIALOG, pchip->regDIALOG); in vxp_dma_read()
425 /* Disable 16-bit accesses */ in vxp_dma_read()
426 pchip->regDIALOG &= ~VXP_DLG_DMA16_SEL_MASK; in vxp_dma_read()
427 vx_outb(chip, DIALOG, pchip->regDIALOG); in vxp_dma_read()
429 vx_outb(chip, ICR, 0); in vxp_dma_read()
436 static void vxp_write_codec_reg(struct vx_core *chip, int codec, unsigned int data) in vxp_write_codec_reg() argument
440 /* Activate access to the corresponding codec register */ in vxp_write_codec_reg()
442 vx_inb(chip, LOFREQ); in vxp_write_codec_reg()
444 vx_inb(chip, CODEC2); in vxp_write_codec_reg()
446 /* We have to send 24 bits (3 x 8 bits). Start with most signif. Bit */ in vxp_write_codec_reg()
448 vx_outb(chip, DATA, ((data & 0x800000) ? VX_DATA_CODEC_MASK : 0)); in vxp_write_codec_reg()
450 /* Terminate access to codec registers */ in vxp_write_codec_reg()
451 vx_inb(chip, HIFREQ); in vxp_write_codec_reg()
456 * vx_set_mic_boost - set mic boost level (on vxp440 only)
459 void vx_set_mic_boost(struct vx_core *chip, int boost) in vx_set_mic_boost() argument
461 struct snd_vxpocket *pchip = to_vxpocket(chip); in vx_set_mic_boost()
463 if (chip->chip_status & VX_STAT_IS_STALE) in vx_set_mic_boost()
466 mutex_lock(&chip->lock); in vx_set_mic_boost()
467 if (pchip->regCDSP & P24_CDSP_MICS_SEL_MASK) { in vx_set_mic_boost()
470 pchip->regCDSP &= ~P24_CDSP_MIC20_SEL_MASK; in vx_set_mic_boost()
471 pchip->regCDSP |= P24_CDSP_MIC38_SEL_MASK; in vx_set_mic_boost()
474 pchip->regCDSP |= P24_CDSP_MIC20_SEL_MASK; in vx_set_mic_boost()
475 pchip->regCDSP &= ~P24_CDSP_MIC38_SEL_MASK; in vx_set_mic_boost()
477 vx_outb(chip, CDSP, pchip->regCDSP); in vx_set_mic_boost()
479 mutex_unlock(&chip->lock); in vx_set_mic_boost()
483 * remap the linear value (0-8) to the actual value (0-15)
498 * vx_set_mic_level - set mic level (on vxpocket only)
499 * @level: the mic level = 0 - 8 (max)
501 void vx_set_mic_level(struct vx_core *chip, int level) in vx_set_mic_level() argument
503 struct snd_vxpocket *pchip = to_vxpocket(chip); in vx_set_mic_level()
505 if (chip->chip_status & VX_STAT_IS_STALE) in vx_set_mic_level()
508 mutex_lock(&chip->lock); in vx_set_mic_level()
509 if (pchip->regCDSP & VXP_CDSP_MIC_SEL_MASK) { in vx_set_mic_level()
511 vx_outb(chip, MICRO, level); in vx_set_mic_level()
513 mutex_unlock(&chip->lock); in vx_set_mic_level()
522 struct snd_vxpocket *chip = to_vxpocket(_chip); in vxp_change_audio_source() local
526 chip->regCDSP |= VXP_CDSP_DATAIN_SEL_MASK; in vxp_change_audio_source()
527 vx_outb(chip, CDSP, chip->regCDSP); in vxp_change_audio_source()
530 chip->regCDSP &= ~VXP_CDSP_DATAIN_SEL_MASK; in vxp_change_audio_source()
531 if (_chip->type == VX_TYPE_VXP440) in vxp_change_audio_source()
532 chip->regCDSP &= ~P24_CDSP_MICS_SEL_MASK; in vxp_change_audio_source()
534 chip->regCDSP &= ~VXP_CDSP_MIC_SEL_MASK; in vxp_change_audio_source()
535 vx_outb(chip, CDSP, chip->regCDSP); in vxp_change_audio_source()
538 chip->regCDSP &= ~VXP_CDSP_DATAIN_SEL_MASK; in vxp_change_audio_source()
540 if (_chip->type == VX_TYPE_VXP440) { in vxp_change_audio_source()
541 chip->regCDSP &= ~P24_CDSP_MICS_SEL_MASK; in vxp_change_audio_source()
542 if (chip->mic_level) in vxp_change_audio_source()
543 chip->regCDSP |= P24_CDSP_MIC38_SEL_MASK; in vxp_change_audio_source()
545 chip->regCDSP |= P24_CDSP_MIC20_SEL_MASK; in vxp_change_audio_source()
546 vx_outb(chip, CDSP, chip->regCDSP); in vxp_change_audio_source()
548 chip->regCDSP |= VXP_CDSP_MIC_SEL_MASK; in vxp_change_audio_source()
549 vx_outb(chip, CDSP, chip->regCDSP); in vxp_change_audio_source()
550 vx_outb(chip, MICRO, vx_compute_mic_level(chip->mic_level)); in vxp_change_audio_source()
562 struct snd_vxpocket *chip = to_vxpocket(_chip); in vxp_set_clock_source() local
565 chip->regCDSP &= ~VXP_CDSP_CLOCKIN_SEL_MASK; in vxp_set_clock_source()
567 chip->regCDSP |= VXP_CDSP_CLOCKIN_SEL_MASK; in vxp_set_clock_source()
568 vx_outb(chip, CDSP, chip->regCDSP); in vxp_set_clock_source()
577 struct snd_vxpocket *chip = to_vxpocket(_chip); in vxp_reset_board() local
579 chip->regCDSP = 0; in vxp_reset_board()
580 chip->regDIALOG = 0; in vxp_reset_board()