mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-04-13 09:59:31 +00:00
ASoC: soc.h: clarify Codec2Codec params
snd_soc_dai_link has params/num_params, but it is unclear that params for what. This patch clarify it is params for Codec2Codec. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87o7o5c2lk.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
750e1a226c
commit
7ddc7f91be
4 changed files with 47 additions and 30 deletions
|
@ -684,8 +684,14 @@ struct snd_soc_dai_link {
|
||||||
|
|
||||||
int id; /* optional ID for machine driver link identification */
|
int id; /* optional ID for machine driver link identification */
|
||||||
|
|
||||||
const struct snd_soc_pcm_stream *params;
|
/*
|
||||||
unsigned int num_params;
|
* for Codec2Codec
|
||||||
|
*/
|
||||||
|
const struct snd_soc_pcm_stream *c2c_params;
|
||||||
|
unsigned int num_c2c_params;
|
||||||
|
|
||||||
|
const struct snd_soc_pcm_stream *params; /* REMOVE ME */
|
||||||
|
unsigned int num_params; /* REMOVE ME */
|
||||||
|
|
||||||
unsigned int dai_fmt; /* format to set on init */
|
unsigned int dai_fmt; /* format to set on init */
|
||||||
|
|
||||||
|
@ -1065,7 +1071,7 @@ struct snd_soc_pcm_runtime {
|
||||||
struct snd_soc_dai_link *dai_link;
|
struct snd_soc_dai_link *dai_link;
|
||||||
struct snd_pcm_ops ops;
|
struct snd_pcm_ops ops;
|
||||||
|
|
||||||
unsigned int params_select; /* currently selected param for dai link */
|
unsigned int c2c_params_select; /* currently selected c2c_param for dai link */
|
||||||
|
|
||||||
/* Dynamic PCM BE runtime data */
|
/* Dynamic PCM BE runtime data */
|
||||||
struct snd_soc_dpcm_runtime dpcm[SNDRV_PCM_STREAM_LAST + 1];
|
struct snd_soc_dpcm_runtime dpcm[SNDRV_PCM_STREAM_LAST + 1];
|
||||||
|
|
|
@ -2294,6 +2294,9 @@ EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls);
|
||||||
*/
|
*/
|
||||||
int snd_soc_register_card(struct snd_soc_card *card)
|
int snd_soc_register_card(struct snd_soc_card *card)
|
||||||
{
|
{
|
||||||
|
struct snd_soc_dai_link *dai_link;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (!card->name || !card->dev)
|
if (!card->name || !card->dev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
@ -2314,6 +2317,14 @@ int snd_soc_register_card(struct snd_soc_card *card)
|
||||||
mutex_init(&card->dapm_mutex);
|
mutex_init(&card->dapm_mutex);
|
||||||
mutex_init(&card->pcm_mutex);
|
mutex_init(&card->pcm_mutex);
|
||||||
|
|
||||||
|
/* REMOVE ME */
|
||||||
|
for_each_card_prelinks(card, i, dai_link) {
|
||||||
|
if (!dai_link->c2c_params) {
|
||||||
|
dai_link->c2c_params = dai_link->params;
|
||||||
|
dai_link->num_c2c_params = dai_link->num_params;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return snd_soc_bind_card(card);
|
return snd_soc_bind_card(card);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(snd_soc_register_card);
|
EXPORT_SYMBOL_GPL(snd_soc_register_card);
|
||||||
|
|
|
@ -1075,7 +1075,7 @@ static int dapm_new_dai_link(struct snd_soc_dapm_widget *w)
|
||||||
struct snd_soc_pcm_runtime *rtd = w->priv;
|
struct snd_soc_pcm_runtime *rtd = w->priv;
|
||||||
|
|
||||||
/* create control for links with > 1 config */
|
/* create control for links with > 1 config */
|
||||||
if (rtd->dai_link->num_params <= 1)
|
if (rtd->dai_link->num_c2c_params <= 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* add kcontrol */
|
/* add kcontrol */
|
||||||
|
@ -3864,7 +3864,7 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
|
||||||
* either party on the link to alter the configuration if
|
* either party on the link to alter the configuration if
|
||||||
* necessary
|
* necessary
|
||||||
*/
|
*/
|
||||||
config = rtd->dai_link->params + rtd->params_select;
|
config = rtd->dai_link->c2c_params + rtd->c2c_params_select;
|
||||||
if (!config) {
|
if (!config) {
|
||||||
dev_err(w->dapm->dev, "ASoC: link config missing\n");
|
dev_err(w->dapm->dev, "ASoC: link config missing\n");
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
@ -4010,7 +4010,7 @@ static int snd_soc_dapm_dai_link_get(struct snd_kcontrol *kcontrol,
|
||||||
struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol);
|
struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol);
|
||||||
struct snd_soc_pcm_runtime *rtd = w->priv;
|
struct snd_soc_pcm_runtime *rtd = w->priv;
|
||||||
|
|
||||||
ucontrol->value.enumerated.item[0] = rtd->params_select;
|
ucontrol->value.enumerated.item[0] = rtd->c2c_params_select;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4025,13 +4025,13 @@ static int snd_soc_dapm_dai_link_put(struct snd_kcontrol *kcontrol,
|
||||||
if (w->power)
|
if (w->power)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
if (ucontrol->value.enumerated.item[0] == rtd->params_select)
|
if (ucontrol->value.enumerated.item[0] == rtd->c2c_params_select)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ucontrol->value.enumerated.item[0] >= rtd->dai_link->num_params)
|
if (ucontrol->value.enumerated.item[0] >= rtd->dai_link->num_c2c_params)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
rtd->params_select = ucontrol->value.enumerated.item[0];
|
rtd->c2c_params_select = ucontrol->value.enumerated.item[0];
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -4039,7 +4039,7 @@ static int snd_soc_dapm_dai_link_put(struct snd_kcontrol *kcontrol,
|
||||||
static void
|
static void
|
||||||
snd_soc_dapm_free_kcontrol(struct snd_soc_card *card,
|
snd_soc_dapm_free_kcontrol(struct snd_soc_card *card,
|
||||||
unsigned long *private_value,
|
unsigned long *private_value,
|
||||||
int num_params,
|
int num_c2c_params,
|
||||||
const char **w_param_text)
|
const char **w_param_text)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
@ -4049,7 +4049,7 @@ snd_soc_dapm_free_kcontrol(struct snd_soc_card *card,
|
||||||
if (!w_param_text)
|
if (!w_param_text)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (count = 0 ; count < num_params; count++)
|
for (count = 0 ; count < num_c2c_params; count++)
|
||||||
devm_kfree(card->dev, (void *)w_param_text[count]);
|
devm_kfree(card->dev, (void *)w_param_text[count]);
|
||||||
devm_kfree(card->dev, w_param_text);
|
devm_kfree(card->dev, w_param_text);
|
||||||
}
|
}
|
||||||
|
@ -4057,8 +4057,8 @@ snd_soc_dapm_free_kcontrol(struct snd_soc_card *card,
|
||||||
static struct snd_kcontrol_new *
|
static struct snd_kcontrol_new *
|
||||||
snd_soc_dapm_alloc_kcontrol(struct snd_soc_card *card,
|
snd_soc_dapm_alloc_kcontrol(struct snd_soc_card *card,
|
||||||
char *link_name,
|
char *link_name,
|
||||||
const struct snd_soc_pcm_stream *params,
|
const struct snd_soc_pcm_stream *c2c_params,
|
||||||
int num_params, const char **w_param_text,
|
int num_c2c_params, const char **w_param_text,
|
||||||
unsigned long *private_value)
|
unsigned long *private_value)
|
||||||
{
|
{
|
||||||
struct soc_enum w_param_enum[] = {
|
struct soc_enum w_param_enum[] = {
|
||||||
|
@ -4070,10 +4070,10 @@ snd_soc_dapm_alloc_kcontrol(struct snd_soc_card *card,
|
||||||
snd_soc_dapm_dai_link_put),
|
snd_soc_dapm_dai_link_put),
|
||||||
};
|
};
|
||||||
struct snd_kcontrol_new *kcontrol_news;
|
struct snd_kcontrol_new *kcontrol_news;
|
||||||
const struct snd_soc_pcm_stream *config = params;
|
const struct snd_soc_pcm_stream *config = c2c_params;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
for (count = 0 ; count < num_params; count++) {
|
for (count = 0 ; count < num_c2c_params; count++) {
|
||||||
if (!config->stream_name) {
|
if (!config->stream_name) {
|
||||||
dev_warn(card->dapm.dev,
|
dev_warn(card->dapm.dev,
|
||||||
"ASoC: anonymous config %d for dai link %s\n",
|
"ASoC: anonymous config %d for dai link %s\n",
|
||||||
|
@ -4093,7 +4093,7 @@ snd_soc_dapm_alloc_kcontrol(struct snd_soc_card *card,
|
||||||
config++;
|
config++;
|
||||||
}
|
}
|
||||||
|
|
||||||
w_param_enum[0].items = num_params;
|
w_param_enum[0].items = num_c2c_params;
|
||||||
w_param_enum[0].texts = w_param_text;
|
w_param_enum[0].texts = w_param_text;
|
||||||
|
|
||||||
*private_value =
|
*private_value =
|
||||||
|
@ -4118,7 +4118,7 @@ snd_soc_dapm_alloc_kcontrol(struct snd_soc_card *card,
|
||||||
return kcontrol_news;
|
return kcontrol_news;
|
||||||
|
|
||||||
outfree_w_param:
|
outfree_w_param:
|
||||||
snd_soc_dapm_free_kcontrol(card, private_value, num_params, w_param_text);
|
snd_soc_dapm_free_kcontrol(card, private_value, num_c2c_params, w_param_text);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4146,17 +4146,17 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card,
|
||||||
w_param_text = NULL;
|
w_param_text = NULL;
|
||||||
kcontrol_news = NULL;
|
kcontrol_news = NULL;
|
||||||
num_kcontrols = 0;
|
num_kcontrols = 0;
|
||||||
if (rtd->dai_link->num_params > 1) {
|
if (rtd->dai_link->num_c2c_params > 1) {
|
||||||
w_param_text = devm_kcalloc(card->dev,
|
w_param_text = devm_kcalloc(card->dev,
|
||||||
rtd->dai_link->num_params,
|
rtd->dai_link->num_c2c_params,
|
||||||
sizeof(char *), GFP_KERNEL);
|
sizeof(char *), GFP_KERNEL);
|
||||||
if (!w_param_text)
|
if (!w_param_text)
|
||||||
goto param_fail;
|
goto param_fail;
|
||||||
|
|
||||||
num_kcontrols = 1;
|
num_kcontrols = 1;
|
||||||
kcontrol_news = snd_soc_dapm_alloc_kcontrol(card, link_name,
|
kcontrol_news = snd_soc_dapm_alloc_kcontrol(card, link_name,
|
||||||
rtd->dai_link->params,
|
rtd->dai_link->c2c_params,
|
||||||
rtd->dai_link->num_params,
|
rtd->dai_link->num_c2c_params,
|
||||||
w_param_text, &private_value);
|
w_param_text, &private_value);
|
||||||
if (!kcontrol_news)
|
if (!kcontrol_news)
|
||||||
goto param_fail;
|
goto param_fail;
|
||||||
|
@ -4187,7 +4187,7 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card,
|
||||||
outfree_kcontrol_news:
|
outfree_kcontrol_news:
|
||||||
devm_kfree(card->dev, (void *)template.kcontrol_news);
|
devm_kfree(card->dev, (void *)template.kcontrol_news);
|
||||||
snd_soc_dapm_free_kcontrol(card, &private_value,
|
snd_soc_dapm_free_kcontrol(card, &private_value,
|
||||||
rtd->dai_link->num_params, w_param_text);
|
rtd->dai_link->num_c2c_params, w_param_text);
|
||||||
param_fail:
|
param_fail:
|
||||||
devm_kfree(card->dev, link_name);
|
devm_kfree(card->dev, link_name);
|
||||||
name_fail:
|
name_fail:
|
||||||
|
@ -4336,7 +4336,7 @@ static void dapm_connect_dai_pair(struct snd_soc_card *card,
|
||||||
struct snd_pcm_str *streams = rtd->pcm->streams;
|
struct snd_pcm_str *streams = rtd->pcm->streams;
|
||||||
int stream;
|
int stream;
|
||||||
|
|
||||||
if (dai_link->params) {
|
if (dai_link->c2c_params) {
|
||||||
playback_cpu = snd_soc_dai_get_widget_capture(cpu_dai);
|
playback_cpu = snd_soc_dai_get_widget_capture(cpu_dai);
|
||||||
capture_cpu = snd_soc_dai_get_widget_playback(cpu_dai);
|
capture_cpu = snd_soc_dai_get_widget_playback(cpu_dai);
|
||||||
} else {
|
} else {
|
||||||
|
@ -4349,7 +4349,7 @@ static void dapm_connect_dai_pair(struct snd_soc_card *card,
|
||||||
codec = snd_soc_dai_get_widget(codec_dai, stream);
|
codec = snd_soc_dai_get_widget(codec_dai, stream);
|
||||||
|
|
||||||
if (playback_cpu && codec) {
|
if (playback_cpu && codec) {
|
||||||
if (dai_link->params && !rtd->c2c_widget[stream]) {
|
if (dai_link->c2c_params && !rtd->c2c_widget[stream]) {
|
||||||
substream = streams[stream].substream;
|
substream = streams[stream].substream;
|
||||||
dai = snd_soc_dapm_new_dai(card, substream, "playback");
|
dai = snd_soc_dapm_new_dai(card, substream, "playback");
|
||||||
if (IS_ERR(dai))
|
if (IS_ERR(dai))
|
||||||
|
@ -4368,7 +4368,7 @@ capture:
|
||||||
codec = snd_soc_dai_get_widget(codec_dai, stream);
|
codec = snd_soc_dai_get_widget(codec_dai, stream);
|
||||||
|
|
||||||
if (codec && capture_cpu) {
|
if (codec && capture_cpu) {
|
||||||
if (dai_link->params && !rtd->c2c_widget[stream]) {
|
if (dai_link->c2c_params && !rtd->c2c_widget[stream]) {
|
||||||
substream = streams[stream].substream;
|
substream = streams[stream].substream;
|
||||||
dai = snd_soc_dapm_new_dai(card, substream, "capture");
|
dai = snd_soc_dapm_new_dai(card, substream, "capture");
|
||||||
if (IS_ERR(dai))
|
if (IS_ERR(dai))
|
||||||
|
|
|
@ -2793,9 +2793,9 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
|
||||||
struct snd_soc_dai *codec_dai;
|
struct snd_soc_dai *codec_dai;
|
||||||
|
|
||||||
/* Adapt stream for codec2codec links */
|
/* Adapt stream for codec2codec links */
|
||||||
int cpu_capture = rtd->dai_link->params ?
|
int cpu_capture = rtd->dai_link->c2c_params ?
|
||||||
SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE;
|
SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE;
|
||||||
int cpu_playback = rtd->dai_link->params ?
|
int cpu_playback = rtd->dai_link->c2c_params ?
|
||||||
SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
|
SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
|
||||||
|
|
||||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
||||||
|
@ -2839,7 +2839,7 @@ static int soc_create_pcm(struct snd_pcm **pcm,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* create the PCM */
|
/* create the PCM */
|
||||||
if (rtd->dai_link->params) {
|
if (rtd->dai_link->c2c_params) {
|
||||||
snprintf(new_name, sizeof(new_name), "codec2codec(%s)",
|
snprintf(new_name, sizeof(new_name), "codec2codec(%s)",
|
||||||
rtd->dai_link->stream_name);
|
rtd->dai_link->stream_name);
|
||||||
|
|
||||||
|
@ -2896,7 +2896,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
|
||||||
* don't interface with the outside world or application layer
|
* don't interface with the outside world or application layer
|
||||||
* we don't have to do any special handling on close.
|
* we don't have to do any special handling on close.
|
||||||
*/
|
*/
|
||||||
if (!rtd->dai_link->params)
|
if (!rtd->dai_link->c2c_params)
|
||||||
rtd->close_delayed_work_func = snd_soc_close_delayed_work;
|
rtd->close_delayed_work_func = snd_soc_close_delayed_work;
|
||||||
|
|
||||||
rtd->pcm = pcm;
|
rtd->pcm = pcm;
|
||||||
|
@ -2904,7 +2904,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
|
||||||
pcm->private_data = rtd;
|
pcm->private_data = rtd;
|
||||||
pcm->no_device_suspend = true;
|
pcm->no_device_suspend = true;
|
||||||
|
|
||||||
if (rtd->dai_link->no_pcm || rtd->dai_link->params) {
|
if (rtd->dai_link->no_pcm || rtd->dai_link->c2c_params) {
|
||||||
if (playback)
|
if (playback)
|
||||||
pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
|
pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
|
||||||
if (capture)
|
if (capture)
|
||||||
|
|
Loading…
Add table
Reference in a new issue