Lines Matching +full:loongson +full:- +full:2 +full:k
1 // SPDX-License-Identifier: GPL-2.0-only
3 // es8323.c -- es8323 ALSA SoC audio driver
7 // Copyright 2024 Loongson Technology Co.,Ltd.
10 // Jianqun Xu <jay.xu@rock-chips.com>
11 // Nickey Yang <nickey.yang@rock-chips.com>
13 // Binbin Zhou <zhoubinbin@loongson.cn>
25 #include <sound/soc-dapm.h>
90 static const char *const es8323_stereo_3d_texts[] = { "No 3D ", "Level 1", "Level 2", "Level 3",
92 static SOC_ENUM_SINGLE_DECL(es8323_stereo_3d_enum, ES8323_DACCONTROL7, 2, es8323_stereo_3d_texts);
110 static const DECLARE_TLV_DB_SCALE(es8323_adc_tlv, -9600, 50, 1);
111 static const DECLARE_TLV_DB_SCALE(es8323_dac_tlv, -9600, 50, 1);
112 static const DECLARE_TLV_DB_SCALE(es8323_out_tlv, -4500, 150, 0);
114 static const DECLARE_TLV_DB_SCALE(es8323_bypass_tlv2, -15, 300, 0);
120 SOC_ENUM("Playback De-emphasis", es8323_playback_deemphasis_enum),
128 SOC_SINGLE("Capture Mute Switch", ES8323_ADC_MUTE, 2, 1, 0),
143 SOC_DOUBLE_R_TLV("Output 2 Playback Volume", ES8323_LOUT2_VOL,
148 static const char *const es8323_pga_sell[] = { "Line 1L", "Line 2L", "NC", "DifferentialL" };
154 static const char *const es8323_pga_selr[] = { "Line 1R", "Line 2R", "NC", "DifferentialR" };
160 static const char *const es8323_lin_sell[] = { "Line 1L", "Line 2L", "NC", "MicL" };
166 static const char *const es8323_lin_selr[] = { "Line 1R", "Line 2R", "NC", "MicR" };
172 static const char *const es8323_diffmux_sel[] = { "Line 1", "Line 2" };
226 SND_SOC_DAPM_PGA("Right Out 2", SND_SOC_NOPM, 2, 0, NULL, 0),
227 SND_SOC_DAPM_PGA("Left Out 2", SND_SOC_NOPM, 3, 0, NULL, 0),
243 {"Left PGA Mux", "Line 2L", "LINPUT2"},
247 {"Right PGA Mux", "Line 2R", "RINPUT2"},
252 {"Differential Mux", "Line 2", "LINPUT2"},
253 {"Differential Mux", "Line 2", "RINPUT2"},
269 {"Left Line Mux", "Line 2L", "LINPUT2"},
273 {"Right Line Mux", "Line 2R", "RINPUT2"},
287 {"Left Out 2", NULL, "Left Mixer"},
288 {"LOUT2", NULL, "Left Out 2"},
289 {"Right Out 2", NULL, "Right Mixer"},
290 {"ROUT2", NULL, "Right Out 2"},
303 /* 8k */
310 /* 11.025k */
315 /* 16k */
320 /* 22.05k */
325 /* 32k */
330 /* 44.1k */
335 /* 48k */
340 /* 88.2k */
345 /* 96k */
389 return -EINVAL; in get_coeff()
395 struct snd_soc_component *component = codec_dai->component; in es8323_set_dai_sysclk()
403 es8323->sysclk_constraints = &constraints_112896; in es8323_set_dai_sysclk()
409 es8323->sysclk_constraints = &constraints_12288; in es8323_set_dai_sysclk()
413 es8323->sysclk_constraints = &constraints_12; in es8323_set_dai_sysclk()
416 return -EINVAL; in es8323_set_dai_sysclk()
419 es8323->sysclk = freq; in es8323_set_dai_sysclk()
425 struct snd_soc_component *component = codec_dai->component; in es8323_set_dai_fmt()
438 return -EINVAL; in es8323_set_dai_fmt()
461 return -EINVAL; in es8323_set_dai_fmt()
487 return -EINVAL; in es8323_set_dai_fmt()
500 struct snd_soc_component *component = dai->component; in es8323_pcm_startup()
503 if (es8323->sysclk) { in es8323_pcm_startup()
504 snd_pcm_hw_constraint_list(substream->runtime, 0, in es8323_pcm_startup()
506 es8323->sysclk_constraints); in es8323_pcm_startup()
516 struct snd_soc_component *component = dai->component; in es8323_pcm_hw_params()
523 coeff = get_coeff(es8323->sysclk, params_rate(params)); in es8323_pcm_hw_params()
525 coeff = get_coeff(es8323->sysclk / 2, params_rate(params)); in es8323_pcm_hw_params()
530 dev_err(component->dev, in es8323_pcm_hw_params()
532 params_rate(params), es8323->sysclk); in es8323_pcm_hw_params()
572 struct snd_soc_component *component = dai->component; in es8323_mute_stream()
596 .channels_max = 2,
603 .channels_max = 2,
616 es8323->component = component; in es8323_probe()
618 es8323->mclk = devm_clk_get_optional(component->dev, "mclk"); in es8323_probe()
619 if (IS_ERR(es8323->mclk)) { in es8323_probe()
620 dev_err(component->dev, "unable to get mclk\n"); in es8323_probe()
621 return PTR_ERR(es8323->mclk); in es8323_probe()
624 if (!es8323->mclk) in es8323_probe()
625 dev_warn(component->dev, "assuming static mclk\n"); in es8323_probe()
627 ret = clk_prepare_enable(es8323->mclk); in es8323_probe()
629 dev_err(component->dev, "unable to enable mclk\n"); in es8323_probe()
648 ret = clk_prepare_enable(es8323->mclk); in es8323_set_bias_level()
672 clk_disable_unprepare(es8323->mclk); in es8323_set_bias_level()
689 clk_disable_unprepare(es8323->mclk); in es8323_remove()
697 regcache_cache_only(es8323->regmap, true); in es8323_suspend()
698 regcache_mark_dirty(es8323->regmap); in es8323_suspend()
707 regcache_cache_only(es8323->regmap, false); in es8323_resume()
708 regcache_sync(es8323->regmap); in es8323_resume()
743 struct device *dev = &i2c_client->dev; in es8323_i2c_probe()
747 return -ENOMEM; in es8323_i2c_probe()
751 es8323->regmap = devm_regmap_init_i2c(i2c_client, &es8323_regmap); in es8323_i2c_probe()
752 if (IS_ERR(es8323->regmap)) in es8323_i2c_probe()
753 return PTR_ERR(es8323->regmap); in es8323_i2c_probe()
791 MODULE_AUTHOR("Binbin Zhou <zhoubinbin@loongson.cn>");