All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] ASoC: Add soc_remove_dai_links
@ 2011-04-08  5:50 Kuninori Morimoto
  2011-04-08 17:35 ` Liam Girdwood
  0 siblings, 1 reply; 4+ messages in thread
From: Kuninori Morimoto @ 2011-04-08  5:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: yoshii, Linux-ALSA, Simon, Magnus, Liam Girdwood

card->num_rtd should be 0 after soc_romve_dai_link

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
To Mark, Liam

I'm not sure that this is correct patch for ASoC.
But without this patch, below command doesn't work

ex) FSI-AK4642 case

# cd /sys/bus/platform/drivers/fsi-ak4642-audio
# echo sh_fsi2_a_ak4643.0 > unbind
# echo sh_fsi2_a_ak4643.0 > bind    *1

*1
soc_new_pcm isn't called, and "aplay -l" doens't show fsi-ak4642.
snd_soc_instantiate_card return around /* bind comleted ? */

 sound/soc/soc-core.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 4dda589..9cd0770 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1451,6 +1451,16 @@ static void soc_remove_dai_link(struct snd_soc_card *card, int num)
 	}
 }
 
+static void soc_remove_dai_links(struct snd_soc_card *card)
+{
+	int i;
+
+	for (i = 0; i < card->num_rtd; i++)
+		soc_remove_dai_link(card, i);
+
+	card->num_rtd = 0;
+}
+
 static void soc_set_name_prefix(struct snd_soc_card *card,
 				struct snd_soc_codec *codec)
 {
@@ -1947,8 +1957,7 @@ probe_aux_dev_err:
 		soc_remove_aux_dev(card, i);
 
 probe_dai_err:
-	for (i = 0; i < card->num_links; i++)
-		soc_remove_dai_link(card, i);
+	soc_remove_dai_links(card);
 
 card_probe_error:
 	if (card->remove)
@@ -2010,8 +2019,7 @@ static int soc_cleanup_card_resources(struct snd_soc_card *card)
 		soc_remove_aux_dev(card, i);
 
 	/* remove and free each DAI */
-	for (i = 0; i < card->num_rtd; i++)
-		soc_remove_dai_link(card, i);
+	soc_remove_dai_links(card);
 
 	soc_cleanup_card_debugfs(card);
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC][PATCH] ASoC: Add soc_remove_dai_links
  2011-04-08  5:50 [RFC][PATCH] ASoC: Add soc_remove_dai_links Kuninori Morimoto
@ 2011-04-08 17:35 ` Liam Girdwood
  2011-04-11  1:11   ` Kuninori Morimoto
  0 siblings, 1 reply; 4+ messages in thread
From: Liam Girdwood @ 2011-04-08 17:35 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: yoshii, Linux-ALSA, Mark Brown, Magnus, Simon

On Fri, 2011-04-08 at 14:50 +0900, Kuninori Morimoto wrote:
> card->num_rtd should be 0 after soc_romve_dai_link
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> To Mark, Liam
> 
> I'm not sure that this is correct patch for ASoC.
> But without this patch, below command doesn't work
> 
> ex) FSI-AK4642 case
> 
> # cd /sys/bus/platform/drivers/fsi-ak4642-audio
> # echo sh_fsi2_a_ak4643.0 > unbind
> # echo sh_fsi2_a_ak4643.0 > bind    *1
> 
> *1
> soc_new_pcm isn't called, and "aplay -l" doens't show fsi-ak4642.
> snd_soc_instantiate_card return around /* bind comleted ? */
> 

Can you confirm are you unloading (all ?) then reloading the driver
modules in this test case ?


>  sound/soc/soc-core.c |   16 ++++++++++++----
>  1 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 4dda589..9cd0770 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -1451,6 +1451,16 @@ static void soc_remove_dai_link(struct snd_soc_card *card, int num)
>  	}
>  }
>  
> +static void soc_remove_dai_links(struct snd_soc_card *card)
> +{
> +	int i;
> +
> +	for (i = 0; i < card->num_rtd; i++)
> +		soc_remove_dai_link(card, i);
> +
> +	card->num_rtd = 0;
> +}
> +
>  static void soc_set_name_prefix(struct snd_soc_card *card,
>  				struct snd_soc_codec *codec)
>  {
> @@ -1947,8 +1957,7 @@ probe_aux_dev_err:
>  		soc_remove_aux_dev(card, i);
>  
>  probe_dai_err:
> -	for (i = 0; i < card->num_links; i++)
> -		soc_remove_dai_link(card, i);
> +	soc_remove_dai_links(card);
>  
>  card_probe_error:
>  	if (card->remove)
> @@ -2010,8 +2019,7 @@ static int soc_cleanup_card_resources(struct snd_soc_card *card)
>  		soc_remove_aux_dev(card, i);
>  
>  	/* remove and free each DAI */
> -	for (i = 0; i < card->num_rtd; i++)
> -		soc_remove_dai_link(card, i);
> +	soc_remove_dai_links(card);
>  
>  	soc_cleanup_card_debugfs(card);
>  

Thanks

Liam

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC][PATCH] ASoC: Add soc_remove_dai_links
  2011-04-08 17:35 ` Liam Girdwood
@ 2011-04-11  1:11   ` Kuninori Morimoto
  2011-04-11 19:57     ` Liam Girdwood
  0 siblings, 1 reply; 4+ messages in thread
From: Kuninori Morimoto @ 2011-04-11  1:11 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: yoshii, Linux-ALSA, Mark Brown, Magnus, Simon


Dear Liam

Thank you for your reply

> > # cd /sys/bus/platform/drivers/fsi-ak4642-audio
> > # echo sh_fsi2_a_ak4643.0 > unbind
> > # echo sh_fsi2_a_ak4643.0 > bind    *1
> >
> > *1
> > soc_new_pcm isn't called, and "aplay -l" doens't show fsi-ak4642.
> > snd_soc_instantiate_card return around /* bind comleted ? */
> >
>
> Can you confirm are you unloading (all ?) then reloading the driver
> modules in this test case ?

Thanks. I show my test in below.

But please check this patch carefully.
I'm not familiar with ASoC core, 
and don't want "confusion" or "new bug" for it.

This issue doesn't happen if I use "rmmod, insmod".
But it happen if I use "unbind" / "bind"
I show each case.
My board has 2 sound card (fsi-ak4642, fsi-hdmi).

=====================
rmmod, insmod case.
no patch, no issue.
=====================

check current status
------------------------
...
ALSA device list:
  No soundcards found.
...

# lsmod
#
------------------------

insmod 2 cards. "aplay -l" show it.
------------------------
# insmod /home/snd-soc-ak4642.ko
# insmod /home/snd-soc-fsi-ak4642.ko
ak4642-codec 0-0013: AK4642 Audio Codec 0.0.1
i2c-sh_mobile i2c-sh_mobile.0: clocks managed by runtime pm
asoc: ak4642-hifi <-> fsia-dai mapping ok
#
# insmod /home/snd-soc-fsi-hdmi.ko
sh-mobile-hdmi sh-mobile-hdmi: SH Mobile HDMI Audio Codec
asoc: sh_mobile_hdmi-hifi <-> fsib-dai mapping ok
# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: AK4643 [FSI2A (AK4643)], device 0: AK4643 ak4642-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: HDMI [FSI2B (SH MOBILE HDMI)], device 0: HDMI sh_mobile_hdmi-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
------------------------

rmmod 2 cards. "aplay -l" show it
------------------------
# lsmod
snd_soc_fsi_hdmi 1533 0 - Live 0xbf00c000
snd_soc_fsi_ak4642 2085 0 - Live 0xbf006000
snd_soc_ak4642 3228 1 - Live 0xbf000000
#
# rmmod snd_soc_fsi_ak4642
# rmmod snd_soc_ak4642
# lsmod
snd_soc_fsi_hdmi 1533 0 - Live 0xbf00c000
# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: HDMI [FSI2B (SH MOBILE HDMI)], device 0: HDMI sh_mobile_hdmi-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
#
# rmmod snd_soc_fsi_hdmi
# lsmod
# aplay -l
aplay: device_list:223: no soundcards found...
------------------------

re-insmod OK.
------------------------
# insmod /home/snd-soc-ak4642.ko                                                
# insmod /home/snd-soc-fsi-ak4642.ko                                            
ak4642-codec 0-0013: AK4642 Audio Codec 0.0.1                                   
asoc: ak4642-hifi <-> fsia-dai mapping ok                                       
# insmod /home/snd-soc-fsi-hdmi.ko                                              
sh-mobile-hdmi sh-mobile-hdmi: SH Mobile HDMI Audio Codec                       
asoc: sh_mobile_hdmi-hifi <-> fsib-dai mapping ok                               
# lsmod                                                                         
snd_soc_fsi_hdmi 1533 0 - Live 0xbf01e000                                       
snd_soc_fsi_ak4642 2085 0 - Live 0xbf018000                                     
snd_soc_ak4642 3228 1 - Live 0xbf012000                                         
# aplay -l                                                                
**** List of PLAYBACK Hardware Devices ****                                     
card 0: AK4643 [FSI2A (AK4643)], device 0: AK4643 ak4642-hifi-0 []              
  Subdevices: 1/1                                                               
  Subdevice #0: subdevice #0                                                    
card 1: HDMI [FSI2B (SH MOBILE HDMI)], device 0: HDMI sh_mobile_hdmi-hifi-0 []  
  Subdevices: 1/1                                                               
  Subdevice #0: subdevice #0                                                    
------------------------


=====================
unbind/bind case.
re-bind have issue without this patch.
=====================

check current status
------------------------
# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: AK4643 [FSI2A (AK4643)], device 0: AK4643 ak4642-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: HDMI [FSI2B (SH MOBILE HDMI)], device 0: HDMI sh_mobile_hdmi-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
------------------------


unbind modules (same behavior with/without patch)
each "aplay -l" show it
------------------------
# cd /sys/bus/platform/drivers/fsi-ak4642-audio/
# echo sh_fsi2_a_ak4643.0 > unbind
# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: HDMI [FSI2B (SH MOBILE HDMI)], device 0: HDMI sh_mobile_hdmi-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
#
#
# cd ../fsi-hdmi-audio/
# echo sh_fsi2_b_hdmi.0 > unbind
# aplay -l
aplay: device_list:223: no soundcards found...
------------------------

without this patch, "re-bind" doesn't work
------------------------
# cd /sys/bus/platform/drivers/fsi-hdmi-audio/
# echo sh_fsi2_b_hdmi.0 > bind
# aplay -l
aplay: device_list:223: no soundcards found...
#
#
# cd ../fsi-ak4642-audio/
# echo sh_fsi2_a_ak4643.0 > bind
# aplay -l
aplay: device_list:223: no soundcards found...
------------------------

with this patch, "re-bind" works
------------------------
# cd /sys/bus/platform/drivers/fsi-hdmi-audio/
# echo sh_fsi2_b_hdmi.0 > bind
sh-mobile-hdmi sh-mobile-hdmi: SH Mobile HDMI Audio Codec
asoc: sh_mobile_hdmi-hifi <-> fsib-dai mapping ok
# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [FSI2B (SH MOBILE HDMI)], device 0: HDMI sh_mobile_hdmi-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
#
#
# cd ../fsi-ak4642-audio/
# echo sh_fsi2_a_ak4643.0 > bind
ak4642-codec 0-0013: AK4642 Audio Codec 0.0.1
asoc: ak4642-hifi <-> fsia-dai mapping ok
# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [FSI2B (SH MOBILE HDMI)], device 0: HDMI sh_mobile_hdmi-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: AK4643 [FSI2A (AK4643)], device 0: AK4643 ak4642-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
------------------------

Best regards
--
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC][PATCH] ASoC: Add soc_remove_dai_links
  2011-04-11  1:11   ` Kuninori Morimoto
@ 2011-04-11 19:57     ` Liam Girdwood
  0 siblings, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2011-04-11 19:57 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, yoshii, Magnus, Simon, Mark Brown

On Mon, 2011-04-11 at 10:11 +0900, Kuninori Morimoto wrote:
> 
> Dear Liam
> 
> Thank you for your reply
> 
> > > # cd /sys/bus/platform/drivers/fsi-ak4642-audio
> > > # echo sh_fsi2_a_ak4643.0 > unbind
> > > # echo sh_fsi2_a_ak4643.0 > bind    *1
> > >
> > > *1
> > > soc_new_pcm isn't called, and "aplay -l" doens't show fsi-ak4642.
> > > snd_soc_instantiate_card return around /* bind comleted ? */
> > >
> >
> > Can you confirm are you unloading (all ?) then reloading the driver
> > modules in this test case ?
> 
> Thanks. I show my test in below.
> 
> But please check this patch carefully.
> I'm not familiar with ASoC core, 
> and don't want "confusion" or "new bug" for it. 

Looks correct.

Acked-by: Liam Girdwood <lrg@ti.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-11 19:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-08  5:50 [RFC][PATCH] ASoC: Add soc_remove_dai_links Kuninori Morimoto
2011-04-08 17:35 ` Liam Girdwood
2011-04-11  1:11   ` Kuninori Morimoto
2011-04-11 19:57     ` Liam Girdwood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.