Add: multi codec support in simple-card

This commit is contained in:
peter.yang 2018-02-07 14:02:45 +08:00
parent edb5a1da65
commit cf52966d00
7 changed files with 43 additions and 217 deletions

View file

@ -1319,7 +1319,6 @@ static int ac10x_hw_params(struct snd_pcm_substream *substream,
break; break;
} }
/* set LRCK/BCLK ratio */ /* set LRCK/BCLK ratio */
aif1_lrck_div = aif1_slot_size * channels; aif1_lrck_div = aif1_slot_size * channels;
for (i = 0; i < ARRAY_SIZE(codec_aif1_lrck); i++) { for (i = 0; i < ARRAY_SIZE(codec_aif1_lrck); i++) {
@ -1372,6 +1371,9 @@ static int ac10x_hw_params(struct snd_pcm_substream *substream,
snd_soc_update_bits(codec, AIF_CLK_CTRL, (0xf<<AIF1_BCLK_DIV), i<<AIF1_BCLK_DIV); snd_soc_update_bits(codec, AIF_CLK_CTRL, (0xf<<AIF1_BCLK_DIV), i<<AIF1_BCLK_DIV);
} }
AC10X_DBG("rate: %d , channels: %d , samp_res: %d",
params_rate(params), channels, aif1_slot_size);
AC10X_DBG("%s() L%d ---\n", __func__, __LINE__); AC10X_DBG("%s() L%d ---\n", __func__, __LINE__);
return 0; return 0;
} }
@ -1632,7 +1634,7 @@ static struct snd_soc_dai_driver ac10x_dai[] = {
.name = "ac10x-aif1", .name = "ac10x-aif1",
.id = AIF1_CLK, .id = AIF1_CLK,
.playback = { .playback = {
.stream_name = "AIF1 Playback", .stream_name = "Playback",
.channels_min = 1, .channels_min = 1,
.channels_max = 8, .channels_max = 8,
.rates = ac10x_RATES, .rates = ac10x_RATES,
@ -1640,7 +1642,7 @@ static struct snd_soc_dai_driver ac10x_dai[] = {
}, },
#if 0 #if 0
.capture = { .capture = {
.stream_name = "AIF1 Capture", .stream_name = "Capture",
.channels_min = 1, .channels_min = 1,
.channels_max = 8, .channels_max = 8,
.rates = ac10x_RATES, .rates = ac10x_RATES,

View file

@ -823,7 +823,8 @@ static int ac108_configure_clocking(struct ac108_priv *ac108, unsigned int rate)
for (i = 0; i < ARRAY_SIZE(ac108_pll_div_list); i++) { for (i = 0; i < ARRAY_SIZE(ac108_pll_div_list); i++) {
if (ac108_pll_div_list[i].freq_in == ac108->sysclk && ac108_pll_div_list[i].freq_out % rate == 0) { if (ac108_pll_div_list[i].freq_in == ac108->sysclk && ac108_pll_div_list[i].freq_out % rate == 0) {
ac108_pll_div = ac108_pll_div_list[i]; 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; break;
} }
} }
@ -973,7 +974,7 @@ static int ac108_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_h
return -EINVAL; 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++) { for (i = 0; i < ARRAY_SIZE(ac108_sample_rate); i++) {
if (ac108_sample_rate[i].real_val == params_rate(params) / (ac108->data_protocol + 1UL)) { if (ac108_sample_rate[i].real_val == params_rate(params) / (ac108->data_protocol + 1UL)) {

View file

@ -86,6 +86,8 @@
/* below is dummy master, real clock master is ac101 */ /* below is dummy master, real clock master is ac101 */
bitclock-master = <&codec0_dai>; bitclock-master = <&codec0_dai>;
frame-master = <&codec0_dai>; frame-master = <&codec0_dai>;
/* bitclock-inversion; */
/* frame-inversion; */
cpu { cpu {
sound-dai = <&i2s>; sound-dai = <&i2s>;
@ -106,6 +108,8 @@
format = "dsp_a"; format = "dsp_a";
bitclock-master = <&codec1_dai>; bitclock-master = <&codec1_dai>;
frame-master = <&codec1_dai>; frame-master = <&codec1_dai>;
/* bitclock-inversion; */
/* frame-inversion; */
cpu { cpu {
sound-dai = <&i2s>; sound-dai = <&i2s>;

View file

@ -22,6 +22,13 @@
#include <sound/soc-dai.h> #include <sound/soc-dai.h>
#include <sound/soc.h> #include <sound/soc.h>
/*
* single codec:
* 0 - allow multi codec
* 1 - yes
*/
#define _SINGLE_CODEC 1
struct asoc_simple_jack { struct asoc_simple_jack {
struct snd_soc_jack jack; struct snd_soc_jack jack;
struct snd_soc_jack_pin pin; 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) 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; 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); __FUNCTION__, substream->stream, cmd);
switch (cmd) { switch (cmd) {
@ -311,9 +319,18 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
if (ret < 0) if (ret < 0)
goto dai_link_of_err; goto dai_link_of_err;
#if _SINGLE_CODEC
ret = asoc_simple_card_parse_codec(codec, dai_link, DAI, CELL); ret = asoc_simple_card_parse_codec(codec, dai_link, DAI, CELL);
if (ret < 0) if (ret < 0)
goto dai_link_of_err; 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); ret = asoc_simple_card_parse_platform(plat, dai_link, DAI, CELL);
if (ret < 0) if (ret < 0)
@ -345,14 +362,21 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
if (ret < 0) if (ret < 0)
goto dai_link_of_err; goto dai_link_of_err;
#if _SINGLE_CODEC
ret = asoc_simple_card_canonicalize_dailink(dai_link); ret = asoc_simple_card_canonicalize_dailink(dai_link);
if (ret < 0) if (ret < 0)
goto dai_link_of_err; goto dai_link_of_err;
#endif
ret = asoc_simple_card_set_dailink_name(dev, dai_link, ret = asoc_simple_card_set_dailink_name(dev, dai_link,
"%s-%s", "%s-%s",
dai_link->cpu_dai_name, 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) if (ret < 0)
goto dai_link_of_err; 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_link->cpu_dai_name,
dai_props->cpu_dai.sysclk); dai_props->cpu_dai.sysclk);
dev_dbg(dev, "\tcodec : %s / %d\n", dev_dbg(dev, "\tcodec : %s / %d\n",
#if _SINGLE_CODEC
dai_link->codec_dai_name, dai_link->codec_dai_name,
#else
dai_link->codecs[0].dai_name,
#endif
dai_props->codec_dai.sysclk); dai_props->codec_dai.sysclk);
asoc_simple_card_canonicalize_cpu(dai_link, single_cpu); asoc_simple_card_canonicalize_cpu(dai_link, single_cpu);

View file

@ -1,72 +0,0 @@
#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
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");

View file

@ -1,68 +0,0 @@
#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
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");

View file

@ -1,69 +0,0 @@
#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
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");