Lines Matching +full:comp +full:- +full:int
1 // SPDX-License-Identifier: GPL-2.0-only
3 // tegra210_dmic.c - Tegra210 DMIC driver
26 /* Below enables all filters - DCR, LP and SC */
43 static int __maybe_unused tegra210_dmic_runtime_suspend(struct device *dev) in tegra210_dmic_runtime_suspend()
47 regcache_cache_only(dmic->regmap, true); in tegra210_dmic_runtime_suspend()
48 regcache_mark_dirty(dmic->regmap); in tegra210_dmic_runtime_suspend()
50 clk_disable_unprepare(dmic->clk_dmic); in tegra210_dmic_runtime_suspend()
55 static int __maybe_unused tegra210_dmic_runtime_resume(struct device *dev) in tegra210_dmic_runtime_resume()
58 int err; in tegra210_dmic_runtime_resume()
60 err = clk_prepare_enable(dmic->clk_dmic); in tegra210_dmic_runtime_resume()
66 regcache_cache_only(dmic->regmap, false); in tegra210_dmic_runtime_resume()
67 regcache_sync(dmic->regmap); in tegra210_dmic_runtime_resume()
72 static int tegra210_dmic_hw_params(struct snd_pcm_substream *substream, in tegra210_dmic_hw_params()
77 unsigned int srate, clk_rate, channels; in tegra210_dmic_hw_params()
80 int err; in tegra210_dmic_hw_params()
88 switch (dmic->ch_select) { in tegra210_dmic_hw_params()
97 dev_err(dai->dev, "invalid DMIC client channels\n"); in tegra210_dmic_hw_params()
98 return -EINVAL; in tegra210_dmic_hw_params()
107 clk_rate = (DMIC_OSR_FACTOR << dmic->osr_val) * srate; in tegra210_dmic_hw_params()
109 err = clk_set_rate(dmic->clk_dmic, clk_rate); in tegra210_dmic_hw_params()
111 dev_err(dai->dev, "can't set DMIC clock rate %u, err: %d\n", in tegra210_dmic_hw_params()
116 regmap_update_bits(dmic->regmap, in tegra210_dmic_hw_params()
124 (dmic->lrsel << LRSEL_POL_SHIFT) | in tegra210_dmic_hw_params()
125 (dmic->osr_val << OSR_SHIFT) | in tegra210_dmic_hw_params()
126 ((dmic->ch_select + 1) << CH_SEL_SHIFT)); in tegra210_dmic_hw_params()
132 if (dmic->boost_gain) in tegra210_dmic_hw_params()
133 gain_q23 = div_u64(gain_q23 * dmic->boost_gain, 100); in tegra210_dmic_hw_params()
135 regmap_write(dmic->regmap, TEGRA210_DMIC_LP_FILTER_GAIN, in tegra210_dmic_hw_params()
136 (unsigned int)gain_q23); in tegra210_dmic_hw_params()
146 dev_err(dai->dev, "unsupported format!\n"); in tegra210_dmic_hw_params()
147 return -EOPNOTSUPP; in tegra210_dmic_hw_params()
151 cif_conf.mono_conv = dmic->mono_to_stereo; in tegra210_dmic_hw_params()
152 cif_conf.stereo_conv = dmic->stereo_to_mono; in tegra210_dmic_hw_params()
154 tegra_set_cif(dmic->regmap, TEGRA210_DMIC_TX_CIF_CTRL, &cif_conf); in tegra210_dmic_hw_params()
159 static int tegra210_dmic_get_boost_gain(struct snd_kcontrol *kcontrol, in tegra210_dmic_get_boost_gain()
162 struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); in tegra210_dmic_get_boost_gain() local
163 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_get_boost_gain()
165 ucontrol->value.integer.value[0] = dmic->boost_gain; in tegra210_dmic_get_boost_gain()
170 static int tegra210_dmic_put_boost_gain(struct snd_kcontrol *kcontrol, in tegra210_dmic_put_boost_gain()
173 struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); in tegra210_dmic_put_boost_gain() local
174 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_put_boost_gain()
175 int value = ucontrol->value.integer.value[0]; in tegra210_dmic_put_boost_gain()
177 if (value == dmic->boost_gain) in tegra210_dmic_put_boost_gain()
180 dmic->boost_gain = value; in tegra210_dmic_put_boost_gain()
185 static int tegra210_dmic_get_ch_select(struct snd_kcontrol *kcontrol, in tegra210_dmic_get_ch_select()
188 struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); in tegra210_dmic_get_ch_select() local
189 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_get_ch_select()
191 ucontrol->value.enumerated.item[0] = dmic->ch_select; in tegra210_dmic_get_ch_select()
196 static int tegra210_dmic_put_ch_select(struct snd_kcontrol *kcontrol, in tegra210_dmic_put_ch_select()
199 struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); in tegra210_dmic_put_ch_select() local
200 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_put_ch_select()
201 unsigned int value = ucontrol->value.enumerated.item[0]; in tegra210_dmic_put_ch_select()
203 if (value == dmic->ch_select) in tegra210_dmic_put_ch_select()
206 dmic->ch_select = value; in tegra210_dmic_put_ch_select()
211 static int tegra210_dmic_get_mono_to_stereo(struct snd_kcontrol *kcontrol, in tegra210_dmic_get_mono_to_stereo()
214 struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); in tegra210_dmic_get_mono_to_stereo() local
215 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_get_mono_to_stereo()
217 ucontrol->value.enumerated.item[0] = dmic->mono_to_stereo; in tegra210_dmic_get_mono_to_stereo()
222 static int tegra210_dmic_put_mono_to_stereo(struct snd_kcontrol *kcontrol, in tegra210_dmic_put_mono_to_stereo()
225 struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); in tegra210_dmic_put_mono_to_stereo() local
226 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_put_mono_to_stereo()
227 unsigned int value = ucontrol->value.enumerated.item[0]; in tegra210_dmic_put_mono_to_stereo()
229 if (value == dmic->mono_to_stereo) in tegra210_dmic_put_mono_to_stereo()
232 dmic->mono_to_stereo = value; in tegra210_dmic_put_mono_to_stereo()
237 static int tegra210_dmic_get_stereo_to_mono(struct snd_kcontrol *kcontrol, in tegra210_dmic_get_stereo_to_mono()
240 struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); in tegra210_dmic_get_stereo_to_mono() local
241 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_get_stereo_to_mono()
243 ucontrol->value.enumerated.item[0] = dmic->stereo_to_mono; in tegra210_dmic_get_stereo_to_mono()
248 static int tegra210_dmic_put_stereo_to_mono(struct snd_kcontrol *kcontrol, in tegra210_dmic_put_stereo_to_mono()
251 struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); in tegra210_dmic_put_stereo_to_mono() local
252 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_put_stereo_to_mono()
253 unsigned int value = ucontrol->value.enumerated.item[0]; in tegra210_dmic_put_stereo_to_mono()
255 if (value == dmic->stereo_to_mono) in tegra210_dmic_put_stereo_to_mono()
258 dmic->stereo_to_mono = value; in tegra210_dmic_put_stereo_to_mono()
263 static int tegra210_dmic_get_osr_val(struct snd_kcontrol *kcontrol, in tegra210_dmic_get_osr_val()
266 struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); in tegra210_dmic_get_osr_val() local
267 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_get_osr_val()
269 ucontrol->value.enumerated.item[0] = dmic->osr_val; in tegra210_dmic_get_osr_val()
274 static int tegra210_dmic_put_osr_val(struct snd_kcontrol *kcontrol, in tegra210_dmic_put_osr_val()
277 struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); in tegra210_dmic_put_osr_val() local
278 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_put_osr_val()
279 unsigned int value = ucontrol->value.enumerated.item[0]; in tegra210_dmic_put_osr_val()
281 if (value == dmic->osr_val) in tegra210_dmic_put_osr_val()
284 dmic->osr_val = value; in tegra210_dmic_put_osr_val()
289 static int tegra210_dmic_get_pol_sel(struct snd_kcontrol *kcontrol, in tegra210_dmic_get_pol_sel()
292 struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); in tegra210_dmic_get_pol_sel() local
293 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_get_pol_sel()
295 ucontrol->value.enumerated.item[0] = dmic->lrsel; in tegra210_dmic_get_pol_sel()
300 static int tegra210_dmic_put_pol_sel(struct snd_kcontrol *kcontrol, in tegra210_dmic_put_pol_sel()
303 struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); in tegra210_dmic_put_pol_sel() local
304 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_put_pol_sel()
305 unsigned int value = ucontrol->value.enumerated.item[0]; in tegra210_dmic_put_pol_sel()
307 if (value == dmic->lrsel) in tegra210_dmic_put_pol_sel()
310 dmic->lrsel = value; in tegra210_dmic_put_pol_sel()
321 .name = "DMIC-CIF",
323 .stream_name = "CIF-Capture",
332 .name = "DMIC-DAP",
334 .stream_name = "DAP-Capture",
352 { "XBAR-RX", NULL, "XBAR-Capture" },
353 { "XBAR-Capture", NULL, "CIF-Capture" },
354 { "CIF-Capture", NULL, "TX" },
355 { "TX", NULL, "DAP-Capture" },
356 { "DAP-Capture", NULL, "MIC" },
428 static bool tegra210_dmic_wr_reg(struct device *dev, unsigned int reg) in tegra210_dmic_wr_reg()
442 static bool tegra210_dmic_rd_reg(struct device *dev, unsigned int reg) in tegra210_dmic_rd_reg()
458 static bool tegra210_dmic_volatile_reg(struct device *dev, unsigned int reg) in tegra210_dmic_volatile_reg()
486 static int tegra210_dmic_probe(struct platform_device *pdev) in tegra210_dmic_probe()
488 struct device *dev = &pdev->dev; in tegra210_dmic_probe()
491 int err; in tegra210_dmic_probe()
495 return -ENOMEM; in tegra210_dmic_probe()
497 dmic->osr_val = DMIC_OSR_64; in tegra210_dmic_probe()
498 dmic->ch_select = DMIC_CH_SELECT_STEREO; in tegra210_dmic_probe()
499 dmic->lrsel = DMIC_LRSEL_LEFT; in tegra210_dmic_probe()
500 dmic->boost_gain = 0; in tegra210_dmic_probe()
501 dmic->stereo_to_mono = 0; /* "CH0" */ in tegra210_dmic_probe()
505 dmic->clk_dmic = devm_clk_get(dev, "dmic"); in tegra210_dmic_probe()
506 if (IS_ERR(dmic->clk_dmic)) { in tegra210_dmic_probe()
508 return PTR_ERR(dmic->clk_dmic); in tegra210_dmic_probe()
515 dmic->regmap = devm_regmap_init_mmio(dev, regs, in tegra210_dmic_probe()
517 if (IS_ERR(dmic->regmap)) { in tegra210_dmic_probe()
519 return PTR_ERR(dmic->regmap); in tegra210_dmic_probe()
522 regcache_cache_only(dmic->regmap, true); in tegra210_dmic_probe()
539 pm_runtime_disable(&pdev->dev); in tegra210_dmic_remove()
550 { .compatible = "nvidia,tegra210-dmic" },
557 .name = "tegra210-dmic",