1
0
Fork 0

MLK-23603-2: ASoC: fsl_xcvr: refactor constraint handling

Refactor constraint handling in order to facilitate
unimplemented cases, such as for ARC and SPDIF.

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
5.4-rM2-2.2.x-imx-squashed
Viorel Suman 2020-03-24 13:08:56 +02:00
parent 6a3380a43a
commit 8a05c23ef2
1 changed files with 33 additions and 18 deletions

View File

@ -82,38 +82,53 @@ static int fsl_xcvr_phy_write(struct fsl_xcvr *xcvr, int reg, int data, int pll_
return 0;
}
static int fsl_xcvr_constr(const struct snd_pcm_substream *substream,
const struct snd_pcm_hw_constraint_list *bits,
const struct snd_pcm_hw_constraint_list *channels,
const struct snd_pcm_hw_constraint_list *rates)
{
struct snd_pcm_runtime *rt = substream->runtime;
int ret;
ret = snd_pcm_hw_constraint_list(rt, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
bits);
if (ret < 0)
return ret;
ret = snd_pcm_hw_constraint_list(rt, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
channels);
if (ret < 0)
return ret;
ret = snd_pcm_hw_constraint_list(rt, 0, SNDRV_PCM_HW_PARAM_RATE,
rates);
if (ret < 0)
return ret;
return 0;
}
static int fsl_xcvr_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
static struct snd_pcm_hw_constraint_list bits, channels, rates;
struct fsl_xcvr *xcvr = snd_soc_dai_get_drvdata(dai);
struct snd_pcm_runtime *rt = substream->runtime;
int ret = 0;
switch (xcvr->mode & FSL_XCVR_AMODE_MASK) {
case FSL_XCVR_AMODE_SPDIF:
case FSL_XCVR_AMODE_ARC:
return 0; /* @todo */
ret = 0; /* @todo */
break;
case FSL_XCVR_AMODE_EARC:
bits = fsl_xcvr_earc_bits_constr;
channels = fsl_xcvr_earc_channels_constr;
rates = fsl_xcvr_earc_rates_constr;
ret = fsl_xcvr_constr(substream, &fsl_xcvr_earc_bits_constr,
&fsl_xcvr_earc_channels_constr,
&fsl_xcvr_earc_rates_constr);
break;
}
ret = snd_pcm_hw_constraint_list(rt, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
&bits);
if (ret)
if (ret < 0)
return ret;
ret = snd_pcm_hw_constraint_list(rt, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
&channels);
if (ret)
return ret;
return snd_pcm_hw_constraint_list(rt, 0, SNDRV_PCM_HW_PARAM_RATE,
&rates);
return 0;
}
static int fsl_xcvr_startup(struct snd_pcm_substream *substream,