Commit dbfd5475 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/88pm860x', 'asoc/topic/ak4613',...

Merge remote-tracking branches 'asoc/topic/88pm860x', 'asoc/topic/ak4613', 'asoc/topic/amd', 'asoc/topic/atmel' and 'asoc/topic/au1x' into asoc-next
...@@ -850,6 +850,9 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream) ...@@ -850,6 +850,9 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct audio_substream_data *rtd = runtime->private_data; struct audio_substream_data *rtd = runtime->private_data;
if (!rtd)
return -EINVAL;
buffersize = frames_to_bytes(runtime, runtime->buffer_size); buffersize = frames_to_bytes(runtime, runtime->buffer_size);
bytescount = acp_get_byte_count(rtd->acp_mmio, substream->stream); bytescount = acp_get_byte_count(rtd->acp_mmio, substream->stream);
...@@ -875,6 +878,8 @@ static int acp_dma_prepare(struct snd_pcm_substream *substream) ...@@ -875,6 +878,8 @@ static int acp_dma_prepare(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct audio_substream_data *rtd = runtime->private_data; struct audio_substream_data *rtd = runtime->private_data;
if (!rtd)
return -EINVAL;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
config_acp_dma_channel(rtd->acp_mmio, SYSRAM_TO_ACP_CH_NUM, config_acp_dma_channel(rtd->acp_mmio, SYSRAM_TO_ACP_CH_NUM,
PLAYBACK_START_DMA_DESCR_CH12, PLAYBACK_START_DMA_DESCR_CH12,
...@@ -1091,7 +1096,11 @@ static int acp_audio_probe(struct platform_device *pdev) ...@@ -1091,7 +1096,11 @@ static int acp_audio_probe(struct platform_device *pdev)
dev_set_drvdata(&pdev->dev, audio_drv_data); dev_set_drvdata(&pdev->dev, audio_drv_data);
/* Initialize the ACP */ /* Initialize the ACP */
acp_init(audio_drv_data->acp_mmio, audio_drv_data->asic_type); status = acp_init(audio_drv_data->acp_mmio, audio_drv_data->asic_type);
if (status) {
dev_err(&pdev->dev, "ACP Init failed status:%d\n", status);
return status;
}
status = snd_soc_register_platform(&pdev->dev, &acp_asoc_platform); status = snd_soc_register_platform(&pdev->dev, &acp_asoc_platform);
if (status != 0) { if (status != 0) {
...@@ -1108,9 +1117,12 @@ static int acp_audio_probe(struct platform_device *pdev) ...@@ -1108,9 +1117,12 @@ static int acp_audio_probe(struct platform_device *pdev)
static int acp_audio_remove(struct platform_device *pdev) static int acp_audio_remove(struct platform_device *pdev)
{ {
int status;
struct audio_drv_data *adata = dev_get_drvdata(&pdev->dev); struct audio_drv_data *adata = dev_get_drvdata(&pdev->dev);
acp_deinit(adata->acp_mmio); status = acp_deinit(adata->acp_mmio);
if (status)
dev_err(&pdev->dev, "ACP Deinit failed status:%d\n", status);
snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_platform(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
...@@ -1120,9 +1132,14 @@ static int acp_audio_remove(struct platform_device *pdev) ...@@ -1120,9 +1132,14 @@ static int acp_audio_remove(struct platform_device *pdev)
static int acp_pcm_resume(struct device *dev) static int acp_pcm_resume(struct device *dev)
{ {
u16 bank; u16 bank;
int status;
struct audio_drv_data *adata = dev_get_drvdata(dev); struct audio_drv_data *adata = dev_get_drvdata(dev);
acp_init(adata->acp_mmio, adata->asic_type); status = acp_init(adata->acp_mmio, adata->asic_type);
if (status) {
dev_err(dev, "ACP Init failed status:%d\n", status);
return status;
}
if (adata->play_stream && adata->play_stream->runtime) { if (adata->play_stream && adata->play_stream->runtime) {
/* For Stoney, Memory gating is disabled,i.e SRAM Banks /* For Stoney, Memory gating is disabled,i.e SRAM Banks
...@@ -1154,18 +1171,26 @@ static int acp_pcm_resume(struct device *dev) ...@@ -1154,18 +1171,26 @@ static int acp_pcm_resume(struct device *dev)
static int acp_pcm_runtime_suspend(struct device *dev) static int acp_pcm_runtime_suspend(struct device *dev)
{ {
int status;
struct audio_drv_data *adata = dev_get_drvdata(dev); struct audio_drv_data *adata = dev_get_drvdata(dev);
acp_deinit(adata->acp_mmio); status = acp_deinit(adata->acp_mmio);
if (status)
dev_err(dev, "ACP Deinit failed status:%d\n", status);
acp_reg_write(0, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); acp_reg_write(0, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);
return 0; return 0;
} }
static int acp_pcm_runtime_resume(struct device *dev) static int acp_pcm_runtime_resume(struct device *dev)
{ {
int status;
struct audio_drv_data *adata = dev_get_drvdata(dev); struct audio_drv_data *adata = dev_get_drvdata(dev);
acp_init(adata->acp_mmio, adata->asic_type); status = acp_init(adata->acp_mmio, adata->asic_type);
if (status) {
dev_err(dev, "ACP Init failed status:%d\n", status);
return status;
}
acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);
return 0; return 0;
} }
......
...@@ -308,15 +308,9 @@ static int atmel_classd_codec_resume(struct snd_soc_codec *codec) ...@@ -308,15 +308,9 @@ static int atmel_classd_codec_resume(struct snd_soc_codec *codec)
return regcache_sync(dd->regmap); return regcache_sync(dd->regmap);
} }
static struct regmap *atmel_classd_codec_get_remap(struct device *dev)
{
return dev_get_regmap(dev, NULL);
}
static struct snd_soc_codec_driver soc_codec_dev_classd = { static struct snd_soc_codec_driver soc_codec_dev_classd = {
.probe = atmel_classd_codec_probe, .probe = atmel_classd_codec_probe,
.resume = atmel_classd_codec_resume, .resume = atmel_classd_codec_resume,
.get_regmap = atmel_classd_codec_get_remap,
.component_driver = { .component_driver = {
.controls = atmel_classd_snd_controls, .controls = atmel_classd_snd_controls,
.num_controls = ARRAY_SIZE(atmel_classd_snd_controls), .num_controls = ARRAY_SIZE(atmel_classd_snd_controls),
......
...@@ -91,8 +91,8 @@ static unsigned short au1xac97c_ac97_read(struct snd_ac97 *ac97, ...@@ -91,8 +91,8 @@ static unsigned short au1xac97c_ac97_read(struct snd_ac97 *ac97,
do { do {
mutex_lock(&ctx->lock); mutex_lock(&ctx->lock);
tmo = 5; tmo = 6;
while ((RD(ctx, AC97_STATUS) & STAT_CP) && tmo--) while ((RD(ctx, AC97_STATUS) & STAT_CP) && --tmo)
udelay(21); /* wait an ac97 frame time */ udelay(21); /* wait an ac97 frame time */
if (!tmo) { if (!tmo) {
pr_debug("ac97rd timeout #1\n"); pr_debug("ac97rd timeout #1\n");
...@@ -105,7 +105,7 @@ static unsigned short au1xac97c_ac97_read(struct snd_ac97 *ac97, ...@@ -105,7 +105,7 @@ static unsigned short au1xac97c_ac97_read(struct snd_ac97 *ac97,
* poll, Forrest, poll... * poll, Forrest, poll...
*/ */
tmo = 0x10000; tmo = 0x10000;
while ((RD(ctx, AC97_STATUS) & STAT_CP) && tmo--) while ((RD(ctx, AC97_STATUS) & STAT_CP) && --tmo)
asm volatile ("nop"); asm volatile ("nop");
data = RD(ctx, AC97_CMDRESP); data = RD(ctx, AC97_CMDRESP);
......
...@@ -1319,6 +1319,7 @@ static int pm860x_probe(struct snd_soc_codec *codec) ...@@ -1319,6 +1319,7 @@ static int pm860x_probe(struct snd_soc_codec *codec)
int i, ret; int i, ret;
pm860x->codec = codec; pm860x->codec = codec;
snd_soc_codec_init_regmap(codec, pm860x->regmap);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
ret = request_threaded_irq(pm860x->irq[i], NULL, ret = request_threaded_irq(pm860x->irq[i], NULL,
...@@ -1348,18 +1349,10 @@ static int pm860x_remove(struct snd_soc_codec *codec) ...@@ -1348,18 +1349,10 @@ static int pm860x_remove(struct snd_soc_codec *codec)
return 0; return 0;
} }
static struct regmap *pm860x_get_regmap(struct device *dev)
{
struct pm860x_priv *pm860x = dev_get_drvdata(dev);
return pm860x->regmap;
}
static const struct snd_soc_codec_driver soc_codec_dev_pm860x = { static const struct snd_soc_codec_driver soc_codec_dev_pm860x = {
.probe = pm860x_probe, .probe = pm860x_probe,
.remove = pm860x_remove, .remove = pm860x_remove,
.set_bias_level = pm860x_set_bias_level, .set_bias_level = pm860x_set_bias_level,
.get_regmap = pm860x_get_regmap,
.component_driver = { .component_driver = {
.controls = pm860x_snd_controls, .controls = pm860x_snd_controls,
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/delay.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of_device.h> #include <linux/of_device.h>
...@@ -95,6 +96,9 @@ struct ak4613_priv { ...@@ -95,6 +96,9 @@ struct ak4613_priv {
struct mutex lock; struct mutex lock;
const struct ak4613_interface *iface; const struct ak4613_interface *iface;
struct snd_pcm_hw_constraint_list constraint; struct snd_pcm_hw_constraint_list constraint;
struct work_struct dummy_write_work;
struct snd_soc_component *component;
unsigned int rate;
unsigned int sysclk; unsigned int sysclk;
unsigned int fmt; unsigned int fmt;
...@@ -392,6 +396,7 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -392,6 +396,7 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream,
default: default:
return -EINVAL; return -EINVAL;
} }
priv->rate = rate;
/* /*
* FIXME * FIXME
...@@ -467,11 +472,83 @@ static int ak4613_set_bias_level(struct snd_soc_codec *codec, ...@@ -467,11 +472,83 @@ static int ak4613_set_bias_level(struct snd_soc_codec *codec,
return 0; return 0;
} }
static void ak4613_dummy_write(struct work_struct *work)
{
struct ak4613_priv *priv = container_of(work,
struct ak4613_priv,
dummy_write_work);
struct snd_soc_component *component = priv->component;
unsigned int mgmt1;
unsigned int mgmt3;
/*
* PW_MGMT1 / PW_MGMT3 needs dummy write at least after 5 LR clocks
*
* Note
*
* To avoid extra delay, we want to avoid preemption here,
* but we can't. Because it uses I2C access which is using IRQ
* and sleep. Thus, delay might be more than 5 LR clocks
* see also
* ak4613_dai_trigger()
*/
udelay(5000000 / priv->rate);
snd_soc_component_read(component, PW_MGMT1, &mgmt1);
snd_soc_component_read(component, PW_MGMT3, &mgmt3);
snd_soc_component_write(component, PW_MGMT1, mgmt1);
snd_soc_component_write(component, PW_MGMT3, mgmt3);
}
static int ak4613_dai_trigger(struct snd_pcm_substream *substream, int cmd,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec);
/*
* FIXME
*
* PW_MGMT1 / PW_MGMT3 needs dummy write at least after 5 LR clocks
* from Power Down Release. Otherwise, Playback volume will be 0dB.
* To avoid complex multiple delay/dummy_write method from
* ak4613_set_bias_level() / SND_SOC_DAPM_DAC_E("DACx", ...),
* call it once here.
*
* But, unfortunately, we can't "write" here because here is atomic
* context (It uses I2C access for writing).
* Thus, use schedule_work() to switching to normal context
* immediately.
*
* Note
*
* Calling ak4613_dummy_write() function might be delayed.
* In such case, ak4613 volume might be temporarily 0dB when
* beggining of playback.
* see also
* ak4613_dummy_write()
*/
if ((cmd != SNDRV_PCM_TRIGGER_START) &&
(cmd != SNDRV_PCM_TRIGGER_RESUME))
return 0;
if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
return 0;
priv->component = &codec->component;
schedule_work(&priv->dummy_write_work);
return 0;
}
static const struct snd_soc_dai_ops ak4613_dai_ops = { static const struct snd_soc_dai_ops ak4613_dai_ops = {
.startup = ak4613_dai_startup, .startup = ak4613_dai_startup,
.shutdown = ak4613_dai_shutdown, .shutdown = ak4613_dai_shutdown,
.set_sysclk = ak4613_dai_set_sysclk, .set_sysclk = ak4613_dai_set_sysclk,
.set_fmt = ak4613_dai_set_fmt, .set_fmt = ak4613_dai_set_fmt,
.trigger = ak4613_dai_trigger,
.hw_params = ak4613_dai_hw_params, .hw_params = ak4613_dai_hw_params,
}; };
...@@ -590,6 +667,7 @@ static int ak4613_i2c_probe(struct i2c_client *i2c, ...@@ -590,6 +667,7 @@ static int ak4613_i2c_probe(struct i2c_client *i2c,
priv->iface = NULL; priv->iface = NULL;
priv->cnt = 0; priv->cnt = 0;
priv->sysclk = 0; priv->sysclk = 0;
INIT_WORK(&priv->dummy_write_work, ak4613_dummy_write);
mutex_init(&priv->lock); mutex_init(&priv->lock);
......
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