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,
153 SOC_SINGLE("SPDIF Switch", CS4265_SPDIF_CTL2, 5, 1, 1),
156 SOC_ENUM("SPDIF Mono/Stereo", spdif_mono_stereo_enum),
177 SND_SOC_DAPM_PGA("Pre-amp MIC", CS4265_PWRCTL, 3,
185 SND_SOC_DAPM_MIXER("SPDIF Transmitter", SND_SOC_NOPM, 0, 0, NULL, 0),
189 SND_SOC_DAPM_SWITCH("SPDIF", SND_SOC_NOPM, 0, 0,
215 {"SPDIF", "Switch", "Input Mux"},
218 {"SPDIFOUT", NULL, "SPDIF"},
220 {"Pre-amp MIC", NULL, "MICL"},
221 {"Pre-amp MIC", NULL, "MICR"},
222 {"ADC Mux", "MIC", "Pre-amp MIC"},
236 u32 mclk; member
307 static int cs4265_get_clk_index(int mclk, int rate) in cs4265_get_clk_index() argument
313 clk_map_table[i].mclk == mclk) in cs4265_get_clk_index()
316 return -EINVAL; in cs4265_get_clk_index()
322 struct snd_soc_component *component = codec_dai->component; in cs4265_set_sysclk()
327 dev_err(component->dev, "Invalid clk_id %d\n", clk_id); in cs4265_set_sysclk()
328 return -EINVAL; in cs4265_set_sysclk()
331 if (clk_map_table[i].mclk == freq) { in cs4265_set_sysclk()
332 cs4265->sysclk = freq; in cs4265_set_sysclk()
336 cs4265->sysclk = 0; in cs4265_set_sysclk()
337 dev_err(component->dev, "Invalid freq parameter %d\n", freq); in cs4265_set_sysclk()
338 return -EINVAL; in cs4265_set_sysclk()
343 struct snd_soc_component *component = codec_dai->component; in cs4265_set_fmt()
359 return -EINVAL; in cs4265_set_fmt()
374 return -EINVAL; in cs4265_set_fmt()
377 cs4265->format = iface; in cs4265_set_fmt()
383 struct snd_soc_component *component = dai->component; in cs4265_mute()
407 struct snd_soc_component *component = dai->component; in cs4265_pcm_hw_params()
411 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && in cs4265_pcm_hw_params()
412 ((cs4265->format & SND_SOC_DAIFMT_FORMAT_MASK) in cs4265_pcm_hw_params()
414 return -EINVAL; in cs4265_pcm_hw_params()
416 index = cs4265_get_clk_index(cs4265->sysclk, params_rate(params)); in cs4265_pcm_hw_params()
425 dev_err(component->dev, "can't get correct mclk\n"); in cs4265_pcm_hw_params()
426 return -EINVAL; in cs4265_pcm_hw_params()
429 switch (cs4265->format & SND_SOC_DAIFMT_FORMAT_MASK) { in cs4265_pcm_hw_params()
461 return -EINVAL; in cs4265_pcm_hw_params()
509 .name = "cs4265-dai1",
527 .name = "cs4265-dai2",
580 cs4265 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs4265_private), in cs4265_i2c_probe()
583 return -ENOMEM; in cs4265_i2c_probe()
585 cs4265->regmap = devm_regmap_init_i2c(i2c_client, &cs4265_regmap); in cs4265_i2c_probe()
586 if (IS_ERR(cs4265->regmap)) { in cs4265_i2c_probe()
587 ret = PTR_ERR(cs4265->regmap); in cs4265_i2c_probe()
588 dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); in cs4265_i2c_probe()
592 cs4265->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev, in cs4265_i2c_probe()
594 if (IS_ERR(cs4265->reset_gpio)) in cs4265_i2c_probe()
595 return PTR_ERR(cs4265->reset_gpio); in cs4265_i2c_probe()
597 if (cs4265->reset_gpio) { in cs4265_i2c_probe()
599 gpiod_set_value_cansleep(cs4265->reset_gpio, 1); in cs4265_i2c_probe()
604 ret = regmap_read(cs4265->regmap, CS4265_CHIP_ID, ®); in cs4265_i2c_probe()
607 ret = -ENODEV; in cs4265_i2c_probe()
608 dev_err(&i2c_client->dev, in cs4265_i2c_probe()
613 dev_info(&i2c_client->dev, in cs4265_i2c_probe()
617 regmap_write(cs4265->regmap, CS4265_PWRCTL, 0x0F); in cs4265_i2c_probe()
619 ret = devm_snd_soc_register_component(&i2c_client->dev, in cs4265_i2c_probe()