audio: auge: add alsaPORT suffix name for android audio hal
authorXing Wang <xing.wang@amlogic.com>
Wed, 28 Feb 2018 07:14:56 +0000 (15:14 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Thu, 8 Mar 2018 03:02:07 +0000 (19:02 -0800)
PD#156734: audio: auge: add alsaPORT suffix name for android audio hal

Change-Id: Ie442dc27c594caf0181425e66fe555c1bd5355ba
Signed-off-by: Xing Wang <xing.wang@amlogic.com>
arch/arm64/boot/dts/amlogic/g12a_skt.dts
sound/soc/amlogic/auge/card.c
sound/soc/amlogic/auge/ddr_mngr.c
sound/soc/amlogic/auge/sharebuffer.c
sound/soc/amlogic/auge/sharebuffer.h
sound/soc/amlogic/auge/tdm.c

index 6819e28..89a7290 100644 (file)
                        //frame-inversion;
                        //bitclock-master = <&tdmacodec>;
                        //frame-master = <&tdmacodec>;
+                       /* suffix-name, sync with android audio hal
+                        * what's the dai link used for
+                        */
+                       suffix-name = "alsaPORT-pcm";
                        tdmacpu: cpu {
                                sound-dai = <&aml_tdma>;
                                dai-tdm-slot-tx-mask =
                        frame-master = <&aml_tdmb>;
                        //bitclock-master = <&tdmbcodec>;
                        //frame-master = <&tdmbcodec>;
+                       /* suffix-name, sync with android audio hal
+                        * what's the dai link used for
+                        */
+                       suffix-name = "alsaPORT-i2s";
                        cpu {
                                sound-dai = <&aml_tdmb>;
 
                        };
                        tdmbcodec: codec {
                                sound-dai = <&dummy_codec &dummy_codec
-                               &amlogic_codec /*&ad82584f_62*/>;
+                               &amlogic_codec &ad82584f_62>;
                        };
                };
 
                        //frame-inversion;
                        bitclock-master = <&aml_tdmc>;
                        frame-master = <&aml_tdmc>;
+                       /* suffix-name, sync with android audio hal
+                        * what's the dai link used for
+                        */
+                       //suffix-name = "alsaPORT-tdm";
                        cpu {
                                sound-dai = <&aml_tdmc>;
                                dai-tdm-slot-tx-mask = <1 1>;
 
                aml-audio-card,dai-link@3 {
                        mclk-fs = <64>;
+                       /* suffix-name, sync with android audio hal
+                        * what's the dai link used for
+                        */
+                       suffix-name = "alsaPORT-pdm";
                        cpu {
                                sound-dai = <&aml_pdm>;
                        };
 
                aml-audio-card,dai-link@4 {
                        mclk-fs = <128>;
+                       /* suffix-name, sync with android audio hal
+                        * what's the dai link used for
+                        */
+                       suffix-name = "alsaPORT-spdif";
                        cpu {
                                sound-dai = <&aml_spdif>;
                                system-clock-frequency = <6144000>;
                };
                aml-audio-card,dai-link@5 {
                        mclk-fs = <128>;
+                       /* suffix-name, sync with android audio hal
+                        * what's the dai link used for
+                        */
+                       suffix-name = "alsaPORT-hdmi";
                        cpu {
                                sound-dai = <&aml_spdif_b>;
                                system-clock-frequency = <6144000>;
                dai-tdm-lane-slot-mask-out = <1 0 0 0>;
                dai-tdm-clk-sel = <1>;
                clocks = <&clkaudio CLKID_AUDIO_MCLK_B
-                               &clkc CLKID_MPLL1>;
-               clock-names = "mclk", "clk_srcpll";
+                               &clkc CLKID_MPLL1
+                               &clkc CLKID_MPLL0>;
+               clock-names = "mclk", "clk_srcpll", "samesource_sysclk";
                pinctrl-names = "tdm_pins";
                pinctrl-0 = <&tdmb_mclk &tdmout_b &tdmin_b>;
                /*
index 4d62dde..7e6fb06 100644 (file)
@@ -53,6 +53,11 @@ struct aml_chipset_info {
 struct aml_card_data {
        struct snd_soc_card snd_card;
        struct aml_dai_props {
+               /* sync with android audio hal,
+                * dai link is used for which output,
+                */
+               const char *suffix_name;
+
                struct aml_dai cpu_dai;
                struct aml_dai codec_dai;
                unsigned int mclk_fs;
@@ -626,10 +631,20 @@ static int aml_card_dai_link_of(struct device_node *node,
        if (ret < 0)
                goto dai_link_of_err;
 
-       ret = aml_card_set_dailink_name(dev, dai_link,
-                                               "%s-%s",
-                                               dai_link->cpu_dai_name,
-                                               dai_link->codecs->dai_name);
+       /* sync with android audio hal, what's the link used for. */
+       of_property_read_string(node, "suffix-name", &dai_props->suffix_name);
+
+       if (dai_props->suffix_name)
+               ret = aml_card_set_dailink_name(dev, dai_link,
+                                       "%s-%s-%s",
+                                       dai_link->cpu_dai_name,
+                                       dai_link->codecs->dai_name,
+                                       dai_props->suffix_name);
+       else
+               ret = aml_card_set_dailink_name(dev, dai_link,
+                                       "%s-%s",
+                                       dai_link->cpu_dai_name,
+                                       dai_link->codecs->dai_name);
        if (ret < 0)
                goto dai_link_of_err;
 
index 6c103c1..2ac4139 100644 (file)
@@ -715,6 +715,9 @@ void aml_frddr_enable(struct frddr *fr, bool enable)
        reg = calc_frddr_address(EE_AUDIO_FRDDR_A_CTRL0, reg_base);
        aml_audiobus_update_bits(actrl, reg, 1<<31, enable<<31);
 
+       if (!enable)
+               aml_audiobus_write(actrl, reg, 0x0);
+
        /* check for Audio EQ/DRC */
        aml_check_aed(enable, fr->dest);
 }
index 851bd66..6d1392b 100644 (file)
@@ -98,3 +98,17 @@ int sharebuffer_trigger(int cmd, int samesource_sel)
 
        return 0;
 }
+
+void sharebuffer_get_mclk_fs_ratio(int samesource_sel,
+       int *pll_mclk_ratio, int *mclk_fs_ratio)
+{
+       if (samesource_sel < 0) {
+               pr_err("Not support same source\n");
+       } else if (samesource_sel < 3) {
+               // TODO: same with tdm
+       } else if (samesource_sel < 5) {
+               /* spdif a/b */
+               *pll_mclk_ratio = 4;
+               *mclk_fs_ratio = 128;
+       }
+}
index c1752f2..fa2823b 100644 (file)
@@ -21,4 +21,6 @@ extern int sharebuffer_prepare(struct snd_pcm_substream *substream,
        void *pfrddr, int samesource_sel);
 extern int sharebuffer_trigger(int cmd, int samesource_sel);
 
+extern void sharebuffer_get_mclk_fs_ratio(int samesource_sel,
+       int *pll_mclk_ratio, int *mclk_fs_ratio);
 #endif
index 528d268..9977187 100644 (file)
@@ -96,6 +96,7 @@ struct aml_tdm {
        struct clk *clk;
        struct clk *clk_gate;
        struct clk *mclk;
+       struct clk *samesrc_sysclk;
        bool contns_clk;
        unsigned int id;
        /* bclk src selection */
@@ -659,6 +660,20 @@ static int aml_dai_tdm_hw_params(struct snd_pcm_substream *substream,
                        return ret;
        }
 
+       /* share buffer trigger */
+       if (p_tdm->chipinfo
+               && (p_tdm->chipinfo->same_src_fn)
+               && (p_tdm->samesource_sel >= 0)) {
+               int mux = 0, ratio = 0;
+
+                       sharebuffer_get_mclk_fs_ratio(p_tdm->samesource_sel,
+                               &mux, &ratio);
+                       pr_info("samesource sysclk:%d\n", rate * ratio * mux);
+                       if (p_tdm->samesrc_sysclk)
+                               clk_set_rate(p_tdm->samesrc_sysclk,
+                                       rate * ratio * mux);
+       }
+
        return 0;
 }
 
@@ -1100,11 +1115,20 @@ static int aml_tdm_platform_probe(struct platform_device *pdev)
        /* default no same source */
        if (p_tdm->chipinfo &&
                p_tdm->chipinfo->same_src_fn) {
+
                ret = of_property_read_u32(node, "samesource_sel",
                                &p_tdm->samesource_sel);
                if (ret < 0)
                        p_tdm->samesource_sel = -1;
-
+               else {
+                       p_tdm->samesrc_sysclk = devm_clk_get(&pdev->dev,
+                               "samesource_sysclk");
+                       if (IS_ERR(p_tdm->samesrc_sysclk)) {
+                               dev_err(&pdev->dev,
+                                       "Can't retrieve samesrc_sysclk clock\n");
+                               return PTR_ERR(p_tdm->samesrc_sysclk);
+                       }
+               }
                pr_info("TDM id %d samesource_sel:%d\n",
                        p_tdm->id,
                        p_tdm->samesource_sel);