Lines Matching +full:tdm +full:- +full:sync +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
5 #include <dt-bindings/sound/qcom,q6afe.h>
15 #include "q6dsp-lpass-ports.h"
16 #include "q6dsp-common.h"
42 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6slim_hw_params()
43 struct q6afe_slim_cfg *slim = &dai_data->port_config[dai->id].slim; in q6slim_hw_params()
45 slim->sample_rate = params_rate(params); in q6slim_hw_params()
50 slim->bit_width = 16; in q6slim_hw_params()
53 slim->bit_width = 24; in q6slim_hw_params()
56 slim->bit_width = 32; in q6slim_hw_params()
61 return -EINVAL; in q6slim_hw_params()
71 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6hdmi_hw_params()
73 struct q6afe_hdmi_cfg *hdmi = &dai_data->port_config[dai->id].hdmi; in q6hdmi_hw_params()
76 hdmi->sample_rate = params_rate(params); in q6hdmi_hw_params()
79 hdmi->bit_width = 16; in q6hdmi_hw_params()
82 hdmi->bit_width = 24; in q6hdmi_hw_params()
90 hdmi->channel_allocation = (u16) ret; in q6hdmi_hw_params()
99 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6i2s_hw_params()
100 struct q6afe_i2s_cfg *i2s = &dai_data->port_config[dai->id].i2s_cfg; in q6i2s_hw_params()
102 i2s->sample_rate = params_rate(params); in q6i2s_hw_params()
103 i2s->bit_width = params_width(params); in q6i2s_hw_params()
104 i2s->num_channels = params_channels(params); in q6i2s_hw_params()
105 i2s->sd_line_mask = dai_data->priv[dai->id].sd_line_mask; in q6i2s_hw_params()
112 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6i2s_set_fmt()
113 struct q6afe_i2s_cfg *i2s = &dai_data->port_config[dai->id].i2s_cfg; in q6i2s_set_fmt()
115 i2s->fmt = fmt; in q6i2s_set_fmt()
126 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6tdm_set_tdm_slot()
127 struct q6afe_tdm_cfg *tdm = &dai_data->port_config[dai->id].tdm; in q6tdm_set_tdm_slot() local
133 dev_err(dai->dev, "%s: invalid slot_width %d\n", in q6tdm_set_tdm_slot()
135 return -EINVAL; in q6tdm_set_tdm_slot()
138 /* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */ in q6tdm_set_tdm_slot()
153 dev_err(dai->dev, "%s: invalid slots %d\n", in q6tdm_set_tdm_slot()
155 return -EINVAL; in q6tdm_set_tdm_slot()
158 switch (dai->id) { in q6tdm_set_tdm_slot()
160 tdm->nslots_per_frame = slots; in q6tdm_set_tdm_slot()
161 tdm->slot_width = slot_width; in q6tdm_set_tdm_slot()
162 /* TDM RX dais ids are even and tx are odd */ in q6tdm_set_tdm_slot()
163 tdm->slot_mask = ((dai->id & 0x1) ? tx_mask : rx_mask) & cap_mask; in q6tdm_set_tdm_slot()
166 dev_err(dai->dev, "%s: invalid dai id 0x%x\n", in q6tdm_set_tdm_slot()
167 __func__, dai->id); in q6tdm_set_tdm_slot()
168 return -EINVAL; in q6tdm_set_tdm_slot()
179 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6tdm_set_channel_map()
180 struct q6afe_tdm_cfg *tdm = &dai_data->port_config[dai->id].tdm; in q6tdm_set_channel_map() local
184 switch (dai->id) { in q6tdm_set_channel_map()
186 if (dai->id & 0x1) { in q6tdm_set_channel_map()
188 dev_err(dai->dev, "tx slot not found\n"); in q6tdm_set_channel_map()
189 return -EINVAL; in q6tdm_set_channel_map()
192 dev_err(dai->dev, "invalid tx num %d\n", in q6tdm_set_channel_map()
194 return -EINVAL; in q6tdm_set_channel_map()
198 tdm->ch_mapping[i] = tx_slot[i]; in q6tdm_set_channel_map()
201 tdm->ch_mapping[i] = Q6AFE_CMAP_INVALID; in q6tdm_set_channel_map()
203 tdm->num_channels = tx_num; in q6tdm_set_channel_map()
207 dev_err(dai->dev, "rx slot not found\n"); in q6tdm_set_channel_map()
208 return -EINVAL; in q6tdm_set_channel_map()
211 dev_err(dai->dev, "invalid rx num %d\n", in q6tdm_set_channel_map()
213 return -EINVAL; in q6tdm_set_channel_map()
217 tdm->ch_mapping[i] = rx_slot[i]; in q6tdm_set_channel_map()
220 tdm->ch_mapping[i] = Q6AFE_CMAP_INVALID; in q6tdm_set_channel_map()
222 tdm->num_channels = rx_num; in q6tdm_set_channel_map()
227 dev_err(dai->dev, "%s: invalid dai id 0x%x\n", in q6tdm_set_channel_map()
228 __func__, dai->id); in q6tdm_set_channel_map()
229 return -EINVAL; in q6tdm_set_channel_map()
239 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6tdm_hw_params()
240 struct q6afe_tdm_cfg *tdm = &dai_data->port_config[dai->id].tdm; in q6tdm_hw_params() local
242 tdm->bit_width = params_width(params); in q6tdm_hw_params()
243 tdm->sample_rate = params_rate(params); in q6tdm_hw_params()
244 tdm->num_channels = params_channels(params); in q6tdm_hw_params()
245 tdm->data_align_type = dai_data->priv[dai->id].data_align; in q6tdm_hw_params()
246 tdm->sync_src = dai_data->priv[dai->id].sync_src; in q6tdm_hw_params()
247 tdm->sync_mode = dai_data->priv[dai->id].sync_mode; in q6tdm_hw_params()
259 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6dma_set_channel_map()
260 struct q6afe_cdc_dma_cfg *cfg = &dai_data->port_config[dai->id].dma_cfg; in q6dma_set_channel_map()
264 switch (dai->id) { in q6dma_set_channel_map()
278 dev_err(dai->dev, "tx slot not found\n"); in q6dma_set_channel_map()
279 return -EINVAL; in q6dma_set_channel_map()
283 dev_err(dai->dev, "invalid tx num %d\n", in q6dma_set_channel_map()
285 return -EINVAL; in q6dma_set_channel_map()
302 dev_err(dai->dev, "rx slot not found\n"); in q6dma_set_channel_map()
303 return -EINVAL; in q6dma_set_channel_map()
306 dev_err(dai->dev, "invalid rx num %d\n", in q6dma_set_channel_map()
308 return -EINVAL; in q6dma_set_channel_map()
314 dev_err(dai->dev, "%s: invalid dai id 0x%x\n", in q6dma_set_channel_map()
315 __func__, dai->id); in q6dma_set_channel_map()
316 return -EINVAL; in q6dma_set_channel_map()
319 cfg->active_channels_mask = ch_mask; in q6dma_set_channel_map()
328 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6dma_hw_params()
329 struct q6afe_cdc_dma_cfg *cfg = &dai_data->port_config[dai->id].dma_cfg; in q6dma_hw_params()
331 cfg->bit_width = params_width(params); in q6dma_hw_params()
332 cfg->sample_rate = params_rate(params); in q6dma_hw_params()
333 cfg->num_channels = params_channels(params); in q6dma_hw_params()
340 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6afe_dai_shutdown()
343 if (!dai_data->is_port_started[dai->id]) in q6afe_dai_shutdown()
346 rc = q6afe_port_stop(dai_data->port[dai->id]); in q6afe_dai_shutdown()
348 dev_err(dai->dev, "fail to close AFE port (%d)\n", rc); in q6afe_dai_shutdown()
350 dai_data->is_port_started[dai->id] = false; in q6afe_dai_shutdown()
357 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6afe_dai_prepare()
360 if (dai_data->is_port_started[dai->id]) { in q6afe_dai_prepare()
362 rc = q6afe_port_stop(dai_data->port[dai->id]); in q6afe_dai_prepare()
364 dev_err(dai->dev, "fail to close AFE port (%d)\n", rc); in q6afe_dai_prepare()
369 switch (dai->id) { in q6afe_dai_prepare()
372 q6afe_hdmi_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
373 &dai_data->port_config[dai->id].hdmi); in q6afe_dai_prepare()
376 q6afe_slim_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
377 &dai_data->port_config[dai->id].slim); in q6afe_dai_prepare()
381 rc = q6afe_i2s_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
382 &dai_data->port_config[dai->id].i2s_cfg); in q6afe_dai_prepare()
384 dev_err(dai->dev, "fail to prepare AFE port %x\n", in q6afe_dai_prepare()
385 dai->id); in q6afe_dai_prepare()
390 q6afe_tdm_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
391 &dai_data->port_config[dai->id].tdm); in q6afe_dai_prepare()
394 q6afe_cdc_dma_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
395 &dai_data->port_config[dai->id].dma_cfg); in q6afe_dai_prepare()
398 return -EINVAL; in q6afe_dai_prepare()
401 rc = q6afe_port_start(dai_data->port[dai->id]); in q6afe_dai_prepare()
403 dev_err(dai->dev, "fail to start AFE port %x\n", dai->id); in q6afe_dai_prepare()
406 dai_data->is_port_started[dai->id] = true; in q6afe_dai_prepare()
417 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6slim_set_channel_map()
418 struct q6afe_port_config *pcfg = &dai_data->port_config[dai->id]; in q6slim_set_channel_map()
421 if (dai->id & 0x1) { in q6slim_set_channel_map()
425 return -EINVAL; in q6slim_set_channel_map()
429 pcfg->slim.ch_mapping[i] = tx_slot[i]; in q6slim_set_channel_map()
431 pcfg->slim.num_channels = tx_num; in q6slim_set_channel_map()
437 return -EINVAL; in q6slim_set_channel_map()
441 pcfg->slim.ch_mapping[i] = rx_slot[i]; in q6slim_set_channel_map()
443 pcfg->slim.num_channels = rx_num; in q6slim_set_channel_map()
453 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6afe_mi2s_set_sysclk()
454 struct q6afe_port *port = dai_data->port[dai->id]; in q6afe_mi2s_set_sysclk()
629 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in msm_dai_q6_dai_probe()
632 port = q6afe_port_get_from_id(dai->dev, dai->id); in msm_dai_q6_dai_probe()
634 dev_err(dai->dev, "Unable to get afe port\n"); in msm_dai_q6_dai_probe()
635 return -EINVAL; in msm_dai_q6_dai_probe()
637 dai_data->port[dai->id] = port; in msm_dai_q6_dai_probe()
644 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in msm_dai_q6_dai_remove()
646 q6afe_port_put(dai_data->port[dai->id]); in msm_dai_q6_dai_remove()
647 dai_data->port[dai->id] = NULL; in msm_dai_q6_dai_remove()
953 .name = "q6afe-dai-component",
968 for_each_child_of_node(dev->of_node, node) { in of_q6afe_parse_dai_data()
983 priv = &data->priv[id]; in of_q6afe_parse_dai_data()
985 "qcom,sd-lines", in of_q6afe_parse_dai_data()
993 priv->sd_line_mask = 0; in of_q6afe_parse_dai_data()
996 priv->sd_line_mask |= BIT(lines[i]); in of_q6afe_parse_dai_data()
1000 priv = &data->priv[id]; in of_q6afe_parse_dai_data()
1001 ret = of_property_read_u32(node, "qcom,tdm-sync-mode", in of_q6afe_parse_dai_data()
1002 &priv->sync_mode); in of_q6afe_parse_dai_data()
1004 dev_err(dev, "No Sync mode from DT\n"); in of_q6afe_parse_dai_data()
1007 ret = of_property_read_u32(node, "qcom,tdm-sync-src", in of_q6afe_parse_dai_data()
1008 &priv->sync_src); in of_q6afe_parse_dai_data()
1010 dev_err(dev, "No Sync Src from DT\n"); in of_q6afe_parse_dai_data()
1013 ret = of_property_read_u32(node, "qcom,tdm-data-out", in of_q6afe_parse_dai_data()
1014 &priv->data_out_enable); in of_q6afe_parse_dai_data()
1019 ret = of_property_read_u32(node, "qcom,tdm-invert-sync", in of_q6afe_parse_dai_data()
1020 &priv->invert_sync); in of_q6afe_parse_dai_data()
1022 dev_err(dev, "No Invert sync from DT\n"); in of_q6afe_parse_dai_data()
1025 ret = of_property_read_u32(node, "qcom,tdm-data-delay", in of_q6afe_parse_dai_data()
1026 &priv->data_delay); in of_q6afe_parse_dai_data()
1031 ret = of_property_read_u32(node, "qcom,tdm-data-align", in of_q6afe_parse_dai_data()
1032 &priv->data_align); in of_q6afe_parse_dai_data()
1049 struct device *dev = &pdev->dev; in q6afe_dai_dev_probe()
1054 return -ENOMEM; in q6afe_dai_dev_probe()
1071 { .compatible = "qcom,q6afe-dais" },
1079 .name = "q6afe-dai",