Skip to contentSkip to conversation

ASoC: Make ams-delta/cx20442 pair back working for multi-component

PATCH Applied Janusz Krzysztofik 3 participants 6 messages Aug 10, 2010 – Aug 14, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

1.
After a static codec pointer removal from the sound/soc/codecs/cx20442.c code, both codec and card specific tty line discipline functions lost their access to the codec structure data. Arrange for passing the pointer back to the codec tty ldisc bits from the card initialization code.

2.
Update incosistent codec device naming in the card code.

3.
Since a new element, control_data, has been added to the cx20442_priv structure, it looks like the old snd_soc_codec->control_data may be scheduled for removal. To avoid problems in the near future, use the cx20442_priv->control_data instead of the snd_soc_codec->control_data throughout the cx20442 code. In the ams-delta card code, check for the snd_soc_codec->hw_write not NULL instead of the snd_soc_codec->control_data.

Created and tested on Amstrad Delta against
git://git.kernel.org/pub/scm/linux/kernel/git/lrg/asoc-2.6.git,
commit a212dd5b2e1da045cbf423c70c87f48265531de4.

---

sound/soc/codecs/cx20442.c renamed from sound/soc/codecs/cx20442.c.orig +18 -15
@@ -165,6 +165,7 @@ static int cx20442_pm_to_v253_vsp(u8 val
 static int cx20442_write(struct snd_soc_codec *codec, unsigned int reg,
 							unsigned int value)
 {
+	struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec);
 	u8 *reg_cache = codec->reg_cache;
 	int vls, vsp, old, len;
 	char buf[18];
@@ -174,7 +175,7 @@ static int cx20442_write(struct snd_soc_
 
 	/* hw_write and control_data pointers required for talking to the modem
 	 * are expected to be set by the line discipline initialization code */
-	if (!codec->hw_write || !codec->control_data)
+	if (!codec->hw_write || !cx20442->control_data)
 		return -EIO;
 
 	old = reg_cache[reg];
@@ -203,17 +204,13 @@ static int cx20442_write(struct snd_soc_
 		return -ENOMEM;
 
 	dev_dbg(codec->dev, "%s: %s\n", __func__, buf);
-	if (codec->hw_write(codec->control_data, buf, len) != len)
+	if (codec->hw_write(cx20442->control_data, buf, len) != len)
 		return -EIO;
 
 	return 0;
 }
 
 
-/* Moved up here as line discipline referres it during initialization */
-static struct snd_soc_codec *cx20442_codec;
-
-
 /*
  * Line discpline related code
  *
@@ -229,15 +226,15 @@ static const char *v253_init = "ate0m0q0
 /* Line discipline .open() */
 static int v253_open(struct tty_struct *tty)
 {
-	struct snd_soc_codec *codec = cx20442_codec;
 	int ret, len = strlen(v253_init);
 
 	/* Doesn't make sense without write callback */
 	if (!tty->ops->write)
 		return -EINVAL;
 
-	/* Pass the codec structure address for use by other ldisc callbacks */
-	tty->disc_data = codec;
+	/* Won't work if no codec pointer has been passed by a card driver */
+	if (!tty->disc_data)
+		return -ENODEV;
 
 	if (tty->ops->write(tty, v253_init, len) != len) {
 		ret = -EIO;
@@ -254,15 +251,18 @@ err:
 static void v253_close(struct tty_struct *tty)
 {
 	struct snd_soc_codec *codec = tty->disc_data;
+	struct cx20442_priv *cx20442;
 
 	tty->disc_data = NULL;
 
 	if (!codec)
 		return;
 
+	cx20442 = snd_soc_codec_get_drvdata(codec);
+
 	/* Prevent the codec driver from further accessing the modem */
 	codec->hw_write = NULL;
-	codec->control_data = NULL;
+	cx20442->control_data = NULL;
 	codec->pop_time = 0;
 }
 
@@ -278,15 +278,18 @@ static void v253_receive(struct tty_stru
 				const unsigned char *cp, char *fp, int count)
 {
 	struct snd_soc_codec *codec = tty->disc_data;
+	struct cx20442_priv *cx20442;
 
 	if (!codec)
 		return;
 
-	if (!codec->control_data) {
+	cx20442 = snd_soc_codec_get_drvdata(codec);
+
+	if (!cx20442->control_data) {
 		/* First modem response, complete setup procedure */
 
 		/* Set up codec driver access to modem controls */
-		codec->control_data = tty;
+		cx20442->control_data = tty;
 		codec->hw_write = (hw_write_t)tty->ops->write;
 		codec->pop_time = 1;
 	}
@@ -343,7 +346,7 @@ static int cx20442_codec_probe(struct sn
 
 	cx20442_add_widgets(codec);
 
-	codec->control_data = NULL;
+	cx20442->control_data = NULL;
 	codec->hw_write = NULL;
 	codec->pop_time = 0;
 
@@ -355,8 +358,8 @@ static int cx20442_codec_remove(struct s
 {
 	struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec);
 
-	if (codec->control_data) {
-			struct tty_struct *tty = codec->control_data;
+	if (cx20442->control_data) {
+			struct tty_struct *tty = cx20442->control_data;
 			tty_hangup(tty);
 	}
 
sound/soc/omap/ams-delta.c renamed from sound/soc/omap/ams-delta.c.orig +38 -7

87 lines not on this page · raw message

#1 lore raw

Hello Janusz!

Since you have not sent patch for the OMAP McBSP part, I assume that it is working correctly on OMAP1.
Thanks for taking time for testing it!

Quoted 9 lines · On Wednesday 11 August 2010 02:29:32 ext Janusz Krzysztofik wrote:

1.
After a static codec pointer removal from the sound/soc/codecs/cx20442.c code, both codec and card specific tty line discipline functions lost their access to the codec structure data. Arrange for passing the pointer back to the codec tty ldisc bits from the card initialization code.

2.
Update incosistent codec device naming in the card code.

Quoted 6 lines

3.
Since a new element, control_data, has been added to the cx20442_priv structure, it looks like the old snd_soc_codec->control_data may be scheduled for removal. To avoid problems in the near future, use the cx20442_priv->control_data instead of the snd_soc_codec->control_data throughout the cx20442 code.

I believe that the snd_soc_codec->control_data is not going away, the control_data in the private struct is used to pass this information from bus probe to soc probe within the private structure.
If I'm not wrong, the reasoning is that sever chip can have I2C/SPI/etc control interfaces, and in this way the soc does not need to know anything about it, since the probe for the used bus will set the needed things for later use. I might misunderstood something, Mark or Liam will correct me for sure ;)

Quoted 7 lines

In the ams-delta card code, check for the
snd_soc_codec->hw_write not NULL instead of the
snd_soc_codec->control_data.

Created and tested on Amstrad Delta against
git://git.kernel.org/pub/scm/linux/kernel/git/lrg/asoc-2.6.git,
commit a212dd5b2e1da045cbf423c70c87f48265531de4.

Signature · 1 line
Péter
#2 lore raw
In reply to Janusz Krzysztofik
Quoted 17 lines · Janusz Krzysztofik

1.
After a static codec pointer removal from the sound/soc/codecs/cx20442.c code, both codec and card specific tty line discipline functions lost their access to the codec structure data. Arrange for passing the pointer back to the codec tty ldisc bits from the card initialization code.

2.
Update incosistent codec device naming in the card code.

3.
Since a new element, control_data, has been added to the cx20442_priv structure, it looks like the old snd_soc_codec->control_data may be scheduled for removal. To avoid problems in the near future, use the cx20442_priv->control_data instead of the snd_soc_codec->control_data throughout the cx20442 code. In the ams-delta card code, check for the snd_soc_codec->hw_write not NULL instead of the snd_soc_codec->control_data.

Quoted 5 lines

Created and tested on Amstrad Delta against
git://git.kernel.org/pub/scm/linux/kernel/git/lrg/asoc-2.6.git,
commit a212dd5b2e1da045cbf423c70c87f48265531de4.

Applied.

Thanks

Liam

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
#3 lore raw

Wednesday 11 August 2010 15:42:31 Liam Girdwood napisał(a):

Quoted 19 lines · Janusz Krzysztofik
Quoted 18 lines

1.
After a static codec pointer removal from the sound/soc/codecs/cx20442.c code, both codec and card specific tty line discipline functions lost their access to the codec structure data. Arrange for passing the pointer back to the codec tty ldisc bits from the card initialization code.

2.
Update incosistent codec device naming in the card code.

3.
Since a new element, control_data, has been added to the cx20442_priv structure, it looks like the old snd_soc_codec->control_data may be scheduled for removal. To avoid problems in the near future, use the cx20442_priv->control_data instead of the snd_soc_codec->control_data throughout the cx20442 code. In the ams-delta card code, check for the snd_soc_codec->hw_write not NULL instead of the snd_soc_codec->control_data.

Quoted 7 lines
Quoted 5 lines

Created and tested on Amstrad Delta against
git://git.kernel.org/pub/scm/linux/kernel/git/lrg/asoc-2.6.git,
commit a212dd5b2e1da045cbf423c70c87f48265531de4.

Applied.

Thanks, and sorry for not commenting on time your related RFC posted in June. I was not subscribed to the list.

BTW, what was the rationale for renaming the codec dai to "cx20422-hifi"? While this doesn't break anything obviously, I think the hifi suffix is missleading for a codec with a sampling rate of 8 kHz ;).

Thanks,
Janusz

Quoted 4 lines

Thanks

Liam

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#4 lore raw
Quoted 26 lines · Janusz Krzysztofik

Wednesday 11 August 2010 15:42:31 Liam Girdwood napisał(a):

Quoted 25 lines · Janusz Krzysztofik
Quoted 23 lines

1.
After a static codec pointer removal from the sound/soc/codecs/cx20442.c code, both codec and card specific tty line discipline functions lost their access to the codec structure data. Arrange for passing the pointer back to the codec tty ldisc bits from the card initialization code.

2.
Update incosistent codec device naming in the card code.

3.
Since a new element, control_data, has been added to the cx20442_priv structure, it looks like the old snd_soc_codec->control_data may be scheduled for removal. To avoid problems in the near future, use the cx20442_priv->control_data instead of the snd_soc_codec->control_data throughout the cx20442 code. In the ams-delta card code, check for the snd_soc_codec->hw_write not NULL instead of the snd_soc_codec->control_data.

Created and tested on Amstrad Delta against
git://git.kernel.org/pub/scm/linux/kernel/git/lrg/asoc-2.6.git,
commit a212dd5b2e1da045cbf423c70c87f48265531de4.

Quoted 8 lines
Quoted 1 line

Applied.

Thanks, and sorry for not commenting on time your related RFC posted in June. I was not subscribed to the list.

BTW, what was the rationale for renaming the codec dai to "cx20422-hifi"? While this doesn't break anything obviously, I think the hifi suffix is missleading for a codec with a sampling rate of 8 kHz ;).

You are right, perhaps this should be labelled "cx20422-voice". Care to send a patch ?

Thanks

Liam

Signature · 8 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#5 lore raw

Saturday 14 August 2010 12:35:35 Liam Girdwood napisał(a):

Quoted 8 lines · Janusz Krzysztofik
Quoted 4 lines

BTW, what was the rationale for renaming the codec dai to "cx20422-hifi"? While this doesn't break anything obviously, I think the hifi suffix is missleading for a codec with a sampling rate of 8 kHz ;).

You are right, perhaps this should be labelled "cx20422-voice". Care to send a patch ?

OK, I will.

Thanks,
Janusz
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel