All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card
@ 2011-01-28 21:26 Stephen Warren
  2011-01-28 21:26 ` [PATCH 2/7] ASoC: Tegra: Harmony: Don't use soc-audio platform device Stephen Warren
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Stephen Warren @ 2011-01-28 21:26 UTC (permalink / raw)
  To: broonie, lrg; +Cc: linux-tegra, alsa-devel, Stephen Warren

All ASoC cards need snd_soc_initialize_card_lists called. Previously, it was
only called for cards backed by a "soc-audio" platform device, via
soc_probe(). However, it's also needed for cards backed by other platform
devices, and registered directly via snd_soc_register_card().

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 sound/soc/soc-core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 9dfbb8f..3feddd9 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1881,7 +1881,6 @@ static int soc_probe(struct platform_device *pdev)
 
 	/* Bodge while we unpick instantiation */
 	card->dev = &pdev->dev;
-	snd_soc_initialize_card_lists(card);
 
 	ret = snd_soc_register_card(card);
 	if (ret != 0) {
@@ -3122,6 +3121,8 @@ int snd_soc_register_card(struct snd_soc_card *card)
 	if (!card->name || !card->dev)
 		return -EINVAL;
 
+	snd_soc_initialize_card_lists(card);
+
 	soc_init_card_debugfs(card);
 
 	card->rtd = kzalloc(sizeof(struct snd_soc_pcm_runtime) *
-- 
1.7.1

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

* [PATCH 2/7] ASoC: Tegra: Harmony: Don't use soc-audio platform device
  2011-01-28 21:26 [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card Stephen Warren
@ 2011-01-28 21:26 ` Stephen Warren
  2011-01-28 21:26 ` [PATCH 3/7] ASoC: Tegra: Harmony: Support the internal speaker Stephen Warren
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Stephen Warren @ 2011-01-28 21:26 UTC (permalink / raw)
  To: broonie, lrg; +Cc: linux-tegra, alsa-devel, Stephen Warren

Previously, snd-soc-tegra-harmony internally instantiated a platform device
object whenever the module was loaded. Instead, switch to a more typical model
where arch/arm/mach-tegra defines a platform device, and snd-soc-tegra-harmony
acts as a driver for such a platform device.

Define a new struct tegra_harmony to store driver data in the future.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 sound/soc/tegra/harmony.c |   94 +++++++++++++++++++++++++++++++-------------
 1 files changed, 66 insertions(+), 28 deletions(-)

diff --git a/sound/soc/tegra/harmony.c b/sound/soc/tegra/harmony.c
index b160b71..2d6a15c 100644
--- a/sound/soc/tegra/harmony.c
+++ b/sound/soc/tegra/harmony.c
@@ -2,7 +2,7 @@
  * harmony.c - Harmony machine ASoC driver
  *
  * Author: Stephen Warren <swarren@nvidia.com>
- * Copyright (C) 2010 - NVIDIA, Inc.
+ * Copyright (C) 2010-2011 - NVIDIA, Inc.
  *
  * Based on code copyright/by:
  *
@@ -29,7 +29,11 @@
  */
 
 #include <asm/mach-types.h>
+
 #include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -40,9 +44,11 @@
 #include "tegra_pcm.h"
 #include "tegra_asoc_utils.h"
 
-#define PREFIX "ASoC Harmony: "
+#define DRV_NAME "tegra-snd-harmony"
+#define PREFIX DRV_NAME ": "
 
-static struct platform_device *harmony_snd_device;
+struct tegra_harmony {
+};
 
 static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
 					struct snd_pcm_hw_params *params)
@@ -154,56 +160,88 @@ static struct snd_soc_card snd_soc_harmony = {
 	.num_links = 1,
 };
 
-static int __init harmony_soc_modinit(void)
+static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev)
 {
+	struct snd_soc_card *card = &snd_soc_harmony;
+	struct tegra_harmony *harmony;
 	int ret;
 
 	if (!machine_is_harmony()) {
-		pr_err(PREFIX "Not running on Tegra Harmony!\n");
+		dev_err(&pdev->dev, "Not running on Tegra Harmony!\n");
 		return -ENODEV;
 	}
 
-	ret = tegra_asoc_utils_init();
-	if (ret) {
-		return ret;
+	harmony = kzalloc(sizeof(struct tegra_harmony), GFP_KERNEL);
+	if (!harmony) {
+		dev_err(&pdev->dev, "Can't allocate tegra_harmony\n");
+		return -ENOMEM;
 	}
 
-	/*
-	 * Create and register platform device
-	 */
-	harmony_snd_device = platform_device_alloc("soc-audio", -1);
-	if (harmony_snd_device == NULL) {
-		pr_err(PREFIX "platform_device_alloc failed\n");
-		ret = -ENOMEM;
-		goto err_clock_utils;
-	}
+	ret = tegra_asoc_utils_init();
+	if (ret)
+		goto err_free_harmony;
 
-	platform_set_drvdata(harmony_snd_device, &snd_soc_harmony);
+	card->dev = &pdev->dev;
+	platform_set_drvdata(pdev, card);
+	snd_soc_card_set_drvdata(card, harmony);
 
-	ret = platform_device_add(harmony_snd_device);
+	ret = snd_soc_register_card(card);
 	if (ret) {
-		pr_err(PREFIX "platform_device_add failed (%d)\n",
+		dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
 			ret);
-		goto err_device_put;
+		goto err_clear_drvdata;
 	}
 
 	return 0;
 
-err_device_put:
-	platform_device_put(harmony_snd_device);
-err_clock_utils:
+err_clear_drvdata:
+	snd_soc_card_set_drvdata(card, NULL);
+	platform_set_drvdata(pdev, NULL);
+	card->dev = NULL;
 	tegra_asoc_utils_fini();
+err_free_harmony:
+	kfree(harmony);
 	return ret;
 }
-module_init(harmony_soc_modinit);
 
-static void __exit harmony_soc_modexit(void)
+static int __devexit tegra_snd_harmony_remove(struct platform_device *pdev)
 {
-	platform_device_unregister(harmony_snd_device);
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct tegra_harmony *harmony = snd_soc_card_get_drvdata(card);
+
+	snd_soc_unregister_card(card);
+
+	snd_soc_card_set_drvdata(card, NULL);
+	platform_set_drvdata(pdev, NULL);
+	card->dev = NULL;
 
 	tegra_asoc_utils_fini();
+
+	kfree(harmony);
+
+	return 0;
+}
+
+static struct platform_driver tegra_snd_harmony_driver = {
+	.driver = {
+		.name = DRV_NAME,
+		.owner = THIS_MODULE,
+	},
+	.probe = tegra_snd_harmony_probe,
+	.remove = __devexit_p(tegra_snd_harmony_remove),
+};
+
+static int __init snd_tegra_harmony_init(void)
+{
+	return platform_driver_register(&tegra_snd_harmony_driver);
+}
+module_init(snd_tegra_harmony_init);
+
+static void __exit snd_tegra_harmony_exit(void)
+{
+	platform_driver_unregister(&tegra_snd_harmony_driver);
 }
-module_exit(harmony_soc_modexit);
+module_exit(snd_tegra_harmony_exit);
 
 MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
 MODULE_DESCRIPTION("Harmony machine ASoC driver");
-- 
1.7.1

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

* [PATCH 3/7] ASoC: Tegra: Harmony: Support the internal speaker
  2011-01-28 21:26 [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card Stephen Warren
  2011-01-28 21:26 ` [PATCH 2/7] ASoC: Tegra: Harmony: Don't use soc-audio platform device Stephen Warren
@ 2011-01-28 21:26 ` Stephen Warren
  2011-01-31 13:14   ` Mark Brown
  2011-01-28 21:26 ` [PATCH 4/7] ASoC: Tegra: Harmony: Fix indentation issue Stephen Warren
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 10+ messages in thread
From: Stephen Warren @ 2011-01-28 21:26 UTC (permalink / raw)
  To: broonie, lrg; +Cc: linux-tegra, alsa-devel, Stephen Warren

Add DAPM widget definitions for the internal speaker paths. Currently, this
path is always enabled while playback is active.

Add code to control the speaker amplifier GPIO.

The GPIO is requested during _init, since that's the first time it is
guaranteed that the WM8903 module is loaded, probed, and hence has exported
its GPIO chip.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 sound/soc/tegra/harmony.c |   51 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/sound/soc/tegra/harmony.c b/sound/soc/tegra/harmony.c
index 2d6a15c..0f5a481 100644
--- a/sound/soc/tegra/harmony.c
+++ b/sound/soc/tegra/harmony.c
@@ -33,6 +33,9 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/gpio.h>
+
+#include <mach/harmony_audio.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -48,6 +51,8 @@
 #define PREFIX DRV_NAME ": "
 
 struct tegra_harmony {
+	struct harmony_audio_platform_data *pdata;
+	int gpio_spkr_en_requested;
 };
 
 static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
@@ -113,7 +118,22 @@ static struct snd_soc_ops harmony_asoc_ops = {
 	.hw_params = harmony_asoc_hw_params,
 };
 
+static int harmony_event_int_spk(struct snd_soc_dapm_widget *w,
+					struct snd_kcontrol *k, int event)
+{
+	struct snd_soc_codec *codec = w->codec;
+	struct snd_soc_card *card = codec->card;
+	struct tegra_harmony *harmony = snd_soc_card_get_drvdata(card);
+	struct harmony_audio_platform_data *pdata = harmony->pdata;
+
+	gpio_set_value_cansleep(pdata->gpio_spkr_en,
+				!!SND_SOC_DAPM_EVENT_ON(event));
+
+	return 0;
+}
+
 static const struct snd_soc_dapm_widget harmony_dapm_widgets[] = {
+	SND_SOC_DAPM_SPK("Int Spk", harmony_event_int_spk),
 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
 	SND_SOC_DAPM_MIC("Mic Jack", NULL),
 };
@@ -121,6 +141,10 @@ static const struct snd_soc_dapm_widget harmony_dapm_widgets[] = {
 static const struct snd_soc_dapm_route harmony_audio_map[] = {
 	{"Headphone Jack", NULL, "HPOUTR"},
 	{"Headphone Jack", NULL, "HPOUTL"},
+	{"Int Spk", NULL, "ROP"},
+	{"Int Spk", NULL, "RON"},
+	{"Int Spk", NULL, "LOP"},
+	{"Int Spk", NULL, "LON"},
 	{"Mic Bias", NULL, "Mic Jack"},
 	{"IN1L", NULL, "Mic Bias"},
 };
@@ -129,6 +153,19 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_codec *codec = rtd->codec;
 	struct snd_soc_dapm_context *dapm = &codec->dapm;
+	struct snd_soc_card *card = codec->card;
+	struct tegra_harmony *harmony = snd_soc_card_get_drvdata(card);
+	struct harmony_audio_platform_data *pdata = harmony->pdata;
+	int ret;
+
+	ret = gpio_request(pdata->gpio_spkr_en, "spkr_en");
+	if (ret) {
+		dev_err(card->dev, "cannot get spkr_en gpio\n");
+		return ret;
+	}
+	harmony->gpio_spkr_en_requested = 1;
+
+	gpio_direction_output(pdata->gpio_spkr_en, 0);
 
 	snd_soc_dapm_new_controls(dapm, harmony_dapm_widgets,
 					ARRAY_SIZE(harmony_dapm_widgets));
@@ -137,6 +174,7 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd)
 				ARRAY_SIZE(harmony_audio_map));
 
 	snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
+	snd_soc_dapm_enable_pin(dapm, "Int Spk");
 	snd_soc_dapm_enable_pin(dapm, "Mic Jack");
 	snd_soc_dapm_sync(dapm);
 
@@ -164,6 +202,7 @@ static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev)
 {
 	struct snd_soc_card *card = &snd_soc_harmony;
 	struct tegra_harmony *harmony;
+	struct harmony_audio_platform_data *pdata;
 	int ret;
 
 	if (!machine_is_harmony()) {
@@ -171,12 +210,20 @@ static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	pdata = pdev->dev.platform_data;
+	if (!pdata) {
+		dev_err(&pdev->dev, "no platform data supplied\n");
+		return -EINVAL;
+	}
+
 	harmony = kzalloc(sizeof(struct tegra_harmony), GFP_KERNEL);
 	if (!harmony) {
 		dev_err(&pdev->dev, "Can't allocate tegra_harmony\n");
 		return -ENOMEM;
 	}
 
+	harmony->pdata = pdata;
+
 	ret = tegra_asoc_utils_init();
 	if (ret)
 		goto err_free_harmony;
@@ -208,6 +255,7 @@ static int __devexit tegra_snd_harmony_remove(struct platform_device *pdev)
 {
 	struct snd_soc_card *card = platform_get_drvdata(pdev);
 	struct tegra_harmony *harmony = snd_soc_card_get_drvdata(card);
+	struct harmony_audio_platform_data *pdata = harmony->pdata;
 
 	snd_soc_unregister_card(card);
 
@@ -217,6 +265,9 @@ static int __devexit tegra_snd_harmony_remove(struct platform_device *pdev)
 
 	tegra_asoc_utils_fini();
 
+	if (harmony->gpio_spkr_en_requested)
+		gpio_free(pdata->gpio_spkr_en);
+
 	kfree(harmony);
 
 	return 0;
-- 
1.7.1

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

* [PATCH 4/7] ASoC: Tegra: Harmony: Fix indentation issue.
  2011-01-28 21:26 [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card Stephen Warren
  2011-01-28 21:26 ` [PATCH 2/7] ASoC: Tegra: Harmony: Don't use soc-audio platform device Stephen Warren
  2011-01-28 21:26 ` [PATCH 3/7] ASoC: Tegra: Harmony: Support the internal speaker Stephen Warren
@ 2011-01-28 21:26 ` Stephen Warren
  2011-01-28 21:26 ` [PATCH 5/7] ASoC: Tegra: Harmony: Use dev_err not pr_err Stephen Warren
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Stephen Warren @ 2011-01-28 21:26 UTC (permalink / raw)
  To: broonie, lrg; +Cc: linux-tegra, alsa-devel, Stephen Warren

Indent with TABs not spaces.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 sound/soc/tegra/harmony.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/sound/soc/tegra/harmony.c b/sound/soc/tegra/harmony.c
index 0f5a481..b5311a3 100644
--- a/sound/soc/tegra/harmony.c
+++ b/sound/soc/tegra/harmony.c
@@ -104,11 +104,12 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
 	}
 
 	if (mclk_change) {
-	    err = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, SND_SOC_CLOCK_IN);
-	    if (err < 0) {
-		    pr_err(PREFIX "codec_dai clock not set\n");
-		    return err;
-	    }
+		err = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
+					     SND_SOC_CLOCK_IN);
+		if (err < 0) {
+			pr_err(PREFIX "codec_dai clock not set\n");
+			return err;
+		}
 	}
 
 	return 0;
-- 
1.7.1

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

* [PATCH 5/7] ASoC: Tegra: Harmony: Use dev_err not pr_err
  2011-01-28 21:26 [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card Stephen Warren
                   ` (2 preceding siblings ...)
  2011-01-28 21:26 ` [PATCH 4/7] ASoC: Tegra: Harmony: Fix indentation issue Stephen Warren
@ 2011-01-28 21:26 ` Stephen Warren
  2011-01-28 21:26 ` [PATCH 6/7] ASoC: Tegra: utils: Don't use global variables Stephen Warren
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Stephen Warren @ 2011-01-28 21:26 UTC (permalink / raw)
  To: broonie, lrg; +Cc: linux-tegra, alsa-devel, Stephen Warren

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 sound/soc/tegra/harmony.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/sound/soc/tegra/harmony.c b/sound/soc/tegra/harmony.c
index b5311a3..76793a9 100644
--- a/sound/soc/tegra/harmony.c
+++ b/sound/soc/tegra/harmony.c
@@ -48,7 +48,6 @@
 #include "tegra_asoc_utils.h"
 
 #define DRV_NAME "tegra-snd-harmony"
-#define PREFIX DRV_NAME ": "
 
 struct tegra_harmony {
 	struct harmony_audio_platform_data *pdata;
@@ -61,6 +60,8 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+	struct snd_soc_codec *codec = rtd->codec;
+	struct snd_soc_card *card = codec->card;
 	int srate, mclk, mclk_change;
 	int err;
 
@@ -81,7 +82,7 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
 
 	err = tegra_asoc_utils_set_rate(srate, mclk, &mclk_change);
 	if (err < 0) {
-		pr_err(PREFIX "Can't configure clocks\n");
+		dev_err(card->dev, "Can't configure clocks\n");
 		return err;
 	}
 
@@ -90,7 +91,7 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
 					SND_SOC_DAIFMT_NB_NF |
 					SND_SOC_DAIFMT_CBS_CFS);
 	if (err < 0) {
-		pr_err(PREFIX "codec_dai fmt not set\n");
+		dev_err(card->dev, "codec_dai fmt not set\n");
 		return err;
 	}
 
@@ -99,7 +100,7 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
 					SND_SOC_DAIFMT_NB_NF |
 					SND_SOC_DAIFMT_CBS_CFS);
 	if (err < 0) {
-		pr_err(PREFIX "cpu_dai fmt not set\n");
+		dev_err(card->dev, "cpu_dai fmt not set\n");
 		return err;
 	}
 
@@ -107,7 +108,7 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
 		err = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
 					     SND_SOC_CLOCK_IN);
 		if (err < 0) {
-			pr_err(PREFIX "codec_dai clock not set\n");
+			dev_err(card->dev, "codec_dai clock not set\n");
 			return err;
 		}
 	}
-- 
1.7.1

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

* [PATCH 6/7] ASoC: Tegra: utils: Don't use global variables
  2011-01-28 21:26 [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card Stephen Warren
                   ` (3 preceding siblings ...)
  2011-01-28 21:26 ` [PATCH 5/7] ASoC: Tegra: Harmony: Use dev_err not pr_err Stephen Warren
@ 2011-01-28 21:26 ` Stephen Warren
  2011-01-28 21:26 ` [PATCH 7/7] ASoC: Tegra: I2S: Use dev_err not pr_err Stephen Warren
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Stephen Warren @ 2011-01-28 21:26 UTC (permalink / raw)
  To: broonie, lrg; +Cc: linux-tegra, alsa-devel, Stephen Warren

Instead, have the machine driver provide storage for the utility data
somehow.

For Harmony in particular, store this within struct tegra_harmony, itself
referenced by snd_soc_card's drvdata.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 sound/soc/tegra/harmony.c          |   11 +++--
 sound/soc/tegra/tegra_asoc_utils.c |   91 +++++++++++++++++------------------
 sound/soc/tegra/tegra_asoc_utils.h |   20 +++++++-
 3 files changed, 68 insertions(+), 54 deletions(-)

diff --git a/sound/soc/tegra/harmony.c b/sound/soc/tegra/harmony.c
index 76793a9..d1faa63 100644
--- a/sound/soc/tegra/harmony.c
+++ b/sound/soc/tegra/harmony.c
@@ -50,6 +50,7 @@
 #define DRV_NAME "tegra-snd-harmony"
 
 struct tegra_harmony {
+	struct tegra_asoc_utils_data util_data;
 	struct harmony_audio_platform_data *pdata;
 	int gpio_spkr_en_requested;
 };
@@ -62,6 +63,7 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_codec *codec = rtd->codec;
 	struct snd_soc_card *card = codec->card;
+	struct tegra_harmony *harmony = snd_soc_card_get_drvdata(card);
 	int srate, mclk, mclk_change;
 	int err;
 
@@ -80,7 +82,8 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
 	while (mclk < 6000000)
 		mclk *= 2;
 
-	err = tegra_asoc_utils_set_rate(srate, mclk, &mclk_change);
+	err = tegra_asoc_utils_set_rate(&harmony->util_data, srate, mclk,
+					&mclk_change);
 	if (err < 0) {
 		dev_err(card->dev, "Can't configure clocks\n");
 		return err;
@@ -226,7 +229,7 @@ static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev)
 
 	harmony->pdata = pdata;
 
-	ret = tegra_asoc_utils_init();
+	ret = tegra_asoc_utils_init(&harmony->util_data, &pdev->dev);
 	if (ret)
 		goto err_free_harmony;
 
@@ -247,7 +250,7 @@ err_clear_drvdata:
 	snd_soc_card_set_drvdata(card, NULL);
 	platform_set_drvdata(pdev, NULL);
 	card->dev = NULL;
-	tegra_asoc_utils_fini();
+	tegra_asoc_utils_fini(&harmony->util_data);
 err_free_harmony:
 	kfree(harmony);
 	return ret;
@@ -265,7 +268,7 @@ static int __devexit tegra_snd_harmony_remove(struct platform_device *pdev)
 	platform_set_drvdata(pdev, NULL);
 	card->dev = NULL;
 
-	tegra_asoc_utils_fini();
+	tegra_asoc_utils_fini(&harmony->util_data);
 
 	if (harmony->gpio_spkr_en_requested)
 		gpio_free(pdata->gpio_spkr_en);
diff --git a/sound/soc/tegra/tegra_asoc_utils.c b/sound/soc/tegra/tegra_asoc_utils.c
index cfe2ea8..cb4fc13 100644
--- a/sound/soc/tegra/tegra_asoc_utils.c
+++ b/sound/soc/tegra/tegra_asoc_utils.c
@@ -21,20 +21,14 @@
  */
 
 #include <linux/clk.h>
+#include <linux/device.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
 
 #include "tegra_asoc_utils.h"
 
-#define PREFIX "ASoC Tegra: "
-
-static struct clk *clk_pll_a;
-static struct clk *clk_pll_a_out0;
-static struct clk *clk_cdev1;
-
-static int set_baseclock, set_mclk;
-
-int tegra_asoc_utils_set_rate(int srate, int mclk, int *mclk_change)
+int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate,
+			      int mclk, int *mclk_change)
 {
 	int new_baseclock;
 	int err;
@@ -58,95 +52,98 @@ int tegra_asoc_utils_set_rate(int srate, int mclk, int *mclk_change)
 		return -EINVAL;
 	}
 
-	*mclk_change = ((new_baseclock != set_baseclock) ||
-			(mclk != set_mclk));
+	*mclk_change = ((new_baseclock != data->set_baseclock) ||
+			(mclk != data->set_mclk));
 	if (!*mclk_change)
 	    return 0;
 
-	set_baseclock = 0;
-	set_mclk = 0;
+	data->set_baseclock = 0;
+	data->set_mclk = 0;
 
-	clk_disable(clk_cdev1);
-	clk_disable(clk_pll_a_out0);
-	clk_disable(clk_pll_a);
+	clk_disable(data->clk_cdev1);
+	clk_disable(data->clk_pll_a_out0);
+	clk_disable(data->clk_pll_a);
 
-	err = clk_set_rate(clk_pll_a, new_baseclock);
+	err = clk_set_rate(data->clk_pll_a, new_baseclock);
 	if (err) {
-		pr_err(PREFIX "Can't set pll_a rate: %d\n", err);
+		dev_err(data->dev, "Can't set pll_a rate: %d\n", err);
 		return err;
 	}
 
-	err = clk_set_rate(clk_pll_a_out0, mclk);
+	err = clk_set_rate(data->clk_pll_a_out0, mclk);
 	if (err) {
-		pr_err(PREFIX "Can't set pll_a_out0 rate: %d\n", err);
+		dev_err(data->dev, "Can't set pll_a_out0 rate: %d\n", err);
 		return err;
 	}
 
 	/* Don't set cdev1 rate; its locked to pll_a_out0 */
 
-	err = clk_enable(clk_pll_a);
+	err = clk_enable(data->clk_pll_a);
 	if (err) {
-		pr_err(PREFIX "Can't enable pll_a: %d\n", err);
+		dev_err(data->dev, "Can't enable pll_a: %d\n", err);
 		return err;
 	}
 
-	err = clk_enable(clk_pll_a_out0);
+	err = clk_enable(data->clk_pll_a_out0);
 	if (err) {
-		pr_err(PREFIX "Can't enable pll_a_out0: %d\n", err);
+		dev_err(data->dev, "Can't enable pll_a_out0: %d\n", err);
 		return err;
 	}
 
-	err = clk_enable(clk_cdev1);
+	err = clk_enable(data->clk_cdev1);
 	if (err) {
-		pr_err(PREFIX "Can't enable cdev1: %d\n", err);
+		dev_err(data->dev, "Can't enable cdev1: %d\n", err);
 		return err;
 	}
 
-	set_baseclock = new_baseclock;
-	set_mclk = mclk;
+	data->set_baseclock = new_baseclock;
+	data->set_mclk = mclk;
 
 	return 0;
 }
 
-int tegra_asoc_utils_init(void)
+int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data,
+			  struct device *dev)
 {
 	int ret;
 
-	clk_pll_a = clk_get_sys(NULL, "pll_a");
-	if (IS_ERR(clk_pll_a)) {
-		pr_err(PREFIX "Can't retrieve clk pll_a\n");
-		ret = PTR_ERR(clk_pll_a);
+	data->dev = dev;
+
+	data->clk_pll_a = clk_get_sys(NULL, "pll_a");
+	if (IS_ERR(data->clk_pll_a)) {
+		dev_err(data->dev, "Can't retrieve clk pll_a\n");
+		ret = PTR_ERR(data->clk_pll_a);
 		goto err;
 	}
 
-	clk_pll_a_out0 = clk_get_sys(NULL, "pll_a_out0");
-	if (IS_ERR(clk_pll_a_out0)) {
-		pr_err(PREFIX "Can't retrieve clk pll_a_out0\n");
-		ret = PTR_ERR(clk_pll_a_out0);
+	data->clk_pll_a_out0 = clk_get_sys(NULL, "pll_a_out0");
+	if (IS_ERR(data->clk_pll_a_out0)) {
+		dev_err(data->dev, "Can't retrieve clk pll_a_out0\n");
+		ret = PTR_ERR(data->clk_pll_a_out0);
 		goto err_put_pll_a;
 	}
 
-	clk_cdev1 = clk_get_sys(NULL, "cdev1");
-	if (IS_ERR(clk_cdev1)) {
-		pr_err(PREFIX "Can't retrieve clk cdev1\n");
-		ret = PTR_ERR(clk_cdev1);
+	data->clk_cdev1 = clk_get_sys(NULL, "cdev1");
+	if (IS_ERR(data->clk_cdev1)) {
+		dev_err(data->dev, "Can't retrieve clk cdev1\n");
+		ret = PTR_ERR(data->clk_cdev1);
 		goto err_put_pll_a_out0;
 	}
 
 	return 0;
 
 err_put_pll_a_out0:
-	clk_put(clk_pll_a_out0);
+	clk_put(data->clk_pll_a_out0);
 err_put_pll_a:
-	clk_put(clk_pll_a);
+	clk_put(data->clk_pll_a);
 err:
 	return ret;
 }
 
-void tegra_asoc_utils_fini(void)
+void tegra_asoc_utils_fini(struct tegra_asoc_utils_data *data)
 {
-	clk_put(clk_cdev1);
-	clk_put(clk_pll_a_out0);
-	clk_put(clk_pll_a);
+	clk_put(data->clk_cdev1);
+	clk_put(data->clk_pll_a_out0);
+	clk_put(data->clk_pll_a);
 }
 
diff --git a/sound/soc/tegra/tegra_asoc_utils.h b/sound/soc/tegra/tegra_asoc_utils.h
index 855f8f6..bbba7af 100644
--- a/sound/soc/tegra/tegra_asoc_utils.h
+++ b/sound/soc/tegra/tegra_asoc_utils.h
@@ -23,9 +23,23 @@
 #ifndef __TEGRA_ASOC_UTILS_H__
 #define __TEGRA_ASOC_UTILS_H_
 
-int tegra_asoc_utils_set_rate(int srate, int mclk_rate, int *mclk_change);
-int tegra_asoc_utils_init(void);
-void tegra_asoc_utils_fini(void);
+struct clk;
+struct device;
+
+struct tegra_asoc_utils_data {
+	struct device *dev;
+	struct clk *clk_pll_a;
+	struct clk *clk_pll_a_out0;
+	struct clk *clk_cdev1;
+	int set_baseclock;
+	int set_mclk;
+};
+
+int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate,
+			      int mclk, int *mclk_change);
+int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data,
+			  struct device *dev);
+void tegra_asoc_utils_fini(struct tegra_asoc_utils_data *data);
 
 #endif
 
-- 
1.7.1

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

* [PATCH 7/7] ASoC: Tegra: I2S: Use dev_err not pr_err
  2011-01-28 21:26 [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card Stephen Warren
                   ` (4 preceding siblings ...)
  2011-01-28 21:26 ` [PATCH 6/7] ASoC: Tegra: utils: Don't use global variables Stephen Warren
@ 2011-01-28 21:26 ` Stephen Warren
  2011-01-31 12:08 ` [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card Liam Girdwood
  2011-01-31 13:17 ` Mark Brown
  7 siblings, 0 replies; 10+ messages in thread
From: Stephen Warren @ 2011-01-28 21:26 UTC (permalink / raw)
  To: broonie, lrg; +Cc: linux-tegra, alsa-devel, Stephen Warren

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 sound/soc/tegra/tegra_i2s.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sound/soc/tegra/tegra_i2s.c b/sound/soc/tegra/tegra_i2s.c
index 6d66878..870ee36 100644
--- a/sound/soc/tegra/tegra_i2s.c
+++ b/sound/soc/tegra/tegra_i2s.c
@@ -386,7 +386,7 @@ static __devinit int tegra_i2s_platform_probe(struct platform_device *pdev)
 	snprintf(clk_name, sizeof(clk_name), DRV_NAME ".%d", pdev->id);
 	i2s->clk_i2s = clk_get_sys(clk_name, NULL);
 	if (IS_ERR(i2s->clk_i2s)) {
-		pr_err("Can't retrieve i2s clock\n");
+		dev_err(&pdev->dev, "Can't retrieve i2s clock\n");
 		ret = PTR_ERR(i2s->clk_i2s);
 		goto err_free;
 	}
-- 
1.7.1

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

* Re: [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card
  2011-01-28 21:26 [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card Stephen Warren
                   ` (5 preceding siblings ...)
  2011-01-28 21:26 ` [PATCH 7/7] ASoC: Tegra: I2S: Use dev_err not pr_err Stephen Warren
@ 2011-01-31 12:08 ` Liam Girdwood
  2011-01-31 13:17 ` Mark Brown
  7 siblings, 0 replies; 10+ messages in thread
From: Liam Girdwood @ 2011-01-31 12:08 UTC (permalink / raw)
  To: Stephen Warren; +Cc: linux-tegra, alsa-devel, broonie

On Fri, 2011-01-28 at 14:26 -0700, Stephen Warren wrote:
> All ASoC cards need snd_soc_initialize_card_lists called. Previously, it was
> only called for cards backed by a "soc-audio" platform device, via
> soc_probe(). However, it's also needed for cards backed by other platform
> devices, and registered directly via snd_soc_register_card().
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>

All

Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

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

* Re: [PATCH 3/7] ASoC: Tegra: Harmony: Support the internal speaker
  2011-01-28 21:26 ` [PATCH 3/7] ASoC: Tegra: Harmony: Support the internal speaker Stephen Warren
@ 2011-01-31 13:14   ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2011-01-31 13:14 UTC (permalink / raw)
  To: Stephen Warren; +Cc: linux-tegra, alsa-devel, lrg

On Fri, Jan 28, 2011 at 02:26:37PM -0700, Stephen Warren wrote:

> +	gpio_set_value_cansleep(pdata->gpio_spkr_en,
> +				!!SND_SOC_DAPM_EVENT_ON(event));

GPIOs should accept C logical values - if you need the !! there's a bug
in the GPIO driver.

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

* Re: [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card
  2011-01-28 21:26 [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card Stephen Warren
                   ` (6 preceding siblings ...)
  2011-01-31 12:08 ` [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card Liam Girdwood
@ 2011-01-31 13:17 ` Mark Brown
  7 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2011-01-31 13:17 UTC (permalink / raw)
  To: Stephen Warren; +Cc: linux-tegra, alsa-devel, lrg

On Fri, Jan 28, 2011 at 02:26:35PM -0700, Stephen Warren wrote:
> All ASoC cards need snd_soc_initialize_card_lists called. Previously, it was
> only called for cards backed by a "soc-audio" platform device, via
> soc_probe(). However, it's also needed for cards backed by other platform
> devices, and registered directly via snd_soc_register_card().

All applied, thanks.

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

end of thread, other threads:[~2011-01-31 13:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-28 21:26 [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card Stephen Warren
2011-01-28 21:26 ` [PATCH 2/7] ASoC: Tegra: Harmony: Don't use soc-audio platform device Stephen Warren
2011-01-28 21:26 ` [PATCH 3/7] ASoC: Tegra: Harmony: Support the internal speaker Stephen Warren
2011-01-31 13:14   ` Mark Brown
2011-01-28 21:26 ` [PATCH 4/7] ASoC: Tegra: Harmony: Fix indentation issue Stephen Warren
2011-01-28 21:26 ` [PATCH 5/7] ASoC: Tegra: Harmony: Use dev_err not pr_err Stephen Warren
2011-01-28 21:26 ` [PATCH 6/7] ASoC: Tegra: utils: Don't use global variables Stephen Warren
2011-01-28 21:26 ` [PATCH 7/7] ASoC: Tegra: I2S: Use dev_err not pr_err Stephen Warren
2011-01-31 12:08 ` [PATCH 1/7] ASoC: Move card list initialization to snd_soc_register_card Liam Girdwood
2011-01-31 13:17 ` Mark Brown

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.