Lines Matching +full:tdm +full:- +full:data +full:- +full:delay

1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
14 #include "q6dsp-lpass-ports.h"
40 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6slim_hw_params()
41 struct q6afe_slim_cfg *slim = &dai_data->port_config[dai->id].slim; in q6slim_hw_params()
43 slim->sample_rate = params_rate(params); in q6slim_hw_params()
48 slim->bit_width = 16; in q6slim_hw_params()
51 slim->bit_width = 24; in q6slim_hw_params()
54 slim->bit_width = 32; in q6slim_hw_params()
59 return -EINVAL; in q6slim_hw_params()
69 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6hdmi_hw_params()
71 struct q6afe_hdmi_cfg *hdmi = &dai_data->port_config[dai->id].hdmi; in q6hdmi_hw_params()
73 hdmi->sample_rate = params_rate(params); in q6hdmi_hw_params()
76 hdmi->bit_width = 16; in q6hdmi_hw_params()
79 hdmi->bit_width = 24; in q6hdmi_hw_params()
83 /* HDMI spec CEA-861-E: Table 28 Audio InfoFrame Data Byte 4 */ in q6hdmi_hw_params()
86 hdmi->channel_allocation = 0; in q6hdmi_hw_params()
89 hdmi->channel_allocation = 0x02; in q6hdmi_hw_params()
92 hdmi->channel_allocation = 0x06; in q6hdmi_hw_params()
95 hdmi->channel_allocation = 0x0A; in q6hdmi_hw_params()
98 hdmi->channel_allocation = 0x0B; in q6hdmi_hw_params()
101 hdmi->channel_allocation = 0x12; in q6hdmi_hw_params()
104 hdmi->channel_allocation = 0x13; in q6hdmi_hw_params()
107 dev_err(dai->dev, "invalid Channels = %u\n", channels); in q6hdmi_hw_params()
108 return -EINVAL; in q6hdmi_hw_params()
118 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6i2s_hw_params()
119 struct q6afe_i2s_cfg *i2s = &dai_data->port_config[dai->id].i2s_cfg; in q6i2s_hw_params()
121 i2s->sample_rate = params_rate(params); in q6i2s_hw_params()
122 i2s->bit_width = params_width(params); in q6i2s_hw_params()
123 i2s->num_channels = params_channels(params); in q6i2s_hw_params()
124 i2s->sd_line_mask = dai_data->priv[dai->id].sd_line_mask; in q6i2s_hw_params()
131 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6i2s_set_fmt()
132 struct q6afe_i2s_cfg *i2s = &dai_data->port_config[dai->id].i2s_cfg; in q6i2s_set_fmt()
134 i2s->fmt = fmt; in q6i2s_set_fmt()
145 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6tdm_set_tdm_slot()
146 struct q6afe_tdm_cfg *tdm = &dai_data->port_config[dai->id].tdm; in q6tdm_set_tdm_slot() local
152 dev_err(dai->dev, "%s: invalid slot_width %d\n", in q6tdm_set_tdm_slot()
154 return -EINVAL; in q6tdm_set_tdm_slot()
157 /* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */ in q6tdm_set_tdm_slot()
172 dev_err(dai->dev, "%s: invalid slots %d\n", in q6tdm_set_tdm_slot()
174 return -EINVAL; in q6tdm_set_tdm_slot()
177 switch (dai->id) { in q6tdm_set_tdm_slot()
179 tdm->nslots_per_frame = slots; in q6tdm_set_tdm_slot()
180 tdm->slot_width = slot_width; in q6tdm_set_tdm_slot()
181 /* TDM RX dais ids are even and tx are odd */ in q6tdm_set_tdm_slot()
182 tdm->slot_mask = ((dai->id & 0x1) ? tx_mask : rx_mask) & cap_mask; in q6tdm_set_tdm_slot()
185 dev_err(dai->dev, "%s: invalid dai id 0x%x\n", in q6tdm_set_tdm_slot()
186 __func__, dai->id); in q6tdm_set_tdm_slot()
187 return -EINVAL; in q6tdm_set_tdm_slot()
198 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6tdm_set_channel_map()
199 struct q6afe_tdm_cfg *tdm = &dai_data->port_config[dai->id].tdm; in q6tdm_set_channel_map() local
203 switch (dai->id) { in q6tdm_set_channel_map()
205 if (dai->id & 0x1) { in q6tdm_set_channel_map()
207 dev_err(dai->dev, "tx slot not found\n"); in q6tdm_set_channel_map()
208 return -EINVAL; in q6tdm_set_channel_map()
211 dev_err(dai->dev, "invalid tx num %d\n", in q6tdm_set_channel_map()
213 return -EINVAL; in q6tdm_set_channel_map()
217 tdm->ch_mapping[i] = tx_slot[i]; in q6tdm_set_channel_map()
220 tdm->ch_mapping[i] = Q6AFE_CMAP_INVALID; in q6tdm_set_channel_map()
222 tdm->num_channels = tx_num; in q6tdm_set_channel_map()
226 dev_err(dai->dev, "rx slot not found\n"); in q6tdm_set_channel_map()
227 return -EINVAL; in q6tdm_set_channel_map()
230 dev_err(dai->dev, "invalid rx num %d\n", in q6tdm_set_channel_map()
232 return -EINVAL; in q6tdm_set_channel_map()
236 tdm->ch_mapping[i] = rx_slot[i]; in q6tdm_set_channel_map()
239 tdm->ch_mapping[i] = Q6AFE_CMAP_INVALID; in q6tdm_set_channel_map()
241 tdm->num_channels = rx_num; in q6tdm_set_channel_map()
246 dev_err(dai->dev, "%s: invalid dai id 0x%x\n", in q6tdm_set_channel_map()
247 __func__, dai->id); in q6tdm_set_channel_map()
248 return -EINVAL; in q6tdm_set_channel_map()
258 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6tdm_hw_params()
259 struct q6afe_tdm_cfg *tdm = &dai_data->port_config[dai->id].tdm; in q6tdm_hw_params() local
261 tdm->bit_width = params_width(params); in q6tdm_hw_params()
262 tdm->sample_rate = params_rate(params); in q6tdm_hw_params()
263 tdm->num_channels = params_channels(params); in q6tdm_hw_params()
264 tdm->data_align_type = dai_data->priv[dai->id].data_align; in q6tdm_hw_params()
265 tdm->sync_src = dai_data->priv[dai->id].sync_src; in q6tdm_hw_params()
266 tdm->sync_mode = dai_data->priv[dai->id].sync_mode; in q6tdm_hw_params()
276 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6dma_set_channel_map()
277 struct q6afe_cdc_dma_cfg *cfg = &dai_data->port_config[dai->id].dma_cfg; in q6dma_set_channel_map()
281 switch (dai->id) { in q6dma_set_channel_map()
295 dev_err(dai->dev, "tx slot not found\n"); in q6dma_set_channel_map()
296 return -EINVAL; in q6dma_set_channel_map()
300 dev_err(dai->dev, "invalid tx num %d\n", in q6dma_set_channel_map()
302 return -EINVAL; in q6dma_set_channel_map()
319 dev_err(dai->dev, "rx slot not found\n"); in q6dma_set_channel_map()
320 return -EINVAL; in q6dma_set_channel_map()
323 dev_err(dai->dev, "invalid rx num %d\n", in q6dma_set_channel_map()
325 return -EINVAL; in q6dma_set_channel_map()
331 dev_err(dai->dev, "%s: invalid dai id 0x%x\n", in q6dma_set_channel_map()
332 __func__, dai->id); in q6dma_set_channel_map()
333 return -EINVAL; in q6dma_set_channel_map()
336 cfg->active_channels_mask = ch_mask; in q6dma_set_channel_map()
345 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6dma_hw_params()
346 struct q6afe_cdc_dma_cfg *cfg = &dai_data->port_config[dai->id].dma_cfg; in q6dma_hw_params()
348 cfg->bit_width = params_width(params); in q6dma_hw_params()
349 cfg->sample_rate = params_rate(params); in q6dma_hw_params()
350 cfg->num_channels = params_channels(params); in q6dma_hw_params()
357 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6afe_dai_shutdown()
360 if (!dai_data->is_port_started[dai->id]) in q6afe_dai_shutdown()
363 rc = q6afe_port_stop(dai_data->port[dai->id]); in q6afe_dai_shutdown()
365 dev_err(dai->dev, "fail to close AFE port (%d)\n", rc); in q6afe_dai_shutdown()
367 dai_data->is_port_started[dai->id] = false; in q6afe_dai_shutdown()
374 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6afe_dai_prepare()
377 if (dai_data->is_port_started[dai->id]) { in q6afe_dai_prepare()
379 rc = q6afe_port_stop(dai_data->port[dai->id]); in q6afe_dai_prepare()
381 dev_err(dai->dev, "fail to close AFE port (%d)\n", rc); in q6afe_dai_prepare()
386 switch (dai->id) { in q6afe_dai_prepare()
389 q6afe_hdmi_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
390 &dai_data->port_config[dai->id].hdmi); in q6afe_dai_prepare()
393 q6afe_slim_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
394 &dai_data->port_config[dai->id].slim); in q6afe_dai_prepare()
398 rc = q6afe_i2s_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
399 &dai_data->port_config[dai->id].i2s_cfg); in q6afe_dai_prepare()
401 dev_err(dai->dev, "fail to prepare AFE port %x\n", in q6afe_dai_prepare()
402 dai->id); in q6afe_dai_prepare()
407 q6afe_tdm_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
408 &dai_data->port_config[dai->id].tdm); in q6afe_dai_prepare()
411 q6afe_cdc_dma_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
412 &dai_data->port_config[dai->id].dma_cfg); in q6afe_dai_prepare()
415 return -EINVAL; in q6afe_dai_prepare()
418 rc = q6afe_port_start(dai_data->port[dai->id]); in q6afe_dai_prepare()
420 dev_err(dai->dev, "fail to start AFE port %x\n", dai->id); in q6afe_dai_prepare()
423 dai_data->is_port_started[dai->id] = true; in q6afe_dai_prepare()
432 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6slim_set_channel_map()
433 struct q6afe_port_config *pcfg = &dai_data->port_config[dai->id]; in q6slim_set_channel_map()
436 if (dai->id & 0x1) { in q6slim_set_channel_map()
440 return -EINVAL; in q6slim_set_channel_map()
444 pcfg->slim.ch_mapping[i] = tx_slot[i]; in q6slim_set_channel_map()
446 pcfg->slim.num_channels = tx_num; in q6slim_set_channel_map()
452 return -EINVAL; in q6slim_set_channel_map()
456 pcfg->slim.ch_mapping[i] = rx_slot[i]; in q6slim_set_channel_map()
458 pcfg->slim.num_channels = rx_num; in q6slim_set_channel_map()
468 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6afe_mi2s_set_sysclk()
469 struct q6afe_port *port = dai_data->port[dai->id]; in q6afe_mi2s_set_sysclk()
682 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in msm_dai_q6_dai_probe()
685 port = q6afe_port_get_from_id(dai->dev, dai->id); in msm_dai_q6_dai_probe()
687 dev_err(dai->dev, "Unable to get afe port\n"); in msm_dai_q6_dai_probe()
688 return -EINVAL; in msm_dai_q6_dai_probe()
690 dai_data->port[dai->id] = port; in msm_dai_q6_dai_probe()
697 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in msm_dai_q6_dai_remove()
699 q6afe_port_put(dai_data->port[dai->id]); in msm_dai_q6_dai_remove()
700 dai_data->port[dai->id] = NULL; in msm_dai_q6_dai_remove()
958 .name = "q6afe-dai-component",
968 struct q6afe_dai_data *data) in of_q6afe_parse_dai_data() argument
973 for_each_child_of_node(dev->of_node, node) { in of_q6afe_parse_dai_data()
988 priv = &data->priv[id]; in of_q6afe_parse_dai_data()
990 "qcom,sd-lines", in of_q6afe_parse_dai_data()
998 priv->sd_line_mask = 0; in of_q6afe_parse_dai_data()
1001 priv->sd_line_mask |= BIT(lines[i]); in of_q6afe_parse_dai_data()
1005 priv = &data->priv[id]; in of_q6afe_parse_dai_data()
1006 ret = of_property_read_u32(node, "qcom,tdm-sync-mode", in of_q6afe_parse_dai_data()
1007 &priv->sync_mode); in of_q6afe_parse_dai_data()
1012 ret = of_property_read_u32(node, "qcom,tdm-sync-src", in of_q6afe_parse_dai_data()
1013 &priv->sync_src); in of_q6afe_parse_dai_data()
1018 ret = of_property_read_u32(node, "qcom,tdm-data-out", in of_q6afe_parse_dai_data()
1019 &priv->data_out_enable); in of_q6afe_parse_dai_data()
1021 dev_err(dev, "No Data out enable from DT\n"); in of_q6afe_parse_dai_data()
1024 ret = of_property_read_u32(node, "qcom,tdm-invert-sync", in of_q6afe_parse_dai_data()
1025 &priv->invert_sync); in of_q6afe_parse_dai_data()
1030 ret = of_property_read_u32(node, "qcom,tdm-data-delay", in of_q6afe_parse_dai_data()
1031 &priv->data_delay); in of_q6afe_parse_dai_data()
1033 dev_err(dev, "No Data Delay from DT\n"); in of_q6afe_parse_dai_data()
1036 ret = of_property_read_u32(node, "qcom,tdm-data-align", in of_q6afe_parse_dai_data()
1037 &priv->data_align); in of_q6afe_parse_dai_data()
1039 dev_err(dev, "No Data align from DT\n"); in of_q6afe_parse_dai_data()
1054 struct device *dev = &pdev->dev; in q6afe_dai_dev_probe()
1059 return -ENOMEM; in q6afe_dai_dev_probe()
1078 { .compatible = "qcom,q6afe-dais" },
1086 .name = "q6afe-dai",