[alsa-devel] [PATCH 1/3] ASoC: smdk_wm8994: Make driver name more unique
From: Mark Brown broonie@linaro.org
Avoid collisions with other SMDK audio by using the CODEC name.
Signed-off-by: Mark Brown broonie@linaro.org --- sound/soc/samsung/smdk_wm8994.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/samsung/smdk_wm8994.c b/sound/soc/samsung/smdk_wm8994.c index 581ea4a..05c479c 100644 --- a/sound/soc/samsung/smdk_wm8994.c +++ b/sound/soc/samsung/smdk_wm8994.c @@ -200,7 +200,7 @@ MODULE_DEVICE_TABLE(of, samsung_wm8994_of_match);
static struct platform_driver smdk_audio_driver = { .driver = { - .name = "smdk-audio", + .name = "smdk-audio-wm8894", .owner = THIS_MODULE, .of_match_table = of_match_ptr(samsung_wm8994_of_match), }, @@ -212,4 +212,4 @@ module_platform_driver(smdk_audio_driver);
MODULE_DESCRIPTION("ALSA SoC SMDK WM8994"); MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:smdk-audio"); +MODULE_ALIAS("platform:smdk-audio-wm8994");
From: Mark Brown broonie@linaro.org
Initialise the DAI format from the data link, saving code and repeated work.
Signed-off-by: Mark Brown broonie@linaro.org --- sound/soc/samsung/smdk_wm8994.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/sound/soc/samsung/smdk_wm8994.c b/sound/soc/samsung/smdk_wm8994.c index 05c479c..a561175 100644 --- a/sound/soc/samsung/smdk_wm8994.c +++ b/sound/soc/samsung/smdk_wm8994.c @@ -41,7 +41,6 @@ static int smdk_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai; unsigned int pll_out; int ret; @@ -54,18 +53,6 @@ static int smdk_hw_params(struct snd_pcm_substream *substream, else pll_out = params_rate(params) * 256;
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S - | SND_SOC_DAIFMT_NB_NF - | SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - return ret; - - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S - | SND_SOC_DAIFMT_NB_NF - | SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - return ret; - ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL1, WM8994_FLL_SRC_MCLK1, SMDK_WM8994_FREQ, pll_out); if (ret < 0) @@ -131,6 +118,8 @@ static struct snd_soc_dai_link smdk_dai[] = { .platform_name = "samsung-i2s.0", .codec_name = "wm8994-codec", .init = smdk_wm8994_init_paiftx, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, .ops = &smdk_ops, }, { /* Sec_Fifo Playback i/f */ .name = "Sec_FIFO TX", @@ -139,6 +128,8 @@ static struct snd_soc_dai_link smdk_dai[] = { .codec_dai_name = "wm8994-aif1", .platform_name = "samsung-i2s-sec", .codec_name = "wm8994-codec", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, .ops = &smdk_ops, }, };
From: Mark Brown broonie@linaro.org
Make the code more generally applicable by refactoring so that the MCLK1 rate can be selected based on the compatible string provided by the device tree, allowing use on other boards which have different rates or use other information sources.
Signed-off-by: Mark Brown broonie@linaro.org --- sound/soc/samsung/smdk_wm8994.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/sound/soc/samsung/smdk_wm8994.c b/sound/soc/samsung/smdk_wm8994.c index a561175..5fd7a05 100644 --- a/sound/soc/samsung/smdk_wm8994.c +++ b/sound/soc/samsung/smdk_wm8994.c @@ -11,6 +11,7 @@ #include <sound/pcm_params.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_device.h>
/* * Default CFG switch settings to use this driver: @@ -37,6 +38,15 @@ /* SMDK has a 16.934MHZ crystal attached to WM8994 */ #define SMDK_WM8994_FREQ 16934000
+struct smdk_wm8994_data { + int mclk1_rate; +}; + +/* Default SMDKs */ +static struct smdk_wm8994_data smdk_board_data = { + .mclk1_rate = SMDK_WM8994_FREQ, +}; + static int smdk_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -141,15 +151,28 @@ static struct snd_soc_card smdk = { .num_links = ARRAY_SIZE(smdk_dai), };
+#ifdef CONFIG_OF +static const struct of_device_id samsung_wm8994_of_match[] = { + { .compatible = "samsung,smdk-wm8994", .data = &smdk_board_data }, + {}, +}; +MODULE_DEVICE_TABLE(of, samsung_wm8994_of_match); +#endif /* CONFIG_OF */
static int smdk_audio_probe(struct platform_device *pdev) { int ret; struct device_node *np = pdev->dev.of_node; struct snd_soc_card *card = &smdk; + struct smdk_wm8994_data *board; + const struct of_device_id *id;
card->dev = &pdev->dev;
+ board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL); + if (!board) + return -ENOMEM; + if (np) { smdk_dai[0].cpu_dai_name = NULL; smdk_dai[0].cpu_of_node = of_parse_phandle(np, @@ -164,6 +187,12 @@ static int smdk_audio_probe(struct platform_device *pdev) smdk_dai[0].platform_of_node = smdk_dai[0].cpu_of_node; }
+ id = of_match_device(samsung_wm8994_of_match, &pdev->dev); + if (id) + *board = *((struct smdk_wm8994_data *)id->data); + + platform_set_drvdata(pdev, board); + ret = snd_soc_register_card(card);
if (ret) @@ -181,14 +210,6 @@ static int smdk_audio_remove(struct platform_device *pdev) return 0; }
-#ifdef CONFIG_OF -static const struct of_device_id samsung_wm8994_of_match[] = { - { .compatible = "samsung,smdk-wm8994", }, - {}, -}; -MODULE_DEVICE_TABLE(of, samsung_wm8994_of_match); -#endif /* CONFIG_OF */ - static struct platform_driver smdk_audio_driver = { .driver = { .name = "smdk-audio-wm8894",
participants (1)
-
Mark Brown