[PATCH v2 2/3] ASoC: core: add slot information parsing supports

From: Xiubo Li
Date: Wed Feb 12 2014 - 03:48:58 EST


For some CPU/CODEC DAI devices the slot infomation maybe needed. This
patch adds the slot parsing from DT supports.

The style of the slot information in DT should be:
<tx_mask, rx_mask, slots, slot_width>

For instance:
simple-slot-info = <0xffffffc 0xffffffc 2 0>;

Please refer to tdm-slot.txt for more detail.

Signed-off-by: Xiubo Li <Li.Xiubo@xxxxxxxxxxxxx>
---
include/sound/soc.h | 10 ++++++++++
sound/soc/soc-core.c | 23 +++++++++++++++++++++++
2 files changed, 33 insertions(+)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 21d025e..1aa85d0 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1110,6 +1110,13 @@ struct soc_enum {
const unsigned int *values;
};

+struct soc_slot_info {
+ unsigned int tx_mask;
+ unsigned int rx_mask;
+ int slots;
+ int slot_width;
+};
+
/* codec IO */
unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
unsigned int snd_soc_write(struct snd_soc_codec *codec,
@@ -1190,6 +1197,9 @@ int snd_soc_of_parse_card_name(struct snd_soc_card *card,
const char *propname);
int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
const char *propname);
+int snd_soc_of_parse_slot_info(struct device_node *np,
+ struct soc_slot_info *info,
+ const char *propname);
int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
const char *propname);
unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index abee5f4..3ad4b88 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4558,6 +4558,29 @@ int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
}
EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_simple_widgets);

+int snd_soc_of_parse_slot_info(struct device_node *np,
+ struct soc_slot_info *info,
+ const char *propname)
+{
+ u32 out_value[4];
+ int ret;
+
+ if (!info)
+ return -EINVAL;
+
+ ret = of_property_read_u32_array(np, propname, out_value, 4);
+ if (ret)
+ return ret;
+
+ info->tx_mask = out_value[0];
+ info->rx_mask = out_value[1];
+ info->slots = out_value[2];
+ info->slot_width = out_value[3];
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_parse_slot_info);
+
int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
const char *propname)
{
--
1.8.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/