Commit dc0a50af authored by Stephen Warren's avatar Stephen Warren Committed by Mark Brown

ASoC: Tegra: Rename harmony.c to tegra_wm8903.c

Soon, this machine driver will be updated to handle a number of Tegra boards
using the WM8903 codec. Rename the file in advance to reflect this.

Fix the content of tegra_wm8903.c to match the rename; replace references
to Harmony board with something more generic.

* s/struct tegra_harmony/struct tegra_wm8903/
* s/harmony/machine/ # variable name
* Similar rename for some functions
* Similar comment fix
* Similar MODULE_DESCRIPTION fix
Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
Acked-by: default avatarLiam Girdwood <lrg@ti.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent c6d46678
...@@ -14,13 +14,14 @@ config SND_TEGRA_SOC_I2S ...@@ -14,13 +14,14 @@ config SND_TEGRA_SOC_I2S
Tegra I2S interface. You will also need to select the individual Tegra I2S interface. You will also need to select the individual
machine drivers to support below. machine drivers to support below.
config SND_TEGRA_SOC_HARMONY config SND_TEGRA_SOC_WM8903
tristate "SoC Audio support for Tegra Harmony reference board" tristate "SoC Audio support for Tegra boards using a WM8903 codec"
depends on SND_TEGRA_SOC && MACH_HARMONY && I2C depends on SND_TEGRA_SOC && MACH_HARMONY && I2C
default m default m
select SND_TEGRA_SOC_I2S select SND_TEGRA_SOC_I2S
select SND_SOC_WM8903 select SND_SOC_WM8903
help help
Say Y or M here if you want to add support for SoC audio on the Say Y or M here if you want to add support for SoC audio on Tegra
Tegra Harmony reference board. boards using the WM8093 codec. Currently, the only supported board
is Harmony.
...@@ -10,6 +10,6 @@ obj-$(CONFIG_SND_TEGRA_SOC) += snd-soc-tegra-pcm.o ...@@ -10,6 +10,6 @@ obj-$(CONFIG_SND_TEGRA_SOC) += snd-soc-tegra-pcm.o
obj-$(CONFIG_SND_TEGRA_SOC_I2S) += snd-soc-tegra-i2s.o obj-$(CONFIG_SND_TEGRA_SOC_I2S) += snd-soc-tegra-i2s.o
# Tegra machine Support # Tegra machine Support
snd-soc-tegra-harmony-objs := harmony.o snd-soc-tegra-wm8903-objs := tegra_wm8903.o
obj-$(CONFIG_SND_TEGRA_SOC_HARMONY) += snd-soc-tegra-harmony.o obj-$(CONFIG_SND_TEGRA_SOC_WM8903) += snd-soc-tegra-wm8903.o
/* /*
* harmony.c - Harmony machine ASoC driver * tegra_wm8903.c - Tegra machine ASoC driver for boards using WM8903 codec.
* *
* Author: Stephen Warren <swarren@nvidia.com> * Author: Stephen Warren <swarren@nvidia.com>
* Copyright (C) 2010-2011 - NVIDIA, Inc. * Copyright (C) 2010-2011 - NVIDIA, Inc.
...@@ -56,13 +56,13 @@ ...@@ -56,13 +56,13 @@
#define GPIO_INT_MIC_EN BIT(1) #define GPIO_INT_MIC_EN BIT(1)
#define GPIO_EXT_MIC_EN BIT(2) #define GPIO_EXT_MIC_EN BIT(2)
struct tegra_harmony { struct tegra_wm8903 {
struct tegra_asoc_utils_data util_data; struct tegra_asoc_utils_data util_data;
struct tegra_wm8903_platform_data *pdata; struct tegra_wm8903_platform_data *pdata;
int gpio_requested; int gpio_requested;
}; };
static int harmony_asoc_hw_params(struct snd_pcm_substream *substream, static int tegra_wm8903_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
...@@ -70,7 +70,7 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream, ...@@ -70,7 +70,7 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_codec *codec = rtd->codec;
struct snd_soc_card *card = codec->card; struct snd_soc_card *card = codec->card;
struct tegra_harmony *harmony = snd_soc_card_get_drvdata(card); struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
int srate, mclk, mclk_change; int srate, mclk, mclk_change;
int err; int err;
...@@ -89,7 +89,7 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream, ...@@ -89,7 +89,7 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
while (mclk < 6000000) while (mclk < 6000000)
mclk *= 2; mclk *= 2;
err = tegra_asoc_utils_set_rate(&harmony->util_data, srate, mclk, err = tegra_asoc_utils_set_rate(&machine->util_data, srate, mclk,
&mclk_change); &mclk_change);
if (err < 0) { if (err < 0) {
dev_err(card->dev, "Can't configure clocks\n"); dev_err(card->dev, "Can't configure clocks\n");
...@@ -126,20 +126,20 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream, ...@@ -126,20 +126,20 @@ static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
return 0; return 0;
} }
static struct snd_soc_ops harmony_asoc_ops = { static struct snd_soc_ops tegra_wm8903_ops = {
.hw_params = harmony_asoc_hw_params, .hw_params = tegra_wm8903_hw_params,
}; };
static struct snd_soc_jack harmony_hp_jack; static struct snd_soc_jack tegra_wm8903_hp_jack;
static struct snd_soc_jack_pin harmony_hp_jack_pins[] = { static struct snd_soc_jack_pin tegra_wm8903_hp_jack_pins[] = {
{ {
.pin = "Headphone Jack", .pin = "Headphone Jack",
.mask = SND_JACK_HEADPHONE, .mask = SND_JACK_HEADPHONE,
}, },
}; };
static struct snd_soc_jack_gpio harmony_hp_jack_gpios[] = { static struct snd_soc_jack_gpio tegra_wm8903_hp_jack_gpios[] = {
{ {
.name = "headphone detect", .name = "headphone detect",
.report = SND_JACK_HEADPHONE, .report = SND_JACK_HEADPHONE,
...@@ -148,22 +148,22 @@ static struct snd_soc_jack_gpio harmony_hp_jack_gpios[] = { ...@@ -148,22 +148,22 @@ static struct snd_soc_jack_gpio harmony_hp_jack_gpios[] = {
} }
}; };
static struct snd_soc_jack harmony_mic_jack; static struct snd_soc_jack tegra_wm8903_mic_jack;
static struct snd_soc_jack_pin harmony_mic_jack_pins[] = { static struct snd_soc_jack_pin tegra_wm8903_mic_jack_pins[] = {
{ {
.pin = "Mic Jack", .pin = "Mic Jack",
.mask = SND_JACK_MICROPHONE, .mask = SND_JACK_MICROPHONE,
}, },
}; };
static int harmony_event_int_spk(struct snd_soc_dapm_widget *w, static int tegra_wm8903_event_int_spk(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
struct snd_soc_codec *codec = w->codec; struct snd_soc_codec *codec = w->codec;
struct snd_soc_card *card = codec->card; struct snd_soc_card *card = codec->card;
struct tegra_harmony *harmony = snd_soc_card_get_drvdata(card); struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
struct tegra_wm8903_platform_data *pdata = harmony->pdata; struct tegra_wm8903_platform_data *pdata = machine->pdata;
gpio_set_value_cansleep(pdata->gpio_spkr_en, gpio_set_value_cansleep(pdata->gpio_spkr_en,
SND_SOC_DAPM_EVENT_ON(event)); SND_SOC_DAPM_EVENT_ON(event));
...@@ -171,8 +171,8 @@ static int harmony_event_int_spk(struct snd_soc_dapm_widget *w, ...@@ -171,8 +171,8 @@ static int harmony_event_int_spk(struct snd_soc_dapm_widget *w,
return 0; return 0;
} }
static const struct snd_soc_dapm_widget harmony_dapm_widgets[] = { static const struct snd_soc_dapm_widget tegra_wm8903_dapm_widgets[] = {
SND_SOC_DAPM_SPK("Int Spk", harmony_event_int_spk), SND_SOC_DAPM_SPK("Int Spk", tegra_wm8903_event_int_spk),
SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_MIC("Mic Jack", NULL), SND_SOC_DAPM_MIC("Mic Jack", NULL),
}; };
...@@ -188,17 +188,17 @@ static const struct snd_soc_dapm_route harmony_audio_map[] = { ...@@ -188,17 +188,17 @@ static const struct snd_soc_dapm_route harmony_audio_map[] = {
{"IN1L", NULL, "Mic Bias"}, {"IN1L", NULL, "Mic Bias"},
}; };
static const struct snd_kcontrol_new harmony_controls[] = { static const struct snd_kcontrol_new tegra_wm8903_controls[] = {
SOC_DAPM_PIN_SWITCH("Int Spk"), SOC_DAPM_PIN_SWITCH("Int Spk"),
}; };
static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd) static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_codec *codec = rtd->codec;
struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_dapm_context *dapm = &codec->dapm;
struct snd_soc_card *card = codec->card; struct snd_soc_card *card = codec->card;
struct tegra_harmony *harmony = snd_soc_card_get_drvdata(card); struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
struct tegra_wm8903_platform_data *pdata = harmony->pdata; struct tegra_wm8903_platform_data *pdata = machine->pdata;
int ret; int ret;
ret = gpio_request(pdata->gpio_spkr_en, "spkr_en"); ret = gpio_request(pdata->gpio_spkr_en, "spkr_en");
...@@ -206,7 +206,7 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd) ...@@ -206,7 +206,7 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd)
dev_err(card->dev, "cannot get spkr_en gpio\n"); dev_err(card->dev, "cannot get spkr_en gpio\n");
return ret; return ret;
} }
harmony->gpio_requested |= GPIO_SPKR_EN; machine->gpio_requested |= GPIO_SPKR_EN;
gpio_direction_output(pdata->gpio_spkr_en, 0); gpio_direction_output(pdata->gpio_spkr_en, 0);
...@@ -215,7 +215,7 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd) ...@@ -215,7 +215,7 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd)
dev_err(card->dev, "cannot get int_mic_en gpio\n"); dev_err(card->dev, "cannot get int_mic_en gpio\n");
return ret; return ret;
} }
harmony->gpio_requested |= GPIO_INT_MIC_EN; machine->gpio_requested |= GPIO_INT_MIC_EN;
/* Disable int mic; enable signal is active-high */ /* Disable int mic; enable signal is active-high */
gpio_direction_output(pdata->gpio_int_mic_en, 0); gpio_direction_output(pdata->gpio_int_mic_en, 0);
...@@ -225,38 +225,39 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd) ...@@ -225,38 +225,39 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd)
dev_err(card->dev, "cannot get ext_mic_en gpio\n"); dev_err(card->dev, "cannot get ext_mic_en gpio\n");
return ret; return ret;
} }
harmony->gpio_requested |= GPIO_EXT_MIC_EN; machine->gpio_requested |= GPIO_EXT_MIC_EN;
/* Enable ext mic; enable signal is active-low */ /* Enable ext mic; enable signal is active-low */
gpio_direction_output(pdata->gpio_ext_mic_en, 0); gpio_direction_output(pdata->gpio_ext_mic_en, 0);
ret = snd_soc_add_controls(codec, harmony_controls, ret = snd_soc_add_controls(codec, tegra_wm8903_controls,
ARRAY_SIZE(harmony_controls)); ARRAY_SIZE(tegra_wm8903_controls));
if (ret < 0) if (ret < 0)
return ret; return ret;
snd_soc_dapm_new_controls(dapm, harmony_dapm_widgets, snd_soc_dapm_new_controls(dapm, tegra_wm8903_dapm_widgets,
ARRAY_SIZE(harmony_dapm_widgets)); ARRAY_SIZE(tegra_wm8903_dapm_widgets));
snd_soc_dapm_add_routes(dapm, harmony_audio_map, snd_soc_dapm_add_routes(dapm, harmony_audio_map,
ARRAY_SIZE(harmony_audio_map)); ARRAY_SIZE(harmony_audio_map));
harmony_hp_jack_gpios[0].gpio = pdata->gpio_hp_det; tegra_wm8903_hp_jack_gpios[0].gpio = pdata->gpio_hp_det;
snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
&harmony_hp_jack); &tegra_wm8903_hp_jack);
snd_soc_jack_add_pins(&harmony_hp_jack, snd_soc_jack_add_pins(&tegra_wm8903_hp_jack,
ARRAY_SIZE(harmony_hp_jack_pins), ARRAY_SIZE(tegra_wm8903_hp_jack_pins),
harmony_hp_jack_pins); tegra_wm8903_hp_jack_pins);
snd_soc_jack_add_gpios(&harmony_hp_jack, snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack,
ARRAY_SIZE(harmony_hp_jack_gpios), ARRAY_SIZE(tegra_wm8903_hp_jack_gpios),
harmony_hp_jack_gpios); tegra_wm8903_hp_jack_gpios);
snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE,
&harmony_mic_jack); &tegra_wm8903_mic_jack);
snd_soc_jack_add_pins(&harmony_mic_jack, snd_soc_jack_add_pins(&tegra_wm8903_mic_jack,
ARRAY_SIZE(harmony_mic_jack_pins), ARRAY_SIZE(tegra_wm8903_mic_jack_pins),
harmony_mic_jack_pins); tegra_wm8903_mic_jack_pins);
wm8903_mic_detect(codec, &harmony_mic_jack, SND_JACK_MICROPHONE, 0); wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE,
0);
snd_soc_dapm_force_enable_pin(dapm, "Mic Bias"); snd_soc_dapm_force_enable_pin(dapm, "Mic Bias");
...@@ -270,27 +271,27 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd) ...@@ -270,27 +271,27 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd)
return 0; return 0;
} }
static struct snd_soc_dai_link harmony_wm8903_dai = { static struct snd_soc_dai_link tegra_wm8903_dai = {
.name = "WM8903", .name = "WM8903",
.stream_name = "WM8903 PCM", .stream_name = "WM8903 PCM",
.codec_name = "wm8903.0-001a", .codec_name = "wm8903.0-001a",
.platform_name = "tegra-pcm-audio", .platform_name = "tegra-pcm-audio",
.cpu_dai_name = "tegra-i2s.0", .cpu_dai_name = "tegra-i2s.0",
.codec_dai_name = "wm8903-hifi", .codec_dai_name = "wm8903-hifi",
.init = harmony_asoc_init, .init = tegra_wm8903_init,
.ops = &harmony_asoc_ops, .ops = &tegra_wm8903_ops,
}; };
static struct snd_soc_card snd_soc_harmony = { static struct snd_soc_card snd_soc_tegra_wm8903 = {
.name = "tegra-harmony", .name = "tegra-wm8903",
.dai_link = &harmony_wm8903_dai, .dai_link = &tegra_wm8903_dai,
.num_links = 1, .num_links = 1,
}; };
static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev) static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev)
{ {
struct snd_soc_card *card = &snd_soc_harmony; struct snd_soc_card *card = &snd_soc_tegra_wm8903;
struct tegra_harmony *harmony; struct tegra_wm8903 *machine;
struct tegra_wm8903_platform_data *pdata; struct tegra_wm8903_platform_data *pdata;
int ret; int ret;
...@@ -305,21 +306,21 @@ static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev) ...@@ -305,21 +306,21 @@ static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
harmony = kzalloc(sizeof(struct tegra_harmony), GFP_KERNEL); machine = kzalloc(sizeof(struct tegra_wm8903), GFP_KERNEL);
if (!harmony) { if (!machine) {
dev_err(&pdev->dev, "Can't allocate tegra_harmony\n"); dev_err(&pdev->dev, "Can't allocate tegra_wm8903 struct\n");
return -ENOMEM; return -ENOMEM;
} }
harmony->pdata = pdata; machine->pdata = pdata;
ret = tegra_asoc_utils_init(&harmony->util_data, &pdev->dev); ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);
if (ret) if (ret)
goto err_free_harmony; goto err_free_machine;
card->dev = &pdev->dev; card->dev = &pdev->dev;
platform_set_drvdata(pdev, card); platform_set_drvdata(pdev, card);
snd_soc_card_set_drvdata(card, harmony); snd_soc_card_set_drvdata(card, machine);
ret = snd_soc_register_card(card); ret = snd_soc_register_card(card);
if (ret) { if (ret) {
...@@ -334,17 +335,17 @@ static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev) ...@@ -334,17 +335,17 @@ static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev)
snd_soc_card_set_drvdata(card, NULL); snd_soc_card_set_drvdata(card, NULL);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
card->dev = NULL; card->dev = NULL;
tegra_asoc_utils_fini(&harmony->util_data); tegra_asoc_utils_fini(&machine->util_data);
err_free_harmony: err_free_machine:
kfree(harmony); kfree(machine);
return ret; return ret;
} }
static int __devexit tegra_snd_harmony_remove(struct platform_device *pdev) static int __devexit tegra_wm8903_driver_remove(struct platform_device *pdev)
{ {
struct snd_soc_card *card = platform_get_drvdata(pdev); struct snd_soc_card *card = platform_get_drvdata(pdev);
struct tegra_harmony *harmony = snd_soc_card_get_drvdata(card); struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
struct tegra_wm8903_platform_data *pdata = harmony->pdata; struct tegra_wm8903_platform_data *pdata = machine->pdata;
snd_soc_unregister_card(card); snd_soc_unregister_card(card);
...@@ -352,43 +353,43 @@ static int __devexit tegra_snd_harmony_remove(struct platform_device *pdev) ...@@ -352,43 +353,43 @@ static int __devexit tegra_snd_harmony_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
card->dev = NULL; card->dev = NULL;
tegra_asoc_utils_fini(&harmony->util_data); tegra_asoc_utils_fini(&machine->util_data);
if (harmony->gpio_requested & GPIO_EXT_MIC_EN) if (machine->gpio_requested & GPIO_EXT_MIC_EN)
gpio_free(pdata->gpio_ext_mic_en); gpio_free(pdata->gpio_ext_mic_en);
if (harmony->gpio_requested & GPIO_INT_MIC_EN) if (machine->gpio_requested & GPIO_INT_MIC_EN)
gpio_free(pdata->gpio_int_mic_en); gpio_free(pdata->gpio_int_mic_en);
if (harmony->gpio_requested & GPIO_SPKR_EN) if (machine->gpio_requested & GPIO_SPKR_EN)
gpio_free(pdata->gpio_spkr_en); gpio_free(pdata->gpio_spkr_en);
kfree(harmony); kfree(machine);
return 0; return 0;
} }
static struct platform_driver tegra_snd_harmony_driver = { static struct platform_driver tegra_wm8903_driver = {
.driver = { .driver = {
.name = DRV_NAME, .name = DRV_NAME,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.pm = &snd_soc_pm_ops, .pm = &snd_soc_pm_ops,
}, },
.probe = tegra_snd_harmony_probe, .probe = tegra_wm8903_driver_probe,
.remove = __devexit_p(tegra_snd_harmony_remove), .remove = __devexit_p(tegra_wm8903_driver_remove),
}; };
static int __init snd_tegra_harmony_init(void) static int __init tegra_wm8903_modinit(void)
{ {
return platform_driver_register(&tegra_snd_harmony_driver); return platform_driver_register(&tegra_wm8903_driver);
} }
module_init(snd_tegra_harmony_init); module_init(tegra_wm8903_modinit);
static void __exit snd_tegra_harmony_exit(void) static void __exit tegra_wm8903_modexit(void)
{ {
platform_driver_unregister(&tegra_snd_harmony_driver); platform_driver_unregister(&tegra_wm8903_driver);
} }
module_exit(snd_tegra_harmony_exit); module_exit(tegra_wm8903_modexit);
MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
MODULE_DESCRIPTION("Harmony machine ASoC driver"); MODULE_DESCRIPTION("Tegra+WM8903 machine ASoC driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:" DRV_NAME); MODULE_ALIAS("platform:" DRV_NAME);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment