24 #include <linux/device.h>
51 static inline unsigned long vxp_reg_addr(
struct vx_core *_chip,
int reg)
54 return chip->
port + vxp_reg_offset[
reg];
63 return inb(vxp_reg_addr(chip, offset));
71 static void vxp_outb(
struct vx_core *chip,
int offset,
unsigned char val)
73 outb(val, vxp_reg_addr(chip, offset));
80 #define vx_inb(chip,reg) vxp_inb((struct vx_core *)(chip), VX_##reg)
82 #define vx_outb(chip,reg,val) vxp_outb((struct vx_core *)(chip), VX_##reg,val)
90 static int vx_check_magic(
struct vx_core *chip)
92 unsigned long end_time =
jiffies +
HZ / 5;
109 #define XX_DSP_RESET_WAIT_TIME 2
111 static void vxp_reset_dsp(
struct vx_core *_chip)
129 static void vxp_reset_codec(
struct vx_core *_chip)
148 static int vxp_load_xilinx_binary(
struct vx_core *_chip,
const struct firmware *
fw)
153 int regCSUER, regRUER;
154 const unsigned char *
image;
162 regCSUER =
vx_inb(chip, CSUER);
163 regRUER =
vx_inb(chip, RUER);
176 for (i = 0; i < fw->
size; i++, image++) {
186 snd_printk(
KERN_ERR "vxpocket: load xilinx mismatch at %d: 0x%x != 0x%x\n", i, c, (
int)data);
212 if (vx_check_magic(_chip) < 0)
216 vx_outb(chip, CSUER, regCSUER);
229 vxp_reset_codec(_chip);
235 vx_outb(chip, CSUER, regCSUER);
253 if ((err = vx_check_magic(vx)) < 0)
260 return vxp_load_xilinx_binary(vx, fw);
281 static int vxp_test_and_ack(
struct vx_core *_chip)
308 static void vxp_validate_irq(
struct vx_core *_chip,
int enable)
344 static void vx_release_pseudo_dma(
struct vx_core *_chip)
368 int offset = pipe->
hw_ptr;
369 unsigned short *
addr = (
unsigned short *)(runtime->
dma_area + offset);
371 vx_setup_pseudo_dma(chip, 1);
377 while (length-- > 0) {
381 addr = (
unsigned short *)runtime->
dma_area;
387 while (count-- > 0) {
391 vx_release_pseudo_dma(chip);
404 struct vx_pipe *pipe,
int count)
407 long port = vxp_reg_addr(chip,
VX_DMA);
408 int offset = pipe->
hw_ptr;
409 unsigned short *addr = (
unsigned short *)(runtime->
dma_area + offset);
413 vx_setup_pseudo_dma(chip, 0);
421 addr = (
unsigned short *)runtime->
dma_area;
445 static void vxp_write_codec_reg(
struct vx_core *chip,
int codec,
unsigned int data)
456 for (i = 0; i < 24; i++, data <<= 1)
489 spin_unlock_irqrestore(&chip->
lock, flags);
495 static int vx_compute_mic_level(
int level)
498 case 5: level = 6 ;
break;
499 case 6: level = 8 ;
break;
500 case 7: level = 11;
break;
501 case 8: level = 15;
break;
521 level = vx_compute_mic_level(level);
524 spin_unlock_irqrestore(&chip->
lock, flags);
531 static void vxp_change_audio_source(
struct vx_core *_chip,
int src)
571 static void vxp_set_clock_source(
struct vx_core *_chip,
int source)
586 static void vxp_reset_board(
struct vx_core *_chip,
int cold_reset)
602 .test_and_ack = vxp_test_and_ack,
603 .validate_irq = vxp_validate_irq,
604 .write_codec = vxp_write_codec_reg,
605 .reset_codec = vxp_reset_codec,
606 .change_audio_source = vxp_change_audio_source,
607 .set_clock_source = vxp_set_clock_source,
608 .load_dsp = vxp_load_dsp,
610 .reset_dsp = vxp_reset_dsp,
611 .reset_board = vxp_reset_board,
612 .dma_write = vxp_dma_write,
613 .dma_read = vxp_dma_read,