From eb6915397e2fd86f745c39d9cb4cec6b04e36124 Mon Sep 17 00:00:00 2001 From: Xing Wang Date: Fri, 2 Feb 2018 22:33:27 +0800 Subject: [PATCH] audio: auge: fix tdm skew, pdm clk, spdif to hdmxtx clk inv PD#156734: audio: auge: fix tdm skew, pdm clk, spdif to hdmxtx clk inv Change-Id: I2033bb0d0843eca309ad58483183293f1c4d92fa Signed-off-by: Xing Wang --- arch/arm64/boot/dts/amlogic/g12a_skt.dts | 21 +++++++++++++++++++-- sound/soc/amlogic/auge/pdm.c | 15 ++++++++++++--- sound/soc/amlogic/auge/regs.h | 2 +- sound/soc/amlogic/auge/spdif_hw.c | 1 + sound/soc/amlogic/auge/tdm_hw.c | 5 ++++- 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/arch/arm64/boot/dts/amlogic/g12a_skt.dts b/arch/arm64/boot/dts/amlogic/g12a_skt.dts index ec13c74..0a5078e 100644 --- a/arch/arm64/boot/dts/amlogic/g12a_skt.dts +++ b/arch/arm64/boot/dts/amlogic/g12a_skt.dts @@ -843,7 +843,7 @@ }; aml-audio-card,dai-link@1 { - format = "i2s"; + format = "i2s"; /*"dsp_a";*/ mclk-fs = <256>; //continuous-clock; //bitclock-inversion; @@ -855,11 +855,19 @@ dai-tdm-slot-tx-mask = <1 1>; dai-tdm-slot-rx-mask = <1 1>; dai-tdm-slot-num = <2>; + /* + * dai-tdm-slot-tx-mask = + * <1 1 1 1 1 1 1 1>; + * dai-tdm-slot-rx-mask = + * <1 1 1 1 1 1 1 1>; + * dai-tdm-slot-num = <8>; + */ dai-tdm-slot-width = <32>; system-clock-frequency = <12288000>; }; codec { - sound-dai = <&dummy_codec &amlogic_codec>; + sound-dai = <&dummy_codec &amlogic_codec + /*&ad82584f_62*/>; }; }; @@ -992,6 +1000,15 @@ pinctrl-names="default"; pinctrl-0=<&c_i2c_master_pin1>; + /* for ref board */ + ad82584f_62: ad82584f_62@62 { + compatible = "ESMT, ad82584f"; + #sound-dai-cells = <0>; + reg = <0x31>; + status = "okay"; + reset_pin = <&gpio GPIOA_5 0>; + }; + tas5707_36: tas5707_36@36 { compatible = "ti,tas5707"; #sound-dai-cells = <0>; diff --git a/sound/soc/amlogic/auge/pdm.c b/sound/soc/amlogic/auge/pdm.c index 15577ea..fb01c92 100644 --- a/sound/soc/amlogic/auge/pdm.c +++ b/sound/soc/amlogic/auge/pdm.c @@ -35,6 +35,9 @@ #include "regs.h" #include "ddr_mngr.h" +/*#define G12A_PTM*/ +#define CLK_INTEGER_MODE + static struct snd_pcm_hardware aml_pdm_hardware = { .info = SNDRV_PCM_INFO_MMAP | @@ -706,8 +709,6 @@ static int aml_pdm_dai_trigger( return 0; } -/*#define G12A_PTM*/ - static int aml_pdm_dai_set_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, unsigned int freq, int dir) { @@ -720,12 +721,16 @@ static int aml_pdm_dai_set_sysclk(struct snd_soc_dai *cpu_dai, #ifdef G12A_PTM clk_set_rate(p_pdm->dclk_srcpll, 24576000); #else +#ifdef CLK_INTEGER_MODE + clk_set_rate(p_pdm->clk_pdm_sysclk, + sysclk_srcpll_freq / 4); +#else clk_set_rate(p_pdm->clk_pdm_sysclk, sysclk_srcpll_freq / 5); +#endif if (dclk_srcpll_freq == 0) clk_set_rate(p_pdm->dclk_srcpll, 24576000); #endif - if (pdm_dclk == 1) clk_set_rate(p_pdm->clk_pdm_dclk, 1024000); else if (pdm_dclk == 2) @@ -733,6 +738,10 @@ static int aml_pdm_dai_set_sysclk(struct snd_soc_dai *cpu_dai, else clk_set_rate(p_pdm->clk_pdm_dclk, 3072000); + pr_info("pdm pdm_sysclk:%lu clk_pdm_dclk:%lu\n", + clk_get_rate(p_pdm->clk_pdm_sysclk), + clk_get_rate(p_pdm->clk_pdm_dclk)); + return 0; } diff --git a/sound/soc/amlogic/auge/regs.h b/sound/soc/amlogic/auge/regs.h index a4514db..5f844378 100644 --- a/sound/soc/amlogic/auge/regs.h +++ b/sound/soc/amlogic/auge/regs.h @@ -377,7 +377,7 @@ /* TOACODEC Registers */ #define EE_AUDIO_TOACODEC_CTRL0 0x1d0 /* TOHDMITX Registers */ -#define EE_AUDIO_TOHDMITX_CTRL0 0x1d0 +#define EE_AUDIO_TOHDMITX_CTRL0 0x1d1 /* acodec reset */ #define EE_RESET1 0x002 diff --git a/sound/soc/amlogic/auge/spdif_hw.c b/sound/soc/amlogic/auge/spdif_hw.c index 03b1e7e..6089d39 100644 --- a/sound/soc/amlogic/auge/spdif_hw.c +++ b/sound/soc/amlogic/auge/spdif_hw.c @@ -274,6 +274,7 @@ void spdifoutb_to_hdmitx_ctrl(void) { audiobus_write(EE_AUDIO_TOHDMITX_CTRL0, 1 << 31 + | 1 << 3 /* spdif_clk_cap_inv */ | 0 << 2 /* spdif_clk_inv */ | 1 << 1 /* spdif_out_b */ | 1 << 0 /* spdif_clk_b */ diff --git a/sound/soc/amlogic/auge/tdm_hw.c b/sound/soc/amlogic/auge/tdm_hw.c index efabed2..8602bf1 100644 --- a/sound/soc/amlogic/auge/tdm_hw.c +++ b/sound/soc/amlogic/auge/tdm_hw.c @@ -264,7 +264,10 @@ void aml_tdm_set_format( * that is, together with the last bit of the previous * data word. */ - bclkout_skew = 1; + if (p_config->sclk_ws_inv) + bclkout_skew = 2; + else + bclkout_skew = 1; bclkin_skew = 3; if (capture_active) -- 2.7.4