Commit 899a8e7d authored by Mark Brown's avatar Mark Brown

ASoC: soc.h: random cleanup

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

These are random cleanup for soc.h
parents e7ff7307 3289dc02
......@@ -1062,7 +1062,8 @@ struct snd_soc_pcm_runtime {
unsigned int params_select; /* currently selected param for dai link */
/* Dynamic PCM BE runtime data */
struct snd_soc_dpcm_runtime dpcm[2];
struct snd_soc_dpcm_runtime dpcm[SNDRV_PCM_STREAM_LAST + 1];
struct snd_soc_dapm_widget *c2c_widget[SNDRV_PCM_STREAM_LAST + 1];
long pmdown_time;
......@@ -1078,11 +1079,6 @@ struct snd_soc_pcm_runtime {
* asoc_rtd_to_codec()
*/
struct snd_soc_dai **dais;
unsigned int num_codecs;
unsigned int num_cpus;
struct snd_soc_dapm_widget *playback_widget;
struct snd_soc_dapm_widget *capture_widget;
struct delayed_work delayed_work;
void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd);
......@@ -1108,7 +1104,7 @@ struct snd_soc_pcm_runtime {
};
/* see soc_new_pcm_runtime() */
#define asoc_rtd_to_cpu(rtd, n) (rtd)->dais[n]
#define asoc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->num_cpus]
#define asoc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->dai_link->num_cpus]
#define asoc_substream_to_rtd(substream) \
(struct snd_soc_pcm_runtime *)snd_pcm_substream_chip(substream)
......@@ -1118,15 +1114,15 @@ struct snd_soc_pcm_runtime {
(i)++)
#define for_each_rtd_cpu_dais(rtd, i, dai) \
for ((i) = 0; \
((i) < rtd->num_cpus) && ((dai) = asoc_rtd_to_cpu(rtd, i)); \
((i) < rtd->dai_link->num_cpus) && ((dai) = asoc_rtd_to_cpu(rtd, i)); \
(i)++)
#define for_each_rtd_codec_dais(rtd, i, dai) \
for ((i) = 0; \
((i) < rtd->num_codecs) && ((dai) = asoc_rtd_to_codec(rtd, i)); \
((i) < rtd->dai_link->num_codecs) && ((dai) = asoc_rtd_to_codec(rtd, i)); \
(i)++)
#define for_each_rtd_dais(rtd, i, dai) \
for ((i) = 0; \
((i) < (rtd)->num_cpus + (rtd)->num_codecs) && \
((i) < (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs) && \
((dai) = (rtd)->dais[i]); \
(i)++)
......
......@@ -172,7 +172,7 @@ static int acp5x_cs35l41_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_card *card = rtd->card;
struct snd_soc_dai *codec_dai;
int ret, i;
unsigned int num_codecs = rtd->num_codecs;
unsigned int num_codecs = rtd->dai_link->num_codecs;
unsigned int bclk_val;
ret = 0;
......
......@@ -97,7 +97,7 @@ static int odroid_card_be_hw_params(struct snd_pcm_substream *substream,
if (ret < 0)
return ret;
if (rtd->num_codecs > 1) {
if (rtd->dai_link->num_codecs > 1) {
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 1);
ret = snd_soc_dai_set_sysclk(codec_dai, 0, rclk_freq,
......
......@@ -560,8 +560,8 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
BUILD_BUG_ON((int)SNDRV_PCM_STREAM_PLAYBACK != (int)SND_COMPRESS_PLAYBACK);
BUILD_BUG_ON((int)SNDRV_PCM_STREAM_CAPTURE != (int)SND_COMPRESS_CAPTURE);
if (rtd->num_cpus > 1 ||
rtd->num_codecs > 1) {
if (rtd->dai_link->num_cpus > 1 ||
rtd->dai_link->num_codecs > 1) {
dev_err(rtd->card->dev,
"Compress ASoC: Multi CPU/Codec not supported\n");
return -EINVAL;
......
......@@ -107,7 +107,7 @@ static umode_t soc_dev_attr_is_visible(struct kobject *kobj,
if (attr == &dev_attr_pmdown_time.attr)
return attr->mode; /* always visible */
return rtd->num_codecs ? attr->mode : 0; /* enabled only with codec */
return rtd->dai_link->num_codecs ? attr->mode : 0; /* enabled only with codec */
}
static const struct attribute_group soc_dapm_dev_group = {
......@@ -482,8 +482,6 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
* asoc_rtd_to_cpu()
* asoc_rtd_to_codec()
*/
rtd->num_cpus = dai_link->num_cpus;
rtd->num_codecs = dai_link->num_codecs;
rtd->card = card;
rtd->dai_link = dai_link;
rtd->num = card->num_rtd++;
......
......@@ -4361,6 +4361,7 @@ static void dapm_connect_dai_pair(struct snd_soc_card *card,
struct snd_soc_dapm_widget *dai, *codec, *playback_cpu, *capture_cpu;
struct snd_pcm_substream *substream;
struct snd_pcm_str *streams = rtd->pcm->streams;
int stream;
if (dai_link->params) {
playback_cpu = cpu_dai->capture_widget;
......@@ -4371,37 +4372,39 @@ static void dapm_connect_dai_pair(struct snd_soc_card *card,
}
/* connect BE DAI playback if widgets are valid */
stream = SNDRV_PCM_STREAM_PLAYBACK;
codec = codec_dai->playback_widget;
if (playback_cpu && codec) {
if (dai_link->params && !rtd->playback_widget) {
substream = streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
if (dai_link->params && !rtd->c2c_widget[stream]) {
substream = streams[stream].substream;
dai = snd_soc_dapm_new_dai(card, substream, "playback");
if (IS_ERR(dai))
goto capture;
rtd->playback_widget = dai;
rtd->c2c_widget[stream] = dai;
}
dapm_connect_dai_routes(&card->dapm, cpu_dai, playback_cpu,
rtd->playback_widget,
rtd->c2c_widget[stream],
codec_dai, codec);
}
capture:
/* connect BE DAI capture if widgets are valid */
stream = SNDRV_PCM_STREAM_CAPTURE;
codec = codec_dai->capture_widget;
if (codec && capture_cpu) {
if (dai_link->params && !rtd->capture_widget) {
substream = streams[SNDRV_PCM_STREAM_CAPTURE].substream;
if (dai_link->params && !rtd->c2c_widget[stream]) {
substream = streams[stream].substream;
dai = snd_soc_dapm_new_dai(card, substream, "capture");
if (IS_ERR(dai))
return;
rtd->capture_widget = dai;
rtd->c2c_widget[stream] = dai;
}
dapm_connect_dai_routes(&card->dapm, codec_dai, codec,
rtd->capture_widget,
rtd->c2c_widget[stream],
cpu_dai, capture_cpu);
}
}
......@@ -4459,11 +4462,11 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card)
if (rtd->dai_link->dynamic)
continue;
if (rtd->num_cpus == 1) {
if (rtd->dai_link->num_cpus == 1) {
for_each_rtd_codec_dais(rtd, i, codec_dai)
dapm_connect_dai_pair(card, rtd, codec_dai,
asoc_rtd_to_cpu(rtd, 0));
} else if (rtd->num_codecs == rtd->num_cpus) {
} else if (rtd->dai_link->num_codecs == rtd->dai_link->num_cpus) {
for_each_rtd_codec_dais(rtd, i, codec_dai)
dapm_connect_dai_pair(card, rtd, codec_dai,
asoc_rtd_to_cpu(rtd, i));
......
......@@ -54,7 +54,7 @@ int snd_dmaengine_pcm_prepare_slave_config(struct snd_pcm_substream *substream,
struct snd_dmaengine_dai_dma_data *dma_data;
int ret;
if (rtd->num_cpus > 1) {
if (rtd->dai_link->num_cpus > 1) {
dev_err(rtd->dev,
"%s doesn't support Multi CPU yet\n", __func__);
return -EINVAL;
......@@ -105,7 +105,7 @@ dmaengine_pcm_set_runtime_hwparams(struct snd_soc_component *component,
struct snd_dmaengine_dai_dma_data *dma_data;
struct snd_pcm_hardware hw;
if (rtd->num_cpus > 1) {
if (rtd->dai_link->num_cpus > 1) {
dev_err(rtd->dev,
"%s doesn't support Multi CPU yet\n", __func__);
return -EINVAL;
......@@ -179,7 +179,7 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel(
struct dmaengine_pcm *pcm = soc_component_to_pcm(component);
struct snd_dmaengine_dai_dma_data *dma_data;
if (rtd->num_cpus > 1) {
if (rtd->dai_link->num_cpus > 1) {
dev_err(rtd->dev,
"%s doesn't support Multi CPU yet\n", __func__);
return NULL;
......
......@@ -84,11 +84,11 @@ static inline void snd_soc_dpcm_stream_unlock_irq(struct snd_soc_pcm_runtime *rt
static inline const char *soc_cpu_dai_name(struct snd_soc_pcm_runtime *rtd)
{
return (rtd)->num_cpus == 1 ? asoc_rtd_to_cpu(rtd, 0)->name : "multicpu";
return (rtd)->dai_link->num_cpus == 1 ? asoc_rtd_to_cpu(rtd, 0)->name : "multicpu";
}
static inline const char *soc_codec_dai_name(struct snd_soc_pcm_runtime *rtd)
{
return (rtd)->num_codecs == 1 ? asoc_rtd_to_codec(rtd, 0)->name : "multicodec";
return (rtd)->dai_link->num_codecs == 1 ? asoc_rtd_to_codec(rtd, 0)->name : "multicodec";
}
#ifdef CONFIG_DEBUG_FS
......@@ -185,7 +185,7 @@ static ssize_t dpcm_state_read_file(struct file *file, char __user *user_buf,
int stream;
char *buf;
if (fe->num_cpus > 1) {
if (fe->dai_link->num_cpus > 1) {
dev_err(fe->dev,
"%s doesn't support Multi CPU yet\n", __func__);
return -EINVAL;
......@@ -637,7 +637,7 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
* connected to CPU DAI(s), use CPU DAI's directly and let
* channel allocation be fixed up later
*/
if (rtd->num_codecs > 1) {
if (rtd->dai_link->num_codecs > 1) {
hw->channels_min = cpu_chan_min;
hw->channels_max = cpu_chan_max;
}
......@@ -1379,7 +1379,7 @@ int dpcm_path_get(struct snd_soc_pcm_runtime *fe,
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
int paths;
if (fe->num_cpus > 1) {
if (fe->dai_link->num_cpus > 1) {
dev_err(fe->dev,
"%s doesn't support Multi CPU yet\n", __func__);
return -EINVAL;
......@@ -1751,7 +1751,7 @@ static void dpcm_runtime_setup_be_chan(struct snd_pcm_substream *substream)
* chan min/max cannot be enforced if there are multiple CODEC
* DAIs connected to a single CPU DAI, use CPU DAI's directly
*/
if (be->num_codecs == 1) {
if (be->dai_link->num_codecs == 1) {
struct snd_soc_pcm_stream *codec_stream = snd_soc_dai_get_pcm_stream(
asoc_rtd_to_codec(be, 0), stream);
......@@ -2590,7 +2590,7 @@ static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
if (!fe->dai_link->dynamic)
return 0;
if (fe->num_cpus > 1) {
if (fe->dai_link->num_cpus > 1) {
dev_err(fe->dev,
"%s doesn't support Multi CPU yet\n", __func__);
return -EINVAL;
......@@ -2734,7 +2734,7 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
struct snd_soc_dai *cpu_dai;
int i;
if (rtd->dai_link->dynamic && rtd->num_cpus > 1) {
if (rtd->dai_link->dynamic && rtd->dai_link->num_cpus > 1) {
dev_err(rtd->dev,
"DPCM doesn't support Multi CPU for Front-Ends yet\n");
return -EINVAL;
......@@ -2786,9 +2786,9 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
for_each_rtd_codec_dais(rtd, i, codec_dai) {
if (rtd->num_cpus == 1) {
if (rtd->dai_link->num_cpus == 1) {
cpu_dai = asoc_rtd_to_cpu(rtd, 0);
} else if (rtd->num_cpus == rtd->num_codecs) {
} else if (rtd->dai_link->num_cpus == rtd->dai_link->num_codecs) {
cpu_dai = asoc_rtd_to_cpu(rtd, i);
} else {
dev_err(rtd->card->dev,
......
......@@ -1029,7 +1029,7 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp,
break;
}
}
if (i == rtd->num_cpus) {
if (i == rtd->dai_link->num_cpus) {
dev_err(scomp->dev, "error: can't find BE for DAI %s\n",
w->name);
......@@ -1051,7 +1051,7 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp,
break;
}
}
if (i == rtd->num_cpus) {
if (i == rtd->dai_link->num_cpus) {
dev_err(scomp->dev, "error: can't find BE for DAI %s\n",
w->name);
......
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