Skip to contentSkip to conversation

ALSA: Fix prototype for snd_soc_dai_link.init() function pointer

PATCH In review Timur Tabi 2 participants 3 messages Jun 1, 2007 – Jun 4, 2007

Subsystems (4)
lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH 1/1 ALSA: Fix prototype for snd_soc_dai_link.init() function pointer

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.

---

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(-)
include/sound/soc.h +1 -1
index db6edba..86e1b1d 100644
@@ -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 */
sound/soc/at91/eti_b1_wm8731.c +2 -1
index 820a676..a4f5a99 100644
@@ -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");
 
sound/soc/pxa/corgi.c +2 -1
index 5ee51a9..43237f9 100644
@@ -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);
sound/soc/pxa/poodle.c +2 -1
index 0915cf7..5e8cb76 100644
@@ -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);
sound/soc/pxa/spitz.c +2 -1
index 80e8210..95dcaa4 100644
@@ -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);
sound/soc/pxa/tosa.c +2 -1
index 5504e30..b438349 100644
@@ -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);
sound/soc/soc-core.c +1 -1
index 92d5d91..654a517 100644
@@ -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);
Signature · 1 line
1.5.0.2.260.g2eb065
#1 lore raw

At Fri, 1 Jun 2007 17:44:57 -0500,

Quoted 7 lines · 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.

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

thanks,

Takashi

Quoted 130 lines

---

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(-)
include/sound/soc.h +1 -1
index db6edba..86e1b1d 100644
@@ -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 */
sound/soc/at91/eti_b1_wm8731.c +2 -1
index 820a676..a4f5a99 100644
@@ -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");
 
sound/soc/pxa/corgi.c +2 -1
index 5ee51a9..43237f9 100644
@@ -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);
sound/soc/pxa/poodle.c +2 -1
index 0915cf7..5e8cb76 100644
@@ -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);
sound/soc/pxa/spitz.c +2 -1
index 80e8210..95dcaa4 100644
@@ -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);
sound/soc/pxa/tosa.c +2 -1
index 5504e30..b438349 100644
@@ -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);
sound/soc/soc-core.c +1 -1
index 92d5d91..654a517 100644
@@ -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);
Signature · 6 lines
1.5.0.2.260.g2eb065

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author
#2 lore raw
Quoted 11 lines · Takashi Iwai

At Fri, 1 Jun 2007 17:44:57 -0500,

Quoted 6 lines · 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.

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.

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale