[alsa-devel][PATCH 3/3] ASoC: fsl_sai: Add support for Right-J mode
Zidan Wang
zidan.wang at freescale.com
Tue Jan 20 23:21:20 AEDT 2015
Add Right-J mode and set TCR5 FBT bit to let data right justify.
Signed-off-by: Zidan Wang <zidan.wang at freescale.com>
---
sound/soc/fsl/fsl_sai.c | 14 +++++++++++---
sound/soc/fsl/fsl_sai.h | 1 +
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index 4c5040d..19cd6f3 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -228,7 +228,11 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,
sai->is_dsp_mode = true;
break;
case SND_SOC_DAIFMT_RIGHT_J:
- /* To be done */
+ /* Frame high, one word length for frame sync */
+ val_cr2 |= FSL_SAI_CR2_BCP;
+ sai->is_right_j_mode = true;
+ break;
+
default:
return -EINVAL;
}
@@ -418,9 +422,13 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
val_cr5 |= FSL_SAI_CR5_WNW(sai->slot_width);
val_cr5 |= FSL_SAI_CR5_W0W(sai->slot_width);
- if (sai->is_lsb_first)
+ if (sai->is_lsb_first && sai->is_right_j_mode)
val_cr5 |= FSL_SAI_CR5_FBT(0);
- else
+ else if (sai->is_lsb_first && !sai->is_right_j_mode)
+ val_cr5 |= FSL_SAI_CR5_FBT(sai->slot_width - word_width);
+ else if (!sai->is_lsb_first && sai->is_right_j_mode)
+ val_cr5 |= FSL_SAI_CR5_FBT(sai->slot_width - 1);
+ else if (!sai->is_lsb_first && !sai->is_right_j_mode)
val_cr5 |= FSL_SAI_CR5_FBT(word_width - 1);
val_cr4 |= FSL_SAI_CR4_FRSZ(sai->slots * channels);
diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h
index 111dfce..e220940 100644
--- a/sound/soc/fsl/fsl_sai.h
+++ b/sound/soc/fsl/fsl_sai.h
@@ -137,6 +137,7 @@ struct fsl_sai {
bool is_lsb_first;
bool is_slave_mode;
bool is_dsp_mode;
+ bool is_right_j_mode;
bool sai_on_imx;
bool synchronous[2];
--
1.9.1
More information about the Linuxppc-dev
mailing list