From e9f798ceff205d4bc26ac88fc5ca72cb3abe5b87 Mon Sep 17 00:00:00 2001 From: "yujie.wu" Date: Fri, 8 Mar 2019 13:51:10 +0800 Subject: [PATCH] audio: Merge code from RSR project [1/2] PD#SWPL-5495 Problem: There is some improvement code on RSR project, we need to merge them back to trunk. Solution: Merge the code from rsr branch Verify: A113 Change-Id: I0ba11c8ff412db659ff2f10bfc00d63c49f84bb5 Signed-off-by: yujie.wu --- arch/arm/boot/dts/amlogic/axg_s400_v03sbr.dts | 2 +- arch/arm64/boot/dts/amlogic/axg_s400_v03sbr.dts | 2 +- sound/soc/amlogic/auge/spdif_hw.c | 14 ++++++- sound/soc/amlogic/auge/tdm.c | 53 +++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 3 deletions(-) diff --git a/arch/arm/boot/dts/amlogic/axg_s400_v03sbr.dts b/arch/arm/boot/dts/amlogic/axg_s400_v03sbr.dts index 55f8011..b87fc56 100644 --- a/arch/arm/boot/dts/amlogic/axg_s400_v03sbr.dts +++ b/arch/arm/boot/dts/amlogic/axg_s400_v03sbr.dts @@ -547,7 +547,7 @@ aml-audio-card,dai-link@2 { format = "i2s"; mclk-fs = <256>; - //continuous-clock; + continuous-clock; //bitclock-inversion; //frame-inversion; //bitclock-master = <&aml_tdmc>; diff --git a/arch/arm64/boot/dts/amlogic/axg_s400_v03sbr.dts b/arch/arm64/boot/dts/amlogic/axg_s400_v03sbr.dts index 2ed3085..6444806 100644 --- a/arch/arm64/boot/dts/amlogic/axg_s400_v03sbr.dts +++ b/arch/arm64/boot/dts/amlogic/axg_s400_v03sbr.dts @@ -547,7 +547,7 @@ aml-audio-card,dai-link@2 { format = "i2s"; mclk-fs = <256>; - //continuous-clock; + continuous-clock; //bitclock-inversion; //frame-inversion; //bitclock-master = <&aml_tdmc>; diff --git a/sound/soc/amlogic/auge/spdif_hw.c b/sound/soc/amlogic/auge/spdif_hw.c index 29e0540..417c86c 100644 --- a/sound/soc/amlogic/auge/spdif_hw.c +++ b/sound/soc/amlogic/auge/spdif_hw.c @@ -509,16 +509,28 @@ void spdifout_samesource_set(int spdif_index, int fifo_id, int spdifin_get_sample_rate(void) { unsigned int val; + /*EE_AUDIO_SPDIFIN_STAT0*/ + /*r_width_max bit17:8 (the max width of two edge;)*/ + unsigned int max_width = 0; val = audiobus_read(EE_AUDIO_SPDIFIN_STAT0); /* NA when check min width of two edges */ if (((val >> 18) & 0x3ff) == 0x3ff) - return 0x7; + return 7; + + /*check the max width of two edge when spdifin sr=32kHz*/ + /*if max_width is more than 0x2f0(magic number),*/ + /*sr(32kHz) is unavailable*/ + max_width = ((val >> 8) & 0x3ff); + + if ((((val >> 28) & 0x7) == 0) && (max_width == 0x3ff)) + return 7; return (val >> 28) & 0x7; } + static int spdifin_get_channel_status(int sel) { unsigned int val; diff --git a/sound/soc/amlogic/auge/tdm.c b/sound/soc/amlogic/auge/tdm.c index 35e9bbf..a4ebd94 100644 --- a/sound/soc/amlogic/auge/tdm.c +++ b/sound/soc/amlogic/auge/tdm.c @@ -148,6 +148,53 @@ static const struct snd_pcm_hardware aml_tdm_hardware = { .channels_max = 32, }; +static int tdmin_clk_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + int clk; + int value; + + clk = meson_clk_measure(70); + if (clk >= 11000000) + value = 3; + else if (clk >= 6000000) + value = 2; + else if (clk >= 2000000) + value = 1; + else + value = 0; + + + ucontrol->value.integer.value[0] = value; + + return 0; +} + +/* current sample mode and its sample rate */ +static const char *const i2sin_clk[] = { + "0", + "3000000", + "6000000", + "12000000" +}; + + + +static const struct soc_enum i2sin_clk_enum[] = { + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(i2sin_clk), + i2sin_clk), +}; + + + +static const struct snd_kcontrol_new snd_tdm_controls[] = { + SOC_ENUM_EXT("I2SIn CLK", i2sin_clk_enum, + tdmin_clk_get, + NULL) +}; + + + static irqreturn_t aml_tdm_ddr_isr(int irq, void *devid) { struct snd_pcm_substream *substream = (struct snd_pcm_substream *)devid; @@ -1079,8 +1126,14 @@ static int aml_dai_set_tdm_slot(struct snd_soc_dai *cpu_dai, static int aml_dai_tdm_probe(struct snd_soc_dai *cpu_dai) { + int ret = 0; struct aml_tdm *p_tdm = snd_soc_dai_get_drvdata(cpu_dai); + ret = snd_soc_add_dai_controls(cpu_dai, snd_tdm_controls, + ARRAY_SIZE(snd_tdm_controls)); + if (ret < 0) + pr_err("%s, failed add snd spdif controls\n", __func__); + /* config ddr arb */ aml_tdm_arb_config(p_tdm->actrl); -- 2.7.4