audio: auge: fix tdm skew, pdm clk, spdif to hdmxtx clk inv
authorXing Wang <xing.wang@amlogic.com>
Fri, 2 Feb 2018 14:33:27 +0000 (22:33 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Fri, 2 Mar 2018 07:07:55 +0000 (15:07 +0800)
PD#156734: audio: auge: fix tdm skew, pdm clk, spdif to hdmxtx clk inv

Change-Id: I2033bb0d0843eca309ad58483183293f1c4d92fa
Signed-off-by: Xing Wang <xing.wang@amlogic.com>
arch/arm64/boot/dts/amlogic/g12a_skt.dts
sound/soc/amlogic/auge/pdm.c
sound/soc/amlogic/auge/regs.h
sound/soc/amlogic/auge/spdif_hw.c
sound/soc/amlogic/auge/tdm_hw.c

index ec13c74..0a5078e 100644 (file)
                };
 
                aml-audio-card,dai-link@1 {
-                       format = "i2s";
+                       format = "i2s"; /*"dsp_a";*/
                        mclk-fs = <256>;
                        //continuous-clock;
                        //bitclock-inversion;
                                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*/>;
                        };
                };
 
        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>;
index 15577ea..fb01c92 100644 (file)
@@ -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;
 }
 
index a4514db..5f84437 100644 (file)
 /* 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
index 03b1e7e..6089d39 100644 (file)
@@ -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 */
index efabed2..8602bf1 100644 (file)
@@ -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)