Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: add new trigger ordering method

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

This patch-set adds new "trigger" starting/stopping method.

+93 -71
+9 -2
include/sound/soc-component.h
··· 159 159 int remove_order; 160 160 161 161 /* 162 + * soc_pcm_trigger() start/stop sequence. 163 + * see also 164 + * snd_soc_dai_link 165 + * soc_pcm_trigger() 166 + */ 167 + enum snd_soc_trigger_order trigger_start; 168 + enum snd_soc_trigger_order trigger_stop; 169 + 170 + /* 162 171 * signal if the module handling the component should not be removed 163 172 * if a pcm is open. Setting this would prevent the module 164 173 * refcount being incremented in probe() but allow it be incremented ··· 198 189 struct snd_pcm_hw_params *params); 199 190 bool use_dai_pcm_id; /* use DAI link PCM ID as PCM device number */ 200 191 int be_pcm_base; /* base device ID for all BE PCMs */ 201 - 202 - unsigned int start_dma_last; 203 192 204 193 #ifdef CONFIG_DEBUG_FS 205 194 const char *debugfs_prefix;
+17 -6
include/sound/soc.h
··· 607 607 int snd_soc_put_strobe(struct snd_kcontrol *kcontrol, 608 608 struct snd_ctl_elem_value *ucontrol); 609 609 610 + enum snd_soc_trigger_order { 611 + /* start stop */ 612 + SND_SOC_TRIGGER_ORDER_DEFAULT = 0, /* Link->Component->DAI DAI->Component->Link */ 613 + SND_SOC_TRIGGER_ORDER_LDC, /* Link->DAI->Component Component->DAI->Link */ 614 + 615 + SND_SOC_TRIGGER_ORDER_MAX, 616 + }; 617 + 610 618 /* SoC PCM stream information */ 611 619 struct snd_soc_pcm_stream { 612 620 const char *stream_name; ··· 721 713 const struct snd_soc_ops *ops; 722 714 const struct snd_soc_compr_ops *compr_ops; 723 715 716 + /* 717 + * soc_pcm_trigger() start/stop sequence. 718 + * see also 719 + * snd_soc_component_driver 720 + * soc_pcm_trigger() 721 + */ 722 + enum snd_soc_trigger_order trigger_start; 723 + enum snd_soc_trigger_order trigger_stop; 724 + 724 725 /* Mark this pcm with non atomic ops */ 725 726 unsigned int nonatomic:1; 726 727 ··· 767 750 768 751 /* Do not create a PCM for this DAI link (Backend link) */ 769 752 unsigned int ignore:1; 770 - 771 - /* This flag will reorder stop sequence. By enabling this flag 772 - * DMA controller stop sequence will be invoked first followed by 773 - * CPU DAI driver stop sequence 774 - */ 775 - unsigned int stop_dma_first:1; 776 753 777 754 #ifdef CONFIG_SND_SOC_TOPOLOGY 778 755 struct snd_soc_dobj dobj; /* For topology */
+10 -10
sound/soc/amd/acp-da7219-max98357a.c
··· 524 524 | SND_SOC_DAIFMT_CBP_CFP, 525 525 .init = cz_da7219_init, 526 526 .dpcm_playback = 1, 527 - .stop_dma_first = 1, 527 + .trigger_stop = SND_SOC_TRIGGER_ORDER_LDC, 528 528 .ops = &cz_da7219_play_ops, 529 529 SND_SOC_DAILINK_REG(designware1, dlgs, platform), 530 530 }, ··· 534 534 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 535 535 | SND_SOC_DAIFMT_CBP_CFP, 536 536 .dpcm_capture = 1, 537 - .stop_dma_first = 1, 537 + .trigger_stop = SND_SOC_TRIGGER_ORDER_LDC, 538 538 .ops = &cz_da7219_cap_ops, 539 539 SND_SOC_DAILINK_REG(designware2, dlgs, platform), 540 540 }, ··· 544 544 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 545 545 | SND_SOC_DAIFMT_CBP_CFP, 546 546 .dpcm_playback = 1, 547 - .stop_dma_first = 1, 547 + .trigger_stop = SND_SOC_TRIGGER_ORDER_LDC, 548 548 .ops = &cz_max_play_ops, 549 549 SND_SOC_DAILINK_REG(designware3, mx, platform), 550 550 }, ··· 555 555 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 556 556 | SND_SOC_DAIFMT_CBP_CFP, 557 557 .dpcm_capture = 1, 558 - .stop_dma_first = 1, 558 + .trigger_stop = SND_SOC_TRIGGER_ORDER_LDC, 559 559 .ops = &cz_dmic0_cap_ops, 560 560 SND_SOC_DAILINK_REG(designware3, adau, platform), 561 561 }, ··· 566 566 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 567 567 | SND_SOC_DAIFMT_CBP_CFP, 568 568 .dpcm_capture = 1, 569 - .stop_dma_first = 1, 569 + .trigger_stop = SND_SOC_TRIGGER_ORDER_LDC, 570 570 .ops = &cz_dmic1_cap_ops, 571 571 SND_SOC_DAILINK_REG(designware2, adau, platform), 572 572 }, ··· 580 580 | SND_SOC_DAIFMT_CBP_CFP, 581 581 .init = cz_rt5682_init, 582 582 .dpcm_playback = 1, 583 - .stop_dma_first = 1, 583 + .trigger_stop = SND_SOC_TRIGGER_ORDER_LDC, 584 584 .ops = &cz_rt5682_play_ops, 585 585 SND_SOC_DAILINK_REG(designware1, rt5682, platform), 586 586 }, ··· 590 590 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 591 591 | SND_SOC_DAIFMT_CBP_CFP, 592 592 .dpcm_capture = 1, 593 - .stop_dma_first = 1, 593 + .trigger_stop = SND_SOC_TRIGGER_ORDER_LDC, 594 594 .ops = &cz_rt5682_cap_ops, 595 595 SND_SOC_DAILINK_REG(designware2, rt5682, platform), 596 596 }, ··· 600 600 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 601 601 | SND_SOC_DAIFMT_CBP_CFP, 602 602 .dpcm_playback = 1, 603 - .stop_dma_first = 1, 603 + .trigger_stop = SND_SOC_TRIGGER_ORDER_LDC, 604 604 .ops = &cz_rt5682_max_play_ops, 605 605 SND_SOC_DAILINK_REG(designware3, mx, platform), 606 606 }, ··· 611 611 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 612 612 | SND_SOC_DAIFMT_CBP_CFP, 613 613 .dpcm_capture = 1, 614 - .stop_dma_first = 1, 614 + .trigger_stop = SND_SOC_TRIGGER_ORDER_LDC, 615 615 .ops = &cz_rt5682_dmic0_cap_ops, 616 616 SND_SOC_DAILINK_REG(designware3, adau, platform), 617 617 }, ··· 622 622 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 623 623 | SND_SOC_DAIFMT_CBP_CFP, 624 624 .dpcm_capture = 1, 625 - .stop_dma_first = 1, 625 + .trigger_stop = SND_SOC_TRIGGER_ORDER_LDC, 626 626 .ops = &cz_rt5682_dmic1_cap_ops, 627 627 SND_SOC_DAILINK_REG(designware2, adau, platform), 628 628 },
+1 -1
sound/soc/amd/acp-es8336.c
··· 149 149 .stream_name = "ES8336 HiFi Play", 150 150 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 151 151 | SND_SOC_DAIFMT_CBP_CFP, 152 - .stop_dma_first = 1, 152 + .trigger_stop = SND_SOC_TRIGGER_ORDER_LDC, 153 153 .dpcm_capture = 1, 154 154 .dpcm_playback = 1, 155 155 .init = st_es8336_init,
+1 -1
sound/soc/atmel/mchp-pdmc.c
··· 423 423 .open = &mchp_pdmc_open, 424 424 .close = &mchp_pdmc_close, 425 425 .legacy_dai_naming = 1, 426 - .start_dma_last = 1, 426 + .trigger_start = SND_SOC_TRIGGER_ORDER_LDC, 427 427 }; 428 428 429 429 static const unsigned int mchp_pdmc_1mic[] = {1};
+54 -50
sound/soc/soc-pcm.c
··· 1094 1094 return ret; 1095 1095 } 1096 1096 1097 + #define TRIGGER_MAX 3 1098 + static int (* const trigger[][TRIGGER_MAX])(struct snd_pcm_substream *substream, int cmd, int rollback) = { 1099 + [SND_SOC_TRIGGER_ORDER_DEFAULT] = { 1100 + snd_soc_link_trigger, 1101 + snd_soc_pcm_component_trigger, 1102 + snd_soc_pcm_dai_trigger, 1103 + }, 1104 + [SND_SOC_TRIGGER_ORDER_LDC] = { 1105 + snd_soc_link_trigger, 1106 + snd_soc_pcm_dai_trigger, 1107 + snd_soc_pcm_component_trigger, 1108 + }, 1109 + }; 1110 + 1097 1111 static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 1098 1112 { 1099 1113 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 1100 1114 struct snd_soc_component *component; 1101 - int ret = -EINVAL, _ret = 0, start_dma_last = 0, i; 1115 + int ret = 0, r = 0, i; 1102 1116 int rollback = 0; 1117 + int start = 0, stop = 0; 1103 1118 1119 + /* 1120 + * select START/STOP sequence 1121 + */ 1122 + for_each_rtd_components(rtd, i, component) { 1123 + if (component->driver->trigger_start) 1124 + start = component->driver->trigger_start; 1125 + if (component->driver->trigger_stop) 1126 + stop = component->driver->trigger_stop; 1127 + } 1128 + if (rtd->dai_link->trigger_start) 1129 + start = rtd->dai_link->trigger_start; 1130 + if (rtd->dai_link->trigger_stop) 1131 + stop = rtd->dai_link->trigger_stop; 1132 + 1133 + if (start < 0 || start >= SND_SOC_TRIGGER_ORDER_MAX || 1134 + stop < 0 || stop >= SND_SOC_TRIGGER_ORDER_MAX) 1135 + return -EINVAL; 1136 + 1137 + /* 1138 + * START 1139 + */ 1104 1140 switch (cmd) { 1105 1141 case SNDRV_PCM_TRIGGER_START: 1106 1142 case SNDRV_PCM_TRIGGER_RESUME: 1107 1143 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 1108 - /* Do we need to start dma last? */ 1109 - for_each_rtd_components(rtd, i, component) { 1110 - if (component->driver->start_dma_last) { 1111 - start_dma_last = 1; 1144 + for (i = 0; i < TRIGGER_MAX; i++) { 1145 + r = trigger[start][i](substream, cmd, 0); 1146 + if (r < 0) 1112 1147 break; 1113 - } 1114 1148 } 1115 - 1116 - ret = snd_soc_link_trigger(substream, cmd, 0); 1117 - if (ret < 0) 1118 - goto start_err; 1119 - 1120 - if (start_dma_last) { 1121 - ret = snd_soc_pcm_dai_trigger(substream, cmd, 0); 1122 - if (ret < 0) 1123 - goto start_err; 1124 - 1125 - ret = snd_soc_pcm_component_trigger(substream, cmd, 0); 1126 - } else { 1127 - ret = snd_soc_pcm_component_trigger(substream, cmd, 0); 1128 - if (ret < 0) 1129 - goto start_err; 1130 - 1131 - ret = snd_soc_pcm_dai_trigger(substream, cmd, 0); 1132 - } 1133 - start_err: 1134 - if (ret < 0) 1135 - rollback = 1; 1136 1149 } 1137 1150 1138 - if (rollback) { 1139 - _ret = ret; 1151 + /* 1152 + * Rollback if START failed 1153 + * find correspond STOP command 1154 + */ 1155 + if (r < 0) { 1156 + rollback = 1; 1157 + ret = r; 1140 1158 switch (cmd) { 1141 1159 case SNDRV_PCM_TRIGGER_START: 1142 1160 cmd = SNDRV_PCM_TRIGGER_STOP; ··· 1168 1150 } 1169 1151 } 1170 1152 1153 + /* 1154 + * STOP 1155 + */ 1171 1156 switch (cmd) { 1172 1157 case SNDRV_PCM_TRIGGER_STOP: 1173 1158 case SNDRV_PCM_TRIGGER_SUSPEND: 1174 1159 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 1175 - if (rtd->dai_link->stop_dma_first) { 1176 - ret = snd_soc_pcm_component_trigger(substream, cmd, rollback); 1177 - if (ret < 0) 1178 - break; 1179 - 1180 - ret = snd_soc_pcm_dai_trigger(substream, cmd, rollback); 1181 - if (ret < 0) 1182 - break; 1183 - } else { 1184 - ret = snd_soc_pcm_dai_trigger(substream, cmd, rollback); 1185 - if (ret < 0) 1186 - break; 1187 - 1188 - ret = snd_soc_pcm_component_trigger(substream, cmd, rollback); 1189 - if (ret < 0) 1190 - break; 1160 + for (i = TRIGGER_MAX; i > 0; i--) { 1161 + r = trigger[stop][i - 1](substream, cmd, rollback); 1162 + if (r < 0) 1163 + ret = r; 1191 1164 } 1192 - ret = snd_soc_link_trigger(substream, cmd, rollback); 1193 - break; 1194 1165 } 1195 - 1196 - if (_ret) 1197 - ret = _ret; 1198 1166 1199 1167 return ret; 1200 1168 }
+1 -1
sound/soc/starfive/jh7110_tdm.c
··· 328 328 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 329 329 struct snd_soc_dai_link *dai_link = rtd->dai_link; 330 330 331 - dai_link->stop_dma_first = 1; 331 + dai_link->trigger_stop = SND_SOC_TRIGGER_ORDER_LDC; 332 332 333 333 return 0; 334 334 }