Lines Matching +full:dai +full:- +full:tdm +full:- +full:slot +full:- +full:tx +full:- +full:mask

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"
15 u32 tx; member
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(snd_soc_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(snd_soc_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(snd_soc_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(snd_soc_rtd_to_cpu(rtd, 0)->dev, "setting tdm link slots failed\n"); in axg_card_tdm_dai_lb_init()
113 ret = meson_card_reallocate_links(card, card->num_links + 1); in axg_card_add_tdm_loopback()
117 pad = &card->dai_link[*index]; in axg_card_add_tdm_loopback()
118 lb = &card->dai_link[*index + 1]; in axg_card_add_tdm_loopback()
120 lb->name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-lb", pad->name); in axg_card_add_tdm_loopback()
121 if (!lb->name) in axg_card_add_tdm_loopback()
122 return -ENOMEM; in axg_card_add_tdm_loopback()
124 dlc = devm_kzalloc(card->dev, sizeof(*dlc), GFP_KERNEL); in axg_card_add_tdm_loopback()
126 return -ENOMEM; in axg_card_add_tdm_loopback()
128 lb->cpus = dlc; in axg_card_add_tdm_loopback()
129 lb->codecs = &snd_soc_dummy_dlc; in axg_card_add_tdm_loopback()
130 lb->num_cpus = 1; in axg_card_add_tdm_loopback()
131 lb->num_codecs = 1; in axg_card_add_tdm_loopback()
133 lb->stream_name = lb->name; in axg_card_add_tdm_loopback()
134 lb->cpus->of_node = pad->cpus->of_node; in axg_card_add_tdm_loopback()
135 lb->cpus->dai_name = "TDM Loopback"; in axg_card_add_tdm_loopback()
136 lb->capture_only = 1; in axg_card_add_tdm_loopback()
137 lb->no_pcm = 1; in axg_card_add_tdm_loopback()
138 lb->ops = &axg_card_tdm_be_ops; in axg_card_add_tdm_loopback()
139 lb->init = axg_card_tdm_dai_lb_init; in axg_card_add_tdm_loopback()
142 priv->link_data[*index + 1] = priv->link_data[*index]; in axg_card_add_tdm_loopback()
148 of_node_get(lb->cpus->of_node); in axg_card_add_tdm_loopback()
162 u32 tx, rx; in axg_card_parse_cpu_tdm_slots() local
165 be->tx_mask = devm_kcalloc(card->dev, AXG_TDM_NUM_LANES, in axg_card_parse_cpu_tdm_slots()
166 sizeof(*be->tx_mask), GFP_KERNEL); in axg_card_parse_cpu_tdm_slots()
167 be->rx_mask = devm_kcalloc(card->dev, AXG_TDM_NUM_LANES, in axg_card_parse_cpu_tdm_slots()
168 sizeof(*be->rx_mask), GFP_KERNEL); in axg_card_parse_cpu_tdm_slots()
169 if (!be->tx_mask || !be->rx_mask) in axg_card_parse_cpu_tdm_slots()
170 return -ENOMEM; in axg_card_parse_cpu_tdm_slots()
172 for (i = 0, tx = 0; i < AXG_TDM_NUM_LANES; i++) { in axg_card_parse_cpu_tdm_slots()
173 snprintf(propname, 32, "dai-tdm-slot-tx-mask-%d", i); in axg_card_parse_cpu_tdm_slots()
174 snd_soc_of_get_slot_mask(node, propname, &be->tx_mask[i]); in axg_card_parse_cpu_tdm_slots()
175 tx = max(tx, be->tx_mask[i]); in axg_card_parse_cpu_tdm_slots()
178 /* Disable playback is the interface has no tx slots */ in axg_card_parse_cpu_tdm_slots()
179 if (!tx) in axg_card_parse_cpu_tdm_slots()
180 link->capture_only = 1; in axg_card_parse_cpu_tdm_slots()
183 snprintf(propname, 32, "dai-tdm-slot-rx-mask-%d", i); in axg_card_parse_cpu_tdm_slots()
184 snd_soc_of_get_slot_mask(node, propname, &be->rx_mask[i]); in axg_card_parse_cpu_tdm_slots()
185 rx = max(rx, be->rx_mask[i]); in axg_card_parse_cpu_tdm_slots()
190 link->playback_only = 1; in axg_card_parse_cpu_tdm_slots()
193 if (!tx && !rx) { in axg_card_parse_cpu_tdm_slots()
194 dev_err(card->dev, "tdm link has no cpu slots\n"); in axg_card_parse_cpu_tdm_slots()
195 return -EINVAL; in axg_card_parse_cpu_tdm_slots()
198 of_property_read_u32(node, "dai-tdm-slot-num", &be->slots); in axg_card_parse_cpu_tdm_slots()
199 if (!be->slots) { in axg_card_parse_cpu_tdm_slots()
201 * If the slot number is not provided, set it such as it in axg_card_parse_cpu_tdm_slots()
202 * accommodates the largest mask in axg_card_parse_cpu_tdm_slots()
204 be->slots = fls(max(tx, rx)); in axg_card_parse_cpu_tdm_slots()
205 } else if (be->slots < fls(max(tx, rx)) || be->slots > 32) { in axg_card_parse_cpu_tdm_slots()
207 * Error if the slots can't accommodate the largest mask or in axg_card_parse_cpu_tdm_slots()
210 dev_err(card->dev, "bad slot number\n"); in axg_card_parse_cpu_tdm_slots()
211 return -EINVAL; in axg_card_parse_cpu_tdm_slots()
214 of_property_read_u32(node, "dai-tdm-slot-width", &be->slot_width); in axg_card_parse_cpu_tdm_slots()
227 codec_mask = devm_kcalloc(card->dev, link->num_codecs, in axg_card_parse_codecs_masks()
230 return -ENOMEM; in axg_card_parse_codecs_masks()
232 be->codec_masks = codec_mask; in axg_card_parse_codecs_masks()
235 snd_soc_of_get_slot_mask(np, "dai-tdm-slot-rx-mask", in axg_card_parse_codecs_masks()
236 &codec_mask->rx); in axg_card_parse_codecs_masks()
237 snd_soc_of_get_slot_mask(np, "dai-tdm-slot-tx-mask", in axg_card_parse_codecs_masks()
238 &codec_mask->tx); in axg_card_parse_codecs_masks()
251 struct snd_soc_dai_link *link = &card->dai_link[*index]; in axg_card_parse_tdm()
255 /* Allocate tdm link parameters */ in axg_card_parse_tdm()
256 be = devm_kzalloc(card->dev, sizeof(*be), GFP_KERNEL); in axg_card_parse_tdm()
258 return -ENOMEM; in axg_card_parse_tdm()
259 priv->link_data[*index] = be; in axg_card_parse_tdm()
261 /* Setup tdm link */ in axg_card_parse_tdm()
262 link->ops = &axg_card_tdm_be_ops; in axg_card_parse_tdm()
263 link->init = axg_card_tdm_dai_init; in axg_card_parse_tdm()
264 link->dai_fmt = meson_card_parse_daifmt(node, link->cpus->of_node); in axg_card_parse_tdm()
266 of_property_read_u32(node, "mclk-fs", &be->mclk_fs); in axg_card_parse_tdm()
270 dev_err(card->dev, "error parsing tdm link slots\n"); in axg_card_parse_tdm()
278 /* Add loopback if the pad dai has playback */ in axg_card_parse_tdm()
279 if (!link->capture_only) { in axg_card_parse_tdm()
290 return of_device_is_compatible(np, DT_PREFIX "axg-toddr"); in axg_card_cpu_is_capture_fe()
295 return of_device_is_compatible(np, DT_PREFIX "axg-frddr"); in axg_card_cpu_is_playback_fe()
300 return of_device_is_compatible(np, DT_PREFIX "axg-tdm-iface"); in axg_card_cpu_is_tdm_iface()
305 return of_device_is_compatible(np, DT_PREFIX "g12a-tohdmitx") || in axg_card_cpu_is_codec()
306 of_device_is_compatible(np, DT_PREFIX "g12a-toacodec"); in axg_card_cpu_is_codec()
312 struct snd_soc_dai_link *dai_link = &card->dai_link[*index]; in axg_card_add_link()
316 cpu = devm_kzalloc(card->dev, sizeof(*cpu), GFP_KERNEL); in axg_card_add_link()
318 return -ENOMEM; in axg_card_add_link()
320 dai_link->cpus = cpu; in axg_card_add_link()
321 dai_link->num_cpus = 1; in axg_card_add_link()
322 dai_link->nonatomic = true; in axg_card_add_link()
324 ret = meson_card_parse_dai(card, np, dai_link->cpus); in axg_card_add_link()
328 if (axg_card_cpu_is_playback_fe(dai_link->cpus->of_node)) in axg_card_add_link()
330 else if (axg_card_cpu_is_capture_fe(dai_link->cpus->of_node)) in axg_card_add_link()
338 if (axg_card_cpu_is_codec(dai_link->cpus->of_node)) { in axg_card_add_link()
339 dai_link->c2c_params = &codec_params; in axg_card_add_link()
340 dai_link->num_c2c_params = 1; in axg_card_add_link()
342 dai_link->no_pcm = 1; in axg_card_add_link()
343 if (axg_card_cpu_is_tdm_iface(dai_link->cpus->of_node)) in axg_card_add_link()
356 .compatible = "amlogic,axg-sound-card",
366 .name = "axg-sound-card",