Diff
Modified: trunk/sound/soc/blackfin/bf5xx-ad1938.c (6730 => 6731)
--- trunk/sound/soc/blackfin/bf5xx-ad1938.c 2009-06-16 03:14:27 UTC (rev 6730)
+++ trunk/sound/soc/blackfin/bf5xx-ad1938.c 2009-06-16 03:49:39 UTC (rev 6731)
@@ -26,7 +26,6 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/device.h>
-#include <linux/delay.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
@@ -44,13 +43,8 @@
#include "bf5xx-tdm-pcm.h"
#include "bf5xx-tdm.h"
-static struct snd_soc_machine bf5xx_ad1938;
+static struct snd_soc_card bf5xx_ad1938;
-static int bf5xx_probe(struct platform_device *pdev)
-{
- return 0;
-}
-
static int bf5xx_ad1938_startup(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
@@ -78,7 +72,7 @@
int ret = 0;
/* set cpu DAI configuration */
- ret = cpu_dai->dai_ops.set_fmt(cpu_dai, SND_SOC_DAIFMT_SPORT_TDM |
+ ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_SPORT_TDM |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
if (ret < 0)
return ret;
@@ -105,16 +99,15 @@
.ops = &bf5xx_ad1938_ops,
};
-static struct snd_soc_machine bf5xx_ad1938 = {
+static struct snd_soc_card bf5xx_ad1938 = {
.name = "bf5xx_ad1938",
- .probe = bf5xx_probe,
+ .platform = &bf5xx_tdm_soc_platform,
.dai_link = &bf5xx_ad1938_dai,
.num_links = 1,
};
static struct snd_soc_device bf5xx_ad1938_snd_devdata = {
- .machine = &bf5xx_ad1938,
- .platform = &bf5xx_tdm_soc_platform,
+ .card = &bf5xx_ad1938,
.codec_dev = &soc_codec_dev_ad1938,
};
Modified: trunk/sound/soc/blackfin/bf5xx-tdm.c (6730 => 6731)
--- trunk/sound/soc/blackfin/bf5xx-tdm.c 2009-06-16 03:14:27 UTC (rev 6730)
+++ trunk/sound/soc/blackfin/bf5xx-tdm.c 2009-06-16 03:49:39 UTC (rev 6731)
@@ -29,7 +29,6 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
-#include <linux/delay.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -85,9 +84,9 @@
#endif
static u16 sport_req[][7] = { {P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
- P_SPORT0_DRPRI, P_SPORT0_RSCLK, LOCAL_SPORT0_TFS, 0},
- {P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS, P_SPORT1_DRPRI,
- P_SPORT1_RSCLK, P_SPORT1_TFS, 0} };
+ P_SPORT0_DRPRI, P_SPORT0_RSCLK, LOCAL_SPORT0_TFS, 0},
+ {P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS, P_SPORT1_DRPRI,
+ P_SPORT1_RSCLK, P_SPORT1_TFS, 0} };
static int bf5xx_tdm_set_dai_fmt(struct snd_soc_dai *cpu_dai,
unsigned int fmt)
@@ -122,7 +121,8 @@
}
static int bf5xx_tdm_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params)
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai)
{
int ret = 0;
@@ -146,14 +146,14 @@
* CPU DAI:slave mode.
*/
ret = sport_config_rx(sport_handle, bf5xx_tdm.rcr1,
- bf5xx_tdm.rcr2, 0, 0);
+ bf5xx_tdm.rcr2, 0, 0);
if (ret) {
pr_err("SPORT is busy!\n");
return -EBUSY;
}
ret = sport_config_tx(sport_handle, bf5xx_tdm.tcr1,
- bf5xx_tdm.tcr2, 0, 0);
+ bf5xx_tdm.tcr2, 0, 0);
if (ret) {
pr_err("SPORT is busy!\n");
return -EBUSY;
@@ -216,8 +216,7 @@
}
#ifdef CONFIG_PM
-static int bf5xx_tdm_suspend(struct platform_device *dev,
- struct snd_soc_dai *dai)
+static int bf5xx_tdm_suspend(struct snd_soc_dai *dai)
{
struct sport_device *sport =
(struct sport_device *)dai->private_data;
@@ -231,8 +230,7 @@
return 0;
}
-static int bf5xx_tdm_resume(struct platform_device *pdev,
- struct snd_soc_dai *dai)
+static int bf5xx_tdm_resume(struct snd_soc_dai *dai)
{
struct sport_device *sport =
(struct sport_device *)dai->private_data;
@@ -252,10 +250,14 @@
#define bf5xx_tdm_resume NULL
#endif
+static struct snd_soc_dai_ops bf5xx_tdm_dai_ops = {
+ .hw_params = bf5xx_tdm_hw_params,
+ .set_fmt = bf5xx_tdm_set_dai_fmt,
+};
+
struct snd_soc_dai bf5xx_tdm_dai = {
.name = "bf5xx-tdm",
.id = 0,
- .type = SND_SOC_DAI_PCM,
.probe = bf5xx_tdm_probe,
.remove = bf5xx_tdm_remove,
.suspend = bf5xx_tdm_suspend,
@@ -270,11 +272,7 @@
.channels_max = 8,
.rates = SNDRV_PCM_RATE_48000,
.formats = SNDRV_PCM_FMTBIT_S32_LE,},
- .ops = {
- .hw_params = bf5xx_tdm_hw_params,},
- .dai_ops = {
- .set_fmt = bf5xx_tdm_set_dai_fmt,
- },
+ .ops = &bf5xx_tdm_dai_ops,
};
EXPORT_SYMBOL_GPL(bf5xx_tdm_dai);
Modified: trunk/sound/soc/codecs/ad1938.c (6730 => 6731)
--- trunk/sound/soc/codecs/ad1938.c 2009-06-16 03:14:27 UTC (rev 6730)
+++ trunk/sound/soc/codecs/ad1938.c 2009-06-16 03:49:39 UTC (rev 6731)
@@ -84,19 +84,7 @@
return 0;
}
-/* dai_ops.digital_mute entry */
-static int ad1938_mute(struct snd_soc_dai *dai, int mute)
-{
- struct snd_soc_codec *codec = dai->codec;
- if (!mute)
- codec->write(codec, AD1938_DAC_CHNL_MUTE, 0);
- else
- codec->write(codec, AD1938_DAC_CHNL_MUTE, 0xff);
-
- return 0;
-}
-
/* dac/adc/pll poweron/off functions */
static int ad1938_dac_powerctrl(struct snd_soc_codec *codec, int cmd)
{
@@ -107,7 +95,6 @@
reg &= ~DAC_POWERDOWN;
else
reg |= DAC_POWERDOWN;
-
codec->write(codec, AD1938_DAC_CTRL0, reg);
return 0;
@@ -123,7 +110,6 @@
reg &= ~ADC_POWERDOWN;
else
reg |= ADC_POWERDOWN;
-
codec->write(codec, AD1938_ADC_CTRL0, reg);
return 0;
@@ -138,14 +124,15 @@
reg &= ~PLL_POWERDOWN;
else
reg |= PLL_POWERDOWN;
-
codec->write(codec, AD1938_PLL_CLK_CTRL0, reg);
return 0;
-
}
-/* dai_ops.set_pll entry */
+/*
+ * DAI ops entries
+ */
+
static int ad1938_set_pll(struct snd_soc_dai *codec_dai,
int pll_id, unsigned int freq_in, unsigned int freq_out)
{
@@ -162,12 +149,57 @@
return 0;
}
-/* ops.prepare entry */
-static int ad1938_pcm_prepare(struct snd_pcm_substream *substream)
+static int ad1938_mute(struct snd_soc_dai *dai, int mute)
{
+ struct snd_soc_codec *codec = dai->codec;
+
+ if (!mute)
+ codec->write(codec, AD1938_DAC_CHNL_MUTE, 0);
+ else
+ codec->write(codec, AD1938_DAC_CHNL_MUTE, 0xff);
+
+ return 0;
+}
+
+static int ad1938_set_dai_fmt(struct snd_soc_dai *codec_dai,
+ unsigned int fmt)
+{
+ struct snd_soc_codec *codec = codec_dai->codec;
+ int adc_reg, dac_reg;
+
+ /* read back adc and dac control registers */
+ adc_reg = codec->read(codec, AD1938_ADC_CTRL1);
+ dac_reg = codec->read(codec, AD1938_DAC_CTRL0);
+ adc_reg &= ~ADC_SERFMT_MASK;
+ dac_reg &= ~DAC_SERFMT_MASK;
+
+ /* interface format */
+ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+ case SND_SOC_DAIFMT_SPORT_TDM:
+ adc_reg |= ADC_SERFMT_AUX;
+ dac_reg |= DAC_SERFMT_TDM;
+ break;
+ case SND_SOC_DAIFMT_I2S:
+ adc_reg |= ADC_SERFMT_STEREO;
+ dac_reg |= DAC_SERFMT_STEREO;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ /* set new format */
+ codec->write(codec, AD1938_ADC_CTRL1, adc_reg);
+ codec->write(codec, AD1938_DAC_CTRL0, dac_reg);
+
+ return 0;
+}
+
+static int ad1938_pcm_prepare(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_device *socdev = rtd->socdev;
- struct snd_soc_codec *codec = socdev->codec;
+ struct snd_soc_codec *codec = socdev->card->codec;
struct snd_soc_dai *codec_dai = codec->dai;
/* set active */
@@ -184,12 +216,12 @@
return 0;
}
-/* ops.shutdown entry */
-static void ad1938_pcm_shutdown(struct snd_pcm_substream *substream)
+static void ad1938_pcm_shutdown(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_device *socdev = rtd->socdev;
- struct snd_soc_codec *codec = socdev->codec;
+ struct snd_soc_codec *codec = socdev->card->codec;
struct snd_soc_dai *codec_dai = codec->dai;
/* deactivate */
@@ -271,7 +303,7 @@
static int __devinit ad1938_spi_probe(struct spi_device *spi)
{
spi->dev.power.power_state = PMSG_ON;
- ad1938_socdev->codec->control_data = spi;
+ ad1938_socdev->card->codec->control_data = spi;
return 0;
}
@@ -301,6 +333,14 @@
spi_unregister_driver(&ad1938_spi_driver);
}
+static struct snd_soc_dai_ops ad1938_dai_ops = {
+ .prepare = ad1938_pcm_prepare,
+ .shutdown = ad1938_pcm_shutdown,
+ .digital_mute = ad1938_mute,
+ .set_pll = ad1938_set_pll,
+ .set_fmt = ad1938_set_dai_fmt,
+};
+
/* codec DAI instance */
struct snd_soc_dai ad1938_dai = {
.name = "AD1938",
@@ -316,14 +356,7 @@
.channels_max = 4,
.rates = SNDRV_PCM_RATE_48000,
.formats = SNDRV_PCM_FMTBIT_S32_LE, },
- .ops = {
- .prepare = ad1938_pcm_prepare,
- .shutdown = ad1938_pcm_shutdown,
- },
- .dai_ops = {
- .digital_mute = ad1938_mute,
- .set_pll = ad1938_set_pll,
- },
+ .ops = &ad1938_dai_ops,
};
EXPORT_SYMBOL_GPL(ad1938_dai);
@@ -344,7 +377,7 @@
codec->num_dai = 1;
codec->write = ad1938_reg_write;
codec->read = ad1938_reg_read;
- socdev->codec = codec;
+ socdev->card->codec = codec;
INIT_LIST_HEAD(&codec->dapm_widgets);
INIT_LIST_HEAD(&codec->dapm_paths);
@@ -364,7 +397,7 @@
goto pcm_err;
}
- ret = snd_soc_register_card(socdev);
+ ret = snd_soc_init_card(socdev);
if (ret < 0) {
printk(KERN_ERR "ad1938: failed to register card\n");
goto register_err;
@@ -392,15 +425,15 @@
pcm_err:
ad1938_spi_done();
spi_err:
- kfree(socdev->codec);
- socdev->codec = NULL;
+ kfree(socdev->card->codec);
+ socdev->card->codec = NULL;
return ret;
}
static int ad1938_soc_remove(struct platform_device *pdev)
{
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
- struct snd_soc_codec *codec = socdev->codec;
+ struct snd_soc_codec *codec = socdev->card->codec;
if (codec == NULL)
return 0;
@@ -416,7 +449,7 @@
pm_message_t state)
{
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
- struct snd_soc_codec *codec = socdev->codec;
+ struct snd_soc_codec *codec = socdev->card->codec;
/* poweroff dac/adc/pll */
ad1938_dac_powerctrl(codec, 0);
@@ -429,7 +462,7 @@
static int ad1938_soc_resume(struct platform_device *pdev)
{
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
- struct snd_soc_codec *codec = socdev->codec;
+ struct snd_soc_codec *codec = socdev->card->codec;
struct snd_soc_dai *codec_dai = codec->dai;
/* playing while recording, framework will poweroff-poweron pll redundantly */
@@ -455,6 +488,18 @@
};
EXPORT_SYMBOL_GPL(soc_codec_dev_ad1938);
+static int __init ad1938_init(void)
+{
+ return snd_soc_register_dai(&ad1938_dai);
+}
+module_init(ad1938_init);
+
+static void __exit ad1938_exit(void)
+{
+ snd_soc_unregister_dai(&ad1938_dai);
+}
+module_exit(ad1938_exit);
+
MODULE_DESCRIPTION("ASoC ad1938 driver");
MODULE_AUTHOR("Barry Song ");
MODULE_LICENSE("GPL");
Modified: trunk/sound/soc/codecs/ad1938.h (6730 => 6731)
--- trunk/sound/soc/codecs/ad1938.h 2009-06-16 03:14:27 UTC (rev 6730)
+++ trunk/sound/soc/codecs/ad1938.h 2009-06-16 03:49:39 UTC (rev 6731)
@@ -34,6 +34,9 @@
#define AD1938_PLL_CLK_CTRL1 1
#define AD1938_DAC_CTRL0 2
#define DAC_POWERDOWN 0x01
+#define DAC_SERFMT_MASK 0xC0
+#define DAC_SERFMT_STEREO (0 << 6)
+#define DAC_SERFMT_TDM (1 << 6)
#define AD1938_DAC_CTRL1 3
#define AD1938_DAC_CTRL2 4
#define AD1938_DAC_CHNL_MUTE 5
@@ -53,6 +56,9 @@
#define ADC2_MUTE 4
#define ADC3_MUTE 5
#define AD1938_ADC_CTRL1 15
+#define ADC_SERFMT_MASK 0x60
+#define ADC_SERFMT_STEREO (0 << 5)
+#define ADC_SERFMT_AUX (2 << 5)
#define AD1938_ADC_CTRL2 16
extern struct snd_soc_dai ad1938_dai;