struct snd_soc_codec *codec = dai->codec;
struct pcm1792a_private *priv = snd_soc_codec_get_drvdata(codec);
int val = 0, ret;
- int pcm_format = params_format(params);
priv->rate = params_rate(params);
switch (priv->format & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_RIGHT_J:
- if (pcm_format == SNDRV_PCM_FORMAT_S24_LE ||
- pcm_format == SNDRV_PCM_FORMAT_S32_LE)
- val = 0x02;
- else if (pcm_format == SNDRV_PCM_FORMAT_S16_LE)
- val = 0x00;
+ switch (params_width(params)) {
+ case 24:
+ case 32:
+ val = 2;
+ break;
+ case 16:
+ val = 0;
+ break;
+ default:
+ return -EINVAL;
+ }
break;
case SND_SOC_DAIFMT_I2S:
- if (pcm_format == SNDRV_PCM_FORMAT_S24_LE ||
- pcm_format == SNDRV_PCM_FORMAT_S32_LE)
- val = 0x05;
- else if (pcm_format == SNDRV_PCM_FORMAT_S16_LE)
- val = 0x04;
+ switch (params_width(params)) {
+ case 24:
+ case 32:
+ val = 5;
+ break;
+ case 16:
+ val = 4;
+ break;
+ default:
+ return -EINVAL;
+ }
break;
default:
dev_err(codec->dev, "Invalid DAI format\n");