24 #include <linux/device.h>
87 static inline unsigned long vx2_reg_addr(
struct vx_core *_chip,
int reg)
90 return chip->
port[vx2_reg_index[
reg]] + vx2_reg_offset[
reg];
99 return inb(vx2_reg_addr(chip, offset));
107 static void vx2_outb(
struct vx_core *chip,
int offset,
unsigned char val)
109 outb(val, vx2_reg_addr(chip, offset));
119 static unsigned int vx2_inl(
struct vx_core *chip,
int offset)
121 return inl(vx2_reg_addr(chip, offset));
129 static void vx2_outl(
struct vx_core *chip,
int offset,
unsigned int val)
134 outl(val, vx2_reg_addr(chip, offset));
141 #define vx_inb(chip,reg) vx2_inb((struct vx_core*)(chip), VX_##reg)
143 #define vx_outb(chip,reg,val) vx2_outb((struct vx_core*)(chip), VX_##reg, val)
145 #define vx_inl(chip,reg) vx2_inl((struct vx_core*)(chip), VX_##reg)
147 #define vx_outl(chip,reg,val) vx2_outl((struct vx_core*)(chip), VX_##reg, val)
154 #define XX_DSP_RESET_WAIT_TIME 2
156 static void vx2_reset_dsp(
struct vx_core *_chip)
171 static int vx2_test_xilinx(
struct vx_core *_chip)
194 if (! (data & VX_STATUS_VAL_TEST0_MASK)) {
214 if (! (data & VX_STATUS_VAL_TEST1_MASK)) {
244 static inline void vx2_release_pseudo_dma(
struct vx_core *chip)
256 unsigned long port = vx2_reg_addr(chip,
VX_DMA);
257 int offset = pipe->
hw_ptr;
263 vx2_setup_pseudo_dma(chip, 1);
272 while (length-- > 0) {
282 while (count-- > 0) {
287 vx2_release_pseudo_dma(chip);
293 struct vx_pipe *pipe,
int count)
295 int offset = pipe->
hw_ptr;
297 unsigned long port = vx2_reg_addr(chip,
VX_DMA);
302 vx2_setup_pseudo_dma(chip, 0);
321 vx2_release_pseudo_dma(chip);
324 #define VX_XILINX_RESET_MASK 0x40000000
325 #define VX_USERBIT0_MASK 0x00000004
326 #define VX_USERBIT1_MASK 0x00000020
327 #define VX_CNTRL_REGISTER_VALUE 0x00172012
332 static int put_xilinx_data(
struct vx_core *chip,
unsigned int port,
unsigned int counts,
unsigned char data)
336 for (i = 0; i < counts; i++) {
341 vx2_outl(chip, port, val);
349 vx2_outl(chip, port, val);
354 vx2_outl(chip, port, val);
364 static int vx2_load_xilinx_binary(
struct vx_core *chip,
const struct firmware *xilinx)
368 const unsigned char *
image;
383 image = xilinx->
data;
384 for (i = 0; i < xilinx->
size; i++, image++) {
385 if (put_xilinx_data(chip, port, 8, *image) < 0)
390 put_xilinx_data(chip, port, 4, 0xff);
418 if ((err = vx2_load_xilinx_binary(vx, dsp)) < 0)
420 if ((err = vx2_test_xilinx(vx)) < 0)
443 static int vx2_test_and_ack(
struct vx_core *chip)
474 static void vx2_validate_irq(
struct vx_core *_chip,
int enable)
495 static void vx2_write_codec_reg(
struct vx_core *chip,
unsigned int data)
502 for (i = 0; i < 24; i++, data <<= 1)
509 #define AKM_CODEC_POWER_CONTROL_CMD 0xA007
510 #define AKM_CODEC_RESET_ON_CMD 0xA100
511 #define AKM_CODEC_RESET_OFF_CMD 0xA103
512 #define AKM_CODEC_CLOCK_FORMAT_CMD 0xA240
513 #define AKM_CODEC_MUTE_CMD 0xA38D
514 #define AKM_CODEC_UNMUTE_CMD 0xA30D
515 #define AKM_CODEC_LEFT_LEVEL_CMD 0xA400
516 #define AKM_CODEC_RIGHT_LEVEL_CMD 0xA500
671 static void vx2_write_akm(
struct vx_core *chip,
int reg,
unsigned int data)
684 if (
snd_BUG_ON(data >=
sizeof(vx2_akm_gains_lut)))
698 val |= vx2_akm_gains_lut[
data];
700 vx2_write_codec_reg(chip, val);
707 static void vx2_old_write_codec_bit(
struct vx_core *chip,
int codec,
unsigned int data)
714 for (i = 0; i < 24; i++, data <<= 1)
725 static void vx2_reset_codec(
struct vx_core *_chip)
767 static void vx2_change_audio_source(
struct vx_core *_chip,
int src)
786 static void vx2_set_clock_source(
struct vx_core *_chip,
int source)
800 static void vx2_reset_board(
struct vx_core *_chip,
int cold_reset)
819 #define V2_MICRO_LEVEL_RANGE (318 - 255)
821 static void vx2_set_input_level(
struct snd_vx222 *chip)
823 int i, miclevel, preamp;
829 while (miclevel > 210) {
831 miclevel -= (18 * 2);
841 data = (
unsigned int)miclevel << 16 |
847 for (i = 0; i < 32; i++, data <<= 1)
854 #define MIC_LEVEL_MAX 0xff
887 if (ucontrol->
value.integer.value[0] < 0 ||
890 if (ucontrol->
value.integer.value[1] < 0 ||
898 vx2_set_input_level(chip);
928 if (ucontrol->
value.integer.value[0] < 0 ||
934 vx2_set_input_level(chip);
946 .
name =
"Capture Volume",
947 .
info = vx_input_level_info,
948 .
get = vx_input_level_get,
949 .
put = vx_input_level_put,
950 .
tlv = { .p = db_scale_mic },
957 .
name =
"Mic Capture Volume",
958 .
info = vx_mic_level_info,
959 .
get = vx_mic_level_get,
960 .
put = vx_mic_level_put,
961 .
tlv = { .p = db_scale_mic },
968 static int vx2_add_mic_controls(
struct vx_core *_chip)
979 vx2_set_input_level(chip);
999 .test_and_ack = vx2_test_and_ack,
1000 .validate_irq = vx2_validate_irq,
1001 .akm_write = vx2_write_akm,
1002 .reset_codec = vx2_reset_codec,
1003 .change_audio_source = vx2_change_audio_source,
1004 .set_clock_source = vx2_set_clock_source,
1005 .load_dsp = vx2_load_dsp,
1006 .reset_dsp = vx2_reset_dsp,
1007 .reset_board = vx2_reset_board,
1008 .dma_write = vx2_dma_write,
1009 .dma_read = vx2_dma_read,
1010 .add_controls = vx2_add_mic_controls,
1019 .test_and_ack = vx2_test_and_ack,
1020 .validate_irq = vx2_validate_irq,
1021 .write_codec = vx2_old_write_codec_bit,
1022 .reset_codec = vx2_reset_codec,
1023 .change_audio_source = vx2_change_audio_source,
1024 .set_clock_source = vx2_set_clock_source,
1025 .load_dsp = vx2_load_dsp,
1026 .reset_dsp = vx2_reset_dsp,
1027 .reset_board = vx2_reset_board,
1028 .dma_write = vx2_dma_write,
1029 .dma_read = vx2_dma_read,