Lines Matching +full:mic +full:- +full:int
1 // SPDX-License-Identifier: GPL-2.0
17 #include <sound/soc-dai.h>
18 #include <sound/soc-dapm.h>
185 static int jz4770_codec_set_bias_level(struct snd_soc_component *codec, in jz4770_codec_set_bias_level()
189 struct regmap *regmap = jz_codec->regmap; in jz4770_codec_set_bias_level()
216 static int jz4770_codec_startup(struct snd_pcm_substream *substream, in jz4770_codec_startup()
219 struct snd_soc_component *codec = dai->component; in jz4770_codec_startup()
227 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in jz4770_codec_startup()
236 struct snd_soc_component *codec = dai->component; in jz4770_codec_shutdown()
239 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in jz4770_codec_shutdown()
244 static int jz4770_codec_pcm_trigger(struct snd_pcm_substream *substream, in jz4770_codec_pcm_trigger()
245 int cmd, struct snd_soc_dai *dai) in jz4770_codec_pcm_trigger()
247 struct snd_soc_component *codec = dai->component; in jz4770_codec_pcm_trigger()
248 int ret = 0; in jz4770_codec_pcm_trigger()
254 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) in jz4770_codec_pcm_trigger()
264 ret = -EINVAL; in jz4770_codec_pcm_trigger()
270 static int jz4770_codec_mute_stream(struct snd_soc_dai *dai, int mute, int direction) in jz4770_codec_mute_stream()
272 struct snd_soc_component *codec = dai->component; in jz4770_codec_mute_stream()
274 unsigned int gain_bit = mute ? REG_IFR_GDO : REG_IFR_GUP; in jz4770_codec_mute_stream()
275 unsigned int val; in jz4770_codec_mute_stream()
276 int change, err; in jz4770_codec_mute_stream()
282 regmap_read(jz_codec->regmap, JZ4770_CODEC_REG_CR_DAC, &val); in jz4770_codec_mute_stream()
287 err = regmap_read_poll_timeout(jz_codec->regmap, in jz4770_codec_mute_stream()
292 dev_err(jz_codec->dev, in jz4770_codec_mute_stream()
298 regmap_set_bits(jz_codec->regmap, JZ4770_CODEC_REG_IFR, in jz4770_codec_mute_stream()
306 static const DECLARE_TLV_DB_MINMAX_MUTE(dac_tlv, -3100, 0);
308 static const DECLARE_TLV_DB_MINMAX(out_tlv, -2500, 600);
309 static const DECLARE_TLV_DB_SCALE(linein_tlv, -2500, 100, 0);
310 static const DECLARE_TLV_DB_MINMAX(mixer_tlv, -3100, 0);
373 static int hpout_event(struct snd_soc_dapm_widget *w, in hpout_event()
374 struct snd_kcontrol *kcontrol, int event) in hpout_event()
376 struct snd_soc_component *codec = snd_soc_dapm_to_component(w->dapm); in hpout_event()
378 unsigned int val; in hpout_event()
379 int err; in hpout_event()
384 regmap_clear_bits(jz_codec->regmap, JZ4770_CODEC_REG_CR_HP, in hpout_event()
389 /* wait for ramp-up complete (RUP) */ in hpout_event()
390 err = regmap_read_poll_timeout(jz_codec->regmap, in hpout_event()
395 dev_err(jz_codec->dev, "RUP timeout: %d", err); in hpout_event()
400 regmap_set_bits(jz_codec->regmap, JZ4770_CODEC_REG_IFR, in hpout_event()
407 regmap_set_bits(jz_codec->regmap, JZ4770_CODEC_REG_CR_HP, in hpout_event()
410 err = regmap_read_poll_timeout(jz_codec->regmap, in hpout_event()
415 dev_err(jz_codec->dev, "RDO timeout: %d", err); in hpout_event()
420 regmap_set_bits(jz_codec->regmap, JZ4770_CODEC_REG_IFR, in hpout_event()
429 static int adc_poweron_event(struct snd_soc_dapm_widget *w, in adc_poweron_event()
430 struct snd_kcontrol *kcontrol, int event) in adc_poweron_event()
439 "PCM", "Line In", "Mic 1", "Mic 2"
441 static const unsigned int jz4770_codec_hp_values[] = { 3, 2, 0, 1 };
461 "Line In", "Mic 1", "Mic 2"
463 static const unsigned int jz4770_codec_cap_values[] = { 2, 0, 1 };
500 SND_SOC_DAPM_PGA("Mic 1", JZ4770_CODEC_REG_CR_MIC,
502 SND_SOC_DAPM_PGA("Mic 2", JZ4770_CODEC_REG_CR_MIC,
505 SND_SOC_DAPM_PGA("Mic Diff", JZ4770_CODEC_REG_CR_MIC,
508 SND_SOC_DAPM_MIXER("Mic", SND_SOC_NOPM, 0, 0,
531 SND_SOC_DAPM_SUPPLY("Cap-less", JZ4770_CODEC_REG_CR_HP,
553 { "Mic 1", NULL, "MIC1P" },
554 { "Mic Diff", NULL, "MIC1N" },
555 { "Mic 1", NULL, "Mic Diff" },
556 { "Mic 2", NULL, "MIC2P" },
557 { "Mic Diff", NULL, "MIC2N" },
558 { "Mic 2", NULL, "Mic Diff" },
563 { "Mic", "Stereo Capture Switch", "Mic 1" },
564 { "Mic", "Stereo Capture Switch", "Mic 2" },
565 { "Headphones Source", "Mic 1", "Mic" },
566 { "Headphones Source", "Mic 2", "Mic" },
567 { "Capture Source", "Mic 1", "Mic" },
568 { "Capture Source", "Mic 2", "Mic" },
570 { "Headphones Source", "Mic 1", "Mic 1" },
571 { "Headphones Source", "Mic 2", "Mic 2" },
577 { "Capture Source", "Mic 1", "Mic 1" },
578 { "Capture Source", "Mic 2", "Mic 2" },
603 struct regmap *regmap = jz_codec->regmap; in jz4770_codec_codec_init_regs()
614 /* Disable stereo mic */ in jz4770_codec_codec_init_regs()
618 /* Set mic 1 as default source for ADC */ in jz4770_codec_codec_init_regs()
654 /* default to cap-less mode(0) */ in jz4770_codec_codec_init_regs()
663 static int jz4770_codec_codec_probe(struct snd_soc_component *codec) in jz4770_codec_codec_probe()
667 clk_prepare_enable(jz_codec->clk); in jz4770_codec_codec_probe()
678 clk_disable_unprepare(jz_codec->clk); in jz4770_codec_codec_remove()
695 static const unsigned int jz4770_codec_sample_rates[] = {
701 static int jz4770_codec_hw_params(struct snd_pcm_substream *substream, in jz4770_codec_hw_params()
705 struct jz_codec *codec = snd_soc_component_get_drvdata(dai->component); in jz4770_codec_hw_params()
706 unsigned int rate, bit_width; in jz4770_codec_hw_params()
722 return -EINVAL; in jz4770_codec_hw_params()
731 return -EINVAL; in jz4770_codec_hw_params()
733 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in jz4770_codec_hw_params()
734 regmap_update_bits(codec->regmap, JZ4770_CODEC_REG_AICR_DAC, in jz4770_codec_hw_params()
737 regmap_update_bits(codec->regmap, JZ4770_CODEC_REG_FCR_DAC, in jz4770_codec_hw_params()
741 regmap_update_bits(codec->regmap, JZ4770_CODEC_REG_AICR_ADC, in jz4770_codec_hw_params()
744 regmap_update_bits(codec->regmap, JZ4770_CODEC_REG_FCR_ADC, in jz4770_codec_hw_params()
767 .name = "jz4770-hifi",
785 static bool jz4770_codec_volatile(struct device *dev, unsigned int reg) in jz4770_codec_volatile()
790 static bool jz4770_codec_readable(struct device *dev, unsigned int reg) in jz4770_codec_readable()
801 static bool jz4770_codec_writeable(struct device *dev, unsigned int reg) in jz4770_codec_writeable()
813 static int jz4770_codec_io_wait(struct jz_codec *codec) in jz4770_codec_io_wait()
817 return readl_poll_timeout(codec->base + ICDC_RGADW_OFFSET, reg, in jz4770_codec_io_wait()
822 static int jz4770_codec_reg_read(void *context, unsigned int reg, in jz4770_codec_reg_read()
823 unsigned int *val) in jz4770_codec_reg_read()
826 unsigned int i; in jz4770_codec_reg_read()
828 int ret; in jz4770_codec_reg_read()
834 tmp = readl(codec->base + ICDC_RGADW_OFFSET); in jz4770_codec_reg_read()
837 writel(tmp, codec->base + ICDC_RGADW_OFFSET); in jz4770_codec_reg_read()
841 *val = readl(codec->base + ICDC_RGDATA_OFFSET) & in jz4770_codec_reg_read()
847 static int jz4770_codec_reg_write(void *context, unsigned int reg, in jz4770_codec_reg_write()
848 unsigned int val) in jz4770_codec_reg_write()
851 int ret; in jz4770_codec_reg_write()
858 codec->base + ICDC_RGADW_OFFSET); in jz4770_codec_reg_write()
892 static int jz4770_codec_probe(struct platform_device *pdev) in jz4770_codec_probe()
894 struct device *dev = &pdev->dev; in jz4770_codec_probe()
896 int ret; in jz4770_codec_probe()
900 return -ENOMEM; in jz4770_codec_probe()
902 codec->dev = dev; in jz4770_codec_probe()
904 codec->base = devm_platform_ioremap_resource(pdev, 0); in jz4770_codec_probe()
905 if (IS_ERR(codec->base)) in jz4770_codec_probe()
906 return PTR_ERR(codec->base); in jz4770_codec_probe()
908 codec->regmap = devm_regmap_init(dev, NULL, codec, in jz4770_codec_probe()
910 if (IS_ERR(codec->regmap)) in jz4770_codec_probe()
911 return PTR_ERR(codec->regmap); in jz4770_codec_probe()
913 codec->clk = devm_clk_get(dev, "aic"); in jz4770_codec_probe()
914 if (IS_ERR(codec->clk)) in jz4770_codec_probe()
915 return PTR_ERR(codec->clk); in jz4770_codec_probe()
930 { .compatible = "ingenic,jz4770-codec", },
938 .name = "jz4770-codec",