Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: simple-card: Add tdm slot mask support to simple-card

Adds DT binding for explicitly choosing a tdm mask for DAI and uses it
in simple-card. The API for snd_soc_of_parse_tdm_slot() has also been
changed.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Jyri Sarha and committed by
Mark Brown
6131084a 6ff33f39

+45 -3
+10 -1
Documentation/devicetree/bindings/sound/tdm-slot.txt
··· 4 4 5 5 TDM slot properties: 6 6 dai-tdm-slot-num : Number of slots in use. 7 - dai-tdm-slot-width : Width in bits for each slot. 7 + dai-tdm-slot-width : Width in bits for each slot. 8 + dai-tdm-slot-tx-mask : Transmit direction slot mask, optional 9 + dai-tdm-slot-rx-mask : Receive direction slot mask, optional 8 10 9 11 For instance: 10 12 dai-tdm-slot-num = <2>; 11 13 dai-tdm-slot-width = <8>; 14 + dai-tdm-slot-tx-mask = <0 1>; 15 + dai-tdm-slot-rx-mask = <1 0>; 12 16 13 17 And for each spcified driver, there could be one .of_xlate_tdm_slot_mask() 14 18 to specify a explicit mapping of the channels and the slots. If it's absent ··· 22 18 For snd_soc_of_xlate_tdm_slot_mask(), the tx and rx masks will use a 1 bit 23 19 for an active slot as default, and the default active bits are at the LSB of 24 20 the masks. 21 + 22 + The explicit masks are given as array of integers, where the first 23 + number presents bit-0 (LSB), second presents bit-1, etc. Any non zero 24 + number is considered 1 and 0 is 0. snd_soc_of_xlate_tdm_slot_mask() 25 + does not do anything, if either mask is set non zero value.
+2
include/sound/simple_card.h
··· 19 19 unsigned int sysclk; 20 20 int slots; 21 21 int slot_width; 22 + unsigned int tx_slot_mask; 23 + unsigned int rx_slot_mask; 22 24 struct clk *clk; 23 25 }; 24 26
+2
include/sound/soc.h
··· 1601 1601 int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card, 1602 1602 const char *propname); 1603 1603 int snd_soc_of_parse_tdm_slot(struct device_node *np, 1604 + unsigned int *tx_mask, 1605 + unsigned int *rx_mask, 1604 1606 unsigned int *slots, 1605 1607 unsigned int *slot_width); 1606 1608 void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
+6 -2
sound/soc/generic/simple-card.c
··· 151 151 } 152 152 153 153 if (set->slots) { 154 - ret = snd_soc_dai_set_tdm_slot(dai, 0, 0, 154 + ret = snd_soc_dai_set_tdm_slot(dai, 155 + set->tx_slot_mask, 156 + set->rx_slot_mask, 155 157 set->slots, 156 158 set->slot_width); 157 159 if (ret && ret != -ENOTSUPP) { ··· 245 243 return ret; 246 244 247 245 /* Parse TDM slot */ 248 - ret = snd_soc_of_parse_tdm_slot(np, &dai->slots, &dai->slot_width); 246 + ret = snd_soc_of_parse_tdm_slot(np, &dai->tx_slot_mask, 247 + &dai->rx_slot_mask, 248 + &dai->slots, &dai->slot_width); 249 249 if (ret) 250 250 return ret; 251 251
+25
sound/soc/soc-core.c
··· 3291 3291 } 3292 3292 EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_simple_widgets); 3293 3293 3294 + static int snd_soc_of_get_slot_mask(struct device_node *np, 3295 + const char *prop_name, 3296 + unsigned int *mask) 3297 + { 3298 + u32 val; 3299 + const u32 *of_slot_mask = of_get_property(np, prop_name, &val); 3300 + int i; 3301 + 3302 + if (!of_slot_mask) 3303 + return 0; 3304 + val /= sizeof(u32); 3305 + for (i = 0; i < val; i++) 3306 + if (be32_to_cpup(&of_slot_mask[i])) 3307 + *mask |= (1 << i); 3308 + 3309 + return val; 3310 + } 3311 + 3294 3312 int snd_soc_of_parse_tdm_slot(struct device_node *np, 3313 + unsigned int *tx_mask, 3314 + unsigned int *rx_mask, 3295 3315 unsigned int *slots, 3296 3316 unsigned int *slot_width) 3297 3317 { 3298 3318 u32 val; 3299 3319 int ret; 3320 + 3321 + if (tx_mask) 3322 + snd_soc_of_get_slot_mask(np, "dai-tdm-slot-tx-mask", tx_mask); 3323 + if (rx_mask) 3324 + snd_soc_of_get_slot_mask(np, "dai-tdm-slot-rx-mask", rx_mask); 3300 3325 3301 3326 if (of_property_read_bool(np, "dai-tdm-slot-num")) { 3302 3327 ret = of_property_read_u32(np, "dai-tdm-slot-num", &val);