From cf52966d00d3c874d7d9f9e92dd3900faa1ce788 Mon Sep 17 00:00:00 2001 From: "peter.yang" Date: Wed, 7 Feb 2018 14:02:45 +0800 Subject: [PATCH] Add: multi codec support in simple-card --- ac101.c | 10 +++-- ac108.c | 5 ++- seeed-8mic-voicecard-overlay.dts | 4 ++ simple-card.c | 32 +++++++++++++- snd-soc-ac101.mod.c | 72 -------------------------------- snd-soc-ac108.mod.c | 68 ------------------------------ snd-soc-simple-card.mod.c | 69 ------------------------------ 7 files changed, 43 insertions(+), 217 deletions(-) delete mode 100644 snd-soc-ac101.mod.c delete mode 100644 snd-soc-ac108.mod.c delete mode 100644 snd-soc-simple-card.mod.c diff --git a/ac101.c b/ac101.c index f0ba56d..97c2622 100644 --- a/ac101.c +++ b/ac101.c @@ -1319,7 +1319,6 @@ static int ac10x_hw_params(struct snd_pcm_substream *substream, break; } - /* set LRCK/BCLK ratio */ aif1_lrck_div = aif1_slot_size * channels; for (i = 0; i < ARRAY_SIZE(codec_aif1_lrck); i++) { @@ -1332,7 +1331,7 @@ static int ac10x_hw_params(struct snd_pcm_substream *substream, /* set PLL output freq */ freq_out = 24576000; for (i = 0; i < ARRAY_SIZE(codec_aif1_fs); i++) { - if (codec_aif1_fs[i].samp_rate == params_rate(params)) { + if (codec_aif1_fs[i].samp_rate == params_rate(params)) { if (codec_dai->capture_active && dmic_used && codec_aif1_fs[i].samp_rate == 44100) { snd_soc_update_bits(codec, AIF_SR_CTRL, (0xf<sysclk && ac108_pll_div_list[i].freq_out % rate == 0) { ac108_pll_div = ac108_pll_div_list[i]; - pr_err("AC108 PLL freq_in match:%u, freq_out:%u\n\n", ac108_pll_div.freq_in, ac108_pll_div.freq_out); + dev_dbg(&ac108->i2c[_MASTER_INDEX]->dev, "AC108 PLL freq_in match:%u, freq_out:%u\n\n", + ac108_pll_div.freq_in, ac108_pll_div.freq_out); break; } } @@ -973,7 +974,7 @@ static int ac108_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_h return -EINVAL; } - dev_dbg(dai->dev, "rate:%d \n", params_rate(params)); + dev_dbg(dai->dev, "params rate: %d\n", params_rate(params)); for (i = 0; i < ARRAY_SIZE(ac108_sample_rate); i++) { if (ac108_sample_rate[i].real_val == params_rate(params) / (ac108->data_protocol + 1UL)) { diff --git a/seeed-8mic-voicecard-overlay.dts b/seeed-8mic-voicecard-overlay.dts index 6a0af40..5c69c4b 100644 --- a/seeed-8mic-voicecard-overlay.dts +++ b/seeed-8mic-voicecard-overlay.dts @@ -86,6 +86,8 @@ /* below is dummy master, real clock master is ac101 */ bitclock-master = <&codec0_dai>; frame-master = <&codec0_dai>; + /* bitclock-inversion; */ + /* frame-inversion; */ cpu { sound-dai = <&i2s>; @@ -106,6 +108,8 @@ format = "dsp_a"; bitclock-master = <&codec1_dai>; frame-master = <&codec1_dai>; + /* bitclock-inversion; */ + /* frame-inversion; */ cpu { sound-dai = <&i2s>; diff --git a/simple-card.c b/simple-card.c index 756ee58..e2a102e 100644 --- a/simple-card.c +++ b/simple-card.c @@ -22,6 +22,13 @@ #include #include +/* + * single codec: + * 0 - allow multi codec + * 1 - yes + */ +#define _SINGLE_CODEC 1 + struct asoc_simple_jack { struct snd_soc_jack jack; struct snd_soc_jack_pin pin; @@ -205,9 +212,10 @@ EXPORT_SYMBOL(register_start_clock); static int asoc_simple_card_trigger(struct snd_pcm_substream *substream, int cmd) { + struct snd_soc_pcm_runtime *rtd = substream->private_data; int ret = 0; - printk("%s() stream=%d cmd=%d\n", + dev_dbg(rtd->card->dev, "%s() stream=%d cmd=%d\n", __FUNCTION__, substream->stream, cmd); switch (cmd) { @@ -311,9 +319,18 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, if (ret < 0) goto dai_link_of_err; + #if _SINGLE_CODEC ret = asoc_simple_card_parse_codec(codec, dai_link, DAI, CELL); if (ret < 0) goto dai_link_of_err; + #else + ret = snd_soc_of_get_dai_link_codecs(dev, codec, dai_link); + if (ret < 0) { + dev_err(dev, "parse codec info error %d\n", ret); + goto dai_link_of_err; + } + dev_dbg(dev, "dai_link num_codecs = %d\n", dai_link->num_codecs); + #endif ret = asoc_simple_card_parse_platform(plat, dai_link, DAI, CELL); if (ret < 0) @@ -345,14 +362,21 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, if (ret < 0) goto dai_link_of_err; + #if _SINGLE_CODEC ret = asoc_simple_card_canonicalize_dailink(dai_link); if (ret < 0) goto dai_link_of_err; + #endif ret = asoc_simple_card_set_dailink_name(dev, dai_link, "%s-%s", dai_link->cpu_dai_name, - dai_link->codec_dai_name); + #if _SINGLE_CODEC + dai_link->codec_dai_name + #else + dai_link->codecs[0].dai_name + #endif + ); if (ret < 0) goto dai_link_of_err; @@ -365,7 +389,11 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, dai_link->cpu_dai_name, dai_props->cpu_dai.sysclk); dev_dbg(dev, "\tcodec : %s / %d\n", + #if _SINGLE_CODEC dai_link->codec_dai_name, + #else + dai_link->codecs[0].dai_name, + #endif dai_props->codec_dai.sysclk); asoc_simple_card_canonicalize_cpu(dai_link, single_cpu); diff --git a/snd-soc-ac101.mod.c b/snd-soc-ac101.mod.c deleted file mode 100644 index 01d309f..0000000 --- a/snd-soc-ac101.mod.c +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include - -MODULE_INFO(vermagic, VERMAGIC_STRING); - -__visible struct module __this_module -__attribute__((section(".gnu.linkonce.this_module"))) = { - .name = KBUILD_MODNAME, - .init = init_module, -#ifdef CONFIG_MODULE_UNLOAD - .exit = cleanup_module, -#endif - .arch = MODULE_ARCH_INIT, -}; - -static const struct modversion_info ____versions[] -__used -__attribute__((section("__versions"))) = { - { 0xdb0d8ebc, __VMLINUX_SYMBOL_STR(module_layout) }, - { 0x2d3385d3, __VMLINUX_SYMBOL_STR(system_wq) }, - { 0xf9a482f9, __VMLINUX_SYMBOL_STR(msleep) }, - { 0x2e5810c6, __VMLINUX_SYMBOL_STR(__aeabi_unwind_cpp_pr1) }, - { 0xd9ead207, __VMLINUX_SYMBOL_STR(i2c_del_driver) }, - { 0x1c9ec9e6, __VMLINUX_SYMBOL_STR(regulator_disable) }, - { 0x6b06fdce, __VMLINUX_SYMBOL_STR(delayed_work_timer_fn) }, - { 0x70139129, __VMLINUX_SYMBOL_STR(snd_soc_add_codec_controls) }, - { 0xb1ad28e0, __VMLINUX_SYMBOL_STR(__gnu_mcount_nc) }, - { 0x8fdf772a, __VMLINUX_SYMBOL_STR(init_timer_key) }, - { 0x2f1f8f20, __VMLINUX_SYMBOL_STR(mutex_unlock) }, - { 0xcb5daba2, __VMLINUX_SYMBOL_STR(snd_soc_put_volsw) }, - { 0xe1250b50, __VMLINUX_SYMBOL_STR(regmap_read) }, - { 0x66da0eca, __VMLINUX_SYMBOL_STR(snd_soc_get_volsw) }, - { 0xb1ea493e, __VMLINUX_SYMBOL_STR(sysfs_remove_group) }, - { 0x84e40310, __VMLINUX_SYMBOL_STR(register_start_clock) }, - { 0xe707d823, __VMLINUX_SYMBOL_STR(__aeabi_uidiv) }, - { 0xe872d1ce, __VMLINUX_SYMBOL_STR(snd_soc_read) }, - { 0x1b55d4fa, __VMLINUX_SYMBOL_STR(dev_err) }, - { 0xf090eadf, __VMLINUX_SYMBOL_STR(__mutex_init) }, - { 0x27e1a049, __VMLINUX_SYMBOL_STR(printk) }, - { 0x19d3b7d8, __VMLINUX_SYMBOL_STR(sysfs_create_group) }, - { 0xac92dc30, __VMLINUX_SYMBOL_STR(snd_soc_update_bits) }, - { 0xb729ab40, __VMLINUX_SYMBOL_STR(regulator_bulk_get) }, - { 0x9138e27f, __VMLINUX_SYMBOL_STR(mutex_lock) }, - { 0x94680ad3, __VMLINUX_SYMBOL_STR(snd_soc_info_volsw) }, - { 0xf204b815, __VMLINUX_SYMBOL_STR(i2c_register_driver) }, - { 0x85d472aa, __VMLINUX_SYMBOL_STR(queue_delayed_work_on) }, - { 0xff227eee, __VMLINUX_SYMBOL_STR(__devm_regmap_init_i2c) }, - { 0xee9ce628, __VMLINUX_SYMBOL_STR(snd_soc_unregister_codec) }, - { 0xbeea083, __VMLINUX_SYMBOL_STR(devm_gpiod_get_optional) }, - { 0x37a0cba, __VMLINUX_SYMBOL_STR(kfree) }, - { 0x3b045959, __VMLINUX_SYMBOL_STR(regulator_put) }, - { 0xb742fd7, __VMLINUX_SYMBOL_STR(simple_strtol) }, - { 0xb2d48a2e, __VMLINUX_SYMBOL_STR(queue_work_on) }, - { 0x103b85f7, __VMLINUX_SYMBOL_STR(snd_soc_register_codec) }, - { 0x5445472c, __VMLINUX_SYMBOL_STR(gpiod_set_value) }, - { 0x40c57909, __VMLINUX_SYMBOL_STR(devm_kmalloc) }, - { 0xad83053c, __VMLINUX_SYMBOL_STR(regcache_sync) }, - { 0x99b90480, __VMLINUX_SYMBOL_STR(regcache_cache_only) }, - { 0x3f14810b, __VMLINUX_SYMBOL_STR(regulator_enable) }, - { 0x44c19f83, __VMLINUX_SYMBOL_STR(snd_soc_write) }, -}; - -static const char __module_depends[] -__used -__attribute__((section(".modinfo"))) = -"depends=snd-soc-core,snd-soc-simple-card"; - -MODULE_ALIAS("of:N*T*Cx-power,ac101"); -MODULE_ALIAS("of:N*T*Cx-power,ac101C*"); - -MODULE_INFO(srcversion, "D993030BC9B6E1FB4EEB3FC"); diff --git a/snd-soc-ac108.mod.c b/snd-soc-ac108.mod.c deleted file mode 100644 index c517e5d..0000000 --- a/snd-soc-ac108.mod.c +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include - -MODULE_INFO(vermagic, VERMAGIC_STRING); - -__visible struct module __this_module -__attribute__((section(".gnu.linkonce.this_module"))) = { - .name = KBUILD_MODNAME, - .init = init_module, -#ifdef CONFIG_MODULE_UNLOAD - .exit = cleanup_module, -#endif - .arch = MODULE_ARCH_INIT, -}; - -static const struct modversion_info ____versions[] -__used -__attribute__((section("__versions"))) = { - { 0xdb0d8ebc, __VMLINUX_SYMBOL_STR(module_layout) }, - { 0x2d3385d3, __VMLINUX_SYMBOL_STR(system_wq) }, - { 0x7ace506a, __VMLINUX_SYMBOL_STR(i2c_master_send) }, - { 0xf9a482f9, __VMLINUX_SYMBOL_STR(msleep) }, - { 0x2e5810c6, __VMLINUX_SYMBOL_STR(__aeabi_unwind_cpp_pr1) }, - { 0xd9ead207, __VMLINUX_SYMBOL_STR(i2c_del_driver) }, - { 0xabdbe515, __VMLINUX_SYMBOL_STR(dev_printk) }, - { 0xf7802486, __VMLINUX_SYMBOL_STR(__aeabi_uidivmod) }, - { 0x6b06fdce, __VMLINUX_SYMBOL_STR(delayed_work_timer_fn) }, - { 0x70139129, __VMLINUX_SYMBOL_STR(snd_soc_add_codec_controls) }, - { 0xb1ad28e0, __VMLINUX_SYMBOL_STR(__gnu_mcount_nc) }, - { 0xb7051343, __VMLINUX_SYMBOL_STR(snd_soc_dapm_new_controls) }, - { 0x8fdf772a, __VMLINUX_SYMBOL_STR(init_timer_key) }, - { 0x82108f90, __VMLINUX_SYMBOL_STR(snd_soc_dapm_add_routes) }, - { 0xe707d823, __VMLINUX_SYMBOL_STR(__aeabi_uidiv) }, - { 0xfa2a45e, __VMLINUX_SYMBOL_STR(__memzero) }, - { 0x1b55d4fa, __VMLINUX_SYMBOL_STR(dev_err) }, - { 0x27e1a049, __VMLINUX_SYMBOL_STR(printk) }, - { 0x19d3b7d8, __VMLINUX_SYMBOL_STR(sysfs_create_group) }, - { 0x94680ad3, __VMLINUX_SYMBOL_STR(snd_soc_info_volsw) }, - { 0xf204b815, __VMLINUX_SYMBOL_STR(i2c_register_driver) }, - { 0x85d472aa, __VMLINUX_SYMBOL_STR(queue_delayed_work_on) }, - { 0x31475f0c, __VMLINUX_SYMBOL_STR(i2c_master_recv) }, - { 0xee9ce628, __VMLINUX_SYMBOL_STR(snd_soc_unregister_codec) }, - { 0xb742fd7, __VMLINUX_SYMBOL_STR(simple_strtol) }, - { 0xc5844d6f, __VMLINUX_SYMBOL_STR(of_property_read_variable_u32_array) }, - { 0x103b85f7, __VMLINUX_SYMBOL_STR(snd_soc_register_codec) }, - { 0x40c57909, __VMLINUX_SYMBOL_STR(devm_kmalloc) }, -}; - -static const char __module_depends[] -__used -__attribute__((section(".modinfo"))) = -"depends=snd-soc-core"; - -MODULE_ALIAS("i2c:ac108_0"); -MODULE_ALIAS("i2c:ac108_1"); -MODULE_ALIAS("i2c:ac108_2"); -MODULE_ALIAS("i2c:ac108_3"); -MODULE_ALIAS("of:N*T*Cx-power,ac108_0"); -MODULE_ALIAS("of:N*T*Cx-power,ac108_0C*"); -MODULE_ALIAS("of:N*T*Cx-power,ac108_1"); -MODULE_ALIAS("of:N*T*Cx-power,ac108_1C*"); -MODULE_ALIAS("of:N*T*Cx-power,ac108_2"); -MODULE_ALIAS("of:N*T*Cx-power,ac108_2C*"); -MODULE_ALIAS("of:N*T*Cx-power,ac108_3"); -MODULE_ALIAS("of:N*T*Cx-power,ac108_3C*"); - -MODULE_INFO(srcversion, "8ED7730CCF1BF1674A70161"); diff --git a/snd-soc-simple-card.mod.c b/snd-soc-simple-card.mod.c deleted file mode 100644 index 2ffbf1a..0000000 --- a/snd-soc-simple-card.mod.c +++ /dev/null @@ -1,69 +0,0 @@ -#include -#include -#include - -MODULE_INFO(vermagic, VERMAGIC_STRING); - -__visible struct module __this_module -__attribute__((section(".gnu.linkonce.this_module"))) = { - .name = KBUILD_MODNAME, - .init = init_module, -#ifdef CONFIG_MODULE_UNLOAD - .exit = cleanup_module, -#endif - .arch = MODULE_ARCH_INIT, -}; - -static const struct modversion_info ____versions[] -__used -__attribute__((section("__versions"))) = { - { 0xdb0d8ebc, __VMLINUX_SYMBOL_STR(module_layout) }, - { 0xb077e70a, __VMLINUX_SYMBOL_STR(clk_unprepare) }, - { 0x8fc5dfb7, __VMLINUX_SYMBOL_STR(devm_snd_soc_register_card) }, - { 0x815588a6, __VMLINUX_SYMBOL_STR(clk_enable) }, - { 0xbcfd140b, __VMLINUX_SYMBOL_STR(asoc_simple_card_canonicalize_dailink) }, - { 0x2733a62b, __VMLINUX_SYMBOL_STR(snd_soc_of_parse_audio_simple_widgets) }, - { 0x2e5810c6, __VMLINUX_SYMBOL_STR(__aeabi_unwind_cpp_pr1) }, - { 0xc3f4c05, __VMLINUX_SYMBOL_STR(asoc_simple_card_canonicalize_cpu) }, - { 0x3dd3f751, __VMLINUX_SYMBOL_STR(of_parse_phandle) }, - { 0xb9e26d37, __VMLINUX_SYMBOL_STR(asoc_simple_card_clean_reference) }, - { 0x870fc8b2, __VMLINUX_SYMBOL_STR(snd_soc_pm_ops) }, - { 0xb6e6d99d, __VMLINUX_SYMBOL_STR(clk_disable) }, - { 0xb1ad28e0, __VMLINUX_SYMBOL_STR(__gnu_mcount_nc) }, - { 0x88dc7e6f, __VMLINUX_SYMBOL_STR(__platform_driver_register) }, - { 0x1b55d4fa, __VMLINUX_SYMBOL_STR(dev_err) }, - { 0x3199c87d, __VMLINUX_SYMBOL_STR(of_device_is_available) }, - { 0x27e1a049, __VMLINUX_SYMBOL_STR(printk) }, - { 0x3e9d3734, __VMLINUX_SYMBOL_STR(of_find_property) }, - { 0x378c26fe, __VMLINUX_SYMBOL_STR(asoc_simple_card_set_dailink_name) }, - { 0xb9dc6bef, __VMLINUX_SYMBOL_STR(of_get_child_by_name) }, - { 0x848b1a5b, __VMLINUX_SYMBOL_STR(asoc_simple_card_init_dai) }, - { 0x42a0de39, __VMLINUX_SYMBOL_STR(asoc_simple_card_parse_clk) }, - { 0x94c40b85, __VMLINUX_SYMBOL_STR(asoc_simple_card_parse_daifmt) }, - { 0xe912cd9a, __VMLINUX_SYMBOL_STR(of_get_next_child) }, - { 0x7c9a7371, __VMLINUX_SYMBOL_STR(clk_prepare) }, - { 0x149259a, __VMLINUX_SYMBOL_STR(of_get_named_gpio_flags) }, - { 0xa6d8aaef, __VMLINUX_SYMBOL_STR(snd_soc_dai_set_sysclk) }, - { 0x4cce7249, __VMLINUX_SYMBOL_STR(snd_soc_of_parse_audio_routing) }, - { 0x48b6c9b2, __VMLINUX_SYMBOL_STR(snd_soc_card_jack_new) }, - { 0xd1b73339, __VMLINUX_SYMBOL_STR(snd_soc_jack_add_gpios) }, - { 0x5a371847, __VMLINUX_SYMBOL_STR(asoc_simple_card_parse_card_name) }, - { 0xb81960ca, __VMLINUX_SYMBOL_STR(snprintf) }, - { 0x63fbc1b9, __VMLINUX_SYMBOL_STR(snd_soc_jack_free_gpios) }, - { 0xfc01da1c, __VMLINUX_SYMBOL_STR(platform_driver_unregister) }, - { 0xc5844d6f, __VMLINUX_SYMBOL_STR(of_property_read_variable_u32_array) }, - { 0x973c1054, __VMLINUX_SYMBOL_STR(of_node_put) }, - { 0x40c57909, __VMLINUX_SYMBOL_STR(devm_kmalloc) }, - { 0x4716d13d, __VMLINUX_SYMBOL_STR(snd_soc_of_parse_tdm_slot) }, - { 0xee2335c2, __VMLINUX_SYMBOL_STR(asoc_simple_card_parse_dai) }, -}; - -static const char __module_depends[] -__used -__attribute__((section(".modinfo"))) = -"depends=snd-soc-core,snd-soc-simple-card-utils"; - -MODULE_ALIAS("of:N*T*Csimple-audio-card"); -MODULE_ALIAS("of:N*T*Csimple-audio-cardC*"); - -MODULE_INFO(srcversion, "4AD728D0E5FB89C88D04665");