diff options
author | Jarkko Nikula <jhnikula@gmail.com> | 2010-12-14 05:18:30 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-12-15 13:00:41 -0500 |
commit | 8ddab3f5107c3955e70e87a632d4d179ddba1189 (patch) | |
tree | 639742e20df719e585f1f31896112fa08314f7a6 /sound/soc/soc-dapm.c | |
parent | 656d4b1edeb32a87042caee5694603706e399929 (diff) |
ASoC: Move DAPM paths from DAPM context to snd_soc_card
Decoupling DAPM paths from DAPM context is a first prerequisite when
extending ASoC core to cross-device paths. This patch is almost a nullop and
does not allow to construct cross-device setup but the path clean-up part in
dapm_free_widgets is prepared to remove cross-device paths between a device
being removed and others.
Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r-- | sound/soc/soc-dapm.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 3d310af28907..5d9ec4a3a9f1 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -272,7 +272,7 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, | |||
272 | 272 | ||
273 | for (i = 0; i < e->max; i++) { | 273 | for (i = 0; i < e->max; i++) { |
274 | if (!(strcmp(control_name, e->texts[i]))) { | 274 | if (!(strcmp(control_name, e->texts[i]))) { |
275 | list_add(&path->list, &dapm->paths); | 275 | list_add(&path->list, &dapm->card->paths); |
276 | list_add(&path->list_sink, &dest->sources); | 276 | list_add(&path->list_sink, &dest->sources); |
277 | list_add(&path->list_source, &src->sinks); | 277 | list_add(&path->list_source, &src->sinks); |
278 | path->name = (char*)e->texts[i]; | 278 | path->name = (char*)e->texts[i]; |
@@ -294,7 +294,7 @@ static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm, | |||
294 | /* search for mixer kcontrol */ | 294 | /* search for mixer kcontrol */ |
295 | for (i = 0; i < dest->num_kcontrols; i++) { | 295 | for (i = 0; i < dest->num_kcontrols; i++) { |
296 | if (!strcmp(control_name, dest->kcontrols[i].name)) { | 296 | if (!strcmp(control_name, dest->kcontrols[i].name)) { |
297 | list_add(&path->list, &dapm->paths); | 297 | list_add(&path->list, &dapm->card->paths); |
298 | list_add(&path->list_sink, &dest->sources); | 298 | list_add(&path->list_sink, &dest->sources); |
299 | list_add(&path->list_source, &src->sinks); | 299 | list_add(&path->list_source, &src->sinks); |
300 | path->name = dest->kcontrols[i].name; | 300 | path->name = dest->kcontrols[i].name; |
@@ -453,7 +453,7 @@ static inline void dapm_clear_walk(struct snd_soc_dapm_context *dapm) | |||
453 | { | 453 | { |
454 | struct snd_soc_dapm_path *p; | 454 | struct snd_soc_dapm_path *p; |
455 | 455 | ||
456 | list_for_each_entry(p, &dapm->paths, list) | 456 | list_for_each_entry(p, &dapm->card->paths, list) |
457 | p->walked = 0; | 457 | p->walked = 0; |
458 | } | 458 | } |
459 | 459 | ||
@@ -1180,7 +1180,7 @@ static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget, | |||
1180 | return 0; | 1180 | return 0; |
1181 | 1181 | ||
1182 | /* find dapm widget path assoc with kcontrol */ | 1182 | /* find dapm widget path assoc with kcontrol */ |
1183 | list_for_each_entry(path, &widget->dapm->paths, list) { | 1183 | list_for_each_entry(path, &widget->dapm->card->paths, list) { |
1184 | if (path->kcontrol != kcontrol) | 1184 | if (path->kcontrol != kcontrol) |
1185 | continue; | 1185 | continue; |
1186 | 1186 | ||
@@ -1214,7 +1214,7 @@ static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget, | |||
1214 | return -ENODEV; | 1214 | return -ENODEV; |
1215 | 1215 | ||
1216 | /* find dapm widget path assoc with kcontrol */ | 1216 | /* find dapm widget path assoc with kcontrol */ |
1217 | list_for_each_entry(path, &widget->dapm->paths, list) { | 1217 | list_for_each_entry(path, &widget->dapm->card->paths, list) { |
1218 | if (path->kcontrol != kcontrol) | 1218 | if (path->kcontrol != kcontrol) |
1219 | continue; | 1219 | continue; |
1220 | 1220 | ||
@@ -1305,15 +1305,28 @@ static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) | |||
1305 | 1305 | ||
1306 | list_for_each_entry_safe(w, next_w, &dapm->widgets, list) { | 1306 | list_for_each_entry_safe(w, next_w, &dapm->widgets, list) { |
1307 | list_del(&w->list); | 1307 | list_del(&w->list); |
1308 | /* | ||
1309 | * remove source and sink paths associated to this widget. | ||
1310 | * While removing the path, remove reference to it from both | ||
1311 | * source and sink widgets so that path is removed only once. | ||
1312 | */ | ||
1313 | list_for_each_entry_safe(p, next_p, &w->sources, list_sink) { | ||
1314 | list_del(&p->list_sink); | ||
1315 | list_del(&p->list_source); | ||
1316 | list_del(&p->list); | ||
1317 | kfree(p->long_name); | ||
1318 | kfree(p); | ||
1319 | } | ||
1320 | list_for_each_entry_safe(p, next_p, &w->sinks, list_source) { | ||
1321 | list_del(&p->list_sink); | ||
1322 | list_del(&p->list_source); | ||
1323 | list_del(&p->list); | ||
1324 | kfree(p->long_name); | ||
1325 | kfree(p); | ||
1326 | } | ||
1308 | kfree(w->name); | 1327 | kfree(w->name); |
1309 | kfree(w); | 1328 | kfree(w); |
1310 | } | 1329 | } |
1311 | |||
1312 | list_for_each_entry_safe(p, next_p, &dapm->paths, list) { | ||
1313 | list_del(&p->list); | ||
1314 | kfree(p->long_name); | ||
1315 | kfree(p); | ||
1316 | } | ||
1317 | } | 1330 | } |
1318 | 1331 | ||
1319 | static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm, | 1332 | static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm, |
@@ -1420,7 +1433,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, | |||
1420 | 1433 | ||
1421 | /* connect static paths */ | 1434 | /* connect static paths */ |
1422 | if (control == NULL) { | 1435 | if (control == NULL) { |
1423 | list_add(&path->list, &dapm->paths); | 1436 | list_add(&path->list, &dapm->card->paths); |
1424 | list_add(&path->list_sink, &wsink->sources); | 1437 | list_add(&path->list_sink, &wsink->sources); |
1425 | list_add(&path->list_source, &wsource->sinks); | 1438 | list_add(&path->list_source, &wsource->sinks); |
1426 | path->connect = 1; | 1439 | path->connect = 1; |
@@ -1442,7 +1455,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, | |||
1442 | case snd_soc_dapm_supply: | 1455 | case snd_soc_dapm_supply: |
1443 | case snd_soc_dapm_aif_in: | 1456 | case snd_soc_dapm_aif_in: |
1444 | case snd_soc_dapm_aif_out: | 1457 | case snd_soc_dapm_aif_out: |
1445 | list_add(&path->list, &dapm->paths); | 1458 | list_add(&path->list, &dapm->card->paths); |
1446 | list_add(&path->list_sink, &wsink->sources); | 1459 | list_add(&path->list_sink, &wsink->sources); |
1447 | list_add(&path->list_source, &wsource->sinks); | 1460 | list_add(&path->list_source, &wsource->sinks); |
1448 | path->connect = 1; | 1461 | path->connect = 1; |
@@ -1465,7 +1478,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, | |||
1465 | case snd_soc_dapm_mic: | 1478 | case snd_soc_dapm_mic: |
1466 | case snd_soc_dapm_line: | 1479 | case snd_soc_dapm_line: |
1467 | case snd_soc_dapm_spk: | 1480 | case snd_soc_dapm_spk: |
1468 | list_add(&path->list, &dapm->paths); | 1481 | list_add(&path->list, &dapm->card->paths); |
1469 | list_add(&path->list_sink, &wsink->sources); | 1482 | list_add(&path->list_sink, &wsink->sources); |
1470 | list_add(&path->list_source, &wsource->sinks); | 1483 | list_add(&path->list_source, &wsource->sinks); |
1471 | path->connect = 0; | 1484 | path->connect = 0; |