Lines Matching +full:bt +full:- +full:pcm +full:- +full:int +full:- +full:params
1 // SPDX-License-Identifier: GPL-2.0-only
3 * ak4641.c -- AK4641 ALSA Soc Audio driver
20 #include <sound/pcm.h>
52 unsigned int sysclk;
53 int deemph;
54 int playback_fs;
68 static const int deemph_settings[] = {44100, 0, 48000, 32000};
70 static int ak4641_set_deemph(struct snd_soc_component *component) in ak4641_set_deemph()
73 int i, best = 0; in ak4641_set_deemph()
77 if (ak4641->deemph && deemph_settings[i] != 0 && in ak4641_set_deemph()
78 abs(deemph_settings[i] - ak4641->playback_fs) < in ak4641_set_deemph()
79 abs(deemph_settings[best] - ak4641->playback_fs)) in ak4641_set_deemph()
82 if (!ak4641->deemph && deemph_settings[i] == 0) in ak4641_set_deemph()
86 dev_dbg(component->dev, "Set deemphasis %d\n", best); in ak4641_set_deemph()
91 static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, in ak4641_put_deemph()
96 int deemph = ucontrol->value.integer.value[0]; in ak4641_put_deemph()
99 return -EINVAL; in ak4641_put_deemph()
101 ak4641->deemph = deemph; in ak4641_put_deemph()
106 static int ak4641_get_deemph(struct snd_kcontrol *kcontrol, in ak4641_get_deemph()
112 ucontrol->value.integer.value[0] = ak4641->deemph; in ak4641_get_deemph()
116 static const char *ak4641_mono_out[] = {"(L + R)/2", "Hi-Z"};
122 static const DECLARE_TLV_DB_SCALE(mono_gain_tlv, -1700, 2300, 0);
124 static const DECLARE_TLV_DB_SCALE(eq_tlv, -1050, 150, 0);
125 static const DECLARE_TLV_DB_SCALE(master_tlv, -12750, 50, 0);
126 static const DECLARE_TLV_DB_SCALE(mic_stereo_sidetone_tlv, -2700, 300, 0);
127 static const DECLARE_TLV_DB_SCALE(mic_mono_sidetone_tlv, -400, 400, 0);
128 static const DECLARE_TLV_DB_SCALE(capture_tlv, -800, 50, 0);
129 static const DECLARE_TLV_DB_SCALE(alc_tlv, -800, 50, 0);
130 static const DECLARE_TLV_DB_SCALE(aux_in_tlv, -2100, 300, 0);
248 SND_SOC_DAPM_MICBIAS("Mic Int Bias", AK4641_MIC, 3, 0),
269 {"Mic Mux", "Internal", "Mic Int Bias"},
271 {"Mic Int Bias", NULL, "MICIN"},
304 static int ak4641_set_dai_sysclk(struct snd_soc_dai *codec_dai, in ak4641_set_dai_sysclk()
305 int clk_id, unsigned int freq, int dir) in ak4641_set_dai_sysclk()
307 struct snd_soc_component *component = codec_dai->component; in ak4641_set_dai_sysclk()
310 ak4641->sysclk = freq; in ak4641_set_dai_sysclk()
314 static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, in ak4641_i2s_hw_params()
315 struct snd_pcm_hw_params *params, in ak4641_i2s_hw_params() argument
318 struct snd_soc_component *component = dai->component; in ak4641_i2s_hw_params()
320 int rate = params_rate(params), fs = 256; in ak4641_i2s_hw_params()
324 fs = ak4641->sysclk / rate; in ak4641_i2s_hw_params()
326 return -EINVAL; in ak4641_i2s_hw_params()
340 dev_err(component->dev, "Error: unsupported fs=%d\n", fs); in ak4641_i2s_hw_params()
341 return -EINVAL; in ak4641_i2s_hw_params()
346 /* Update de-emphasis filter for the new rate */ in ak4641_i2s_hw_params()
347 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in ak4641_i2s_hw_params()
348 ak4641->playback_fs = rate; in ak4641_i2s_hw_params()
355 static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, in ak4641_pcm_set_dai_fmt()
356 unsigned int fmt) in ak4641_pcm_set_dai_fmt()
358 struct snd_soc_component *component = codec_dai->component; in ak4641_pcm_set_dai_fmt()
360 int ret; in ak4641_pcm_set_dai_fmt()
377 return -EINVAL; in ak4641_pcm_set_dai_fmt()
387 static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, in ak4641_i2s_set_dai_fmt()
388 unsigned int fmt) in ak4641_i2s_set_dai_fmt()
390 struct snd_soc_component *component = codec_dai->component; in ak4641_i2s_set_dai_fmt()
402 return -EINVAL; in ak4641_i2s_set_dai_fmt()
408 static int ak4641_mute(struct snd_soc_dai *dai, int mute, int direction) in ak4641_mute()
410 struct snd_soc_component *component = dai->component; in ak4641_mute()
415 static int ak4641_set_bias_level(struct snd_soc_component *component, in ak4641_set_bias_level()
419 struct ak4641_platform_data *pdata = component->dev->platform_data; in ak4641_set_bias_level()
420 int ret; in ak4641_set_bias_level()
433 if (pdata && gpio_is_valid(pdata->gpio_power)) in ak4641_set_bias_level()
434 gpio_set_value(pdata->gpio_power, 1); in ak4641_set_bias_level()
436 if (pdata && gpio_is_valid(pdata->gpio_npdn)) in ak4641_set_bias_level()
437 gpio_set_value(pdata->gpio_npdn, 1); in ak4641_set_bias_level()
440 ret = regcache_sync(ak4641->regmap); in ak4641_set_bias_level()
442 dev_err(component->dev, in ak4641_set_bias_level()
452 if (pdata && gpio_is_valid(pdata->gpio_npdn)) in ak4641_set_bias_level()
453 gpio_set_value(pdata->gpio_npdn, 0); in ak4641_set_bias_level()
454 if (pdata && gpio_is_valid(pdata->gpio_power)) in ak4641_set_bias_level()
455 gpio_set_value(pdata->gpio_power, 0); in ak4641_set_bias_level()
456 regcache_mark_dirty(ak4641->regmap); in ak4641_set_bias_level()
476 .hw_params = NULL, /* rates are controlled by BT chip */
485 .name = "ak4641-hifi",
505 .name = "ak4641-voice",
550 static int ak4641_i2c_probe(struct i2c_client *i2c) in ak4641_i2c_probe()
552 struct ak4641_platform_data *pdata = i2c->dev.platform_data; in ak4641_i2c_probe()
554 int ret; in ak4641_i2c_probe()
556 ak4641 = devm_kzalloc(&i2c->dev, sizeof(struct ak4641_priv), in ak4641_i2c_probe()
559 return -ENOMEM; in ak4641_i2c_probe()
561 ak4641->regmap = devm_regmap_init_i2c(i2c, &ak4641_regmap); in ak4641_i2c_probe()
562 if (IS_ERR(ak4641->regmap)) in ak4641_i2c_probe()
563 return PTR_ERR(ak4641->regmap); in ak4641_i2c_probe()
566 if (gpio_is_valid(pdata->gpio_power)) { in ak4641_i2c_probe()
567 ret = gpio_request_one(pdata->gpio_power, in ak4641_i2c_probe()
572 if (gpio_is_valid(pdata->gpio_npdn)) { in ak4641_i2c_probe()
573 ret = gpio_request_one(pdata->gpio_npdn, in ak4641_i2c_probe()
579 gpio_set_value(pdata->gpio_npdn, 1); in ak4641_i2c_probe()
585 ret = devm_snd_soc_register_component(&i2c->dev, in ak4641_i2c_probe()
595 if (gpio_is_valid(pdata->gpio_power)) in ak4641_i2c_probe()
596 gpio_set_value(pdata->gpio_power, 0); in ak4641_i2c_probe()
597 if (gpio_is_valid(pdata->gpio_npdn)) in ak4641_i2c_probe()
598 gpio_free(pdata->gpio_npdn); in ak4641_i2c_probe()
601 if (pdata && gpio_is_valid(pdata->gpio_power)) in ak4641_i2c_probe()
602 gpio_free(pdata->gpio_power); in ak4641_i2c_probe()
609 struct ak4641_platform_data *pdata = i2c->dev.platform_data; in ak4641_i2c_remove()
612 if (gpio_is_valid(pdata->gpio_power)) { in ak4641_i2c_remove()
613 gpio_set_value(pdata->gpio_power, 0); in ak4641_i2c_remove()
614 gpio_free(pdata->gpio_power); in ak4641_i2c_remove()
616 if (gpio_is_valid(pdata->gpio_npdn)) in ak4641_i2c_remove()
617 gpio_free(pdata->gpio_npdn); in ak4641_i2c_remove()