Lines Matching +full:dai +full:- +full:tdm +full:- +full:slot +full:- +full:width

1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
9 #include <sound/soc-dai.h>
11 #include "axg-tdm.h"
12 #include "meson-card.h"
30 * Those will be over-written by the CPU side of the link
44 struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card); in axg_card_tdm_be_hw_params()
46 (struct axg_dai_link_tdm_data *)priv->link_data[rtd->num]; in axg_card_tdm_be_hw_params()
48 return meson_card_i2s_set_sysclk(substream, params, be->mclk_fs); in axg_card_tdm_be_hw_params()
57 struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card); in axg_card_tdm_dai_init()
59 (struct axg_dai_link_tdm_data *)priv->link_data[rtd->num]; in axg_card_tdm_dai_init()
65 be->codec_masks[i].tx, in axg_card_tdm_dai_init()
66 be->codec_masks[i].rx, in axg_card_tdm_dai_init()
67 be->slots, be->slot_width); in axg_card_tdm_dai_init()
68 if (ret && ret != -ENOTSUPP) { in axg_card_tdm_dai_init()
69 dev_err(codec_dai->dev, in axg_card_tdm_dai_init()
70 "setting tdm link slots failed\n"); in axg_card_tdm_dai_init()
75 ret = axg_tdm_set_tdm_slots(asoc_rtd_to_cpu(rtd, 0), be->tx_mask, be->rx_mask, in axg_card_tdm_dai_init()
76 be->slots, be->slot_width); in axg_card_tdm_dai_init()
78 dev_err(asoc_rtd_to_cpu(rtd, 0)->dev, "setting tdm link slots failed\n"); in axg_card_tdm_dai_init()
87 struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card); in axg_card_tdm_dai_lb_init()
89 (struct axg_dai_link_tdm_data *)priv->link_data[rtd->num]; in axg_card_tdm_dai_lb_init()
93 ret = axg_tdm_set_tdm_slots(asoc_rtd_to_cpu(rtd, 0), NULL, be->tx_mask, in axg_card_tdm_dai_lb_init()
94 be->slots, be->slot_width); in axg_card_tdm_dai_lb_init()
96 dev_err(asoc_rtd_to_cpu(rtd, 0)->dev, "setting tdm link slots failed\n"); in axg_card_tdm_dai_lb_init()
107 struct snd_soc_dai_link *pad = &card->dai_link[*index]; in axg_card_add_tdm_loopback()
113 ret = meson_card_reallocate_links(card, card->num_links + 1); in axg_card_add_tdm_loopback()
117 lb = &card->dai_link[*index + 1]; in axg_card_add_tdm_loopback()
119 lb->name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-lb", pad->name); in axg_card_add_tdm_loopback()
120 if (!lb->name) in axg_card_add_tdm_loopback()
121 return -ENOMEM; in axg_card_add_tdm_loopback()
123 dlc = devm_kzalloc(card->dev, sizeof(*dlc), GFP_KERNEL); in axg_card_add_tdm_loopback()
125 return -ENOMEM; in axg_card_add_tdm_loopback()
127 lb->cpus = dlc; in axg_card_add_tdm_loopback()
128 lb->codecs = &asoc_dummy_dlc; in axg_card_add_tdm_loopback()
129 lb->num_cpus = 1; in axg_card_add_tdm_loopback()
130 lb->num_codecs = 1; in axg_card_add_tdm_loopback()
132 lb->stream_name = lb->name; in axg_card_add_tdm_loopback()
133 lb->cpus->of_node = pad->cpus->of_node; in axg_card_add_tdm_loopback()
134 lb->cpus->dai_name = "TDM Loopback"; in axg_card_add_tdm_loopback()
135 lb->dpcm_capture = 1; in axg_card_add_tdm_loopback()
136 lb->no_pcm = 1; in axg_card_add_tdm_loopback()
137 lb->ops = &axg_card_tdm_be_ops; in axg_card_add_tdm_loopback()
138 lb->init = axg_card_tdm_dai_lb_init; in axg_card_add_tdm_loopback()
141 priv->link_data[*index + 1] = priv->link_data[*index]; in axg_card_add_tdm_loopback()
147 of_node_get(lb->cpus->of_node); in axg_card_add_tdm_loopback()
164 be->tx_mask = devm_kcalloc(card->dev, AXG_TDM_NUM_LANES, in axg_card_parse_cpu_tdm_slots()
165 sizeof(*be->tx_mask), GFP_KERNEL); in axg_card_parse_cpu_tdm_slots()
166 be->rx_mask = devm_kcalloc(card->dev, AXG_TDM_NUM_LANES, in axg_card_parse_cpu_tdm_slots()
167 sizeof(*be->rx_mask), GFP_KERNEL); in axg_card_parse_cpu_tdm_slots()
168 if (!be->tx_mask || !be->rx_mask) in axg_card_parse_cpu_tdm_slots()
169 return -ENOMEM; in axg_card_parse_cpu_tdm_slots()
172 snprintf(propname, 32, "dai-tdm-slot-tx-mask-%d", i); in axg_card_parse_cpu_tdm_slots()
173 snd_soc_of_get_slot_mask(node, propname, &be->tx_mask[i]); in axg_card_parse_cpu_tdm_slots()
174 tx = max(tx, be->tx_mask[i]); in axg_card_parse_cpu_tdm_slots()
179 link->dpcm_playback = 0; in axg_card_parse_cpu_tdm_slots()
182 snprintf(propname, 32, "dai-tdm-slot-rx-mask-%d", i); in axg_card_parse_cpu_tdm_slots()
183 snd_soc_of_get_slot_mask(node, propname, &be->rx_mask[i]); in axg_card_parse_cpu_tdm_slots()
184 rx = max(rx, be->rx_mask[i]); in axg_card_parse_cpu_tdm_slots()
189 link->dpcm_capture = 0; in axg_card_parse_cpu_tdm_slots()
193 dev_err(card->dev, "tdm link has no cpu slots\n"); in axg_card_parse_cpu_tdm_slots()
194 return -EINVAL; in axg_card_parse_cpu_tdm_slots()
197 of_property_read_u32(node, "dai-tdm-slot-num", &be->slots); in axg_card_parse_cpu_tdm_slots()
198 if (!be->slots) { in axg_card_parse_cpu_tdm_slots()
200 * If the slot number is not provided, set it such as it in axg_card_parse_cpu_tdm_slots()
203 be->slots = fls(max(tx, rx)); in axg_card_parse_cpu_tdm_slots()
204 } else if (be->slots < fls(max(tx, rx)) || be->slots > 32) { in axg_card_parse_cpu_tdm_slots()
209 dev_err(card->dev, "bad slot number\n"); in axg_card_parse_cpu_tdm_slots()
210 return -EINVAL; in axg_card_parse_cpu_tdm_slots()
213 of_property_read_u32(node, "dai-tdm-slot-width", &be->slot_width); in axg_card_parse_cpu_tdm_slots()
226 codec_mask = devm_kcalloc(card->dev, link->num_codecs, in axg_card_parse_codecs_masks()
229 return -ENOMEM; in axg_card_parse_codecs_masks()
231 be->codec_masks = codec_mask; in axg_card_parse_codecs_masks()
234 snd_soc_of_get_slot_mask(np, "dai-tdm-slot-rx-mask", in axg_card_parse_codecs_masks()
235 &codec_mask->rx); in axg_card_parse_codecs_masks()
236 snd_soc_of_get_slot_mask(np, "dai-tdm-slot-tx-mask", in axg_card_parse_codecs_masks()
237 &codec_mask->tx); in axg_card_parse_codecs_masks()
250 struct snd_soc_dai_link *link = &card->dai_link[*index]; in axg_card_parse_tdm()
254 /* Allocate tdm link parameters */ in axg_card_parse_tdm()
255 be = devm_kzalloc(card->dev, sizeof(*be), GFP_KERNEL); in axg_card_parse_tdm()
257 return -ENOMEM; in axg_card_parse_tdm()
258 priv->link_data[*index] = be; in axg_card_parse_tdm()
260 /* Setup tdm link */ in axg_card_parse_tdm()
261 link->ops = &axg_card_tdm_be_ops; in axg_card_parse_tdm()
262 link->init = axg_card_tdm_dai_init; in axg_card_parse_tdm()
263 link->dai_fmt = meson_card_parse_daifmt(node, link->cpus->of_node); in axg_card_parse_tdm()
265 of_property_read_u32(node, "mclk-fs", &be->mclk_fs); in axg_card_parse_tdm()
269 dev_err(card->dev, "error parsing tdm link slots\n"); in axg_card_parse_tdm()
277 /* Add loopback if the pad dai has playback */ in axg_card_parse_tdm()
278 if (link->dpcm_playback) { in axg_card_parse_tdm()
289 return of_device_is_compatible(np, DT_PREFIX "axg-toddr"); in axg_card_cpu_is_capture_fe()
294 return of_device_is_compatible(np, DT_PREFIX "axg-frddr"); in axg_card_cpu_is_playback_fe()
299 return of_device_is_compatible(np, DT_PREFIX "axg-tdm-iface"); in axg_card_cpu_is_tdm_iface()
304 return of_device_is_compatible(np, DT_PREFIX "g12a-tohdmitx") || in axg_card_cpu_is_codec()
305 of_device_is_compatible(np, DT_PREFIX "g12a-toacodec"); in axg_card_cpu_is_codec()
311 struct snd_soc_dai_link *dai_link = &card->dai_link[*index]; in axg_card_add_link()
315 cpu = devm_kzalloc(card->dev, sizeof(*cpu), GFP_KERNEL); in axg_card_add_link()
317 return -ENOMEM; in axg_card_add_link()
319 dai_link->cpus = cpu; in axg_card_add_link()
320 dai_link->num_cpus = 1; in axg_card_add_link()
322 ret = meson_card_parse_dai(card, np, dai_link->cpus); in axg_card_add_link()
326 if (axg_card_cpu_is_playback_fe(dai_link->cpus->of_node)) in axg_card_add_link()
328 else if (axg_card_cpu_is_capture_fe(dai_link->cpus->of_node)) in axg_card_add_link()
336 if (axg_card_cpu_is_codec(dai_link->cpus->of_node)) { in axg_card_add_link()
337 dai_link->c2c_params = &codec_params; in axg_card_add_link()
338 dai_link->num_c2c_params = 1; in axg_card_add_link()
340 dai_link->no_pcm = 1; in axg_card_add_link()
342 if (axg_card_cpu_is_tdm_iface(dai_link->cpus->of_node)) in axg_card_add_link()
355 .compatible = "amlogic,axg-sound-card",
365 .name = "axg-sound-card",