public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: alsa-devel@alsa-project.org
Cc: Takashi Iwai <tiwai@suse.de>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH] Allow passing platform_data to devices attached to AC97 bus
Date: Tue, 21 Jul 2009 16:33:14 +0200	[thread overview]
Message-ID: <200907211633.14388.marek.vasut@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

Hi,

I managed to put together this patch with huge help from Mark. It allows 
passing platform_data to devices on ac97 bus and implements this for pxa2xx-
ac97. Please consider applying.

[-- Attachment #2: 0001-Allow-passing-platform_data-to-devices-attached-to-A.patch --]
[-- Type: text/x-patch, Size: 5195 bytes --]

From dc427c54f0fede86acb6e21b09908597b066f021 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH] Allow passing platform_data to devices attached to AC97 bus

This patch allows passing platform_data to devices attached to AC97 bus
(like touchscreens, battery measurement chips ...). This patch also adds
this support into PXA2xx-AC97 driver as a reference implementation.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 arch/arm/mach-pxa/include/mach/audio.h |    1 +
 include/sound/ac97_codec.h             |    3 +++
 include/sound/soc-dai.h                |    1 +
 sound/arm/pxa2xx-ac97.c                |    3 +++
 sound/pci/ac97/ac97_codec.c            |    7 +++++++
 sound/soc/pxa/pxa2xx-ac97.c            |    7 ++++++-
 sound/soc/soc-core.c                   |    5 ++++-
 7 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/include/mach/audio.h b/arch/arm/mach-pxa/include/mach/audio.h
index 16eb025..8825b18 100644
--- a/arch/arm/mach-pxa/include/mach/audio.h
+++ b/arch/arm/mach-pxa/include/mach/audio.h
@@ -20,6 +20,7 @@ typedef struct {
 	void (*resume)(void *);
 	void *priv;
 	int reset_gpio;
+	void *codec_pdata[4];
 } pxa2xx_audio_ops_t;
 
 extern void pxa_set_ac97_info(pxa2xx_audio_ops_t *ops);
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 251fc1c..c6b24e2 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -642,4 +642,7 @@ int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);
 /* ad hoc AC97 device driver access */
 extern struct bus_type ac97_bus_type;
 
+/* AC97 platform_data adding function */
+void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data);
+
 #endif /* __SOUND_AC97_CODEC_H */
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 352d7ee..0d65a03 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -179,6 +179,7 @@ struct snd_soc_dai {
 	int ac97_control;
 
 	struct device *dev;
+	void *ac97_pdata;	/* platform_data for the ac97 codec */
 
 	/* DAI callbacks */
 	int (*probe)(struct platform_device *pdev,
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index c570ebd..cfab74e 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -170,6 +170,8 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	struct snd_ac97_bus *ac97_bus;
 	struct snd_ac97_template ac97_template;
 	int ret;
+	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
+	int id = dev->id < 0 ? 0 : dev->id;
 
 	ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
 			      THIS_MODULE, 0, &card);
@@ -200,6 +202,7 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	snprintf(card->longname, sizeof(card->longname),
 		 "%s (%s)", dev->dev.driver->name, card->mixername);
 
+	snd_ac97_dev_add_pdata(ac97_bus->codec[id], pdata->codec_pdata[id]);
 	snd_card_set_dev(card, &dev->dev);
 	ret = snd_card_register(card);
 	if (ret == 0) {
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 78288db..476853a 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -1922,6 +1922,13 @@ static void ac97_device_release(struct device * dev)
 {
 }
 
+/* add platform_data to the ac97 device */
+void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data)
+{
+	ac97->dev.platform_data = data;
+}
+EXPORT_SYMBOL_GPL(snd_ac97_dev_add_pdata);
+
 /* register ac97 codec to bus */
 static int snd_ac97_dev_register(struct snd_device *device)
 {
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index d9c94d7..dea18ee 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -22,6 +22,7 @@
 #include <mach/hardware.h>
 #include <mach/regs-ac97.h>
 #include <mach/dma.h>
+#include <mach/audio.h>
 
 #include "pxa2xx-pcm.h"
 #include "pxa2xx-ac97.h"
@@ -241,9 +242,13 @@ EXPORT_SYMBOL_GPL(soc_ac97_ops);
 static int __devinit pxa2xx_ac97_dev_probe(struct platform_device *pdev)
 {
 	int i;
+	pxa2xx_audio_ops_t *pdata = pdev->dev.platform_data;
 
-	for (i = 0; i < ARRAY_SIZE(pxa_ac97_dai); i++)
+	for (i = 0; i < ARRAY_SIZE(pxa_ac97_dai); i++) {
 		pxa_ac97_dai[i].dev = &pdev->dev;
+		pxa_ac97_dai[i].ac97_pdata = pdata->codec_pdata
+					[pdev->id < 0 ? 0 : pdev->id];
+	}
 
 	/* Punt most of the init to the SoC probe; we may need the machine
 	 * driver to do interesting things with the clocking to get us up
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1d70829..0b12fe5 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1381,8 +1381,11 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
 				continue;
 			}
 		}
-		if (card->dai_link[i].codec_dai->ac97_control)
+		if (card->dai_link[i].codec_dai->ac97_control) {
 			ac97 = 1;
+			codec->ac97->dev.platform_data =
+				card->dai_link[i].cpu_dai->ac97_pdata;
+		}
 	}
 	snprintf(codec->card->shortname, sizeof(codec->card->shortname),
 		 "%s",  card->name);
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

             reply	other threads:[~2009-07-21 14:33 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-21 14:33 Marek Vasut [this message]
2009-07-21 14:50 ` [PATCH] Allow passing platform_data to devices attached to AC97 bus Takashi Iwai
2009-07-21 14:53   ` Mark Brown
2009-07-21 15:16     ` Takashi Iwai
2009-07-21 15:40       ` Marek Vasut
2009-07-21 18:30         ` Mark Brown
2009-07-21 19:51           ` Marek Vasut
2009-07-22 10:40             ` Mark Brown
2009-07-22 10:59               ` [PATCH 1/4] " Marek Vasut
2009-07-23 10:16                 ` Mark Brown
2009-07-23 10:28                   ` Takashi Iwai
2009-07-23 10:31                     ` Mark Brown
2009-07-21 20:24           ` [PATCH] " Marek Vasut
2009-07-21 20:59             ` Takashi Iwai
2009-07-21 21:53               ` Marek Vasut
2009-07-21 22:13                 ` Marek Vasut
2009-07-21 22:33                   ` Russell King - ARM Linux
2009-07-21 22:39                     ` Marek Vasut
2009-07-21 22:40                       ` Marek Vasut
2009-07-21 22:34                   ` Anton Vorontsov
2009-07-21 22:43                     ` Marek Vasut
2009-07-22 11:01                     ` [PATCH 1/4] " Marek Vasut
2009-07-22 11:02                       ` [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97 Marek Vasut
2009-07-23 10:27                         ` Mark Brown
2009-07-23 14:16                           ` Marek Vasut
2009-07-23 15:14                             ` Mark Brown
2009-07-23 18:39                             ` Marek Vasut
2009-07-28  5:28                               ` Marek Vasut
2009-07-30  0:55                                 ` Marek Vasut
2009-08-13 20:40                                   ` Mark Brown
2009-08-13 23:34                                     ` Marek Vasut
2009-08-13 23:42                                       ` Anton Vorontsov
2009-08-14  8:57                                       ` Mark Brown
2009-07-22 11:04                       ` [PATCH 3/4] Convert WM97xx driver to use platform_data Marek Vasut
2009-07-23 11:49                         ` Mark Brown
2009-07-24 19:44                         ` Robert Jarzmik
2009-07-24 21:03                           ` Marek Vasut
2009-07-22 11:05                       ` [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery Marek Vasut
2009-07-22 18:09                         ` Robert Jarzmik
2009-07-22 18:30                           ` Marek Vasut
2009-07-25 20:55                             ` Robert Jarzmik
2009-07-27  0:06                             ` Marek Vasut
2009-07-21 20:25           ` [PATCH] Allow passing platform_data to devices attached to AC97 bus Marek Vasut
2009-07-21 15:41       ` Marek Vasut
2009-07-21 17:40       ` Marek Vasut
2009-07-21 18:27         ` Mark Brown
2009-07-21 18:38           ` Mark Brown
2009-07-21 17:42       ` Marek Vasut
2009-07-21 18:18       ` Marek Vasut
2009-07-21 15:11 ` Robert Jarzmik
2009-07-21 15:17   ` Takashi Iwai
2009-07-25 20:56   ` Robert Jarzmik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200907211633.14388.marek.vasut@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox