From: Xing Wang Date: Wed, 28 Feb 2018 07:14:56 +0000 (+0800) Subject: audio: auge: add alsaPORT suffix name for android audio hal X-Git-Tag: khadas-vims-v0.9.6-release~2359 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f74d1317865be9cdbb445875863bbc157f21c09;p=platform%2Fkernel%2Flinux-amlogic.git audio: auge: add alsaPORT suffix name for android audio hal PD#156734: audio: auge: add alsaPORT suffix name for android audio hal Change-Id: Ie442dc27c594caf0181425e66fe555c1bd5355ba Signed-off-by: Xing Wang --- diff --git a/arch/arm64/boot/dts/amlogic/g12a_skt.dts b/arch/arm64/boot/dts/amlogic/g12a_skt.dts index 6819e28..89a7290 100644 --- a/arch/arm64/boot/dts/amlogic/g12a_skt.dts +++ b/arch/arm64/boot/dts/amlogic/g12a_skt.dts @@ -1042,6 +1042,10 @@ //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 = @@ -1067,6 +1071,10 @@ 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>; @@ -1086,7 +1094,7 @@ }; tdmbcodec: codec { sound-dai = <&dummy_codec &dummy_codec - &amlogic_codec /*&ad82584f_62*/>; + &amlogic_codec &ad82584f_62>; }; }; @@ -1098,6 +1106,10 @@ //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>; @@ -1113,6 +1125,10 @@ 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>; }; @@ -1123,6 +1139,10 @@ 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>; @@ -1133,6 +1153,10 @@ }; 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>; @@ -1446,8 +1470,9 @@ 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>; /* diff --git a/sound/soc/amlogic/auge/card.c b/sound/soc/amlogic/auge/card.c index 4d62dde..7e6fb06 100644 --- a/sound/soc/amlogic/auge/card.c +++ b/sound/soc/amlogic/auge/card.c @@ -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; diff --git a/sound/soc/amlogic/auge/ddr_mngr.c b/sound/soc/amlogic/auge/ddr_mngr.c index 6c103c1..2ac4139 100644 --- a/sound/soc/amlogic/auge/ddr_mngr.c +++ b/sound/soc/amlogic/auge/ddr_mngr.c @@ -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); } diff --git a/sound/soc/amlogic/auge/sharebuffer.c b/sound/soc/amlogic/auge/sharebuffer.c index 851bd66..6d1392b 100644 --- a/sound/soc/amlogic/auge/sharebuffer.c +++ b/sound/soc/amlogic/auge/sharebuffer.c @@ -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; + } +} diff --git a/sound/soc/amlogic/auge/sharebuffer.h b/sound/soc/amlogic/auge/sharebuffer.h index c1752f2..fa2823b 100644 --- a/sound/soc/amlogic/auge/sharebuffer.h +++ b/sound/soc/amlogic/auge/sharebuffer.h @@ -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 diff --git a/sound/soc/amlogic/auge/tdm.c b/sound/soc/amlogic/auge/tdm.c index 528d268..9977187 100644 --- a/sound/soc/amlogic/auge/tdm.c +++ b/sound/soc/amlogic/auge/tdm.c @@ -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);