static int init_chip(void) { unsigned short val; static int initialized; if (initialized) return 0; pxa2xx_ac97_init(); /* * Check that the is codec connected to ac97 bus is WM9713L */ val = pxa2xx_ac97_read(0, AC97_VENDOR_ID1); if (val != WM9713L_VENDOR_ID_1) return -ENODEV; val = pxa2xx_ac97_read(0, AC97_VENDOR_ID2); if (val != WM9713L_VENDOR_ID_2) return -ENODEV; pxa2xx_ac97_write(0, AC97_POWERDOWN, 0x000); initialized = 1; return 0; }
static void pxa2xx_ac97_legacy_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { int ret; ret = pxa2xx_ac97_write(ac97->num, reg, val); }
static unsigned short ts_get_sample_1(unsigned short reg) { unsigned long wait; unsigned short v; pxa2xx_ac97_write(0, WM9713L_DIGITIZER_1_WM13, reg); wait = 0; do { v = pxa2xx_ac97_read(0, WM9713L_DIGITIZER_1_WM13); if ( !(v & 0x200 ) ) break; } while ( 100 > wait++ ); return pxa2xx_ac97_read(0, WM9713L_DIGITIZER_READ_BACK); }
int pxa3xx_wm9713l_ts_init(void) { int err; err = init_chip(); if (err) return err; ts_pw_on(); pxa2xx_ac97_write(0, WM9713L_DIGITIZER_3_WM13, 0xc008); pxa2xx_ac97_modify_register(0, WM9713L_GPIO_PIN_CFG, 0x4, 0); pxa2xx_ac97_modify_register(0, WM9713L_GPIO_PIN_SHARING, 0x4, 0); pxa2xx_ac97_modify_register(0, WM9713L_GPIO_PIN_WAKEUP, 0, 0x2000); pxa2xx_ac97_modify_register(0, WM9713L_GPIO_PIN_STICKY, 0, 0x2000); return 0; }
int pxa3xx_wm9713l_snd_init(void) { int err; err = init_chip(); if (err) return err; snd_pw_on(); /* * PLL */ /* initialise PLL when appropriate - do not forget to power on PLL */ /* * Capture path */ /* Turn on MIC1 only */ pxa2xx_ac97_write(0, WM9713L_MIC_BIAS, 0xc440); /* Select MUX source: MICA for both channels; no boost; no path to phone mixer */ pxa2xx_ac97_write(0, WM9713L_REC_ROUTE_MUX_SEL, 0xd600); /* * Playback path */ /* Unmute to phones mixer only; 0dB gain */ pxa2xx_ac97_write(0, WM9713L_DAC_PGA_VOL_ROUTE, 0x6808); /* mono, spk, out <- disable; hp <- hpmix */ pxa2xx_ac97_write(0, WM9713L_OUTPUT_PGA_MUX, 0xffaf); /* * Playbacl/Capture rates */ /* Enable variable rate audio */ pxa2xx_ac97_write(0, AC97_EXTENDED_STATUS, 0x1); /* Set rates */ pxa2xx_ac97_write(0, WM9713L_AUDIO_DAC_RATE, 44100); /* 0x2c */ pxa2xx_ac97_write(0, WM9713L_AUDIO_ADC_RATE, 16000); /* 0x32 */ return 0; }
void pxa3xx_wm9713l_ts_irq_reset(void) { unsigned short v; v = pxa2xx_ac97_read(0, WM9713L_GPIO_PIN_STATUS); pxa2xx_ac97_write(0, WM9713L_GPIO_PIN_STATUS, v & ~((1<<13)|(1<<2))); }
int pxa3xx_wm9713l_snd_set_capture_rate(unsigned int rate) { pxa2xx_ac97_write(0, WM9713L_AUDIO_ADC_RATE, rate); return 0; }
int pxa3xx_wm9713l_snd_set_playback_rate(unsigned int rate) { pxa2xx_ac97_write(0, WM9713L_AUDIO_DAC_RATE, rate); return 0; }