ASoC: simple-card-utils: prepare for multi support
Subsystems (4)
Kuninori Morimoto
maintainercover ASoC: simple-card-utils: prepare for multi support
Hi Mark
I want to add new audio-graph-card2 driver which can support not only DPCM, but also Multi-CPU/Codec, and Codec2Codec. And it is also supporting audio-graph-card2 base custom driver.
But before supporting such driver, we need to cleanup existing simple-card / audio-graph, because these and new driver are sharing code.
This patch-set are for Multi-CPU/Codec support,
and some cleanups.
Kuninori Morimoto (14):
ASoC: simple-card-utils: enable flexible CPU/Codec/Platform
ASoC: simple-card-utils: share dummy DAI and reduce memory
ASoC: simple-card-utils: setup dai_props cpu_dai/codec_dai at initial timing
ASoC: simple-card-utils: remove li->dais/li->conf
ASoC: simple-card-utils: use for_each_prop_xxx()
ASoC: simple-card-utils: remove asoc_simple_parse_xxx()
ASoC: simple-card-utils: care multi DAI at asoc_simple_clean_reference()
ASoC: simple-card-utils: indicate dai_fmt if exist
ASoC: simple-card-utils: indicate missing CPU/Codec numbers for debug
ASoC: simple-card-utils: add simple_props_to_xxx() macro
ASoC: simple-card-utils: multi support at asoc_simple_canonicalize_cpu/platform()
ASoC: simple-card-utils: tidyup debug info for clock
ASoC: simple-card-utils: tidyup dev_dbg() to use 1 line
ASoC: simple-card-utils: tidyup asoc_simple_parse_convert()
include/sound/simple_card_utils.h | 116 +++++++---- sound/soc/generic/audio-graph-card.c | 90 ++++----- sound/soc/generic/simple-card-utils.c | 272 +++++++++++++++++--------- sound/soc/generic/simple-card.c | 104 +++++----- 4 files changed, 352 insertions(+), 230 deletions(-)
Signature · 1 line
2.25.1
Kuninori Morimoto
maintainerPATCH 1/14 ASoC: simple-card-utils: enable flexible CPU/Codec/Platform
From: Kuninori Morimoto <[email protected]>
Current simple-card / audio-graph are assuming fixed single-CPU/Codec/Platform.
This patch prepares multi-CPU/Codec/Platform support.
Note is that it is not yet full-multi-support.
--- include/sound/simple_card_utils.h | 8 +++ sound/soc/generic/audio-graph-card.c | 22 ++++++++ sound/soc/generic/simple-card-utils.c | 72 +++++++++++++++++++-------- sound/soc/generic/simple-card.c | 30 +++++++++++ 4 files changed, 110 insertions(+), 22 deletions(-)
include/sound/simple_card_utils.h +8 -0
@@ -38,6 +38,12 @@ struct asoc_simple_jack {struct snd_soc_jack_gpio gpio; }; +struct prop_nums { +int cpus; +int codecs; +int platforms; +}; + struct asoc_simple_priv { struct snd_soc_card snd_card; struct simple_dai_props {
@@ -48,6 +54,7 @@ struct asoc_simple_priv {struct snd_soc_dai_link_component *platforms;struct asoc_simple_data adata;struct snd_soc_codec_conf *codec_conf; +struct prop_nums num;unsigned int mclk_fs; } *dai_props;struct asoc_simple_jack hp_jack;
@@ -71,6 +78,7 @@ struct link_info {int link;/* number of link */ int conf;/* number of codec_conf */ int cpu;/* turn for CPU / Codec */ +struct prop_nums num[SNDRV_MINOR_DEVICES ]; }; int asoc_simple_parse_daifmt(struct device *dev,
sound/soc/generic/audio-graph-card.c +22 -0
@@ -628,6 +628,15 @@ static int graph_count_noml(struct asoc_simple_priv *priv, {struct device *dev =simple_priv_to_dev (priv); +if (li->link >=SNDRV_MINOR_DEVICES ) { +dev_err (dev,"too many links\n" ); +return -EINVAL ; + } + + li->num[li->link].cpus =1 ; + li->num[li->link].codecs =1 ; + li->num[li->link].platforms =1 ; + li->link +=1 ;/* 1xCPU-Codec */ li->dais +=2 ;/* 1xCPU + 1xCodec */
@@ -643,10 +652,23 @@ static int graph_count_dpcm(struct asoc_simple_priv *priv, {struct device *dev =simple_priv_to_dev (priv); +if (li->link >=SNDRV_MINOR_DEVICES ) { +dev_err (dev,"too many links\n" ); +return -EINVAL ; + } +if (li->cpu) { + li->num[li->link].cpus =1 ; + li->num[li->link].codecs =1 ; + li->num[li->link].platforms =1 ; + li->link++;/* 1xCPU-dummy */ li->dais++;/* 1xCPU */ }else { + li->num[li->link].cpus =1 ; + li->num[li->link].codecs =1 ; + li->num[li->link].platforms =1 ; + li->link++;/* 1xdummy-Codec */ li->conf++;/* 1xdummy-Codec */ li->dais++;/* 1xCodec */
sound/soc/generic/simple-card-utils.c +50 -22
93 lines not on this page · raw message
sound/soc/generic/simple-card.c +30 -0
@@ -499,6 +499,17 @@ static int simple_count_noml(struct asoc_simple_priv *priv,struct device_node *codec, struct link_info *li, bool is_top) { + if (li->link >= SNDRV_MINOR_DEVICES) { + struct device *dev = simple_priv_to_dev(priv); + +dev_err (dev,"too many links\n" ); +return -EINVAL ; + } + + li->num[li->link].cpus =1 ; + li->num[li->link].codecs =1 ; + li->num[li->link].platforms =1 ; + li->link +=1 ; li->dais +=2 ;
@@ -510,10 +521,25 @@ static int simple_count_dpcm(struct asoc_simple_priv *priv,struct device_node *codec, struct link_info *li, bool is_top) { + if (li->link >= SNDRV_MINOR_DEVICES) { + struct device *dev = simple_priv_to_dev(priv); + +dev_err (dev,"too many links\n" ); +return -EINVAL ; + } +if (li->cpu) { + li->num[li->link].cpus =1 ; + li->num[li->link].codecs =1 ; + li->num[li->link].platforms =1 ; + li->link++;/* CPU-dummy */ li->dais++; }else { + li->num[li->link].cpus =1 ; + li->num[li->link].codecs =1 ; + li->num[li->link].platforms =1 ; + li->link++;/* dummy-Codec */ li->dais++; li->conf++;
@@ -575,6 +601,10 @@ static void simple_get_dais_count(struct asoc_simple_priv *priv,* => 1 ccnf = 1xdummy-Codec */ if (!top) { + li->num[0 ].cpus =1 ; + li->num[0 ].codecs =1 ; + li->num[0 ].platforms =1 ; + li->link =1 ; li->dais =2 ; li->conf =0 ;
Signature · 1 line
2.25.1
Re: [PATCH 01/14] ASoC: simple-card-utils: enable flexible CPU/Codec/Platform
Quoted 8 lines · Kuninori Morimoto
From: Kuninori Morimoto <[email protected]>
Current simple-card / audio-graph are assuming fixed single-CPU/Codec/Platform.
This patch prepares multi-CPU/Codec/Platform support.Note is that it is not yet full-multi-support.
Quoted 7 lines
Signed-off-by Kuninori Morimoto <[email protected]>--- include/sound/simple_card_utils.h | 8 +++ sound/soc/generic/audio-graph-card.c | 22 ++++++++ sound/soc/generic/simple-card-utils.c | 72 +++++++++++++++++++-------- sound/soc/generic/simple-card.c | 30 +++++++++++ 4 files changed, 110 insertions(+), 22 deletions(-)
Hi,
This seems to break display support on a Jetson TX2 board for me, though I admittedly don't quite understand how it would be related to display at all. Reverting basically the whole series (because subsequent patches depend on this on) on top of next-20210415, I get working display again.
There's this in the log, which seems to be related:
[ 14.671377] tegra-audio-graph-card sound: too many links [ 14.799645] tegra-audio-graph-card sound: too many links [ 14.845375] tegra-audio-graph-card sound: too many links [ 14.853635] tegra-audio-graph-card sound: too many links [ 14.860934] tegra-audio-graph-card sound: too many links [ 14.868781] tegra-audio-graph-card sound: too many links [ 14.875659] tegra-audio-graph-card sound: too many links [ 14.907874] tegra-audio-graph-card sound: too many links [ 14.917351] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010 [ 14.926255] Mem abort info: [ 14.929096] ESR = 0x96000047 [ 14.932208] EC = 0x25: DABT (current EL), IL = 32 bits [ 14.937559] SET = 0, FnV = 0 [ 14.940642] EA = 0, S1PTW = 0 [ 14.943867] Data abort info: [ 14.946753] ISV = 0, ISS = 0x00000047 [ 14.950611] CM = 0, WnR = 1 [ 14.953614] user pgtable: 64k pages, 48-bit VAs, pgdp=0000000100b94400 [ 14.960185] [0000000000000010] pgd=0800000102280003, p4d=0800000102280003, pud=0800000102280003, pmd=0800000101050003, pte=0000000000000000 [ 14.972774] Internal error: Oops: 96000047 [#1] PREEMPT SMP [ 14.978362] Modules linked in: drm_kms_helper snd_soc_tegra210_admaif snd_soc_tegra_pcm snd_soc_tegra210_dmic snd_soc_tegra210_i2s snd_soc_tegra186_dspk cfbfillrect cfbimgblt cfbcopyarea snd_soc_tegra210_ahub snd_soc_tegra_audio_graph_card snd_soc_audio_graph_card snd_soc_simple_card_utils crct10dif_ce at24 tegra_aconnect tegra_bpmp_thermal host1x drm fuse drm_panel_orientation_quirks ipv6 [ 15.012917] CPU: 2 PID: 69 Comm: kworker/u12:3 Tainted: G S 5.12.0-rc7-next-20210415 #108 [ 15.022390] Hardware name: NVIDIA Jetson TX2 Developer Kit (DT) [ 15.028303] Workqueue: events_unbound deferred_probe_work_func [ 15.034159] pstate: 40000005 (nZcv daif -PAN -UAO -TCO BTYPE=--) [ 15.040162] pc : snd_soc_get_dai_name+0x124/0x150 [ 15.044883] lr : snd_soc_get_dai_name+0xa4/0x150 [ 15.049521] sp : ffff800011fef780 [ 15.052849] x29: ffff800011fef780 x28: ffff00008bc14980 [ 15.058181] x27: 0000000000000000 x26: ffff000081aafc10 [ 15.063511] x25: ffff0001f7091680 x24: ffff800011538798 [ 15.068841] x23: 0000000000000010 x22: ffff800011538778 [ 15.074169] x21: ffff800011fef808 x20: 00000000fffffdf4 [ 15.079486] x19: ffff0000809c7880 x18: 0000000000000030 [ 15.084813] x17: 0000000000000000 x16: 0000000000000000 [ 15.090142] x15: ffffffffffffffff x14: ffffffff00000000 [ 15.095468] x13: ffffffffffffffff x12: 0000000000000020 [ 15.100804] x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f [ 15.106135] x9 : 7f7f7f7f7f7f7f7f x8 : feff303f73716e6f [ 15.111464] x7 : 00000000ffffffff x6 : 0000314000000000 [ 15.116791] x5 : ffff0001f7091d28 x4 : ffff00008c41a010 [ 15.122109] x3 : 0000000000000000 x2 : 0000000000000010 [ 15.127439] x1 : 0000000000000000 x0 : ffff8000094614d8 [ 15.132756] Call trace: [ 15.135201] snd_soc_get_dai_name+0x124/0x150 [ 15.139560] asoc_simple_parse_dai.part.0+0x70/0xd0 [snd_soc_audio_graph_card] [ 15.146784] graph_dai_link_of_dpcm+0x100/0x38c [snd_soc_audio_graph_card] [ 15.153672] __graph_for_each_link+0x1dc/0x204 [snd_soc_audio_graph_card] [ 15.160471] audio_graph_parse_of+0x148/0x20c [snd_soc_audio_graph_card] [ 15.167178] tegra_audio_graph_probe+0x6c/0x8c [snd_soc_tegra_audio_graph_card] [ 15.174499] platform_probe+0x68/0xe0 [ 15.178164] really_probe+0xe4/0x50c [ 15.181754] driver_probe_device+0x64/0xc4 [ 15.185861] __device_attach_driver+0xb4/0x110 [ 15.190314] bus_for_each_drv+0x78/0xd0 [ 15.194149] __device_attach+0xd8/0x180 [ 15.197985] device_initial_probe+0x14/0x20 [ 15.202168] bus_probe_device+0x9c/0xa4 [ 15.206003] deferred_probe_work_func+0x88/0xc0 [ 15.210532] process_one_work+0x1cc/0x350 [ 15.214542] worker_thread+0x68/0x3ac [ 15.218203] kthread+0x128/0x134 [ 15.221431] ret_from_fork+0x10/0x34 [ 15.225045] Code: fa531004 54ffff81 f9400c00 f9400000 (f90002e0) [ 15.231134] ---[ end trace 671a11645631ca2f ]---
Any ideas what could be wrong?
Adding Jon and linux-tegra for visibility.
Thierry
Mark Brown
maintainerRe: [PATCH 01/14] ASoC: simple-card-utils: enable flexible CPU/Codec/Platform
Quoted 4 lines · Thierry Reding
This seems to break display support on a Jetson TX2 board for me, though I admittedly don't quite understand how it would be related to display at all. Reverting basically the whole series (because subsequent patches depend on this on) on top of next-20210415, I get working display again.
Given that we got an oops it's probably just memory corruption somewhere.
Quoted 4 lines
There's this in the log, which seems to be related:
[ 14.671377] tegra-audio-graph-card sound: too many links [ 14.799645] tegra-audio-graph-card sound: too many links
This looks like an issue? Or perhaps it's just DPCM triggered...
Quoted 7 lines
[ 15.106135] x9 : 7f7f7f7f7f7f7f7f x8 : feff303f73716e6f [ 15.111464] x7 : 00000000ffffffff x6 : 0000314000000000 [ 15.116791] x5 : ffff0001f7091d28 x4 : ffff00008c41a010 [ 15.122109] x3 : 0000000000000000 x2 : 0000000000000010 [ 15.127439] x1 : 0000000000000000 x0 : ffff8000094614d8 [ 15.132756] Call trace: [ 15.135201] snd_soc_get_dai_name+0x124/0x150
Can you check where that is in the function?
Re: [PATCH 01/14] ASoC: simple-card-utils: enable flexible CPU/Codec/Platform
Quoted 10 lines · Mark Brown
Quoted 4 lines · Thierry Reding
This seems to break display support on a Jetson TX2 board for me, though I admittedly don't quite understand how it would be related to display at all. Reverting basically the whole series (because subsequent patches depend on this on) on top of next-20210415, I get working display again.
Given that we got an oops it's probably just memory corruption somewhere.
Quoted 6 lines
Quoted 4 lines
There's this in the log, which seems to be related:
[ 14.671377] tegra-audio-graph-card sound: too many links [ 14.799645] tegra-audio-graph-card sound: too many linksThis looks like an issue? Or perhaps it's just DPCM triggered...
Yeah, as I was looking into this a bit, I noticed that on Tegra186 and later the number of links can go up to 72. I'm not sure why this is wreaking havoc, since presumably the check is there to prevent the array from being overwritten, but apparently it's not. I suspect that the same check might be missing somewhere else.
In any case, I came up with the attached. I don't know how good it is because now the number of links exceeds SNDRV_MINOR_DEVICES, but perhaps that's just irrelevant and that constant was used merely because it was conveniently there.
The patch restores display on Jetson TX2. I can look around a bit if I can find where the boundary checks might be missing so that we gracefully fail rather than corrupting everything.
Thierry
From ba07d30380492661c8fc2677155c9c6230bae2fe Mon Sep 17 00:00:00 2001
From: Thierry Reding <[email protected]>
Date: Thu, 15 Apr 2021 20:16:09 +0200
Subject: [PATCH] ASoC: simple-card-utils: Increase maximum number of links to
128
On Tegra186 and later, the number of links can go up to 72, so bump the maximum number of links to the next power of two (128).
--- include/sound/simple_card_utils.h | 4 +++- sound/soc/generic/audio-graph-card.c | 4 ++-- sound/soc/generic/simple-card.c | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-)
include/sound/simple_card_utils.h +3 -1
@@ -115,10 +115,12 @@ struct asoc_simple_priv { ((codec) =simple_props_to_dai_codec (props, i)); \ (i)++) +#define SNDRV_MAX_LINKS 128 +struct link_info {int link;/* number of link */ int cpu;/* turn for CPU / Codec */ -struct prop_nums num[SNDRV_MINOR_DEVICES ]; +struct prop_nums num[SNDRV_MAX_LINKS ]; }; int asoc_simple_parse_daifmt(struct device *dev,
sound/soc/generic/audio-graph-card.c +2 -2
@@ -613,7 +613,7 @@ static int graph_count_noml(struct asoc_simple_priv *priv, {struct device *dev =simple_priv_to_dev (priv); -if (li->link >=SNDRV_MINOR_DEVICES ) { +if (li->link >=SNDRV_MAX_LINKS ) {dev_err (dev,"too many links\n" );return -EINVAL ; }
@@ -636,7 +636,7 @@ static int graph_count_dpcm(struct asoc_simple_priv *priv, {struct device *dev =simple_priv_to_dev (priv); -if (li->link >=SNDRV_MINOR_DEVICES ) { +if (li->link >=SNDRV_MAX_LINKS ) {dev_err (dev,"too many links\n" );return -EINVAL ; }
sound/soc/generic/simple-card.c +2 -2
@@ -484,7 +484,7 @@ static int simple_count_noml(struct asoc_simple_priv *priv,struct device_node *codec, struct link_info *li, bool is_top) { - if (li->link >= SNDRV_MINOR_DEVICES) { + if (li->link >= SNDRV_MAX_LINKS) { struct device *dev = simple_priv_to_dev(priv);dev_err (dev,"too many links\n" );
@@ -505,7 +505,7 @@ static int simple_count_dpcm(struct asoc_simple_priv *priv,struct device_node *codec, struct link_info *li, bool is_top) { - if (li->link >= SNDRV_MINOR_DEVICES) { + if (li->link >= SNDRV_MAX_LINKS) { struct device *dev = simple_priv_to_dev(priv);dev_err (dev,"too many links\n" );
Signature · 1 line
2.30.2
Mark Brown
maintainerRe: [PATCH 01/14] ASoC: simple-card-utils: enable flexible CPU/Codec/Platform
Quoted 4 lines · Thierry Reding
In any case, I came up with the attached. I don't know how good it is because now the number of links exceeds
SNDRV_MINOR_DEVICES, but perhaps that's just irrelevant and that constant was used merely because it was conveniently there.
We shouldn't actually end up creating that many devices, a lot of those should be DPCM links which are internal only.
Quoted 3 lines
The patch restores display on Jetson TX2. I can look around a bit if I can find where the boundary checks might be missing so that we gracefully fail rather than corrupting everything.
That'd be good, thanks.
Kuninori Morimoto
maintainerPATCH 2/14 ASoC: simple-card-utils: share dummy DAI and reduce memory
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current simple-card / audio-graph creates 1xCPU + 1xCodec + 1xPlatform for all dai_link, but some of them is not needed.
For example Platform is not needed for DPCM BE case. Moreover, we can share snd-soc-dummy DAI for CPU-dummy / dummy-Codec in DPCM.
This patch adds dummy DAI and share it when DPCM case, I beliave it can contribute to reduce memory.
By this patch, CPU-dummy / dummy-CPU are set at asoc_simple_init_priv(), thus, its settings are no longer needed at DPCM detecting timing on simple-card / audio-graph.
Moreover, we can remove triky Platform settings code for DPCM BE, because un-needed Platform is not created.
--- include/sound/simple_card_utils.h | 1 + sound/soc/generic/audio-graph-card.c | 12 +---------- sound/soc/generic/simple-card-utils.c | 30 ++++++++++++++++++++------- sound/soc/generic/simple-card.c | 12 +---------- 4 files changed, 26 insertions(+), 29 deletions(-)
include/sound/simple_card_utils.h +1 -0
@@ -62,6 +62,7 @@ struct asoc_simple_priv {struct snd_soc_dai_link *dai_link;struct asoc_simple_dai *dais;struct snd_soc_dai_link_component *dlcs; +struct snd_soc_dai_link_component dummy;struct snd_soc_codec_conf *codec_conf;struct gpio_desc *pa_gpio;const struct snd_soc_ops *ops;
sound/soc/generic/audio-graph-card.c +1 -11
@@ -240,9 +240,6 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,int is_single_links =0 ;/* Codec is dummy */ - codecs->of_node =NULL ; - codecs->dai_name ="snd-soc-dummy-dai" ; - codecs->name ="snd-soc-dummy" ;/* FE settings */ dai_link->dynamic =1 ;
@@ -281,13 +278,11 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,/* card->num_links includes Codec */ asoc_simple_canonicalize_cpu (dai_link, is_single_links); +asoc_simple_canonicalize_platform (dai_link); }else {struct snd_soc_codec_conf *cconf;/* CPU is dummy */ - cpus->of_node =NULL ; - cpus->dai_name ="snd-soc-dummy-dai" ; - cpus->name ="snd-soc-dummy" ;/* BE settings */ dai_link->no_pcm =1 ;
@@ -328,8 +323,6 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,graph_parse_convert (dev, ep, &dai_props->adata);graph_parse_mclk_fs (top, ep, dai_props); -asoc_simple_canonicalize_platform (dai_link); - ret =asoc_simple_parse_tdm (ep, dai);if (ret) goto out_put_node;
@@ -659,15 +652,12 @@ static int graph_count_dpcm(struct asoc_simple_priv *priv,if (li->cpu) { li->num[li->link].cpus =1 ; - li->num[li->link].codecs =1 ; li->num[li->link].platforms =1 ; li->link++;/* 1xCPU-dummy */ li->dais++;/* 1xCPU */ }else { - li->num[li->link].cpus =1 ; li->num[li->link].codecs =1 ; - li->num[li->link].platforms =1 ; li->link++;/* 1xdummy-Codec */ li->conf++;/* 1xdummy-Codec */
sound/soc/generic/simple-card-utils.c +23 -7
@@ -404,13 +404,6 @@ void asoc_simple_canonicalize_platform(struct snd_soc_dai_link *dai_link)/* Assumes platform == cpu */ if (!dai_link->platforms->of_node) dai_link->platforms->of_node = dai_link->cpus->of_node; - -/* -* DPCM BE can be no platform. -* Alloced memory will be waste, but not leak. -*/ -if (!dai_link->platforms->of_node) - dai_link->num_platforms =0 ; }EXPORT_SYMBOL_GPL (asoc_simple_canonicalize_platform);
@@ -633,6 +626,11 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,return -ENOMEM ; } +/* dummy CPU/Codec */ + priv->dummy.of_node =NULL ; + priv->dummy.dai_name ="snd-soc-dummy-dai" ; + priv->dummy.name ="snd-soc-dummy" ; + priv->dai_props = dai_props; priv->dai_link = dai_link; priv->dais = dais;
@@ -653,6 +651,12 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, dai_link[i].num_cpus = li->num[i].cpus; dlcs += li->num[i].cpus; + }else { +/* DPCM Be's CPU = dummy */ + dai_props[i].cpus = + dai_link[i].cpus = &priv->dummy; + dai_props[i].num.cpus = + dai_link[i].num_cpus =1 ; }if (li->num[i].codecs) {
@@ -663,6 +667,12 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, dai_link[i].num_codecs = li->num[i].codecs; dlcs += li->num[i].codecs; + }else { +/* DPCM Fe's Codec = dummy */ + dai_props[i].codecs = + dai_link[i].codecs = &priv->dummy; + dai_props[i].num.codecs = + dai_link[i].num_codecs =1 ; }if (li->num[i].platforms) {
@@ -673,6 +683,12 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, dai_link[i].num_platforms = li->num[i].platforms; dlcs += li->num[i].platforms; + }else { +/* Doesn't have Platform */ + dai_props[i].platforms = + dai_link[i].platforms =NULL ; + dai_props[i].num.platforms = + dai_link[i].num_platforms =0 ; } }
sound/soc/generic/simple-card.c +1 -11
@@ -141,9 +141,6 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,int is_single_links =0 ;/* Codec is dummy */ - codecs->of_node =NULL ; - codecs->dai_name ="snd-soc-dummy-dai" ; - codecs->name ="snd-soc-dummy" ;/* FE settings */ dai_link->dynamic =1 ;
@@ -167,13 +164,11 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, goto out_put_node;asoc_simple_canonicalize_cpu (dai_link, is_single_links); +asoc_simple_canonicalize_platform (dai_link); }else {struct snd_soc_codec_conf *cconf;/* CPU is dummy */ - cpus->of_node =NULL ; - cpus->dai_name ="snd-soc-dummy-dai" ; - cpus->name ="snd-soc-dummy" ;/* BE settings */ dai_link->no_pcm =1 ;
@@ -211,8 +206,6 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,simple_parse_convert (dev, np, &dai_props->adata);simple_parse_mclk_fs (top, np, codec, dai_props, prefix); -asoc_simple_canonicalize_platform (dai_link); - ret =asoc_simple_parse_tdm (np, dai);if (ret) goto out_put_node;
@@ -530,15 +523,12 @@ static int simple_count_dpcm(struct asoc_simple_priv *priv,if (li->cpu) { li->num[li->link].cpus =1 ; - li->num[li->link].codecs =1 ; li->num[li->link].platforms =1 ; li->link++;/* CPU-dummy */ li->dais++; }else { - li->num[li->link].cpus =1 ; li->num[li->link].codecs =1 ; - li->num[li->link].platforms =1 ; li->link++;/* dummy-Codec */ li->dais++;
Signature · 1 line
2.25.1
Kuninori Morimoto
maintainerPATCH 3/14 ASoC: simple-card-utils: setup dai_props cpu_dai/codec_dai at initial timing
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
We couldn't setup dai_props cpu_dai/codec_dai at the initial timing, because "counting DAIs loop" and "detecting DAIs loop" were different. But we can do it now, because these are using same loops.
This patch setups dai_props cpu_dai/codec_dai at the initial timing. It can removes triky code from simple-card / audio-graph.
--- sound/soc/generic/audio-graph-card.c | 19 +++++-------------- sound/soc/generic/simple-card-utils.c | 10 ++++++++++ sound/soc/generic/simple-card.c | 24 +++++------------------- 3 files changed, 20 insertions(+), 33 deletions(-)
sound/soc/generic/audio-graph-card.c +5 -14
@@ -245,8 +245,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->dynamic =1 ; dai_link->dpcm_merged_format =1 ; - dai = - dai_props->cpu_dai = &priv->dais[li->dais++]; + dai = dai_props->cpu_dai; ret =asoc_simple_parse_cpu (ep, dai_link, &is_single_links);if (ret)
@@ -288,11 +287,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->no_pcm =1 ; dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup; - dai = - dai_props->codec_dai = &priv->dais[li->dais++]; - - cconf = - dai_props->codec_conf = &priv->codec_conf[li->conf++]; + dai = dai_props->codec_dai; + cconf = dai_props->codec_conf; ret =asoc_simple_parse_codec (ep, dai_link);if (ret <0 )
@@ -358,19 +354,14 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv,struct snd_soc_dai_link *dai_link =simple_priv_to_link (priv, li->link);struct simple_dai_props *dai_props =simple_priv_to_props (priv, li->link);struct device_node *top = dev->of_node; -struct asoc_simple_dai *cpu_dai; -struct asoc_simple_dai *codec_dai; +struct asoc_simple_dai *cpu_dai = dai_props->cpu_dai; +struct asoc_simple_dai *codec_dai = dai_props->codec_dai;int ret, single_cpu;dev_dbg (dev,"link_of (%pOF)\n" , cpu_ep); li->link++; - cpu_dai = - dai_props->cpu_dai = &priv->dais[li->dais++]; - codec_dai = - dai_props->codec_dai = &priv->dais[li->dais++]; -/* Factor to mclk, used in hw_params() */ graph_parse_mclk_fs (top, cpu_ep, dai_props);graph_parse_mclk_fs (top, codec_ep, dai_props);
sound/soc/generic/simple-card-utils.c +10 -0
@@ -649,8 +649,10 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, dai_link[i].cpus = dlcs; dai_props[i].num.cpus = dai_link[i].num_cpus = li->num[i].cpus; + dai_props[i].cpu_dai = dais; dlcs += li->num[i].cpus; + dais += li->num[i].cpus; }else {/* DPCM Be's CPU = dummy */ dai_props[i].cpus =
@@ -665,8 +667,16 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, dai_link[i].codecs = dlcs; dai_props[i].num.codecs = dai_link[i].num_codecs = li->num[i].codecs; + dai_props[i].codec_dai = dais; dlcs += li->num[i].codecs; + dais += li->num[i].codecs; + +if (!li->num[i].cpus) { +/* DPCM Be's Codec */ + dai_props[i].codec_conf = cconf; + cconf += li->num[i].codecs; + } }else {/* DPCM Fe's Codec = dummy */ dai_props[i].codecs =
sound/soc/generic/simple-card.c +5 -19
@@ -146,8 +146,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->dynamic =1 ; dai_link->dpcm_merged_format =1 ; - dai = - dai_props->cpu_dai = &priv->dais[li->dais++]; + dai = dai_props->cpu_dai; ret =asoc_simple_parse_cpu (np, dai_link, &is_single_links);if (ret)
@@ -174,11 +173,8 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->no_pcm =1 ; dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup; - dai = - dai_props->codec_dai = &priv->dais[li->dais++]; - - cconf = - dai_props->codec_conf = &priv->codec_conf[li->conf++]; + dai = dai_props->codec_dai; + cconf = dai_props->codec_conf; ret =asoc_simple_parse_codec (np, dai_link);if (ret <0 )
@@ -234,8 +230,8 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv,struct device *dev =simple_priv_to_dev (priv);struct snd_soc_dai_link *dai_link =simple_priv_to_link (priv, li->link);struct simple_dai_props *dai_props =simple_priv_to_props (priv, li->link); -struct asoc_simple_dai *cpu_dai; -struct asoc_simple_dai *codec_dai; +struct asoc_simple_dai *cpu_dai = dai_props->cpu_dai; +struct asoc_simple_dai *codec_dai = dai_props->codec_dai;struct device_node *top = dev->of_node;struct device_node *cpu =NULL ;struct device_node *node =NULL ;
@@ -257,11 +253,6 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv,snprintf (prop,sizeof (prop),"%splat" , prefix); plat =of_get_child_by_name (node, prop); - cpu_dai = - dai_props->cpu_dai = &priv->dais[li->dais++]; - codec_dai = - dai_props->codec_dai = &priv->dais[li->dais++]; - ret =asoc_simple_parse_daifmt (dev, node, codec, prefix, &dai_link->dai_fmt);if (ret <0 )
@@ -670,8 +661,6 @@ static int asoc_simple_probe(struct platform_device *pdev)struct snd_soc_dai_link *dai_link = priv->dai_link;struct simple_dai_props *dai_props = priv->dai_props; -int dai_idx =0 ; - cinfo = dev->platform_data;if (!cinfo) {dev_err (dev,"no info for asoc-simple-card\n" );
@@ -687,9 +676,6 @@ static int asoc_simple_probe(struct platform_device *pdev)return -EINVAL ; } - dai_props->cpu_dai = &priv->dais[dai_idx++]; - dai_props->codec_dai = &priv->dais[dai_idx++]; - cpus = dai_link->cpus; cpus->dai_name = cinfo->cpu_dai.name;
Signature · 1 line
2.25.1
Mark Brown
maintainerRe: [PATCH 03/14] ASoC: simple-card-utils: setup dai_props cpu_dai/codec_dai at initial timing
Quoted 5 lines · Kuninori Morimoto
From: Kuninori Morimoto <[email protected]>
We couldn't setup
dai_propscpu_dai/codec_dai at the initial timing, because "counting DAIs loop" and "detecting DAIs loop" were different. But we can do it now, because these are using same loops.
This doesn't reply against current code, please check and resend:
Applying: ASoC: simple-card-utils: setup dai_props cpu_dai/codec_dai at initial timing Using index info to reconstruct a base tree...
M sound/soc/generic/audio-graph-card.c
M sound/soc/generic/simple-card.c
Falling back to patching base and 3-way merge...
Auto-merging sound/soc/generic/simple-card.c
Auto-merging sound/soc/generic/audio-graph-card.c
CONFLICT (content): Merge conflict in sound/soc/generic/audio-graph-card.c
error: Failed to merge in the changes.
Patch failed at 0003 ASoC: simple-card-utils: setup dai_props cpu_dai/codec_dai at initial timing
Kuninori Morimoto
maintainerPATCH 4/14 ASoC: simple-card-utils: remove li->dais/li->conf
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
li->dais is same as number of CPU + Codec, li->conf is same as number of Codec when dummy-Codec.
li->dais/li->conf are no longer needed.
This patch removes these.
--- include/sound/simple_card_utils.h | 2 -- sound/soc/generic/audio-graph-card.c | 10 +--------- sound/soc/generic/simple-card-utils.c | 14 ++++++++++---- sound/soc/generic/simple-card.c | 11 +---------- 4 files changed, 12 insertions(+), 25 deletions(-)
include/sound/simple_card_utils.h +0 -2
@@ -75,9 +75,7 @@ struct asoc_simple_priv {#define simple_priv_to_link (priv, i) (simple_priv_to_card(priv)->dai_link + (i))struct link_info { -int dais;/* number of dai */ int link;/* number of link */ -int conf;/* number of codec_conf */ int cpu;/* turn for CPU / Codec */ struct prop_nums num[SNDRV_MINOR_DEVICES ]; };
sound/soc/generic/audio-graph-card.c +1 -9
@@ -552,7 +552,7 @@ int audio_graph_parse_of(struct asoc_simple_priv *priv, struct device *dev)memset (&li,0 ,sizeof (li));graph_get_dais_count (priv, &li); -if (!li.link || !li.dais) +if (!li.link)return -EINVAL ; ret =asoc_simple_init_priv (priv, &li);
@@ -622,7 +622,6 @@ static int graph_count_noml(struct asoc_simple_priv *priv, li->num[li->link].platforms =1 ; li->link +=1 ;/* 1xCPU-Codec */ - li->dais +=2 ;/* 1xCPU + 1xCodec */ dev_dbg (dev,"Count As Normal\n" );
@@ -646,13 +645,10 @@ static int graph_count_dpcm(struct asoc_simple_priv *priv, li->num[li->link].platforms =1 ; li->link++;/* 1xCPU-dummy */ - li->dais++;/* 1xCPU */ }else { li->num[li->link].codecs =1 ; li->link++;/* 1xdummy-Codec */ - li->conf++;/* 1xdummy-Codec */ - li->dais++;/* 1xCodec */ }dev_dbg (dev,"Count As DPCM\n" );
@@ -663,8 +659,6 @@ static int graph_count_dpcm(struct asoc_simple_priv *priv,static void graph_get_dais_count (struct asoc_simple_priv *priv,struct link_info *li) { -struct device *dev =simple_priv_to_dev (priv); -/* * link_num : number of links. * CPU-Codec / CPU-dummy / dummy-Codec
@@ -714,8 +708,6 @@ static void graph_get_dais_count(struct asoc_simple_priv *priv,graph_for_each_link (priv, li, graph_count_noml, graph_count_dpcm); -dev_dbg (dev,"link %d, dais %d, ccnf %d\n" , - li->link, li->dais, li->conf); }int audio_graph_card_probe (struct snd_soc_card *card)
sound/soc/generic/simple-card-utils.c +10 -4
@@ -597,7 +597,7 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,struct asoc_simple_dai *dais;struct snd_soc_dai_link_component *dlcs;struct snd_soc_codec_conf *cconf =NULL ; -int i, dai_num =0 , dlc_num =0 ; +int i, dai_num =0 , dlc_num =0 , cnf_num =0 ; dai_props =devm_kcalloc (dev, li->link,sizeof (*dai_props),GFP_KERNEL ); dai_link =devm_kcalloc (dev, li->link,sizeof (*dai_link),GFP_KERNEL );
@@ -613,6 +613,9 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, dai_num += cc; dlc_num += cc + li->num[i].platforms; + +if (!li->num[i].cpus) + cnf_num += li->num[i].codecs; } dais =devm_kcalloc (dev, dai_num,sizeof (*dais),GFP_KERNEL );
@@ -620,12 +623,15 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,if (!dais || !dlcs)return -ENOMEM ; -if (li->conf) { - cconf =devm_kcalloc (dev, li->conf,sizeof (*cconf),GFP_KERNEL ); +if (cnf_num) { + cconf =devm_kcalloc (dev, cnf_num,sizeof (*cconf),GFP_KERNEL );if (!cconf)return -ENOMEM ; } +dev_dbg (dev,"link %d, dais %d, ccnf %d\n" , + li->link, dai_num, cnf_num); +/* dummy CPU/Codec */ priv->dummy.of_node =NULL ; priv->dummy.dai_name ="snd-soc-dummy-dai" ;
@@ -640,7 +646,7 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, card->dai_link = priv->dai_link; card->num_links = li->link; card->codec_conf = cconf; - card->num_configs = li->conf; + card->num_configs = cnf_num;for (i =0 ; i < li->link; i++) {if (li->num[i].cpus) {
sound/soc/generic/simple-card.c +1 -10
@@ -495,7 +495,6 @@ static int simple_count_noml(struct asoc_simple_priv *priv, li->num[li->link].platforms =1 ; li->link +=1 ; - li->dais +=2 ;return 0 ; }
@@ -517,13 +516,10 @@ static int simple_count_dpcm(struct asoc_simple_priv *priv, li->num[li->link].platforms =1 ; li->link++;/* CPU-dummy */ - li->dais++; }else { li->num[li->link].codecs =1 ; li->link++;/* dummy-Codec */ - li->dais++; - li->conf++; }return 0 ;
@@ -587,17 +583,12 @@ static void simple_get_dais_count(struct asoc_simple_priv *priv, li->num[0 ].platforms =1 ; li->link =1 ; - li->dais =2 ; - li->conf =0 ;return ; }simple_for_each_link (priv, li, simple_count_noml, simple_count_dpcm); - -dev_dbg (dev,"link %d, dais %d, ccnf %d\n" , - li->link, li->dais, li->conf); }static int simple_soc_probe (struct snd_soc_card *card)
@@ -637,7 +628,7 @@ static int asoc_simple_probe(struct platform_device *pdev)memset (&li,0 ,sizeof (li));simple_get_dais_count (priv, &li); -if (!li.link || !li.dais) +if (!li.link)return -EINVAL ; ret =asoc_simple_init_priv (priv, &li);
Signature · 1 line
2.25.1
Kuninori Morimoto
maintainerPATCH 5/14 ASoC: simple-card-utils: use for_each_prop_xxx()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
ASoC is now supporting multi DAI, but, current simple-card / audio-graph are assuming fixed single DAI.
This patch uses for_each_prop_xxx() to support multi DAI.
--- include/sound/simple_card_utils.h | 43 ++++++++- sound/soc/generic/simple-card-utils.c | 126 +++++++++++++++----------- 2 files changed, 113 insertions(+), 56 deletions(-)
include/sound/simple_card_utils.h +38 -5
@@ -74,6 +74,34 @@ struct asoc_simple_priv {#define simple_priv_to_dev (priv) (simple_priv_to_card(priv)->dev)#define simple_priv_to_link (priv, i) (simple_priv_to_card(priv)->dai_link + (i)) +#define for_each_prop_dlc_cpus (props, i, cpu) \ + for ((i) = 0; \ + ((i) < (props)->num.cpus) && ((cpu) = &(props)->cpus[i]); \ + (i)++) +#define for_each_prop_dlc_codecs (props, i, codec) \ + for ((i) = 0; \ + ((i) < (props)->num.codecs) && ((codec) = &(props)->codecs[i]); \ + (i)++) +#define for_each_prop_dlc_platforms (props, i, platform) \ + for ((i) = 0; \ + ((i) < (props)->num.platforms) && ((platform) = &(props)->platforms[i]); \ + (i)++) +#define for_each_prop_codec_conf (props, i, conf) \ + for ((i) = 0; \ + ((i) < (props)->num.codecs) && \ + (props)->codec_conf && \ + ((conf) = &(props)->codec_conf[i]); \ + (i)++) + +#define for_each_prop_dai_cpu (props, i, cpu) \ + for ((i) = 0; \ + ((i) < (props)->num.cpus) && ((cpu) = &(props)->cpu_dai[i]); \ + (i)++) +#define for_each_prop_dai_codec (props, i, codec) \ + for ((i) = 0; \ + ((i) < (props)->num.codecs) && ((codec) = &(props)->codec_dai[i]); \ + (i)++) +struct link_info {int link;/* number of link */ int cpu;/* turn for CPU / Codec */
@@ -192,11 +220,16 @@ static inline void asoc_simple_debug_info(struct asoc_simple_priv *priv)for (i =0 ; i < card->num_links; i++) {struct simple_dai_props *props =simple_priv_to_props (priv, i);struct snd_soc_dai_link *link =simple_priv_to_link (priv, i); +struct asoc_simple_dai *dai; +struct snd_soc_codec_conf *cnf; +int j;dev_dbg (dev,"DAI%d\n" , i); -asoc_simple_debug_dai (priv,"cpu" , props->cpu_dai); -asoc_simple_debug_dai (priv,"codec" , props->codec_dai); +for_each_prop_dai_cpu (props, j, dai) +asoc_simple_debug_dai (priv,"cpu" , dai); +for_each_prop_dai_codec (props, j, dai) +asoc_simple_debug_dai (priv,"codec" , dai);if (link->name)dev_dbg (dev,"dai name = %s\n" , link->name);
@@ -209,9 +242,9 @@ static inline void asoc_simple_debug_info(struct asoc_simple_priv *priv)if (props->adata.convert_channels)dev_dbg (dev,"convert_channels = %d\n" , props->adata.convert_channels); -if (props->codec_conf && props->codec_conf->name_prefix) -dev_dbg (dev,"name prefix = %s\n" , - props->codec_conf->name_prefix); +for_each_prop_codec_conf (props, j, cnf) +if (cnf->name_prefix) +dev_dbg (dev,"name prefix = %s\n" , cnf->name_prefix);if (props->mclk_fs)dev_dbg (dev,"mclk-fs = %d\n" , props->mclk_fs);
sound/soc/generic/simple-card-utils.c +75 -51
170 lines not on this page · raw message
Signature · 1 line
2.25.1
Kuninori Morimoto
maintainerPATCH 6/14 ASoC: simple-card-utils: remove asoc_simple_parse_xxx()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
ASoC is now supporting multi DAI, but, current simple-card / audio-graph are assuming fixed single DAI.
Now, asoc_simple_parse_xxx() macro is assuming single DAI. To support multi-CPU/Codec, this patch unpack asoc_simple_parse_xxx() macro, and uses "&dai_link->cpus[i]" instead of "dai_link->cpus".
--- include/sound/simple_card_utils.h | 11 ----------- sound/soc/generic/audio-graph-card.c | 16 ++++++++-------- sound/soc/generic/simple-card.c | 18 +++++++++--------- 3 files changed, 17 insertions(+), 28 deletions(-)
include/sound/simple_card_utils.h +0 -11
@@ -120,10 +120,6 @@ int asoc_simple_set_dailink_name(struct device *dev,int asoc_simple_parse_card_name (struct snd_soc_card *card,char *prefix); -#define asoc_simple_parse_clk_cpu (dev, node, dai_link, simple_dai) \ - asoc_simple_parse_clk(dev, node, simple_dai, dai_link->cpus) -#define asoc_simple_parse_clk_codec (dev, node, dai_link, simple_dai) \ - asoc_simple_parse_clk(dev, node, simple_dai, dai_link->codecs) int asoc_simple_parse_clk(struct device *dev, struct device_node *node, struct asoc_simple_dai *simple_dai,
@@ -136,13 +132,6 @@ int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd);int asoc_simple_be_hw_params_fixup (struct snd_soc_pcm_runtime *rtd,struct snd_pcm_hw_params *params); -#define asoc_simple_parse_cpu (node, dai_link, is_single_link) \ - asoc_simple_parse_dai(node, dai_link->cpus, is_single_link) -#define asoc_simple_parse_codec (node, dai_link) \ - asoc_simple_parse_dai(node, dai_link->codecs, NULL) -#define asoc_simple_parse_platform (node, dai_link) \ - asoc_simple_parse_dai(node, dai_link->platforms, NULL) -#define asoc_simple_parse_tdm (np, dai) \ snd_soc_of_parse_tdm_slot(np, &(dai)->tx_slot_mask, \ &(dai)->rx_slot_mask, \
sound/soc/generic/audio-graph-card.c +8 -8
@@ -247,11 +247,11 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai = dai_props->cpu_dai; - ret =asoc_simple_parse_cpu (ep, dai_link, &is_single_links); + ret =asoc_simple_parse_dai (ep, dai_link->cpus, &is_single_links);if (ret) goto out_put_node; - ret =asoc_simple_parse_clk_cpu (dev, ep, dai_link, dai); + ret =asoc_simple_parse_clk (dev, ep, dai, dai_link->cpus);if (ret <0 ) goto out_put_node;
@@ -290,11 +290,11 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai = dai_props->codec_dai; cconf = dai_props->codec_conf; - ret =asoc_simple_parse_codec (ep, dai_link); + ret =asoc_simple_parse_dai (ep, dai_link->codecs,NULL );if (ret <0 ) goto out_put_node; - ret =asoc_simple_parse_clk_codec (dev, ep, dai_link, dai); + ret =asoc_simple_parse_clk (dev, ep, dai, dai_link->codecs);if (ret <0 ) goto out_put_node;
@@ -371,11 +371,11 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv,if (ret <0 )return ret; - ret =asoc_simple_parse_cpu (cpu_ep, dai_link, &single_cpu); + ret =asoc_simple_parse_dai (cpu_ep, dai_link->cpus, &single_cpu);if (ret <0 )return ret; - ret =asoc_simple_parse_codec (codec_ep, dai_link); + ret =asoc_simple_parse_dai (codec_ep, dai_link->codecs,NULL );if (ret <0 )return ret;
@@ -387,11 +387,11 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv,if (ret <0 )return ret; - ret =asoc_simple_parse_clk_cpu (dev, cpu_ep, dai_link, cpu_dai); + ret =asoc_simple_parse_clk (dev, cpu_ep, cpu_dai, dai_link->cpus);if (ret <0 )return ret; - ret =asoc_simple_parse_clk_codec (dev, codec_ep, dai_link, codec_dai); + ret =asoc_simple_parse_clk (dev, codec_ep, codec_dai, dai_link->codecs);if (ret <0 )return ret;
sound/soc/generic/simple-card.c +9 -9
@@ -148,11 +148,11 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai = dai_props->cpu_dai; - ret =asoc_simple_parse_cpu (np, dai_link, &is_single_links); + ret =asoc_simple_parse_dai (np, dai_link->cpus, &is_single_links);if (ret) goto out_put_node; - ret =asoc_simple_parse_clk_cpu (dev, np, dai_link, dai); + ret =asoc_simple_parse_clk (dev, np, dai, dai_link->cpus);if (ret <0 ) goto out_put_node;
@@ -176,11 +176,11 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai = dai_props->codec_dai; cconf = dai_props->codec_conf; - ret =asoc_simple_parse_codec (np, dai_link); + ret =asoc_simple_parse_dai (np, dai_link->codecs,NULL );if (ret <0 ) goto out_put_node; - ret =asoc_simple_parse_clk_codec (dev, np, dai_link, dai); + ret =asoc_simple_parse_clk (dev, np, dai, dai_link->codecs);if (ret <0 ) goto out_put_node;
@@ -260,15 +260,15 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv,simple_parse_mclk_fs (top, cpu, codec, dai_props, prefix); - ret =asoc_simple_parse_cpu (cpu, dai_link, &single_cpu); + ret =asoc_simple_parse_dai (cpu, dai_link->cpus, &single_cpu);if (ret <0 ) goto dai_link_of_err; - ret =asoc_simple_parse_codec (codec, dai_link); + ret =asoc_simple_parse_dai (codec, dai_link->codecs,NULL );if (ret <0 ) goto dai_link_of_err; - ret =asoc_simple_parse_platform (plat, dai_link); + ret =asoc_simple_parse_dai (plat, dai_link->platforms,NULL );if (ret <0 ) goto dai_link_of_err;
@@ -280,11 +280,11 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv,if (ret <0 ) goto dai_link_of_err; - ret =asoc_simple_parse_clk_cpu (dev, cpu, dai_link, cpu_dai); + ret =asoc_simple_parse_clk (dev, cpu, cpu_dai, dai_link->cpus);if (ret <0 ) goto dai_link_of_err; - ret =asoc_simple_parse_clk_codec (dev, codec, dai_link, codec_dai); + ret =asoc_simple_parse_clk (dev, codec, codec_dai, dai_link->codecs);if (ret <0 ) goto dai_link_of_err;
Signature · 1 line
2.25.1
Kuninori Morimoto
maintainerPATCH 7/14 ASoC: simple-card-utils: care multi DAI at asoc_simple_clean_reference()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
ASoC is now supporting multi DAI, but, current simple-card / audio-graph are assuming fixed single DAI.
This patch cares multi DAI at asoc_simple_clean_reference() for of_node_put().
--- sound/soc/generic/simple-card-utils.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
sound/soc/generic/simple-card-utils.c +7 -3
@@ -451,11 +451,15 @@ EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_cpu);int asoc_simple_clean_reference (struct snd_soc_card *card) {struct snd_soc_dai_link *dai_link; -int i; +struct snd_soc_dai_link_component *cpu; +struct snd_soc_dai_link_component *codec; +int i, j;for_each_card_prelinks (card, i, dai_link) { -of_node_put (dai_link->cpus->of_node); -of_node_put (dai_link->codecs->of_node); +for_each_link_cpus (dai_link, j, cpu) +of_node_put (cpu->of_node); +for_each_link_codecs (dai_link, j, codec) +of_node_put (codec->of_node); }return 0 ; }
Signature · 1 line
2.25.1
Kuninori Morimoto
maintainerPATCH 8/14 ASoC: simple-card-utils: indicate dai_fmt if exist
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
link->dai_fmt might be 0.
Don't indicate it in such case when debugging.
--- include/sound/simple_card_utils.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
include/sound/simple_card_utils.h +2 -3
@@ -222,9 +222,8 @@ static inline void asoc_simple_debug_info(struct asoc_simple_priv *priv)if (link->name)dev_dbg (dev,"dai name = %s\n" , link->name); - -dev_dbg (dev,"dai format = %04x\n" , link->dai_fmt); - +if (link->dai_fmt) +dev_dbg (dev,"dai format = %04x\n" , link->dai_fmt);if (props->adata.convert_rate)dev_dbg (dev,"convert_rate = %d\n" , props->adata.convert_rate);
Signature · 1 line
2.25.1
Kuninori Morimoto
maintainerPATCH 9/14 ASoC: simple-card-utils: indicate missing CPU/Codec numbers for debug
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Now ALSA is supporting multi-CPU/Codec,
thus, we want to know number of CPU/Codec when debugging. This patch indicates it.
--- include/sound/simple_card_utils.h | 2 ++ 1 file changed, 2 insertions(+)
include/sound/simple_card_utils.h +2 -0
@@ -215,8 +215,10 @@ static inline void asoc_simple_debug_info(struct asoc_simple_priv *priv)dev_dbg (dev,"DAI%d\n" , i); +dev_dbg (dev,"cpu num = %d\n" , link->num_cpus);for_each_prop_dai_cpu (props, j, dai)asoc_simple_debug_dai (priv,"cpu" , dai); +dev_dbg (dev,"codec num = %d\n" , link->num_codecs);for_each_prop_dai_codec (props, j, dai)asoc_simple_debug_dai (priv,"codec" , dai);
Signature · 1 line
2.25.1
Kuninori Morimoto
maintainerPATCH 10/14 ASoC: simple-card-utils: add simple_props_to_xxx() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
We shouldn't use dai_props->cpus/codecs/cpu_dai/codec_dai/codec_conf directly, because these are array to supporting multi CPU/Codec/Platform. This patch adds asoc_link_to_xxx() macro for it.
--- include/sound/simple_card_utils.h | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
include/sound/simple_card_utils.h +20 -7
@@ -74,32 +74,45 @@ struct asoc_simple_priv {#define simple_priv_to_dev (priv) (simple_priv_to_card(priv)->dev)#define simple_priv_to_link (priv, i) (simple_priv_to_card(priv)->dai_link + (i)) +#define simple_props_to_dlc_cpu (props, i) ((props)->cpus + i) +#define simple_props_to_dlc_codec (props, i) ((props)->codecs + i) +#define simple_props_to_dlc_platform (props, i) ((props)->platforms + i) + +#define simple_props_to_dai_cpu (props, i) ((props)->cpu_dai + i) +#define simple_props_to_dai_codec (props, i) ((props)->codec_dai + i) +#define simple_props_to_codec_conf (props, i) ((props)->codec_conf + i) +#define for_each_prop_dlc_cpus (props, i, cpu) \ for ((i) = 0; \ - ((i) < (props)->num.cpus) && ((cpu) = &(props)->cpus[i]); \ + ((i) < (props)->num.cpus) && \ + ((cpu) = simple_props_to_dlc_cpu(props, i)); \ (i)++) -#define for_each_prop_dlc_codecs (props, i, codec) \ +#define for_each_prop_dlc_codecs (props, i, codec) \ for ((i) = 0; \ - ((i) < (props)->num.codecs) && ((codec) = &(props)->codecs[i]); \ + ((i) < (props)->num.codecs) && \ + ((codec) = simple_props_to_dlc_codec(props, i)); \ (i)++)#define for_each_prop_dlc_platforms (props, i, platform) \ for ((i) = 0; \ - ((i) < (props)->num.platforms) && ((platform) = &(props)->platforms[i]); \ + ((i) < (props)->num.platforms) && \ + ((platform) = simple_props_to_dlc_platform(props, i)); \ (i)++)#define for_each_prop_codec_conf (props, i, conf) \ for ((i) = 0; \ ((i) < (props)->num.codecs) && \ (props)->codec_conf && \ - ((conf) = &(props)->codec_conf[i]); \ + ((conf) = simple_props_to_codec_conf(props, i)); \ (i)++)#define for_each_prop_dai_cpu (props, i, cpu) \ for ((i) = 0; \ - ((i) < (props)->num.cpus) && ((cpu) = &(props)->cpu_dai[i]); \ + ((i) < (props)->num.cpus) && \ + ((cpu) = simple_props_to_dai_cpu(props, i)); \ (i)++)#define for_each_prop_dai_codec (props, i, codec) \ for ((i) = 0; \ - ((i) < (props)->num.codecs) && ((codec) = &(props)->codec_dai[i]); \ + ((i) < (props)->num.codecs) && \ + ((codec) = simple_props_to_dai_codec(props, i)); \ (i)++)struct link_info {
Signature · 1 line
2.25.1
Kuninori Morimoto
maintainerPATCH 11/14 ASoC: simple-card-utils: multi support at asoc_simple_canonicalize_cpu/platform()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current asoc_simple_canonicalize_cpu/platform() is assuming single CPU, single Platform, but we want to support Multi support.
This patch is prepare for it.
--- include/sound/simple_card_utils.h | 7 ++++--- sound/soc/generic/audio-graph-card.c | 9 +++++---- sound/soc/generic/simple-card-utils.c | 11 ++++++----- sound/soc/generic/simple-card.c | 9 +++++---- 4 files changed, 20 insertions(+), 16 deletions(-)
include/sound/simple_card_utils.h +4 -3
@@ -151,9 +151,10 @@ int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, &(dai)->slots, \ &(dai)->slot_width); -void asoc_simple_canonicalize_platform (struct snd_soc_dai_link *dai_link); -void asoc_simple_canonicalize_cpu (struct snd_soc_dai_link *dai_link, -int is_single_links); +void asoc_simple_canonicalize_platform (struct snd_soc_dai_link_component *platforms, +struct snd_soc_dai_link_component *cpus); +void asoc_simple_canonicalize_cpu (struct snd_soc_dai_link_component *cpus, +int is_single_links);int asoc_simple_clean_reference (struct snd_soc_card *card);
sound/soc/generic/audio-graph-card.c +5 -4
@@ -226,6 +226,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,struct asoc_simple_dai *dai;struct snd_soc_dai_link_component *cpus = dai_link->cpus;struct snd_soc_dai_link_component *codecs = dai_link->codecs; +struct snd_soc_dai_link_component *platforms = dai_link->platforms;int ret; port =of_get_parent (ep);
@@ -276,8 +277,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->no_pcm =1 ;/* card->num_links includes Codec */ -asoc_simple_canonicalize_cpu (dai_link, is_single_links); -asoc_simple_canonicalize_platform (dai_link); +asoc_simple_canonicalize_cpu (cpus, is_single_links); +asoc_simple_canonicalize_platform (platforms, cpus); }else {struct snd_soc_codec_conf *cconf;
@@ -405,8 +406,8 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, dai_link->ops = &graph_ops; dai_link->init = asoc_simple_dai_init; -asoc_simple_canonicalize_cpu (dai_link, single_cpu); -asoc_simple_canonicalize_platform (dai_link); +asoc_simple_canonicalize_cpu (dai_link->cpus, single_cpu); +asoc_simple_canonicalize_platform (dai_link->platforms, dai_link->cpus);return 0 ; }
sound/soc/generic/simple-card-utils.c +6 -5
@@ -423,15 +423,16 @@ int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd) }EXPORT_SYMBOL_GPL (asoc_simple_dai_init); -void asoc_simple_canonicalize_platform (struct snd_soc_dai_link *dai_link) +void asoc_simple_canonicalize_platform (struct snd_soc_dai_link_component *platforms, +struct snd_soc_dai_link_component *cpus) {/* Assumes platform == cpu */ -if (!dai_link->platforms->of_node) - dai_link->platforms->of_node = dai_link->cpus->of_node; +if (!platforms->of_node) + platforms->of_node = cpus->of_node; }EXPORT_SYMBOL_GPL (asoc_simple_canonicalize_platform); -void asoc_simple_canonicalize_cpu (struct snd_soc_dai_link *dai_link, +void asoc_simple_canonicalize_cpu (struct snd_soc_dai_link_component *cpus,int is_single_links) {/*
@@ -444,7 +445,7 @@ void asoc_simple_canonicalize_cpu(struct snd_soc_dai_link *dai_link,* fmt_multiple_name() */ if (is_single_links) - dai_link->cpus->dai_name =NULL ; + cpus->dai_name =NULL ; }EXPORT_SYMBOL_GPL (asoc_simple_canonicalize_cpu);
sound/soc/generic/simple-card.c +5 -4
@@ -124,6 +124,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,struct asoc_simple_dai *dai;struct snd_soc_dai_link_component *cpus = dai_link->cpus;struct snd_soc_dai_link_component *codecs = dai_link->codecs; +struct snd_soc_dai_link_component *platforms = dai_link->platforms;struct device_node *top = dev->of_node;struct device_node *node =of_get_parent (np);char *prefix ="" ;
@@ -162,8 +163,8 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,if (ret <0 ) goto out_put_node; -asoc_simple_canonicalize_cpu (dai_link, is_single_links); -asoc_simple_canonicalize_platform (dai_link); +asoc_simple_canonicalize_cpu (cpus, is_single_links); +asoc_simple_canonicalize_platform (platforms, cpus); }else {struct snd_soc_codec_conf *cconf;
@@ -298,8 +299,8 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, dai_link->ops = &simple_ops; dai_link->init = asoc_simple_dai_init; -asoc_simple_canonicalize_cpu (dai_link, single_cpu); -asoc_simple_canonicalize_platform (dai_link); +asoc_simple_canonicalize_cpu (dai_link->cpus, single_cpu); +asoc_simple_canonicalize_platform (dai_link->platforms, dai_link->cpus); dai_link_of_err:of_node_put (plat);
Signature · 1 line
2.25.1
Kuninori Morimoto
maintainerPATCH 12/14 ASoC: simple-card-utils: tidyup debug info for clock
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
simple-card / audio-graph can use clock as dai->clk or dai->sysclk. These related information should be indicated at same position. This patch tidyup it.
--- include/sound/simple_card_utils.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
include/sound/simple_card_utils.h +6 -6
@@ -191,12 +191,6 @@ static inline void asoc_simple_debug_dai(struct asoc_simple_priv *priv,if (dai->name)dev_dbg (dev,"%s dai name = %s\n" , name, dai->name); -if (dai->sysclk) -dev_dbg (dev,"%s sysclk = %d\n" , - name, dai->sysclk); - -dev_dbg (dev,"%s direction = %s\n" , - name, dai->clk_direction ?"OUT" :"IN" );if (dai->slots)dev_dbg (dev,"%s slots = %d\n" , name, dai->slots);
@@ -208,6 +202,12 @@ static inline void asoc_simple_debug_dai(struct asoc_simple_priv *priv,dev_dbg (dev,"%s rx slot mask = %d\n" , name, dai->rx_slot_mask);if (dai->clk)dev_dbg (dev,"%s clk %luHz\n" , name,clk_get_rate (dai->clk)); +if (dai->sysclk) +dev_dbg (dev,"%s sysclk = %dHz\n" , + name, dai->sysclk); +if (dai->clk || dai->sysclk) +dev_dbg (dev,"%s direction = %s\n" , + name, dai->clk_direction ?"OUT" :"IN" ); }static inline void asoc_simple_debug_info (struct asoc_simple_priv *priv)
Signature · 1 line
2.25.1
Kuninori Morimoto
maintainerPATCH 13/14 ASoC: simple-card-utils: tidyup dev_dbg() to use 1 line
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
We can use 100 char now for 1 line.
This patch tidyup unreadable dev_dbg() message.
--- include/sound/simple_card_utils.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
include/sound/simple_card_utils.h +3 -6
@@ -241,17 +241,14 @@ static inline void asoc_simple_debug_info(struct asoc_simple_priv *priv)if (link->dai_fmt)dev_dbg (dev,"dai format = %04x\n" , link->dai_fmt);if (props->adata.convert_rate) -dev_dbg (dev,"convert_rate = %d\n" , - props->adata.convert_rate); +dev_dbg (dev,"convert_rate = %d\n" , props->adata.convert_rate);if (props->adata.convert_channels) -dev_dbg (dev,"convert_channels = %d\n" , - props->adata.convert_channels); +dev_dbg (dev,"convert_channels = %d\n" , props->adata.convert_channels);for_each_prop_codec_conf (props, j, cnf)if (cnf->name_prefix)dev_dbg (dev,"name prefix = %s\n" , cnf->name_prefix);if (props->mclk_fs) -dev_dbg (dev,"mclk-fs = %d\n" , - props->mclk_fs); + dev_dbg(dev, "mclk-fs = %d\n", props->mclk_fs); } }#else
Signature · 1 line
2.25.1
Kuninori Morimoto
maintainerPATCH 14/14 ASoC: simple-card-utils: tidyup asoc_simple_parse_convert()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
dev is not used. This patch removes it.
--- include/sound/simple_card_utils.h | 3 +-- sound/soc/generic/audio-graph-card.c | 10 +++++----- sound/soc/generic/simple-card-utils.c | 3 +-- sound/soc/generic/simple-card.c | 8 ++++---- 4 files changed, 11 insertions(+), 13 deletions(-)
include/sound/simple_card_utils.h +1 -2
@@ -160,8 +160,7 @@ int asoc_simple_clean_reference(struct snd_soc_card *card);void asoc_simple_convert_fixup (struct asoc_simple_data *data,struct snd_pcm_hw_params *params); -void asoc_simple_parse_convert (struct device *dev, -struct device_node *np,char *prefix, +void asoc_simple_parse_convert (struct device_node *np,char *prefix,struct asoc_simple_data *data); int asoc_simple_parse_routing(struct snd_soc_card *card,
sound/soc/generic/audio-graph-card.c +5 -5
@@ -180,11 +180,11 @@ static void graph_parse_convert(struct device *dev,struct device_node *ports =of_get_parent (port);struct device_node *node =of_graph_get_port_parent (ep); -asoc_simple_parse_convert (dev, top,NULL , adata); -asoc_simple_parse_convert (dev, node,PREFIX , adata); -asoc_simple_parse_convert (dev, ports,NULL , adata); -asoc_simple_parse_convert (dev, port,NULL , adata); -asoc_simple_parse_convert (dev, ep,NULL , adata); +asoc_simple_parse_convert (top,NULL , adata); +asoc_simple_parse_convert (node,PREFIX , adata); +asoc_simple_parse_convert (ports,NULL , adata); +asoc_simple_parse_convert (port,NULL , adata); +asoc_simple_parse_convert (ep,NULL , adata);of_node_put (port);of_node_put (ports);
sound/soc/generic/simple-card-utils.c +1 -2
@@ -32,8 +32,7 @@ void asoc_simple_convert_fixup(struct asoc_simple_data *data, }EXPORT_SYMBOL_GPL (asoc_simple_convert_fixup); -void asoc_simple_parse_convert (struct device *dev, -struct device_node *np, +void asoc_simple_parse_convert (struct device_node *np,char *prefix,struct asoc_simple_data *data) {
sound/soc/generic/simple-card.c +4 -4
@@ -84,10 +84,10 @@ static void simple_parse_convert(struct device *dev,struct device_node *top = dev->of_node;struct device_node *node =of_get_parent (np); -asoc_simple_parse_convert (dev, top,PREFIX , adata); -asoc_simple_parse_convert (dev, node,PREFIX , adata); -asoc_simple_parse_convert (dev, node,NULL , adata); -asoc_simple_parse_convert (dev, np,NULL , adata); +asoc_simple_parse_convert (top,PREFIX , adata); +asoc_simple_parse_convert (node,PREFIX , adata); +asoc_simple_parse_convert (node,NULL , adata); +asoc_simple_parse_convert (np,NULL , adata);of_node_put (node); }
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 9 lines · Kuninori Morimoto
I want to add new audio-graph-card2 driver which can support not only DPCM, but also Multi-CPU/Codec, and Codec2Codec. And it is also supporting audio-graph-card2 base custom driver.
But before supporting such driver, we need to cleanup existing simple-card / audio-graph, because these and new driver are sharing code.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/14] ASoC: simple-card-utils: enable flexible CPU/Codec/Platform
commit: f2138aed231c88d5c4fa8d06aa15ad19685087c2
[02/14] ASoC: simple-card-utils: share dummy DAI and reduce memory
commit: 205eb17eddb473c3159743c7d3aaf68db37b7231[03/14] ASoC: simple-card-utils: setup dai_props cpu_dai/codec_dai at initial timing
(no commit info)
[04/14] ASoC: simple-card-utils: remove li->dais/li->conf
(no commit info)
[05/14] ASoC: simple-card-utils: use for_each_prop_xxx()
(no commit info)
[06/14] ASoC: simple-card-utils: remove asoc_simple_parse_xxx()
(no commit info)
[07/14] ASoC: simple-card-utils: care multi DAI at asoc_simple_clean_reference()
(no commit info)
[08/14] ASoC: simple-card-utils: indicate dai_fmt if exist
(no commit info)
[09/14] ASoC: simple-card-utils: indicate missing CPU/Codec numbers for debug
(no commit info)
[10/14] ASoC: simple-card-utils: add simple_props_to_xxx() macro
(no commit info)
[11/14] ASoC: simple-card-utils: multi support at asoc_simple_canonicalize_cpu/platform()
(no commit info)
[12/14] ASoC: simple-card-utils: tidyup debug info for clock
(no commit info)
[13/14] ASoC: simple-card-utils: tidyup dev_dbg() to use 1 line
(no commit info)
[14/14] ASoC: simple-card-utils: tidyup asoc_simple_parse_convert()
(no commit info)
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark