|
14 | 14 | #include "sof-of-dev.h" |
15 | 15 | #include "ops.h" |
16 | 16 |
|
| 17 | +static bool is_virtual_widget(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *widget, |
| 18 | + const char *func) |
| 19 | +{ |
| 20 | + switch (widget->id) { |
| 21 | + case snd_soc_dapm_out_drv: |
| 22 | + case snd_soc_dapm_output: |
| 23 | + case snd_soc_dapm_input: |
| 24 | + dev_dbg(sdev->dev, "%s: %s is a virtual widget\n", func, widget->name); |
| 25 | + return true; |
| 26 | + default: |
| 27 | + return false; |
| 28 | + } |
| 29 | +} |
| 30 | + |
17 | 31 | static void sof_reset_route_setup_status(struct snd_sof_dev *sdev, struct snd_sof_widget *widget) |
18 | 32 | { |
19 | 33 | const struct sof_ipc_tplg_ops *tplg_ops = sof_ipc_get_ops(sdev, tplg); |
@@ -231,23 +245,9 @@ int sof_route_setup(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *wsourc |
231 | 245 | bool route_found = false; |
232 | 246 |
|
233 | 247 | /* ignore routes involving virtual widgets in topology */ |
234 | | - switch (src_widget->id) { |
235 | | - case snd_soc_dapm_out_drv: |
236 | | - case snd_soc_dapm_output: |
237 | | - case snd_soc_dapm_input: |
| 248 | + if (is_virtual_widget(sdev, src_widget->widget, __func__) || |
| 249 | + is_virtual_widget(sdev, sink_widget->widget, __func__)) |
238 | 250 | return 0; |
239 | | - default: |
240 | | - break; |
241 | | - } |
242 | | - |
243 | | - switch (sink_widget->id) { |
244 | | - case snd_soc_dapm_out_drv: |
245 | | - case snd_soc_dapm_output: |
246 | | - case snd_soc_dapm_input: |
247 | | - return 0; |
248 | | - default: |
249 | | - break; |
250 | | - } |
251 | 251 |
|
252 | 252 | /* find route matching source and sink widgets */ |
253 | 253 | list_for_each_entry(sroute, &sdev->route_list, list) |
@@ -396,6 +396,9 @@ sof_unprepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widg |
396 | 396 | const struct sof_ipc_tplg_widget_ops *widget_ops; |
397 | 397 | struct snd_soc_dapm_path *p; |
398 | 398 |
|
| 399 | + if (is_virtual_widget(sdev, widget, __func__)) |
| 400 | + return; |
| 401 | + |
399 | 402 | /* skip if the widget is in use or if it is already unprepared */ |
400 | 403 | if (!swidget || !swidget->prepared || swidget->use_count > 0) |
401 | 404 | goto sink_unprepare; |
@@ -433,6 +436,9 @@ sof_prepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget |
433 | 436 | struct snd_soc_dapm_path *p; |
434 | 437 | int ret; |
435 | 438 |
|
| 439 | + if (is_virtual_widget(sdev, widget, __func__)) |
| 440 | + return 0; |
| 441 | + |
436 | 442 | widget_ops = tplg_ops ? tplg_ops->widget : NULL; |
437 | 443 | if (!widget_ops) |
438 | 444 | return 0; |
@@ -488,6 +494,9 @@ static int sof_free_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dap |
488 | 494 | int err; |
489 | 495 | int ret = 0; |
490 | 496 |
|
| 497 | + if (is_virtual_widget(sdev, widget, __func__)) |
| 498 | + return 0; |
| 499 | + |
491 | 500 | if (widget->dobj.private) { |
492 | 501 | err = sof_widget_free(sdev, widget->dobj.private); |
493 | 502 | if (err < 0) |
@@ -527,6 +536,9 @@ static int sof_set_up_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_d |
527 | 536 | struct snd_soc_dapm_path *p; |
528 | 537 | int ret; |
529 | 538 |
|
| 539 | + if (is_virtual_widget(sdev, widget, __func__)) |
| 540 | + return 0; |
| 541 | + |
530 | 542 | if (swidget) { |
531 | 543 | int i; |
532 | 544 |
|
@@ -592,6 +604,9 @@ sof_walk_widgets_in_order(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, |
592 | 604 | return 0; |
593 | 605 |
|
594 | 606 | for_each_dapm_widgets(list, i, widget) { |
| 607 | + if (is_virtual_widget(sdev, widget, __func__)) |
| 608 | + continue; |
| 609 | + |
595 | 610 | /* starting widget for playback is AIF type */ |
596 | 611 | if (dir == SNDRV_PCM_STREAM_PLAYBACK && widget->id != snd_soc_dapm_aif_in) |
597 | 612 | continue; |
|
0 commit comments