mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
ASoC: rockchip: multi-dais: Skip the zero-channel sub dais
Should skip the dais which mapped as zero channel. Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com> Change-Id: I875f6dc6795b8cfed5abffcaf849fb52b729d5a3
This commit is contained in:
@@ -30,6 +30,13 @@ static inline struct rk_mdais_dev *to_info(struct snd_soc_dai *dai)
|
||||
return snd_soc_dai_get_drvdata(dai);
|
||||
}
|
||||
|
||||
static inline unsigned int *mdais_channel_maps(struct rk_mdais_dev *mdais,
|
||||
struct snd_pcm_substream *substream)
|
||||
{
|
||||
return substream->stream ? mdais->capture_channel_maps :
|
||||
mdais->playback_channel_maps;
|
||||
}
|
||||
|
||||
static void hw_refine_channels(struct snd_pcm_hw_params *params,
|
||||
unsigned int channel)
|
||||
{
|
||||
@@ -54,27 +61,27 @@ static int rockchip_mdais_hw_params(struct snd_pcm_substream *substream,
|
||||
if (IS_ERR(cparams))
|
||||
return PTR_ERR(cparams);
|
||||
|
||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
||||
channel_maps = mdais->playback_channel_maps;
|
||||
else
|
||||
channel_maps = mdais->capture_channel_maps;
|
||||
channel_maps = mdais_channel_maps(mdais, substream);
|
||||
|
||||
for (i = 0; i < mdais->num_dais; i++) {
|
||||
child = mdais->dais[i].dai;
|
||||
if (channel_maps[i])
|
||||
hw_refine_channels(cparams, channel_maps[i]);
|
||||
if (!channel_maps[i])
|
||||
continue;
|
||||
|
||||
hw_refine_channels(cparams, channel_maps[i]);
|
||||
if (child->driver->ops && child->driver->ops->hw_params) {
|
||||
ret = child->driver->ops->hw_params(substream, cparams, child);
|
||||
if (ret < 0) {
|
||||
dev_err(dai->dev, "ASoC: can't set %s hw params: %d\n",
|
||||
dev_err(dai->dev, "Failed to set %s hw params: %d\n",
|
||||
dai->name, ret);
|
||||
return ret;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kfree(cparams);
|
||||
return 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rockchip_mdais_trigger(struct snd_pcm_substream *substream,
|
||||
@@ -85,10 +92,7 @@ static int rockchip_mdais_trigger(struct snd_pcm_substream *substream,
|
||||
unsigned int *channel_maps;
|
||||
int ret = 0, i = 0;
|
||||
|
||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
||||
channel_maps = mdais->playback_channel_maps;
|
||||
else
|
||||
channel_maps = mdais->capture_channel_maps;
|
||||
channel_maps = mdais_channel_maps(mdais, substream);
|
||||
|
||||
for (i = 0; i < mdais->num_dais; i++) {
|
||||
/* skip DAIs which have no channel mapping */
|
||||
@@ -112,9 +116,15 @@ static int rockchip_mdais_startup(struct snd_pcm_substream *substream,
|
||||
{
|
||||
struct rk_mdais_dev *mdais = to_info(dai);
|
||||
struct snd_soc_dai *child;
|
||||
unsigned int *channel_maps;
|
||||
int ret = 0, i = 0;
|
||||
|
||||
channel_maps = mdais_channel_maps(mdais, substream);
|
||||
|
||||
for (i = 0; i < mdais->num_dais; i++) {
|
||||
if (!channel_maps[i])
|
||||
continue;
|
||||
|
||||
child = mdais->dais[i].dai;
|
||||
if (child->driver->ops && child->driver->ops->startup) {
|
||||
ret = child->driver->ops->startup(substream, child);
|
||||
@@ -131,9 +141,15 @@ static void rockchip_mdais_shutdown(struct snd_pcm_substream *substream,
|
||||
{
|
||||
struct rk_mdais_dev *mdais = to_info(dai);
|
||||
struct snd_soc_dai *child;
|
||||
unsigned int *channel_maps;
|
||||
int i = 0;
|
||||
|
||||
channel_maps = mdais_channel_maps(mdais, substream);
|
||||
|
||||
for (i = 0; i < mdais->num_dais; i++) {
|
||||
if (!channel_maps[i])
|
||||
continue;
|
||||
|
||||
child = mdais->dais[i].dai;
|
||||
if (child->driver->ops && child->driver->ops->shutdown) {
|
||||
child->driver->ops->shutdown(substream, child);
|
||||
@@ -146,9 +162,15 @@ static int rockchip_mdais_prepare(struct snd_pcm_substream *substream,
|
||||
{
|
||||
struct rk_mdais_dev *mdais = to_info(dai);
|
||||
struct snd_soc_dai *child;
|
||||
unsigned int *channel_maps;
|
||||
int ret = 0, i = 0;
|
||||
|
||||
channel_maps = mdais_channel_maps(mdais, substream);
|
||||
|
||||
for (i = 0; i < mdais->num_dais; i++) {
|
||||
if (!channel_maps[i])
|
||||
continue;
|
||||
|
||||
child = mdais->dais[i].dai;
|
||||
if (child->driver->ops && child->driver->ops->prepare) {
|
||||
ret = child->driver->ops->prepare(substream, child);
|
||||
@@ -242,7 +264,7 @@ static int rockchip_mdais_dai_probe(struct snd_soc_dai *dai)
|
||||
ret = child->driver->probe(child);
|
||||
if (ret < 0) {
|
||||
dev_err(child->dev,
|
||||
"ASoC: failed to probe DAI %s: %d\n",
|
||||
"Failed to probe DAI %s: %d\n",
|
||||
child->name, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user