Skip to content

Commit

Permalink
Merge remote-tracking branches 'asoc/topic/dwc', 'asoc/topic/es8328',…
Browse files Browse the repository at this point in the history
… 'asoc/topic/fsl' and 'asoc/topic/fsl-card' into asoc-next
  • Loading branch information
broonie committed Oct 26, 2015
5 parents 1c9d000 + ab57b8e + 7ab8a54 + 739146b + 50760ca commit f72362e
Show file tree
Hide file tree
Showing 9 changed files with 503 additions and 74 deletions.
10 changes: 6 additions & 4 deletions Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ So having this generic sound card allows all Freescale SoC users to benefit
from the simplification of a new card support and the capability of the wide
sample rates support through ASRC.

Note: The card is initially designed for those sound cards who use I2S and
PCM DAI formats. However, it'll be also possible to support those non
I2S/PCM type sound cards, such as S/PDIF audio and HDMI audio, as long
as the driver has been properly upgraded.
Note: The card is initially designed for those sound cards who use AC'97, I2S
and PCM DAI formats. However, it'll be also possible to support those non
AC'97/I2S/PCM type sound cards, such as S/PDIF audio and HDMI audio, as
long as the driver has been properly upgraded.


The compatible list for this generic sound card currently:
"fsl,imx-audio-ac97"

"fsl,imx-audio-cs42888"

"fsl,imx-audio-wm8962"
Expand Down
2 changes: 2 additions & 0 deletions include/sound/designware_i2s.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ struct i2s_clk_config_data {
struct i2s_platform_data {
#define DWC_I2S_PLAY (1 << 0)
#define DWC_I2S_RECORD (1 << 1)
#define DW_I2S_SLAVE (1 << 2)
#define DW_I2S_MASTER (1 << 3)
unsigned int cap;
int channel;
u32 snd_fmts;
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/codecs/es8328.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static int es8328_put_deemph(struct snd_kcontrol *kcontrol,
{
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct es8328_priv *es8328 = snd_soc_codec_get_drvdata(codec);
int deemph = ucontrol->value.integer.value[0];
unsigned int deemph = ucontrol->value.integer.value[0];
int ret;

if (deemph > 1)
Expand Down
123 changes: 86 additions & 37 deletions sound/soc/dwc/designware_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,23 +282,25 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream,

config->sample_rate = params_rate(params);

if (dev->i2s_clk_cfg) {
ret = dev->i2s_clk_cfg(config);
if (ret < 0) {
dev_err(dev->dev, "runtime audio clk config fail\n");
return ret;
}
} else {
u32 bitclk = config->sample_rate * config->data_width * 2;

ret = clk_set_rate(dev->clk, bitclk);
if (ret) {
dev_err(dev->dev, "Can't set I2S clock rate: %d\n",
ret);
return ret;
if (dev->capability & DW_I2S_MASTER) {
if (dev->i2s_clk_cfg) {
ret = dev->i2s_clk_cfg(config);
if (ret < 0) {
dev_err(dev->dev, "runtime audio clk config fail\n");
return ret;
}
} else {
u32 bitclk = config->sample_rate *
config->data_width * 2;

ret = clk_set_rate(dev->clk, bitclk);
if (ret) {
dev_err(dev->dev, "Can't set I2S clock rate: %d\n",
ret);
return ret;
}
}
}

return 0;
}

Expand Down Expand Up @@ -348,12 +350,43 @@ static int dw_i2s_trigger(struct snd_pcm_substream *substream,
return ret;
}

static int dw_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
{
struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
int ret = 0;

switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM:
if (dev->capability & DW_I2S_SLAVE)
ret = 0;
else
ret = -EINVAL;
break;
case SND_SOC_DAIFMT_CBS_CFS:
if (dev->capability & DW_I2S_MASTER)
ret = 0;
else
ret = -EINVAL;
break;
case SND_SOC_DAIFMT_CBM_CFS:
case SND_SOC_DAIFMT_CBS_CFM:
ret = -EINVAL;
break;
default:
dev_dbg(dev->dev, "dwc : Invalid master/slave format\n");
ret = -EINVAL;
break;
}
return ret;
}

static struct snd_soc_dai_ops dw_i2s_dai_ops = {
.startup = dw_i2s_startup,
.shutdown = dw_i2s_shutdown,
.hw_params = dw_i2s_hw_params,
.prepare = dw_i2s_prepare,
.trigger = dw_i2s_trigger,
.set_fmt = dw_i2s_set_fmt,
};

static const struct snd_soc_component_driver dw_i2s_component = {
Expand All @@ -366,15 +399,17 @@ static int dw_i2s_suspend(struct snd_soc_dai *dai)
{
struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);

clk_disable(dev->clk);
if (dev->capability & DW_I2S_MASTER)
clk_disable(dev->clk);
return 0;
}

static int dw_i2s_resume(struct snd_soc_dai *dai)
{
struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);

clk_enable(dev->clk);
if (dev->capability & DW_I2S_MASTER)
clk_enable(dev->clk);
return 0;
}

Expand Down Expand Up @@ -452,6 +487,14 @@ static int dw_configure_dai(struct dw_i2s_dev *dev,
dw_i2s_dai->capture.rates = rates;
}

if (COMP1_MODE_EN(comp1)) {
dev_dbg(dev->dev, "designware: i2s master mode supported\n");
dev->capability |= DW_I2S_MASTER;
} else {
dev_dbg(dev->dev, "designware: i2s slave mode supported\n");
dev->capability |= DW_I2S_SLAVE;
}

return 0;
}

Expand Down Expand Up @@ -538,6 +581,7 @@ static int dw_i2s_probe(struct platform_device *pdev)
struct resource *res;
int ret;
struct snd_soc_dai_driver *dw_i2s_dai;
const char *clk_id;

dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
if (!dev) {
Expand All @@ -559,32 +603,35 @@ static int dw_i2s_probe(struct platform_device *pdev)
return PTR_ERR(dev->i2s_base);

dev->dev = &pdev->dev;

if (pdata) {
dev->capability = pdata->cap;
clk_id = NULL;
ret = dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata);
if (ret < 0)
return ret;
} else {
clk_id = "i2sclk";
ret = dw_configure_dai_by_dt(dev, dw_i2s_dai, res);
}
if (ret < 0)
return ret;

dev->capability = pdata->cap;
dev->i2s_clk_cfg = pdata->i2s_clk_cfg;
if (!dev->i2s_clk_cfg) {
dev_err(&pdev->dev, "no clock configure method\n");
return -ENODEV;
if (dev->capability & DW_I2S_MASTER) {
if (pdata) {
dev->i2s_clk_cfg = pdata->i2s_clk_cfg;
if (!dev->i2s_clk_cfg) {
dev_err(&pdev->dev, "no clock configure method\n");
return -ENODEV;
}
}
dev->clk = devm_clk_get(&pdev->dev, clk_id);

dev->clk = devm_clk_get(&pdev->dev, NULL);
} else {
ret = dw_configure_dai_by_dt(dev, dw_i2s_dai, res);
if (IS_ERR(dev->clk))
return PTR_ERR(dev->clk);

ret = clk_prepare_enable(dev->clk);
if (ret < 0)
return ret;

dev->clk = devm_clk_get(&pdev->dev, "i2sclk");
}
if (IS_ERR(dev->clk))
return PTR_ERR(dev->clk);

ret = clk_prepare_enable(dev->clk);
if (ret < 0)
return ret;

dev_set_drvdata(&pdev->dev, dev);
ret = devm_snd_soc_register_component(&pdev->dev, &dw_i2s_component,
Expand All @@ -606,15 +653,17 @@ static int dw_i2s_probe(struct platform_device *pdev)
return 0;

err_clk_disable:
clk_disable_unprepare(dev->clk);
if (dev->capability & DW_I2S_MASTER)
clk_disable_unprepare(dev->clk);
return ret;
}

static int dw_i2s_remove(struct platform_device *pdev)
{
struct dw_i2s_dev *dev = dev_get_drvdata(&pdev->dev);

clk_disable_unprepare(dev->clk);
if (dev->capability & DW_I2S_MASTER)
clk_disable_unprepare(dev->clk);

return 0;
}
Expand Down
Loading

0 comments on commit f72362e

Please sign in to comment.