Lines Matching +full:mic +full:- +full:int

1 // SPDX-License-Identifier: GPL-2.0
18 #include <sound/soc-dai.h>
19 #include <sound/soc-dapm.h>
169 static int jz4760_codec_set_bias_level(struct snd_soc_component *codec, in jz4760_codec_set_bias_level()
173 struct regmap *regmap = jz_codec->regmap; in jz4760_codec_set_bias_level()
196 static int jz4760_codec_startup(struct snd_pcm_substream *substream, in jz4760_codec_startup()
199 struct snd_soc_component *codec = dai->component; in jz4760_codec_startup()
201 int ret = 0; in jz4760_codec_startup()
208 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in jz4760_codec_startup()
216 struct snd_soc_component *codec = dai->component; in jz4760_codec_shutdown()
219 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in jz4760_codec_shutdown()
224 static int jz4760_codec_pcm_trigger(struct snd_pcm_substream *substream, in jz4760_codec_pcm_trigger()
225 int cmd, struct snd_soc_dai *dai) in jz4760_codec_pcm_trigger()
227 struct snd_soc_component *codec = dai->component; in jz4760_codec_pcm_trigger()
228 int ret = 0; in jz4760_codec_pcm_trigger()
234 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) in jz4760_codec_pcm_trigger()
243 ret = -EINVAL; in jz4760_codec_pcm_trigger()
249 static int jz4760_codec_mute_stream(struct snd_soc_dai *dai, int mute, int direction) in jz4760_codec_mute_stream()
251 struct snd_soc_component *codec = dai->component; in jz4760_codec_mute_stream()
253 unsigned int gain_bit = mute ? REG_IFR_GDO : REG_IFR_GUP; in jz4760_codec_mute_stream()
254 unsigned int val, reg; in jz4760_codec_mute_stream()
255 int change, err; in jz4760_codec_mute_stream()
261 regmap_read(jz_codec->regmap, JZ4760_CODEC_REG_PMR2, &val); in jz4760_codec_mute_stream()
266 err = regmap_read_poll_timeout(jz_codec->regmap, in jz4760_codec_mute_stream()
271 dev_err(jz_codec->dev, in jz4760_codec_mute_stream()
277 regmap_write(jz_codec->regmap, JZ4760_CODEC_REG_IFR, gain_bit); in jz4760_codec_mute_stream()
280 regmap_read(jz_codec->regmap, JZ4760_CODEC_REG_CR2, &reg); in jz4760_codec_mute_stream()
286 static const DECLARE_TLV_DB_MINMAX_MUTE(dac_tlv, -3100, 100);
288 static const DECLARE_TLV_DB_MINMAX(out_tlv, -2500, 100);
289 static const DECLARE_TLV_DB_SCALE(linein_tlv, -2500, 100, 0);
290 static const DECLARE_TLV_DB_MINMAX(mixer_tlv, -3100, 0);
311 SOC_SINGLE("High-Pass Filter Capture Switch",
350 static int hpout_event(struct snd_soc_dapm_widget *w, in hpout_event()
351 struct snd_kcontrol *kcontrol, int event) in hpout_event()
353 struct snd_soc_component *codec = snd_soc_dapm_to_component(w->dapm); in hpout_event()
355 unsigned int val; in hpout_event()
356 int err; in hpout_event()
361 regmap_clear_bits(jz_codec->regmap, JZ4760_CODEC_REG_CR1, in hpout_event()
366 /* wait for ramp-up complete (RUP) */ in hpout_event()
367 err = regmap_read_poll_timeout(jz_codec->regmap, in hpout_event()
372 dev_err(jz_codec->dev, "RUP timeout: %d", err); in hpout_event()
377 regmap_set_bits(jz_codec->regmap, JZ4760_CODEC_REG_IFR, in hpout_event()
384 regmap_set_bits(jz_codec->regmap, JZ4760_CODEC_REG_CR1, in hpout_event()
387 err = regmap_read_poll_timeout(jz_codec->regmap, in hpout_event()
392 dev_err(jz_codec->dev, "RDO timeout: %d", err); in hpout_event()
397 regmap_set_bits(jz_codec->regmap, JZ4760_CODEC_REG_IFR, in hpout_event()
407 "PCM", "Line In", "Mic 1", "Mic 2"
410 static const unsigned int jz4760_codec_hp_values[] = { 3, 2, 0, 1 };
422 "Line In", "Mic 1", "Mic 2"
425 static const unsigned int jz4760_codec_cap_values[] = { 2, 0, 1 };
471 SND_SOC_DAPM_PGA("Mic 1", JZ4760_CODEC_REG_PMR1,
474 SND_SOC_DAPM_PGA("Mic 2", JZ4760_CODEC_REG_PMR1,
477 SND_SOC_DAPM_PGA("Mic Diff", JZ4760_CODEC_REG_CR3,
480 SND_SOC_DAPM_MIXER("Mic", SND_SOC_NOPM, 0, 0,
526 { "Mic 1", NULL, "MIC1P" },
527 { "Mic Diff", NULL, "MIC1N" },
528 { "Mic 1", NULL, "Mic Diff" },
529 { "Mic 2", NULL, "MIC2P" },
530 { "Mic Diff", NULL, "MIC2N" },
531 { "Mic 2", NULL, "Mic Diff" },
536 { "Mic", "Stereo Capture Switch", "Mic 1" },
537 { "Mic", "Stereo Capture Switch", "Mic 2" },
538 { "Headphones Source", "Mic 1", "Mic" },
539 { "Headphones Source", "Mic 2", "Mic" },
540 { "Capture Source", "Mic 1", "Mic" },
541 { "Capture Source", "Mic 2", "Mic" },
544 { "Capture Source", "Mic 1", "Mic 1" },
545 { "Capture Source", "Mic 2", "Mic 2" },
550 { "Headphones Source", "Mic 1", "Mic 1" },
551 { "Headphones Source", "Mic 2", "Mic 2" },
576 struct regmap *regmap = jz_codec->regmap; in jz4760_codec_codec_init_regs()
584 /* Disable stereo mic */ in jz4760_codec_codec_init_regs()
588 /* Set mic 1 as default source for ADC */ in jz4760_codec_codec_init_regs()
611 regmap_set_bits(jz_codec->regmap, JZ4760_CODEC_REG_CR2, in jz4760_codec_codec_init_regs()
626 static int jz4760_codec_codec_probe(struct snd_soc_component *codec) in jz4760_codec_codec_probe()
630 clk_prepare_enable(jz_codec->clk); in jz4760_codec_codec_probe()
641 clk_disable_unprepare(jz_codec->clk); in jz4760_codec_codec_remove()
658 static const unsigned int jz4760_codec_sample_rates[] = {
664 static int jz4760_codec_hw_params(struct snd_pcm_substream *substream, in jz4760_codec_hw_params()
668 struct jz_codec *codec = snd_soc_component_get_drvdata(dai->component); in jz4760_codec_hw_params()
669 unsigned int rate, bit_width; in jz4760_codec_hw_params()
685 return -EINVAL; in jz4760_codec_hw_params()
694 return -EINVAL; in jz4760_codec_hw_params()
696 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in jz4760_codec_hw_params()
697 regmap_update_bits(codec->regmap, JZ4760_CODEC_REG_AICR, in jz4760_codec_hw_params()
700 regmap_update_bits(codec->regmap, JZ4760_CODEC_REG_CCR2, in jz4760_codec_hw_params()
704 regmap_update_bits(codec->regmap, JZ4760_CODEC_REG_AICR, in jz4760_codec_hw_params()
707 regmap_update_bits(codec->regmap, JZ4760_CODEC_REG_CCR2, in jz4760_codec_hw_params()
730 .name = "jz4760-hifi",
748 static bool jz4760_codec_volatile(struct device *dev, unsigned int reg) in jz4760_codec_volatile()
753 static bool jz4760_codec_writeable(struct device *dev, unsigned int reg) in jz4760_codec_writeable()
763 static int jz4760_codec_io_wait(struct jz_codec *codec) in jz4760_codec_io_wait()
767 return readl_poll_timeout(codec->base + ICDC_RGADW_OFFSET, reg, in jz4760_codec_io_wait()
772 static int jz4760_codec_reg_read(void *context, unsigned int reg, in jz4760_codec_reg_read()
773 unsigned int *val) in jz4760_codec_reg_read()
776 unsigned int i; in jz4760_codec_reg_read()
778 int ret; in jz4760_codec_reg_read()
784 tmp = readl(codec->base + ICDC_RGADW_OFFSET); in jz4760_codec_reg_read()
787 writel(tmp, codec->base + ICDC_RGADW_OFFSET); in jz4760_codec_reg_read()
791 *val = readl(codec->base + ICDC_RGDATA_OFFSET) & in jz4760_codec_reg_read()
797 static int jz4760_codec_reg_write(void *context, unsigned int reg, in jz4760_codec_reg_write()
798 unsigned int val) in jz4760_codec_reg_write()
801 int ret; in jz4760_codec_reg_write()
808 codec->base + ICDC_RGADW_OFFSET); in jz4760_codec_reg_write()
840 static int jz4760_codec_probe(struct platform_device *pdev) in jz4760_codec_probe()
842 struct device *dev = &pdev->dev; in jz4760_codec_probe()
844 int ret; in jz4760_codec_probe()
848 return -ENOMEM; in jz4760_codec_probe()
850 codec->dev = dev; in jz4760_codec_probe()
852 codec->base = devm_platform_ioremap_resource(pdev, 0); in jz4760_codec_probe()
853 if (IS_ERR(codec->base)) in jz4760_codec_probe()
854 return PTR_ERR(codec->base); in jz4760_codec_probe()
856 codec->regmap = devm_regmap_init(dev, NULL, codec, in jz4760_codec_probe()
858 if (IS_ERR(codec->regmap)) in jz4760_codec_probe()
859 return PTR_ERR(codec->regmap); in jz4760_codec_probe()
861 codec->clk = devm_clk_get(dev, "aic"); in jz4760_codec_probe()
862 if (IS_ERR(codec->clk)) in jz4760_codec_probe()
863 return PTR_ERR(codec->clk); in jz4760_codec_probe()
878 { .compatible = "ingenic,jz4760-codec", },
886 .name = "jz4760-codec",