alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: Fix prototype for snd_soc_dai_link.init() function pointer
@ 2007-06-01 22:44 Timur Tabi
  2007-06-04 10:31 ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Timur Tabi @ 2007-06-01 22:44 UTC (permalink / raw)
  To: lg, alsa-devel; +Cc: Timur Tabi

Change the snd_soc_dai_link.init() function to take a pointer to the
corresponding snd_soc_dai_link structure, instead of a pointer to a
snd_soc_codec structure.  This allows the initialization function to initialize
its own structure.

Signed-off-by: Timur Tabi <timur@freescale.com>
---

This is a fix for ALSA bug 3135
(https://bugtrack.alsa-project.org/alsa-bug/view.php?id=3135).  Since I
don't have an ARM cross-compiler, and currently all ASoC drivers are for ARM
platforms only, I'm not sure if this fix is correct.

 include/sound/soc.h            |    2 +-
 sound/soc/at91/eti_b1_wm8731.c |    3 ++-
 sound/soc/pxa/corgi.c          |    3 ++-
 sound/soc/pxa/poodle.c         |    3 ++-
 sound/soc/pxa/spitz.c          |    3 ++-
 sound/soc/pxa/tosa.c           |    3 ++-
 sound/soc/soc-core.c           |    2 +-
 7 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index db6edba..86e1b1d 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -410,7 +410,7 @@ struct snd_soc_dai_link  {
 	struct snd_soc_ops *ops;
 
 	/* codec/machine specific init - e.g. add machine controls */
-	int (*init)(struct snd_soc_codec *codec);
+	int (*init)(struct snd_soc_dai_link *codec);
 };
 
 /* SoC machine */
diff --git a/sound/soc/at91/eti_b1_wm8731.c b/sound/soc/at91/eti_b1_wm8731.c
index 820a676..a4f5a99 100644
--- a/sound/soc/at91/eti_b1_wm8731.c
+++ b/sound/soc/at91/eti_b1_wm8731.c
@@ -216,9 +216,10 @@ static const char *intercon[][3] = {
 /*
  * Logic for a wm8731 as connected on a Endrelia ETI-B1 board.
  */
-static int eti_b1_wm8731_init(struct snd_soc_codec *codec)
+static int eti_b1_wm8731_init(struct snd_soc_dai_link *dai)
 {
 	int i;
+	struct snd_soc_codec *codec = dai->codec_dai->codec;
 
 	DBG("eti_b1_wm8731_init() called\n");
 
diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c
index 5ee51a9..43237f9 100644
--- a/sound/soc/pxa/corgi.c
+++ b/sound/soc/pxa/corgi.c
@@ -286,9 +286,10 @@ static const struct snd_kcontrol_new wm8731_corgi_controls[] = {
 /*
  * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device
  */
-static int corgi_wm8731_init(struct snd_soc_codec *codec)
+static int corgi_wm8731_init(struct snd_soc_dai_link *dai)
 {
 	int i, err;
+	struct snd_soc_codec *codec = dai->codec_dai->codec;
 
 	snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0);
 	snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0);
diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c
index 0915cf7..5e8cb76 100644
--- a/sound/soc/pxa/poodle.c
+++ b/sound/soc/pxa/poodle.c
@@ -246,9 +246,10 @@ static const snd_kcontrol_new_t wm8731_poodle_controls[] = {
 /*
  * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device
  */
-static int poodle_wm8731_init(struct snd_soc_codec *codec)
+static int poodle_wm8731_init(struct snd_soc_dai_link *dai)
 {
 	int i, err;
+	struct snd_soc_codec *codec = dai->codec_dai->codec;
 
 	snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0);
 	snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0);
diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
index 80e8210..95dcaa4 100644
--- a/sound/soc/pxa/spitz.c
+++ b/sound/soc/pxa/spitz.c
@@ -292,9 +292,10 @@ static const struct snd_kcontrol_new wm8750_spitz_controls[] = {
 /*
  * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device
  */
-static int spitz_wm8750_init(struct snd_soc_codec *codec)
+static int spitz_wm8750_init(struct snd_soc_dai_link *dai)
 {
 	int i, err;
+	struct snd_soc_codec *codec = dai->codec_dai->codec;
 
 	/* NC codec pins */
 	snd_soc_dapm_set_endpoint(codec, "RINPUT1", 0);
diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c
index 5504e30..b438349 100644
--- a/sound/soc/pxa/tosa.c
+++ b/sound/soc/pxa/tosa.c
@@ -192,9 +192,10 @@ static const struct snd_kcontrol_new tosa_controls[] = {
 		tosa_set_spk),
 };
 
-static int tosa_ac97_init(struct snd_soc_codec *codec)
+static int tosa_ac97_init(struct snd_soc_dai_link *dai)
 {
 	int i, err;
+	struct snd_soc_codec *codec = dai->codec_dai->codec;
 
 	snd_soc_dapm_set_endpoint(codec, "OUT3", 0);
 	snd_soc_dapm_set_endpoint(codec, "MONOOUT", 0);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 92d5d91..654a517 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1093,7 +1093,7 @@ int snd_soc_register_card(struct snd_soc_device *socdev)
 	mutex_lock(&codec->mutex);
 	for(i = 0; i < machine->num_links; i++) {
 		if (socdev->machine->dai_link[i].init) {
-			err = socdev->machine->dai_link[i].init(codec);
+			err = socdev->machine->dai_link[i].init(&machine->dai_link[i]);
 			if (err < 0) {
 				printk(KERN_ERR "asoc: failed to init %s\n",
 					socdev->machine->dai_link[i].stream_name);
-- 
1.5.0.2.260.g2eb065

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

* Re: [PATCH] ALSA: Fix prototype for snd_soc_dai_link.init() function pointer
  2007-06-01 22:44 [PATCH] ALSA: Fix prototype for snd_soc_dai_link.init() function pointer Timur Tabi
@ 2007-06-04 10:31 ` Takashi Iwai
  2007-06-04 16:44   ` Timur Tabi
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2007-06-04 10:31 UTC (permalink / raw)
  To: lg; +Cc: alsa-devel, Timur Tabi

At Fri,  1 Jun 2007 17:44:57 -0500,
Timur Tabi wrote:
> 
> Change the snd_soc_dai_link.init() function to take a pointer to the
> corresponding snd_soc_dai_link structure, instead of a pointer to a
> snd_soc_codec structure.  This allows the initialization function to initialize
> its own structure.
> 
> Signed-off-by: Timur Tabi <timur@freescale.com>

Liam, is this change OK for you?
If yes, I'll add this to HG tree after 1.0.14 release.


thanks,

Takashi

> ---
> 
> This is a fix for ALSA bug 3135
> (https://bugtrack.alsa-project.org/alsa-bug/view.php?id=3135).  Since I
> don't have an ARM cross-compiler, and currently all ASoC drivers are for ARM
> platforms only, I'm not sure if this fix is correct.
> 
>  include/sound/soc.h            |    2 +-
>  sound/soc/at91/eti_b1_wm8731.c |    3 ++-
>  sound/soc/pxa/corgi.c          |    3 ++-
>  sound/soc/pxa/poodle.c         |    3 ++-
>  sound/soc/pxa/spitz.c          |    3 ++-
>  sound/soc/pxa/tosa.c           |    3 ++-
>  sound/soc/soc-core.c           |    2 +-
>  7 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index db6edba..86e1b1d 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -410,7 +410,7 @@ struct snd_soc_dai_link  {
>  	struct snd_soc_ops *ops;
>  
>  	/* codec/machine specific init - e.g. add machine controls */
> -	int (*init)(struct snd_soc_codec *codec);
> +	int (*init)(struct snd_soc_dai_link *codec);
>  };
>  
>  /* SoC machine */
> diff --git a/sound/soc/at91/eti_b1_wm8731.c b/sound/soc/at91/eti_b1_wm8731.c
> index 820a676..a4f5a99 100644
> --- a/sound/soc/at91/eti_b1_wm8731.c
> +++ b/sound/soc/at91/eti_b1_wm8731.c
> @@ -216,9 +216,10 @@ static const char *intercon[][3] = {
>  /*
>   * Logic for a wm8731 as connected on a Endrelia ETI-B1 board.
>   */
> -static int eti_b1_wm8731_init(struct snd_soc_codec *codec)
> +static int eti_b1_wm8731_init(struct snd_soc_dai_link *dai)
>  {
>  	int i;
> +	struct snd_soc_codec *codec = dai->codec_dai->codec;
>  
>  	DBG("eti_b1_wm8731_init() called\n");
>  
> diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c
> index 5ee51a9..43237f9 100644
> --- a/sound/soc/pxa/corgi.c
> +++ b/sound/soc/pxa/corgi.c
> @@ -286,9 +286,10 @@ static const struct snd_kcontrol_new wm8731_corgi_controls[] = {
>  /*
>   * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device
>   */
> -static int corgi_wm8731_init(struct snd_soc_codec *codec)
> +static int corgi_wm8731_init(struct snd_soc_dai_link *dai)
>  {
>  	int i, err;
> +	struct snd_soc_codec *codec = dai->codec_dai->codec;
>  
>  	snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0);
>  	snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0);
> diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c
> index 0915cf7..5e8cb76 100644
> --- a/sound/soc/pxa/poodle.c
> +++ b/sound/soc/pxa/poodle.c
> @@ -246,9 +246,10 @@ static const snd_kcontrol_new_t wm8731_poodle_controls[] = {
>  /*
>   * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device
>   */
> -static int poodle_wm8731_init(struct snd_soc_codec *codec)
> +static int poodle_wm8731_init(struct snd_soc_dai_link *dai)
>  {
>  	int i, err;
> +	struct snd_soc_codec *codec = dai->codec_dai->codec;
>  
>  	snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0);
>  	snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0);
> diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
> index 80e8210..95dcaa4 100644
> --- a/sound/soc/pxa/spitz.c
> +++ b/sound/soc/pxa/spitz.c
> @@ -292,9 +292,10 @@ static const struct snd_kcontrol_new wm8750_spitz_controls[] = {
>  /*
>   * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device
>   */
> -static int spitz_wm8750_init(struct snd_soc_codec *codec)
> +static int spitz_wm8750_init(struct snd_soc_dai_link *dai)
>  {
>  	int i, err;
> +	struct snd_soc_codec *codec = dai->codec_dai->codec;
>  
>  	/* NC codec pins */
>  	snd_soc_dapm_set_endpoint(codec, "RINPUT1", 0);
> diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c
> index 5504e30..b438349 100644
> --- a/sound/soc/pxa/tosa.c
> +++ b/sound/soc/pxa/tosa.c
> @@ -192,9 +192,10 @@ static const struct snd_kcontrol_new tosa_controls[] = {
>  		tosa_set_spk),
>  };
>  
> -static int tosa_ac97_init(struct snd_soc_codec *codec)
> +static int tosa_ac97_init(struct snd_soc_dai_link *dai)
>  {
>  	int i, err;
> +	struct snd_soc_codec *codec = dai->codec_dai->codec;
>  
>  	snd_soc_dapm_set_endpoint(codec, "OUT3", 0);
>  	snd_soc_dapm_set_endpoint(codec, "MONOOUT", 0);
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 92d5d91..654a517 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -1093,7 +1093,7 @@ int snd_soc_register_card(struct snd_soc_device *socdev)
>  	mutex_lock(&codec->mutex);
>  	for(i = 0; i < machine->num_links; i++) {
>  		if (socdev->machine->dai_link[i].init) {
> -			err = socdev->machine->dai_link[i].init(codec);
> +			err = socdev->machine->dai_link[i].init(&machine->dai_link[i]);
>  			if (err < 0) {
>  				printk(KERN_ERR "asoc: failed to init %s\n",
>  					socdev->machine->dai_link[i].stream_name);
> -- 
> 1.5.0.2.260.g2eb065
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

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

* Re: [PATCH] ALSA: Fix prototype for snd_soc_dai_link.init() function pointer
  2007-06-04 10:31 ` Takashi Iwai
@ 2007-06-04 16:44   ` Timur Tabi
  0 siblings, 0 replies; 3+ messages in thread
From: Timur Tabi @ 2007-06-04 16:44 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Takashi Iwai wrote:
> At Fri,  1 Jun 2007 17:44:57 -0500,
> Timur Tabi wrote:
>> Change the snd_soc_dai_link.init() function to take a pointer to the
>> corresponding snd_soc_dai_link structure, instead of a pointer to a
>> snd_soc_codec structure.  This allows the initialization function to initialize
>> its own structure.
>>
>> Signed-off-by: Timur Tabi <timur@freescale.com>
> 
> Liam, is this change OK for you?
> If yes, I'll add this to HG tree after 1.0.14 release.

Please note my comment in the patch.  I have not compiled all the code that I changed, so 
I don't know if this patch is good.  I would like someone to test this patch.

This patch is just a refactoring - no new features have been added, so after applying this 
patch, everything should still compile and run exactly the same.

The key code changes are:

	struct snd_soc_codec *codec = dai->codec_dai->codec;

I'm hoping that 'codec' contains the same value that it did before the patch, and

	err = socdev->machine->dai_link[i].init(&machine->dai_link[i]);

I hope this passes the correct snd_soc_dai_link pointer.


-- 
Timur Tabi
Linux Kernel Developer @ Freescale

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

end of thread, other threads:[~2007-06-04 16:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-01 22:44 [PATCH] ALSA: Fix prototype for snd_soc_dai_link.init() function pointer Timur Tabi
2007-06-04 10:31 ` Takashi Iwai
2007-06-04 16:44   ` Timur Tabi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).