aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorXiubo Li <Li.Xiubo@freescale.com>2014-03-21 02:17:13 -0400
committerMark Brown <broonie@linaro.org>2014-03-25 09:06:43 -0400
commit82535314a942c1235d54a0cdbe48d38f640d56ba (patch)
treed42ca8af5eb904eadc582c853f1fb8fbcf6c3c59 /sound/soc
parente5c2151483facbe1a67b12ec881f45ae25b54c21 (diff)
ASoC: fsl-utils: Add fsl_asoc_xlate_tdm_slot_mask() support.
This patch add fsl_asoc_xlate_tdm_slot_mask() support for utils. For the some spcified DAI driver, this will be used to generate the TDM slot TX/RX mask. And the TX/RX mask will use a 0 bit for an active slot as default, and the default active bits are at the LSB of the masks. Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/fsl/fsl_utils.c27
-rw-r--r--sound/soc/fsl/fsl_utils.h4
2 files changed, 30 insertions, 1 deletions
diff --git a/sound/soc/fsl/fsl_utils.c b/sound/soc/fsl/fsl_utils.c
index b9e42b503a37..2ac7755da876 100644
--- a/sound/soc/fsl/fsl_utils.c
+++ b/sound/soc/fsl/fsl_utils.c
@@ -86,6 +86,33 @@ int fsl_asoc_get_dma_channel(struct device_node *ssi_np,
86} 86}
87EXPORT_SYMBOL(fsl_asoc_get_dma_channel); 87EXPORT_SYMBOL(fsl_asoc_get_dma_channel);
88 88
89/**
90 * fsl_asoc_xlate_tdm_slot_mask - generate TDM slot TX/RX mask.
91 *
92 * @slots: Number of slots in use.
93 * @tx_mask: bitmask representing active TX slots.
94 * @rx_mask: bitmask representing active RX slots.
95 *
96 * This function used to generate the TDM slot TX/RX mask. And the TX/RX
97 * mask will use a 0 bit for an active slot as default, and the default
98 * active bits are at the LSB of the mask value.
99 */
100int fsl_asoc_xlate_tdm_slot_mask(unsigned int slots,
101 unsigned int *tx_mask,
102 unsigned int *rx_mask)
103{
104 if (!slots)
105 return -EINVAL;
106
107 if (tx_mask)
108 *tx_mask = ~((1 << slots) - 1);
109 if (rx_mask)
110 *rx_mask = ~((1 << slots) - 1);
111
112 return 0;
113}
114EXPORT_SYMBOL_GPL(fsl_asoc_xlate_tdm_slot_mask);
115
89MODULE_AUTHOR("Timur Tabi <timur@freescale.com>"); 116MODULE_AUTHOR("Timur Tabi <timur@freescale.com>");
90MODULE_DESCRIPTION("Freescale ASoC utility code"); 117MODULE_DESCRIPTION("Freescale ASoC utility code");
91MODULE_LICENSE("GPL v2"); 118MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/fsl/fsl_utils.h b/sound/soc/fsl/fsl_utils.h
index b2951126527c..df535db40313 100644
--- a/sound/soc/fsl/fsl_utils.h
+++ b/sound/soc/fsl/fsl_utils.h
@@ -22,5 +22,7 @@ int fsl_asoc_get_dma_channel(struct device_node *ssi_np, const char *name,
22 struct snd_soc_dai_link *dai, 22 struct snd_soc_dai_link *dai,
23 unsigned int *dma_channel_id, 23 unsigned int *dma_channel_id,
24 unsigned int *dma_id); 24 unsigned int *dma_id);
25 25int fsl_asoc_xlate_tdm_slot_mask(unsigned int slots,
26 unsigned int *tx_mask,
27 unsigned int *rx_mask);
26#endif /* _FSL_UTILS_H */ 28#endif /* _FSL_UTILS_H */