26 #include <linux/module.h>
31 #include <linux/i2c.h>
33 #include <linux/slab.h>
123 {
AIC32X4_FREQ_12000000, 8000, 1, 7, 6800, 768, 5, 3, 128, 5, 18, 24},
124 {
AIC32X4_FREQ_24000000, 8000, 2, 7, 6800, 768, 15, 1, 64, 45, 4, 24},
125 {
AIC32X4_FREQ_25000000, 8000, 2, 7, 3728, 768, 15, 1, 64, 45, 4, 24},
127 {
AIC32X4_FREQ_12000000, 11025, 1, 7, 5264, 512, 8, 2, 128, 8, 8, 16},
128 {
AIC32X4_FREQ_24000000, 11025, 2, 7, 5264, 512, 16, 1, 64, 32, 4, 16},
130 {
AIC32X4_FREQ_12000000, 16000, 1, 7, 6800, 384, 5, 3, 128, 5, 9, 12},
131 {
AIC32X4_FREQ_24000000, 16000, 2, 7, 6800, 384, 15, 1, 64, 18, 5, 12},
132 {
AIC32X4_FREQ_25000000, 16000, 2, 7, 3728, 384, 15, 1, 64, 18, 5, 12},
134 {
AIC32X4_FREQ_12000000, 22050, 1, 7, 5264, 256, 4, 4, 128, 4, 8, 8},
135 {
AIC32X4_FREQ_24000000, 22050, 2, 7, 5264, 256, 16, 1, 64, 16, 4, 8},
136 {
AIC32X4_FREQ_25000000, 22050, 2, 7, 2253, 256, 16, 1, 64, 16, 4, 8},
138 {
AIC32X4_FREQ_12000000, 32000, 1, 7, 1680, 192, 2, 7, 64, 2, 21, 6},
139 {
AIC32X4_FREQ_24000000, 32000, 2, 7, 1680, 192, 7, 2, 64, 7, 6, 6},
141 {
AIC32X4_FREQ_12000000, 44100, 1, 7, 5264, 128, 2, 8, 128, 2, 8, 4},
142 {
AIC32X4_FREQ_24000000, 44100, 2, 7, 5264, 128, 8, 2, 64, 8, 4, 4},
143 {
AIC32X4_FREQ_25000000, 44100, 2, 7, 2253, 128, 8, 2, 64, 8, 4, 4},
145 {
AIC32X4_FREQ_12000000, 48000, 1, 8, 1920, 128, 2, 8, 128, 2, 8, 4},
146 {
AIC32X4_FREQ_24000000, 48000, 2, 8, 1920, 128, 8, 2, 64, 8, 4, 4},
147 {
AIC32X4_FREQ_25000000, 48000, 2, 7, 8643, 128, 8, 2, 64, 8, 4, 4}
183 &hpl_output_mixer_controls[0],
188 &lol_output_mixer_controls[0],
194 &hpr_output_mixer_controls[0],
198 &lor_output_mixer_controls[0],
202 &left_input_mixer_controls[0],
205 &right_input_mixer_controls[0],
225 {
"HPL Output Mixer",
"L_DAC Switch",
"Left DAC"},
226 {
"HPL Output Mixer",
"IN1_L Switch",
"IN1_L"},
228 {
"HPL Power",
NULL,
"HPL Output Mixer"},
229 {
"HPL",
NULL,
"HPL Power"},
231 {
"LOL Output Mixer",
"L_DAC Switch",
"Left DAC"},
233 {
"LOL Power",
NULL,
"LOL Output Mixer"},
234 {
"LOL",
NULL,
"LOL Power"},
237 {
"HPR Output Mixer",
"R_DAC Switch",
"Right DAC"},
238 {
"HPR Output Mixer",
"IN1_R Switch",
"IN1_R"},
240 {
"HPR Power",
NULL,
"HPR Output Mixer"},
241 {
"HPR",
NULL,
"HPR Power"},
243 {
"LOR Output Mixer",
"R_DAC Switch",
"Right DAC"},
245 {
"LOR Power",
NULL,
"LOR Output Mixer"},
246 {
"LOR",
NULL,
"LOR Power"},
249 {
"Left Input Mixer",
"IN1_L P Switch",
"IN1_L"},
250 {
"Left Input Mixer",
"IN2_L P Switch",
"IN2_L"},
251 {
"Left Input Mixer",
"IN3_L P Switch",
"IN3_L"},
253 {
"Left ADC",
NULL,
"Left Input Mixer"},
256 {
"Right Input Mixer",
"IN1_R P Switch",
"IN1_R"},
257 {
"Right Input Mixer",
"IN2_R P Switch",
"IN2_R"},
258 {
"Right Input Mixer",
"IN3_R P Switch",
"IN3_R"},
260 {
"Right ADC",
NULL,
"Right Input Mixer"},
264 unsigned int new_page)
266 struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
271 data[1] = new_page & 0xff;
285 struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
286 unsigned int page = reg / 128;
287 unsigned int fixed_reg = reg % 128;
293 return aic32x4_change_page(codec, val);
295 if (aic32x4->
page_no != page) {
296 ret = aic32x4_change_page(codec, page);
301 data[0] = fixed_reg & 0xff;
302 data[1] = val & 0xff;
310 static unsigned int aic32x4_read(
struct snd_soc_codec *codec,
unsigned int reg)
312 struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
313 unsigned int page = reg / 128;
314 unsigned int fixed_reg = reg % 128;
317 if (aic32x4->
page_no != page) {
318 ret = aic32x4_change_page(codec, page);
325 static inline int aic32x4_get_divs(
int mclk,
int rate)
329 for (i = 0; i <
ARRAY_SIZE(aic32x4_divs); i++) {
330 if ((aic32x4_divs[i].rate == rate)
335 printk(
KERN_ERR "aic32x4: master clock and sample rate is not supported\n");
351 static int aic32x4_set_dai_sysclk(
struct snd_soc_dai *codec_dai,
352 int clk_id,
unsigned int freq,
int dir)
355 struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
364 printk(
KERN_ERR "aic32x4: invalid frequency to set DAI system clock\n");
368 static int aic32x4_set_dai_fmt(
struct snd_soc_dai *codec_dai,
unsigned int fmt)
376 iface_reg_1 = iface_reg_1 & ~(3 << 6 | 3 << 2);
380 iface_reg_3 = iface_reg_3 & ~(1 << 3);
399 iface_reg_3 |= (1 << 3);
404 iface_reg_3 |= (1 << 3);
430 struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
448 (data | (aic32x4_divs[i].p_val << 4) | 0x01));
454 (aic32x4_divs[i].pll_d & 0xff));
469 (aic32x4_divs[i].dosr & 0xff));
490 data = data & ~(3 << 4);
522 static int aic32x4_set_bias_level(
struct snd_soc_codec *codec,
585 #define AIC32X4_RATES SNDRV_PCM_RATE_8000_48000
586 #define AIC32X4_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE \
587 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE)
590 .hw_params = aic32x4_hw_params,
591 .digital_mute = aic32x4_mute,
592 .set_fmt = aic32x4_set_dai_fmt,
593 .set_sysclk = aic32x4_set_dai_sysclk,
597 .name =
"tlv320aic32x4-hifi",
599 .stream_name =
"Playback",
605 .stream_name =
"Capture",
611 .symmetric_rates = 1,
628 struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
676 aic32x4_add_widgets(codec);
688 .read = aic32x4_read,
689 .write = aic32x4_write,
690 .probe = aic32x4_probe,
691 .remove = aic32x4_remove,
692 .suspend = aic32x4_suspend,
693 .resume = aic32x4_resume,
694 .set_bias_level = aic32x4_set_bias_level,
710 i2c_set_clientdata(i2c, aic32x4);
723 &soc_codec_dev_aic32x4, &aic32x4_dai, 1);
734 {
"tlv320aic32x4", 0 },
739 static struct i2c_driver aic32x4_i2c_driver = {
741 .name =
"tlv320aic32x4",
744 .probe = aic32x4_i2c_probe,
746 .id_table = aic32x4_i2c_id,