15 #include <linux/module.h>
20 #include <linux/i2c.h>
22 #include <linux/slab.h>
40 static const struct reg_default ak4535_reg_defaults[] = {
58 static bool ak4535_volatile(
struct device *
dev,
unsigned int reg)
68 static const char *ak4535_mono_gain[] = {
"+6dB",
"-17dB"};
69 static const char *ak4535_mono_out[] = {
"(L + R)/2",
"Hi-Z"};
70 static const char *ak4535_hp_out[] = {
"Stereo",
"Mono"};
71 static const char *ak4535_deemp[] = {
"44.1kHz",
"Off",
"48kHz",
"32kHz"};
72 static const char *ak4535_mic_select[] = {
"Internal",
"External"};
74 static const struct soc_enum ak4535_enum[] = {
84 SOC_ENUM(
"Mono 1 Output", ak4535_enum[1]),
85 SOC_ENUM(
"Mono 1 Gain", ak4535_enum[0]),
86 SOC_ENUM(
"Headphone Output", ak4535_enum[2]),
87 SOC_ENUM(
"Playback Deemphasis", ak4535_enum[3]),
90 SOC_ENUM(
"Mic Select", ak4535_enum[4]),
146 &ak4535_stereo_mixer_controls[0],
149 &ak4535_mono1_mixer_controls[0],
152 &ak4535_input_mixer_controls[0],
155 &ak4535_input_mux_control),
158 &ak4535_mono2_control),
162 &ak4535_line_control),
164 &ak4535_hpl_control),
166 &ak4535_hpr_control),
196 {
"Stereo Mixer",
"Playback Switch",
"DAC"},
197 {
"Stereo Mixer",
"Mic Sidetone Switch",
"Mic"},
198 {
"Stereo Mixer",
"Aux Bypass Switch",
"AUX In"},
201 {
"Mono1 Mixer",
"Mic Sidetone Switch",
"Mic"},
202 {
"Mono1 Mixer",
"Mono Playback Switch",
"DAC"},
205 {
"Mic",
NULL,
"AIN"},
206 {
"Input Mux",
"Internal",
"Mic Int Bias"},
207 {
"Input Mux",
"External",
"Mic Ext Bias"},
208 {
"Mic Int Bias",
NULL,
"MICIN"},
209 {
"Mic Ext Bias",
NULL,
"MICEXT"},
210 {
"MICOUT",
NULL,
"Input Mux"},
213 {
"LOUT",
NULL,
"Line Out Enable"},
214 {
"ROUT",
NULL,
"Line Out Enable"},
215 {
"Line Out Enable",
"Switch",
"Line Out"},
216 {
"Line Out",
NULL,
"Stereo Mixer"},
219 {
"MOUT1",
NULL,
"Mono Out"},
220 {
"Mono Out",
NULL,
"Mono1 Mixer"},
223 {
"HPL",
NULL,
"Left HP Enable"},
224 {
"Left HP Enable",
"Switch",
"HP L Amp"},
225 {
"HP L Amp",
NULL,
"Stereo Mixer"},
228 {
"HPR",
NULL,
"Right HP Enable"},
229 {
"Right HP Enable",
"Switch",
"HP R Amp"},
230 {
"HP R Amp",
NULL,
"Stereo Mixer"},
233 {
"SPP",
NULL,
"Speaker Enable"},
234 {
"SPN",
NULL,
"Speaker Enable"},
235 {
"Speaker Enable",
"Switch",
"Spk Amp"},
236 {
"Spk Amp",
NULL,
"MIN"},
239 {
"MOUT2",
NULL,
"Mono 2 Enable"},
240 {
"Mono 2 Enable",
"Switch",
"Stereo Mixer"},
243 {
"Aux In",
NULL,
"AUX"},
246 {
"ADC",
NULL,
"Input Mixer"},
247 {
"Input Mixer",
"Mic Capture Switch",
"Mic"},
248 {
"Input Mixer",
"Aux Capture Switch",
"Aux In"},
251 static int ak4535_set_dai_sysclk(
struct snd_soc_dai *codec_dai,
252 int clk_id,
unsigned int freq,
int dir)
255 struct ak4535_priv *ak4535 = snd_soc_codec_get_drvdata(codec);
266 struct ak4535_priv *ak4535 = snd_soc_codec_get_drvdata(codec);
290 static int ak4535_set_dai_fmt(
struct snd_soc_dai *codec_dai,
326 static int ak4535_set_bias_level(
struct snd_soc_codec *codec,
348 #define AK4535_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
349 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
350 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
353 .hw_params = ak4535_hw_params,
354 .set_fmt = ak4535_set_dai_fmt,
355 .digital_mute = ak4535_mute,
356 .set_sysclk = ak4535_set_dai_sysclk,
360 .name =
"ak4535-hifi",
362 .stream_name =
"Playback",
368 .stream_name =
"Capture",
373 .ops = &ak4535_dai_ops,
391 struct ak4535_priv *ak4535 = snd_soc_codec_get_drvdata(codec);
397 dev_err(codec->
dev,
"Failed to set cache I/O: %d\n", ret);
415 static const struct regmap_config ak4535_regmap = {
420 .volatile_reg = ak4535_volatile,
423 .reg_defaults = ak4535_reg_defaults,
424 .num_reg_defaults =
ARRAY_SIZE(ak4535_reg_defaults),
428 .probe = ak4535_probe,
429 .remove = ak4535_remove,
430 .suspend = ak4535_suspend,
431 .resume = ak4535_resume,
432 .set_bias_level = ak4535_set_bias_level,
433 .dapm_widgets = ak4535_dapm_widgets,
434 .num_dapm_widgets =
ARRAY_SIZE(ak4535_dapm_widgets),
435 .dapm_routes = ak4535_audio_map,
436 .num_dapm_routes =
ARRAY_SIZE(ak4535_audio_map),
451 if (IS_ERR(ak4535->
regmap)) {
452 ret = PTR_ERR(ak4535->
regmap);
453 dev_err(&i2c->
dev,
"Failed to init regmap: %d\n", ret);
457 i2c_set_clientdata(i2c, ak4535);
460 &soc_codec_dev_ak4535, &ak4535_dai, 1);
469 struct ak4535_priv *ak4535 = i2c_get_clientdata(client);
482 static struct i2c_driver ak4535_i2c_driver = {
487 .probe = ak4535_i2c_probe,
489 .id_table = ak4535_i2c_id,