Lines Matching +full:spdif +full:- +full:mclk
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);
136 SOC_SINGLE("De-emp 44.1kHz Switch", CS4265_DAC_CTL, 1,
155 SOC_ENUM("SPDIF Mono/Stereo", spdif_mono_stereo_enum),
176 SND_SOC_DAPM_PGA("Pre-amp MIC", CS4265_PWRCTL, 3,
184 SND_SOC_DAPM_MIXER("SPDIF Transmitter", SND_SOC_NOPM, 0, 0, NULL, 0),
188 SND_SOC_DAPM_SWITCH("SPDIF", CS4265_SPDIF_CTL2, 5, 1,
214 {"SPDIF", "Switch", "Input Mux"},
217 {"SPDIFOUT", NULL, "SPDIF"},
219 {"Pre-amp MIC", NULL, "MICL"},
220 {"Pre-amp MIC", NULL, "MICR"},
221 {"ADC Mux", "MIC", "Pre-amp MIC"},
235 u32 mclk; member
306 static int cs4265_get_clk_index(int mclk, int rate) in cs4265_get_clk_index() argument
312 clk_map_table[i].mclk == mclk) in cs4265_get_clk_index()
315 return -EINVAL; in cs4265_get_clk_index()
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, ®); 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()