Lines Matching +full:capture +full:- +full:sd +full:- +full:lines
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()
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()
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()
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()
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()
493 {"SLIMBUS_0_TX", NULL, "Slimbus Capture"},
494 {"SLIMBUS_1_TX", NULL, "Slimbus1 Capture"},
495 {"SLIMBUS_2_TX", NULL, "Slimbus2 Capture"},
496 {"SLIMBUS_3_TX", NULL, "Slimbus3 Capture"},
497 {"SLIMBUS_4_TX", NULL, "Slimbus4 Capture"},
498 {"SLIMBUS_5_TX", NULL, "Slimbus5 Capture"},
499 {"SLIMBUS_6_TX", NULL, "Slimbus6 Capture"},
552 {"PRIMARY_TDM_TX_0", NULL, "Primary TDM0 Capture"},
553 {"PRIMARY_TDM_TX_1", NULL, "Primary TDM1 Capture"},
554 {"PRIMARY_TDM_TX_2", NULL, "Primary TDM2 Capture"},
555 {"PRIMARY_TDM_TX_3", NULL, "Primary TDM3 Capture"},
556 {"PRIMARY_TDM_TX_4", NULL, "Primary TDM4 Capture"},
557 {"PRIMARY_TDM_TX_5", NULL, "Primary TDM5 Capture"},
558 {"PRIMARY_TDM_TX_6", NULL, "Primary TDM6 Capture"},
559 {"PRIMARY_TDM_TX_7", NULL, "Primary TDM7 Capture"},
561 {"SEC_TDM_TX_0", NULL, "Secondary TDM0 Capture"},
562 {"SEC_TDM_TX_1", NULL, "Secondary TDM1 Capture"},
563 {"SEC_TDM_TX_2", NULL, "Secondary TDM2 Capture"},
564 {"SEC_TDM_TX_3", NULL, "Secondary TDM3 Capture"},
565 {"SEC_TDM_TX_4", NULL, "Secondary TDM4 Capture"},
566 {"SEC_TDM_TX_5", NULL, "Secondary TDM5 Capture"},
567 {"SEC_TDM_TX_6", NULL, "Secondary TDM6 Capture"},
568 {"SEC_TDM_TX_7", NULL, "Secondary TDM7 Capture"},
570 {"TERT_TDM_TX_0", NULL, "Tertiary TDM0 Capture"},
571 {"TERT_TDM_TX_1", NULL, "Tertiary TDM1 Capture"},
572 {"TERT_TDM_TX_2", NULL, "Tertiary TDM2 Capture"},
573 {"TERT_TDM_TX_3", NULL, "Tertiary TDM3 Capture"},
574 {"TERT_TDM_TX_4", NULL, "Tertiary TDM4 Capture"},
575 {"TERT_TDM_TX_5", NULL, "Tertiary TDM5 Capture"},
576 {"TERT_TDM_TX_6", NULL, "Tertiary TDM6 Capture"},
577 {"TERT_TDM_TX_7", NULL, "Tertiary TDM7 Capture"},
579 {"QUAT_TDM_TX_0", NULL, "Quaternary TDM0 Capture"},
580 {"QUAT_TDM_TX_1", NULL, "Quaternary TDM1 Capture"},
581 {"QUAT_TDM_TX_2", NULL, "Quaternary TDM2 Capture"},
582 {"QUAT_TDM_TX_3", NULL, "Quaternary TDM3 Capture"},
583 {"QUAT_TDM_TX_4", NULL, "Quaternary TDM4 Capture"},
584 {"QUAT_TDM_TX_5", NULL, "Quaternary TDM5 Capture"},
585 {"QUAT_TDM_TX_6", NULL, "Quaternary TDM6 Capture"},
586 {"QUAT_TDM_TX_7", NULL, "Quaternary TDM7 Capture"},
588 {"QUIN_TDM_TX_0", NULL, "Quinary TDM0 Capture"},
589 {"QUIN_TDM_TX_1", NULL, "Quinary TDM1 Capture"},
590 {"QUIN_TDM_TX_2", NULL, "Quinary TDM2 Capture"},
591 {"QUIN_TDM_TX_3", NULL, "Quinary TDM3 Capture"},
592 {"QUIN_TDM_TX_4", NULL, "Quinary TDM4 Capture"},
593 {"QUIN_TDM_TX_5", NULL, "Quinary TDM5 Capture"},
594 {"QUIN_TDM_TX_6", NULL, "Quinary TDM6 Capture"},
595 {"QUIN_TDM_TX_7", NULL, "Quinary TDM7 Capture"},
597 {"TERT_MI2S_TX", NULL, "Tertiary MI2S Capture"},
598 {"PRI_MI2S_TX", NULL, "Primary MI2S Capture"},
599 {"SEC_MI2S_TX", NULL, "Secondary MI2S Capture"},
600 {"QUAT_MI2S_TX", NULL, "Quaternary MI2S Capture"},
601 {"QUIN_MI2S_TX", NULL, "Quinary MI2S Capture"},
604 {"WSA_CODEC_DMA_TX_0", NULL, "WSA_CODEC_DMA_TX_0 Capture"},
606 {"WSA_CODEC_DMA_TX_1", NULL, "WSA_CODEC_DMA_TX_1 Capture"},
607 {"WSA_CODEC_DMA_TX_2", NULL, "WSA_CODEC_DMA_TX_2 Capture"},
608 {"VA_CODEC_DMA_TX_0", NULL, "VA_CODEC_DMA_TX_0 Capture"},
609 {"VA_CODEC_DMA_TX_1", NULL, "VA_CODEC_DMA_TX_1 Capture"},
610 {"VA_CODEC_DMA_TX_2", NULL, "VA_CODEC_DMA_TX_2 Capture"},
612 {"TX_CODEC_DMA_TX_0", NULL, "TX_CODEC_DMA_TX_0 Capture"},
614 {"TX_CODEC_DMA_TX_1", NULL, "TX_CODEC_DMA_TX_1 Capture"},
616 {"TX_CODEC_DMA_TX_2", NULL, "TX_CODEC_DMA_TX_2 Capture"},
618 {"TX_CODEC_DMA_TX_3", NULL, "TX_CODEC_DMA_TX_3 Capture"},
620 {"TX_CODEC_DMA_TX_4", NULL, "TX_CODEC_DMA_TX_4 Capture"},
622 {"TX_CODEC_DMA_TX_5", NULL, "TX_CODEC_DMA_TX_5 Capture"},
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()
969 unsigned int lines[Q6AFE_MAX_MI2S_LINES]; in of_q6afe_parse_dai_data() local
983 priv = &data->priv[id]; in of_q6afe_parse_dai_data()
985 "qcom,sd-lines", in of_q6afe_parse_dai_data()
986 lines, 0, 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()
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()
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()
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",