• Home
  • Raw
  • Download

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()
213 static int jz4770_codec_startup(struct snd_pcm_substream *substream, in jz4770_codec_startup()
216 struct snd_soc_component *codec = dai->component; in jz4770_codec_startup()
224 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in jz4770_codec_startup()
233 struct snd_soc_component *codec = dai->component; in jz4770_codec_shutdown()
236 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in jz4770_codec_shutdown()
241 static int jz4770_codec_pcm_trigger(struct snd_pcm_substream *substream, in jz4770_codec_pcm_trigger()
242 int cmd, struct snd_soc_dai *dai) in jz4770_codec_pcm_trigger()
244 struct snd_soc_component *codec = dai->component; in jz4770_codec_pcm_trigger()
245 int ret = 0; in jz4770_codec_pcm_trigger()
251 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) in jz4770_codec_pcm_trigger()
261 ret = -EINVAL; in jz4770_codec_pcm_trigger()
267 static int jz4770_codec_mute_stream(struct snd_soc_dai *dai, int mute, int direction) in jz4770_codec_mute_stream()
269 struct snd_soc_component *codec = dai->component; in jz4770_codec_mute_stream()
271 unsigned int gain_bit = mute ? REG_IFR_GDO : REG_IFR_GUP; in jz4770_codec_mute_stream()
272 unsigned int val; in jz4770_codec_mute_stream()
273 int change, err; in jz4770_codec_mute_stream()
279 regmap_read(jz_codec->regmap, JZ4770_CODEC_REG_CR_DAC, &val); in jz4770_codec_mute_stream()
284 err = regmap_read_poll_timeout(jz_codec->regmap, in jz4770_codec_mute_stream()
289 dev_err(jz_codec->dev, in jz4770_codec_mute_stream()
295 regmap_update_bits(jz_codec->regmap, JZ4770_CODEC_REG_IFR, in jz4770_codec_mute_stream()
303 static const DECLARE_TLV_DB_MINMAX_MUTE(dac_tlv, -3100, 0);
305 static const DECLARE_TLV_DB_MINMAX(out_tlv, -2500, 600);
306 static const DECLARE_TLV_DB_SCALE(linein_tlv, -2500, 100, 0);
361 static int hpout_event(struct snd_soc_dapm_widget *w, in hpout_event()
362 struct snd_kcontrol *kcontrol, int event) in hpout_event()
364 struct snd_soc_component *codec = snd_soc_dapm_to_component(w->dapm); in hpout_event()
366 unsigned int val; in hpout_event()
367 int err; in hpout_event()
371 /* set cap-less, unmute HP */ in hpout_event()
372 regmap_update_bits(jz_codec->regmap, JZ4770_CODEC_REG_CR_HP, in hpout_event()
377 /* wait for ramp-up complete (RUP) */ in hpout_event()
378 err = regmap_read_poll_timeout(jz_codec->regmap, in hpout_event()
383 dev_err(jz_codec->dev, "RUP timeout: %d", err); in hpout_event()
388 regmap_update_bits(jz_codec->regmap, JZ4770_CODEC_REG_IFR, in hpout_event()
394 /* set cap-couple, mute HP */ in hpout_event()
395 regmap_update_bits(jz_codec->regmap, JZ4770_CODEC_REG_CR_HP, in hpout_event()
399 err = regmap_read_poll_timeout(jz_codec->regmap, in hpout_event()
404 dev_err(jz_codec->dev, "RDO timeout: %d", err); in hpout_event()
409 regmap_update_bits(jz_codec->regmap, JZ4770_CODEC_REG_IFR, in hpout_event()
418 static int adc_poweron_event(struct snd_soc_dapm_widget *w, in adc_poweron_event()
419 struct snd_kcontrol *kcontrol, int event) in adc_poweron_event()
428 "PCM", "Line In", "Mic 1", "Mic 2"
430 static const unsigned int jz4770_codec_hp_values[] = { 3, 2, 0, 1 };
450 "Line In", "Mic 1", "Mic 2"
452 static const unsigned int jz4770_codec_cap_values[] = { 2, 0, 1 };
489 SND_SOC_DAPM_PGA("Mic 1", JZ4770_CODEC_REG_CR_MIC,
491 SND_SOC_DAPM_PGA("Mic 2", JZ4770_CODEC_REG_CR_MIC,
494 SND_SOC_DAPM_PGA("Mic Diff", JZ4770_CODEC_REG_CR_MIC,
497 SND_SOC_DAPM_MIXER("Mic", SND_SOC_NOPM, 0, 0,
539 { "Mic 1", NULL, "MIC1P" },
540 { "Mic Diff", NULL, "MIC1N" },
541 { "Mic 1", NULL, "Mic Diff" },
542 { "Mic 2", NULL, "MIC2P" },
543 { "Mic Diff", NULL, "MIC2N" },
544 { "Mic 2", NULL, "Mic Diff" },
549 { "Mic", "Stereo Capture Switch", "Mic 1" },
550 { "Mic", "Stereo Capture Switch", "Mic 2" },
551 { "Headphones Source", "Mic 1", "Mic" },
552 { "Headphones Source", "Mic 2", "Mic" },
553 { "Capture Source", "Mic 1", "Mic" },
554 { "Capture Source", "Mic 2", "Mic" },
556 { "Headphones Source", "Mic 1", "Mic 1" },
557 { "Headphones Source", "Mic 2", "Mic 2" },
563 { "Capture Source", "Mic 1", "Mic 1" },
564 { "Capture Source", "Mic 2", "Mic 2" },
589 struct regmap *regmap = jz_codec->regmap; in jz4770_codec_codec_init_regs()
602 /* Disable stereo mic */ in jz4770_codec_codec_init_regs()
606 /* Set mic 1 as default source for ADC */ in jz4770_codec_codec_init_regs()
649 /* default to cap-less mode(0) */ in jz4770_codec_codec_init_regs()
661 static int jz4770_codec_codec_probe(struct snd_soc_component *codec) in jz4770_codec_codec_probe()
665 clk_prepare_enable(jz_codec->clk); in jz4770_codec_codec_probe()
676 clk_disable_unprepare(jz_codec->clk); in jz4770_codec_codec_remove()
693 static const unsigned int jz4770_codec_sample_rates[] = {
699 static int jz4770_codec_hw_params(struct snd_pcm_substream *substream, in jz4770_codec_hw_params()
703 struct jz_codec *codec = snd_soc_component_get_drvdata(dai->component); in jz4770_codec_hw_params()
704 unsigned int rate, bit_width; in jz4770_codec_hw_params()
720 return -EINVAL; in jz4770_codec_hw_params()
729 return -EINVAL; in jz4770_codec_hw_params()
731 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in jz4770_codec_hw_params()
732 regmap_update_bits(codec->regmap, JZ4770_CODEC_REG_AICR_DAC, in jz4770_codec_hw_params()
735 regmap_update_bits(codec->regmap, JZ4770_CODEC_REG_FCR_DAC, in jz4770_codec_hw_params()
739 regmap_update_bits(codec->regmap, JZ4770_CODEC_REG_AICR_ADC, in jz4770_codec_hw_params()
742 regmap_update_bits(codec->regmap, JZ4770_CODEC_REG_FCR_ADC, in jz4770_codec_hw_params()
765 .name = "jz4770-hifi",
783 static bool jz4770_codec_volatile(struct device *dev, unsigned int reg) in jz4770_codec_volatile()
788 static bool jz4770_codec_readable(struct device *dev, unsigned int reg) in jz4770_codec_readable()
799 static bool jz4770_codec_writeable(struct device *dev, unsigned int reg) in jz4770_codec_writeable()
811 static int jz4770_codec_io_wait(struct jz_codec *codec) in jz4770_codec_io_wait()
815 return readl_poll_timeout(codec->base + ICDC_RGADW_OFFSET, reg, in jz4770_codec_io_wait()
820 static int jz4770_codec_reg_read(void *context, unsigned int reg, in jz4770_codec_reg_read()
821 unsigned int *val) in jz4770_codec_reg_read()
824 unsigned int i; in jz4770_codec_reg_read()
826 int ret; in jz4770_codec_reg_read()
832 tmp = readl(codec->base + ICDC_RGADW_OFFSET); in jz4770_codec_reg_read()
835 writel(tmp, codec->base + ICDC_RGADW_OFFSET); in jz4770_codec_reg_read()
839 *val = readl(codec->base + ICDC_RGDATA_OFFSET) & in jz4770_codec_reg_read()
845 static int jz4770_codec_reg_write(void *context, unsigned int reg, in jz4770_codec_reg_write()
846 unsigned int val) in jz4770_codec_reg_write()
849 int ret; in jz4770_codec_reg_write()
856 codec->base + ICDC_RGADW_OFFSET); in jz4770_codec_reg_write()
890 static int jz4770_codec_probe(struct platform_device *pdev) in jz4770_codec_probe()
892 struct device *dev = &pdev->dev; in jz4770_codec_probe()
894 int ret; in jz4770_codec_probe()
898 return -ENOMEM; in jz4770_codec_probe()
900 codec->dev = dev; in jz4770_codec_probe()
902 codec->base = devm_platform_ioremap_resource(pdev, 0); in jz4770_codec_probe()
903 if (IS_ERR(codec->base)) { in jz4770_codec_probe()
904 ret = PTR_ERR(codec->base); in jz4770_codec_probe()
909 codec->regmap = devm_regmap_init(dev, NULL, codec, in jz4770_codec_probe()
911 if (IS_ERR(codec->regmap)) in jz4770_codec_probe()
912 return PTR_ERR(codec->regmap); in jz4770_codec_probe()
914 codec->clk = devm_clk_get(dev, "aic"); in jz4770_codec_probe()
915 if (IS_ERR(codec->clk)) in jz4770_codec_probe()
916 return PTR_ERR(codec->clk); in jz4770_codec_probe()
931 { .compatible = "ingenic,jz4770-codec", },
939 .name = "jz4770-codec",