]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
ASoC: fsl-utils: Add fsl_asoc_xlate_tdm_slot_mask() support.
authorXiubo Li <Li.Xiubo@freescale.com>
Fri, 21 Mar 2014 06:17:13 +0000 (14:17 +0800)
committerMark Brown <broonie@linaro.org>
Tue, 25 Mar 2014 13:06:43 +0000 (13:06 +0000)
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>
sound/soc/fsl/fsl_utils.c
sound/soc/fsl/fsl_utils.h

index b9e42b503a37728b8a20a14a3979ada69ed82872..2ac7755da8768dfe2b12a9d35a5aa5eda9e1d766 100644 (file)
@@ -86,6 +86,33 @@ int fsl_asoc_get_dma_channel(struct device_node *ssi_np,
 }
 EXPORT_SYMBOL(fsl_asoc_get_dma_channel);
 
+/**
+ * fsl_asoc_xlate_tdm_slot_mask - generate TDM slot TX/RX mask.
+ *
+ * @slots: Number of slots in use.
+ * @tx_mask: bitmask representing active TX slots.
+ * @rx_mask: bitmask representing active RX slots.
+ *
+ * This function 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 mask value.
+ */
+int fsl_asoc_xlate_tdm_slot_mask(unsigned int slots,
+                                   unsigned int *tx_mask,
+                                   unsigned int *rx_mask)
+{
+       if (!slots)
+               return -EINVAL;
+
+       if (tx_mask)
+               *tx_mask = ~((1 << slots) - 1);
+       if (rx_mask)
+               *rx_mask = ~((1 << slots) - 1);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(fsl_asoc_xlate_tdm_slot_mask);
+
 MODULE_AUTHOR("Timur Tabi <timur@freescale.com>");
 MODULE_DESCRIPTION("Freescale ASoC utility code");
 MODULE_LICENSE("GPL v2");
index b2951126527c0868595954f0857cf99a05dbd5df..df535db40313e61ae25d6e46ba68a149c5e62346 100644 (file)
@@ -22,5 +22,7 @@ int fsl_asoc_get_dma_channel(struct device_node *ssi_np, const char *name,
                             struct snd_soc_dai_link *dai,
                             unsigned int *dma_channel_id,
                             unsigned int *dma_id);
-
+int fsl_asoc_xlate_tdm_slot_mask(unsigned int slots,
+                                   unsigned int *tx_mask,
+                                   unsigned int *rx_mask);
 #endif /* _FSL_UTILS_H */