Lines Matching +full:adc +full:- +full:freq

1 // SPDX-License-Identifier: GPL-2.0-only
3 * cs4265.c -- CS4265 ALSA SoC audio driver
25 #include <sound/soc-dapm.h>
76 static DECLARE_TLV_DB_SCALE(pga_tlv, -1200, 50, 0);
78 static DECLARE_TLV_DB_SCALE(dac_tlv, -12750, 50, 0);
119 SOC_DAPM_ENUM("ADC Input Capture Mux", mic_linein_enum);
136 SOC_SINGLE("De-emp 44.1kHz Switch", CS4265_DAC_CTL, 1,
144 SOC_SINGLE("ADC HPF Switch", CS4265_ADC_CTL, 1,
146 SOC_SINGLE("ADC Zero Cross Switch", CS4265_ADC_CTL2, 3,
148 SOC_SINGLE("ADC Soft Ramp Switch", CS4265_ADC_CTL2, 7,
173 SND_SOC_DAPM_MUX("ADC Mux", SND_SOC_NOPM, 0, 0, &mic_linein_mux),
175 SND_SOC_DAPM_ADC("ADC", NULL, CS4265_PWRCTL, 2, 1),
176 SND_SOC_DAPM_PGA("Pre-amp MIC", CS4265_PWRCTL, 3,
219 {"Pre-amp MIC", NULL, "MICL"},
220 {"Pre-amp MIC", NULL, "MICR"},
221 {"ADC Mux", "MIC", "Pre-amp MIC"},
222 {"ADC Mux", "LINEIN", "LINEINL"},
223 {"ADC Mux", "LINEIN", "LINEINR"},
224 {"ADC", NULL, "ADC Mux"},
225 {"DOUT", NULL, "ADC"},
230 {"Loopback", "Switch", "ADC"},
315 return -EINVAL; in cs4265_get_clk_index()
319 unsigned int freq, int dir) in cs4265_set_sysclk() argument
321 struct snd_soc_component *component = codec_dai->component; in cs4265_set_sysclk()
326 dev_err(component->dev, "Invalid clk_id %d\n", clk_id); in cs4265_set_sysclk()
327 return -EINVAL; in cs4265_set_sysclk()
330 if (clk_map_table[i].mclk == freq) { in cs4265_set_sysclk()
331 cs4265->sysclk = freq; in cs4265_set_sysclk()
335 cs4265->sysclk = 0; in cs4265_set_sysclk()
336 dev_err(component->dev, "Invalid freq parameter %d\n", freq); in cs4265_set_sysclk()
337 return -EINVAL; in cs4265_set_sysclk()
342 struct snd_soc_component *component = codec_dai->component; in cs4265_set_fmt()
358 return -EINVAL; in cs4265_set_fmt()
373 return -EINVAL; in cs4265_set_fmt()
376 cs4265->format = iface; in cs4265_set_fmt()
382 struct snd_soc_component *component = dai->component; in cs4265_mute()
406 struct snd_soc_component *component = dai->component; in cs4265_pcm_hw_params()
410 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && in cs4265_pcm_hw_params()
411 ((cs4265->format & SND_SOC_DAIFMT_FORMAT_MASK) in cs4265_pcm_hw_params()
413 return -EINVAL; in cs4265_pcm_hw_params()
415 index = cs4265_get_clk_index(cs4265->sysclk, params_rate(params)); in cs4265_pcm_hw_params()
424 dev_err(component->dev, "can't get correct mclk\n"); in cs4265_pcm_hw_params()
425 return -EINVAL; in cs4265_pcm_hw_params()
428 switch (cs4265->format & SND_SOC_DAIFMT_FORMAT_MASK) { in cs4265_pcm_hw_params()
460 return -EINVAL; in cs4265_pcm_hw_params()
508 .name = "cs4265-dai1",
526 .name = "cs4265-dai2",
577 cs4265 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs4265_private), in cs4265_i2c_probe()
580 return -ENOMEM; in cs4265_i2c_probe()
582 cs4265->regmap = devm_regmap_init_i2c(i2c_client, &cs4265_regmap); in cs4265_i2c_probe()
583 if (IS_ERR(cs4265->regmap)) { in cs4265_i2c_probe()
584 ret = PTR_ERR(cs4265->regmap); in cs4265_i2c_probe()
585 dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); in cs4265_i2c_probe()
589 cs4265->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev, in cs4265_i2c_probe()
591 if (IS_ERR(cs4265->reset_gpio)) in cs4265_i2c_probe()
592 return PTR_ERR(cs4265->reset_gpio); in cs4265_i2c_probe()
594 if (cs4265->reset_gpio) { in cs4265_i2c_probe()
596 gpiod_set_value_cansleep(cs4265->reset_gpio, 1); in cs4265_i2c_probe()
601 ret = regmap_read(cs4265->regmap, CS4265_CHIP_ID, &reg); in cs4265_i2c_probe()
603 dev_err(&i2c_client->dev, "Failed to read chip ID: %d\n", ret); in cs4265_i2c_probe()
609 ret = -ENODEV; in cs4265_i2c_probe()
610 dev_err(&i2c_client->dev, in cs4265_i2c_probe()
615 dev_info(&i2c_client->dev, in cs4265_i2c_probe()
619 regmap_write(cs4265->regmap, CS4265_PWRCTL, 0x0F); in cs4265_i2c_probe()
621 return devm_snd_soc_register_component(&i2c_client->dev, in cs4265_i2c_probe()
630 if (cs4265->reset_gpio) in cs4265_i2c_remove()
631 gpiod_set_value_cansleep(cs4265->reset_gpio, 0); in cs4265_i2c_remove()