Commit e1f05993 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/link-param', 'asoc/topic/max98090',...

Merge remote-tracking branches 'asoc/topic/link-param', 'asoc/topic/max98090', 'asoc/topic/max98925' and 'asoc/topic/nuc900' into asoc-next
max98925 audio CODEC
This device supports I2C.
Required properties:
- compatible : "maxim,max98925"
- vmon-slot-no : slot number used to send voltage information
- imon-slot-no : slot number used to send current information
- reg : the I2C address of the device for I2C
Example:
codec: max98925@1a {
compatible = "maxim,max98925";
vmon-slot-no = <0>;
imon-slot-no = <2>;
reg = <0x1a>;
};
......@@ -378,6 +378,7 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card);
void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);
int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
const struct snd_soc_pcm_stream *params,
unsigned int num_params,
struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink);
......@@ -530,6 +531,8 @@ struct snd_soc_dapm_widget {
void *priv; /* widget specific data */
struct regulator *regulator; /* attached regulator */
const struct snd_soc_pcm_stream *params; /* params for dai links */
unsigned int num_params; /* number of params for dai links */
unsigned int params_select; /* currently selected param for dai link */
/* dapm control */
int reg; /* negative reg = no direct dapm */
......
......@@ -943,6 +943,7 @@ struct snd_soc_dai_link {
int be_id; /* optional ID for machine driver BE identification */
const struct snd_soc_pcm_stream *params;
unsigned int num_params;
unsigned int dai_fmt; /* format to set on init */
......
......@@ -70,6 +70,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_MAX98090 if I2C
select SND_SOC_MAX98095 if I2C
select SND_SOC_MAX98357A if GPIOLIB
select SND_SOC_MAX98925 if I2C
select SND_SOC_MAX9850 if I2C
select SND_SOC_MAX9768 if I2C
select SND_SOC_MAX9877 if I2C
......@@ -461,6 +462,9 @@ config SND_SOC_MAX98095
config SND_SOC_MAX98357A
tristate
config SND_SOC_MAX98925
tristate
config SND_SOC_MAX9850
tristate
......
......@@ -65,6 +65,7 @@ snd-soc-max98088-objs := max98088.o
snd-soc-max98090-objs := max98090.o
snd-soc-max98095-objs := max98095.o
snd-soc-max98357a-objs := max98357a.o
snd-soc-max98925-objs := max98925.o
snd-soc-max9850-objs := max9850.o
snd-soc-mc13783-objs := mc13783.o
snd-soc-ml26124-objs := ml26124.o
......@@ -249,6 +250,7 @@ obj-$(CONFIG_SND_SOC_MAX98088) += snd-soc-max98088.o
obj-$(CONFIG_SND_SOC_MAX98090) += snd-soc-max98090.o
obj-$(CONFIG_SND_SOC_MAX98095) += snd-soc-max98095.o
obj-$(CONFIG_SND_SOC_MAX98357A) += snd-soc-max98357a.o
obj-$(CONFIG_SND_SOC_MAX98925) += snd-soc-max98925.o
obj-$(CONFIG_SND_SOC_MAX9850) += snd-soc-max9850.o
obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o
obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o
......
......@@ -2605,8 +2605,24 @@ static int max98090_i2c_probe(struct i2c_client *i2c,
return ret;
}
static void max98090_i2c_shutdown(struct i2c_client *i2c)
{
struct max98090_priv *max98090 = dev_get_drvdata(&i2c->dev);
/*
* Enable volume smoothing, disable zero cross. This will cause
* a quick 40ms ramp to mute on shutdown.
*/
regmap_write(max98090->regmap,
M98090_REG_LEVEL_CONTROL, M98090_VSENN_MASK);
regmap_write(max98090->regmap,
M98090_REG_DEVICE_SHUTDOWN, 0x00);
msleep(40);
}
static int max98090_i2c_remove(struct i2c_client *client)
{
max98090_i2c_shutdown(client);
snd_soc_unregister_codec(&client->dev);
return 0;
}
......@@ -2696,6 +2712,7 @@ static struct i2c_driver max98090_i2c_driver = {
.acpi_match_table = ACPI_PTR(max98090_acpi_match),
},
.probe = max98090_i2c_probe,
.shutdown = max98090_i2c_shutdown,
.remove = max98090_i2c_remove,
.id_table = max98090_i2c_id,
};
......
This diff is collapsed.
This diff is collapsed.
......@@ -100,10 +100,7 @@
struct nuc900_audio {
void __iomem *mmio;
spinlock_t lock;
dma_addr_t dma_addr[2];
unsigned long buffersize[2];
unsigned long irq_num;
struct snd_pcm_substream *substream;
struct resource *res;
struct clk *clk;
struct device *dev;
......
......@@ -42,29 +42,10 @@ static const struct snd_pcm_hardware nuc900_pcm_hardware = {
static int nuc900_dma_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct nuc900_audio *nuc900_audio = runtime->private_data;
unsigned long flags;
int ret = 0;
ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
if (ret < 0)
return ret;
spin_lock_irqsave(&nuc900_audio->lock, flags);
nuc900_audio->substream = substream;
nuc900_audio->dma_addr[substream->stream] = runtime->dma_addr;
nuc900_audio->buffersize[substream->stream] =
params_buffer_bytes(params);
spin_unlock_irqrestore(&nuc900_audio->lock, flags);
return ret;
return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
}
static void nuc900_update_dma_register(struct snd_pcm_substream *substream,
dma_addr_t dma_addr, size_t count)
static void nuc900_update_dma_register(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct nuc900_audio *nuc900_audio = runtime->private_data;
......@@ -78,8 +59,8 @@ static void nuc900_update_dma_register(struct snd_pcm_substream *substream,
mmio_len = nuc900_audio->mmio + ACTL_RDST_LENGTH;
}
AUDIO_WRITE(mmio_addr, dma_addr);
AUDIO_WRITE(mmio_len, count);
AUDIO_WRITE(mmio_addr, runtime->dma_addr);
AUDIO_WRITE(mmio_len, runtime->dma_bytes);
}
static void nuc900_dma_start(struct snd_pcm_substream *substream)
......@@ -170,9 +151,7 @@ static int nuc900_dma_prepare(struct snd_pcm_substream *substream)
spin_lock_irqsave(&nuc900_audio->lock, flags);
nuc900_update_dma_register(substream,
nuc900_audio->dma_addr[substream->stream],
nuc900_audio->buffersize[substream->stream]);
nuc900_update_dma_register(substream);
val = AUDIO_READ(nuc900_audio->mmio + ACTL_RESET);
......
......@@ -1298,7 +1298,8 @@ static int soc_link_dai_widgets(struct snd_soc_card *card,
capture_w = cpu_dai->capture_widget;
if (play_w && capture_w) {
ret = snd_soc_dapm_new_pcm(card, dai_link->params,
capture_w, play_w);
dai_link->num_params, capture_w,
play_w);
if (ret != 0) {
dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
play_w->name, capture_w->name, ret);
......@@ -1310,7 +1311,8 @@ static int soc_link_dai_widgets(struct snd_soc_card *card,
capture_w = codec_dai->capture_widget;
if (play_w && capture_w) {
ret = snd_soc_dapm_new_pcm(card, dai_link->params,
capture_w, play_w);
dai_link->num_params, capture_w,
play_w);
if (ret != 0) {
dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
play_w->name, capture_w->name, ret);
......
......@@ -843,6 +843,36 @@ static int dapm_new_pga(struct snd_soc_dapm_widget *w)
return 0;
}
/* create new dapm dai link control */
static int dapm_new_dai_link(struct snd_soc_dapm_widget *w)
{
int i, ret;
struct snd_kcontrol *kcontrol;
struct snd_soc_dapm_context *dapm = w->dapm;
struct snd_card *card = dapm->card->snd_card;
/* create control for links with > 1 config */
if (w->num_params <= 1)
return 0;
/* add kcontrol */
for (i = 0; i < w->num_kcontrols; i++) {
kcontrol = snd_soc_cnew(&w->kcontrol_news[i], w,
w->name, NULL);
ret = snd_ctl_add(card, kcontrol);
if (ret < 0) {
dev_err(dapm->dev,
"ASoC: failed to add widget %s dapm kcontrol %s: %d\n",
w->name, w->kcontrol_news[i].name, ret);
return ret;
}
kcontrol->private_data = w;
w->kcontrols[i] = kcontrol;
}
return 0;
}
/* We implement power down on suspend by checking the power state of
* the ALSA card - when we are suspending the ALSA state for the card
* is set to D3.
......@@ -2712,6 +2742,9 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card)
case snd_soc_dapm_out_drv:
dapm_new_pga(w);
break;
case snd_soc_dapm_dai_link:
dapm_new_dai_link(w);
break;
default:
break;
}
......@@ -3186,7 +3219,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
{
struct snd_soc_dapm_path *source_p, *sink_p;
struct snd_soc_dai *source, *sink;
const struct snd_soc_pcm_stream *config = w->params;
const struct snd_soc_pcm_stream *config = w->params + w->params_select;
struct snd_pcm_substream substream;
struct snd_pcm_hw_params *params = NULL;
u64 fmt;
......@@ -3278,22 +3311,97 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
return ret;
}
static int snd_soc_dapm_dai_link_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol);
ucontrol->value.integer.value[0] = w->params_select;
return 0;
}
static int snd_soc_dapm_dai_link_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol);
/* Can't change the config when widget is already powered */
if (w->power)
return -EBUSY;
if (ucontrol->value.integer.value[0] == w->params_select)
return 0;
if (ucontrol->value.integer.value[0] >= w->num_params)
return -EINVAL;
w->params_select = ucontrol->value.integer.value[0];
return 0;
}
int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
const struct snd_soc_pcm_stream *params,
unsigned int num_params,
struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{
struct snd_soc_dapm_widget template;
struct snd_soc_dapm_widget *w;
size_t len;
char *link_name;
int ret;
len = strlen(source->name) + strlen(sink->name) + 2;
link_name = devm_kzalloc(card->dev, len, GFP_KERNEL);
if (!link_name)
int ret, count;
unsigned long private_value;
const char **w_param_text;
struct soc_enum w_param_enum[] = {
SOC_ENUM_SINGLE(0, 0, 0, NULL),
};
struct snd_kcontrol_new kcontrol_dai_link[] = {
SOC_ENUM_EXT(NULL, w_param_enum[0],
snd_soc_dapm_dai_link_get,
snd_soc_dapm_dai_link_put),
};
const struct snd_soc_pcm_stream *config = params;
w_param_text = devm_kcalloc(card->dev, num_params,
sizeof(char *), GFP_KERNEL);
if (!w_param_text)
return -ENOMEM;
snprintf(link_name, len, "%s-%s", source->name, sink->name);
link_name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-%s",
source->name, sink->name);
if (!link_name) {
ret = -ENOMEM;
goto outfree_w_param;
}
for (count = 0 ; count < num_params; count++) {
if (!config->stream_name) {
dev_warn(card->dapm.dev,
"ASoC: anonymous config %d for dai link %s\n",
count, link_name);
w_param_text[count] =
devm_kasprintf(card->dev, GFP_KERNEL,
"Anonymous Configuration %d",
count);
if (!w_param_text[count]) {
ret = -ENOMEM;
goto outfree_link_name;
}
} else {
w_param_text[count] = devm_kmemdup(card->dev,
config->stream_name,
strlen(config->stream_name) + 1,
GFP_KERNEL);
if (!w_param_text[count]) {
ret = -ENOMEM;
goto outfree_link_name;
}
}
config++;
}
w_param_enum[0].items = num_params;
w_param_enum[0].texts = w_param_text;
memset(&template, 0, sizeof(template));
template.reg = SND_SOC_NOPM;
......@@ -3302,6 +3410,30 @@ int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
template.event = snd_soc_dai_link_event;
template.event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_PRE_PMD;
template.num_kcontrols = 1;
/* duplicate w_param_enum on heap so that memory persists */
private_value =
(unsigned long) devm_kmemdup(card->dev,
(void *)(kcontrol_dai_link[0].private_value),
sizeof(struct soc_enum), GFP_KERNEL);
if (!private_value) {
dev_err(card->dev, "ASoC: Failed to create control for %s widget\n",
link_name);
ret = -ENOMEM;
goto outfree_link_name;
}
kcontrol_dai_link[0].private_value = private_value;
/* duplicate kcontrol_dai_link on heap so that memory persists */
template.kcontrol_news =
devm_kmemdup(card->dev, &kcontrol_dai_link[0],
sizeof(struct snd_kcontrol_new),
GFP_KERNEL);
if (!template.kcontrol_news) {
dev_err(card->dev, "ASoC: Failed to create control for %s widget\n",
link_name);
ret = -ENOMEM;
goto outfree_private_value;
}
dev_dbg(card->dev, "ASoC: adding %s widget\n", link_name);
......@@ -3309,15 +3441,32 @@ int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
if (!w) {
dev_err(card->dev, "ASoC: Failed to create %s widget\n",
link_name);
return -ENOMEM;
ret = -ENOMEM;
goto outfree_kcontrol_news;
}
w->params = params;
w->num_params = num_params;
ret = snd_soc_dapm_add_path(&card->dapm, source, w, NULL, NULL);
if (ret)
return ret;
goto outfree_w;
return snd_soc_dapm_add_path(&card->dapm, w, sink, NULL, NULL);
outfree_w:
devm_kfree(card->dev, w);
outfree_kcontrol_news:
devm_kfree(card->dev, (void *)template.kcontrol_news);
outfree_private_value:
devm_kfree(card->dev, (void *)private_value);
outfree_link_name:
devm_kfree(card->dev, link_name);
outfree_w_param:
for (count = 0 ; count < num_params; count++)
devm_kfree(card->dev, (void *)w_param_text[count]);
devm_kfree(card->dev, w_param_text);
return ret;
}
int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
......
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