Lines Matching +full:tdm +full:- +full:data +full:- +full:out
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
14 #include "q6dsp-lpass-ports.h"
15 #include "q6dsp-common.h"
41 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6slim_hw_params()
42 struct q6afe_slim_cfg *slim = &dai_data->port_config[dai->id].slim; in q6slim_hw_params()
44 slim->sample_rate = params_rate(params); in q6slim_hw_params()
49 slim->bit_width = 16; in q6slim_hw_params()
52 slim->bit_width = 24; in q6slim_hw_params()
55 slim->bit_width = 32; in q6slim_hw_params()
60 return -EINVAL; in q6slim_hw_params()
70 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6hdmi_hw_params()
72 struct q6afe_hdmi_cfg *hdmi = &dai_data->port_config[dai->id].hdmi; in q6hdmi_hw_params()
75 hdmi->sample_rate = params_rate(params); in q6hdmi_hw_params()
78 hdmi->bit_width = 16; in q6hdmi_hw_params()
81 hdmi->bit_width = 24; in q6hdmi_hw_params()
89 hdmi->channel_allocation = (u16) ret; in q6hdmi_hw_params()
98 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6i2s_hw_params()
99 struct q6afe_i2s_cfg *i2s = &dai_data->port_config[dai->id].i2s_cfg; in q6i2s_hw_params()
101 i2s->sample_rate = params_rate(params); in q6i2s_hw_params()
102 i2s->bit_width = params_width(params); in q6i2s_hw_params()
103 i2s->num_channels = params_channels(params); in q6i2s_hw_params()
104 i2s->sd_line_mask = dai_data->priv[dai->id].sd_line_mask; in q6i2s_hw_params()
111 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6i2s_set_fmt()
112 struct q6afe_i2s_cfg *i2s = &dai_data->port_config[dai->id].i2s_cfg; in q6i2s_set_fmt()
114 i2s->fmt = fmt; in q6i2s_set_fmt()
125 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6tdm_set_tdm_slot()
126 struct q6afe_tdm_cfg *tdm = &dai_data->port_config[dai->id].tdm; in q6tdm_set_tdm_slot() local
132 dev_err(dai->dev, "%s: invalid slot_width %d\n", in q6tdm_set_tdm_slot()
134 return -EINVAL; in q6tdm_set_tdm_slot()
137 /* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */ in q6tdm_set_tdm_slot()
152 dev_err(dai->dev, "%s: invalid slots %d\n", in q6tdm_set_tdm_slot()
154 return -EINVAL; in q6tdm_set_tdm_slot()
157 switch (dai->id) { in q6tdm_set_tdm_slot()
159 tdm->nslots_per_frame = slots; in q6tdm_set_tdm_slot()
160 tdm->slot_width = slot_width; in q6tdm_set_tdm_slot()
161 /* TDM RX dais ids are even and tx are odd */ in q6tdm_set_tdm_slot()
162 tdm->slot_mask = ((dai->id & 0x1) ? tx_mask : rx_mask) & cap_mask; in q6tdm_set_tdm_slot()
165 dev_err(dai->dev, "%s: invalid dai id 0x%x\n", in q6tdm_set_tdm_slot()
166 __func__, dai->id); in q6tdm_set_tdm_slot()
167 return -EINVAL; in q6tdm_set_tdm_slot()
178 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6tdm_set_channel_map()
179 struct q6afe_tdm_cfg *tdm = &dai_data->port_config[dai->id].tdm; in q6tdm_set_channel_map() local
183 switch (dai->id) { in q6tdm_set_channel_map()
185 if (dai->id & 0x1) { in q6tdm_set_channel_map()
187 dev_err(dai->dev, "tx slot not found\n"); in q6tdm_set_channel_map()
188 return -EINVAL; in q6tdm_set_channel_map()
191 dev_err(dai->dev, "invalid tx num %d\n", in q6tdm_set_channel_map()
193 return -EINVAL; in q6tdm_set_channel_map()
197 tdm->ch_mapping[i] = tx_slot[i]; in q6tdm_set_channel_map()
200 tdm->ch_mapping[i] = Q6AFE_CMAP_INVALID; in q6tdm_set_channel_map()
202 tdm->num_channels = tx_num; in q6tdm_set_channel_map()
206 dev_err(dai->dev, "rx slot not found\n"); in q6tdm_set_channel_map()
207 return -EINVAL; in q6tdm_set_channel_map()
210 dev_err(dai->dev, "invalid rx num %d\n", in q6tdm_set_channel_map()
212 return -EINVAL; in q6tdm_set_channel_map()
216 tdm->ch_mapping[i] = rx_slot[i]; in q6tdm_set_channel_map()
219 tdm->ch_mapping[i] = Q6AFE_CMAP_INVALID; in q6tdm_set_channel_map()
221 tdm->num_channels = rx_num; in q6tdm_set_channel_map()
226 dev_err(dai->dev, "%s: invalid dai id 0x%x\n", in q6tdm_set_channel_map()
227 __func__, dai->id); in q6tdm_set_channel_map()
228 return -EINVAL; in q6tdm_set_channel_map()
238 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6tdm_hw_params()
239 struct q6afe_tdm_cfg *tdm = &dai_data->port_config[dai->id].tdm; in q6tdm_hw_params() local
241 tdm->bit_width = params_width(params); in q6tdm_hw_params()
242 tdm->sample_rate = params_rate(params); in q6tdm_hw_params()
243 tdm->num_channels = params_channels(params); in q6tdm_hw_params()
244 tdm->data_align_type = dai_data->priv[dai->id].data_align; in q6tdm_hw_params()
245 tdm->sync_src = dai_data->priv[dai->id].sync_src; in q6tdm_hw_params()
246 tdm->sync_mode = dai_data->priv[dai->id].sync_mode; in q6tdm_hw_params()
256 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6dma_set_channel_map()
257 struct q6afe_cdc_dma_cfg *cfg = &dai_data->port_config[dai->id].dma_cfg; in q6dma_set_channel_map()
261 switch (dai->id) { in q6dma_set_channel_map()
275 dev_err(dai->dev, "tx slot not found\n"); in q6dma_set_channel_map()
276 return -EINVAL; in q6dma_set_channel_map()
280 dev_err(dai->dev, "invalid tx num %d\n", in q6dma_set_channel_map()
282 return -EINVAL; in q6dma_set_channel_map()
299 dev_err(dai->dev, "rx slot not found\n"); in q6dma_set_channel_map()
300 return -EINVAL; in q6dma_set_channel_map()
303 dev_err(dai->dev, "invalid rx num %d\n", in q6dma_set_channel_map()
305 return -EINVAL; in q6dma_set_channel_map()
311 dev_err(dai->dev, "%s: invalid dai id 0x%x\n", in q6dma_set_channel_map()
312 __func__, dai->id); in q6dma_set_channel_map()
313 return -EINVAL; in q6dma_set_channel_map()
316 cfg->active_channels_mask = ch_mask; in q6dma_set_channel_map()
325 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6dma_hw_params()
326 struct q6afe_cdc_dma_cfg *cfg = &dai_data->port_config[dai->id].dma_cfg; in q6dma_hw_params()
328 cfg->bit_width = params_width(params); in q6dma_hw_params()
329 cfg->sample_rate = params_rate(params); in q6dma_hw_params()
330 cfg->num_channels = params_channels(params); in q6dma_hw_params()
337 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6afe_dai_shutdown()
340 if (!dai_data->is_port_started[dai->id]) in q6afe_dai_shutdown()
343 rc = q6afe_port_stop(dai_data->port[dai->id]); in q6afe_dai_shutdown()
345 dev_err(dai->dev, "fail to close AFE port (%d)\n", rc); in q6afe_dai_shutdown()
347 dai_data->is_port_started[dai->id] = false; in q6afe_dai_shutdown()
354 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6afe_dai_prepare()
357 if (dai_data->is_port_started[dai->id]) { in q6afe_dai_prepare()
359 rc = q6afe_port_stop(dai_data->port[dai->id]); in q6afe_dai_prepare()
361 dev_err(dai->dev, "fail to close AFE port (%d)\n", rc); in q6afe_dai_prepare()
366 switch (dai->id) { in q6afe_dai_prepare()
369 q6afe_hdmi_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
370 &dai_data->port_config[dai->id].hdmi); in q6afe_dai_prepare()
373 q6afe_slim_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
374 &dai_data->port_config[dai->id].slim); in q6afe_dai_prepare()
378 rc = q6afe_i2s_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
379 &dai_data->port_config[dai->id].i2s_cfg); in q6afe_dai_prepare()
381 dev_err(dai->dev, "fail to prepare AFE port %x\n", in q6afe_dai_prepare()
382 dai->id); in q6afe_dai_prepare()
387 q6afe_tdm_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
388 &dai_data->port_config[dai->id].tdm); in q6afe_dai_prepare()
391 q6afe_cdc_dma_port_prepare(dai_data->port[dai->id], in q6afe_dai_prepare()
392 &dai_data->port_config[dai->id].dma_cfg); in q6afe_dai_prepare()
395 return -EINVAL; in q6afe_dai_prepare()
398 rc = q6afe_port_start(dai_data->port[dai->id]); in q6afe_dai_prepare()
400 dev_err(dai->dev, "fail to start AFE port %x\n", dai->id); in q6afe_dai_prepare()
403 dai_data->is_port_started[dai->id] = true; in q6afe_dai_prepare()
412 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6slim_set_channel_map()
413 struct q6afe_port_config *pcfg = &dai_data->port_config[dai->id]; in q6slim_set_channel_map()
416 if (dai->id & 0x1) { in q6slim_set_channel_map()
420 return -EINVAL; in q6slim_set_channel_map()
424 pcfg->slim.ch_mapping[i] = tx_slot[i]; in q6slim_set_channel_map()
426 pcfg->slim.num_channels = tx_num; in q6slim_set_channel_map()
432 return -EINVAL; in q6slim_set_channel_map()
436 pcfg->slim.ch_mapping[i] = rx_slot[i]; in q6slim_set_channel_map()
438 pcfg->slim.num_channels = rx_num; in q6slim_set_channel_map()
448 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in q6afe_mi2s_set_sysclk()
449 struct q6afe_port *port = dai_data->port[dai->id]; in q6afe_mi2s_set_sysclk()
624 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in msm_dai_q6_dai_probe()
627 port = q6afe_port_get_from_id(dai->dev, dai->id); in msm_dai_q6_dai_probe()
629 dev_err(dai->dev, "Unable to get afe port\n"); in msm_dai_q6_dai_probe()
630 return -EINVAL; in msm_dai_q6_dai_probe()
632 dai_data->port[dai->id] = port; in msm_dai_q6_dai_probe()
639 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); in msm_dai_q6_dai_remove()
641 q6afe_port_put(dai_data->port[dai->id]); in msm_dai_q6_dai_remove()
642 dai_data->port[dai->id] = NULL; in msm_dai_q6_dai_remove()
948 .name = "q6afe-dai-component",
958 struct q6afe_dai_data *data) in of_q6afe_parse_dai_data() argument
963 for_each_child_of_node(dev->of_node, node) { in of_q6afe_parse_dai_data()
978 priv = &data->priv[id]; in of_q6afe_parse_dai_data()
980 "qcom,sd-lines", in of_q6afe_parse_dai_data()
988 priv->sd_line_mask = 0; in of_q6afe_parse_dai_data()
991 priv->sd_line_mask |= BIT(lines[i]); in of_q6afe_parse_dai_data()
995 priv = &data->priv[id]; in of_q6afe_parse_dai_data()
996 ret = of_property_read_u32(node, "qcom,tdm-sync-mode", in of_q6afe_parse_dai_data()
997 &priv->sync_mode); in of_q6afe_parse_dai_data()
1002 ret = of_property_read_u32(node, "qcom,tdm-sync-src", in of_q6afe_parse_dai_data()
1003 &priv->sync_src); in of_q6afe_parse_dai_data()
1008 ret = of_property_read_u32(node, "qcom,tdm-data-out", in of_q6afe_parse_dai_data()
1009 &priv->data_out_enable); in of_q6afe_parse_dai_data()
1011 dev_err(dev, "No Data out enable from DT\n"); in of_q6afe_parse_dai_data()
1014 ret = of_property_read_u32(node, "qcom,tdm-invert-sync", in of_q6afe_parse_dai_data()
1015 &priv->invert_sync); in of_q6afe_parse_dai_data()
1020 ret = of_property_read_u32(node, "qcom,tdm-data-delay", in of_q6afe_parse_dai_data()
1021 &priv->data_delay); in of_q6afe_parse_dai_data()
1023 dev_err(dev, "No Data Delay from DT\n"); in of_q6afe_parse_dai_data()
1026 ret = of_property_read_u32(node, "qcom,tdm-data-align", in of_q6afe_parse_dai_data()
1027 &priv->data_align); in of_q6afe_parse_dai_data()
1029 dev_err(dev, "No Data align from DT\n"); in of_q6afe_parse_dai_data()
1044 struct device *dev = &pdev->dev; in q6afe_dai_dev_probe()
1049 return -ENOMEM; in q6afe_dai_dev_probe()
1066 { .compatible = "qcom,q6afe-dais" },
1074 .name = "q6afe-dai",