*参照元 [#f5c83456] #backlinks *説明 [#n2551856] -パス: [[linux-4.4.1/sound/soc/soc-dapm.c]] -FIXME: これは何? --説明 **引数 [#z671eac0] -struct snd_soc_dapm_context *dapm -- --[[linux-4.4.1/snd_soc_dapm_context]] -struct snd_soc_dapm_widget *wsource -- --[[linux-4.4.1/snd_soc_dapm_widget]] -struct snd_soc_dapm_widget *wsink -- -const char *control -- --コントロール名 --この引数は NULL でも良い、NULL 以外に指定するのは下記の関数。 --[[linux-4.4.1/snd_soc_dapm_add_route()]] -int (*connected)(struct snd_soc_dapm_widget *source, snd_soc_dapm_widget *sink) -- **返り値 [#rca0ac64] -int -- **参考 [#ge55b032] *実装 [#ca007455] static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm, struct snd_soc_dapm_widget *wsource, struct snd_soc_dapm_widget *wsink, const char *control, int (*connected)(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink)) { struct snd_soc_dapm_widget *widgets[2]; enum snd_soc_dapm_direction dir; struct snd_soc_dapm_path *path; int ret; - --[[linux-4.4.1/snd_soc_dapm_direction]] if (wsink->is_supply && !wsource->is_supply) { dev_err(dapm->dev, "Connecting non-supply widget to supply widget is not supported (%s -> %s)\n", wsource->name, wsink->name); return -EINVAL; } if (connected && !wsource->is_supply) { dev_err(dapm->dev, "connected() callback only supported for supply widgets (%s -> %s)\n", wsource->name, wsink->name); return -EINVAL; } if (wsource->is_supply && control) { dev_err(dapm->dev, "Conditional paths are not supported for supply widgets (%s -> [%s] -> %s)\n", wsource->name, control, wsink->name); return -EINVAL; } - --[[linux-4.4.1/dev_err()]] ret = snd_soc_dapm_check_dynamic_path(dapm, wsource, wsink, control); if (ret) return ret; - --[[linux-4.4.1/snd_soc_dapm_check_dynamic_path()]] path = kzalloc(sizeof(struct snd_soc_dapm_path), GFP_KERNEL); if (!path) return -ENOMEM; - --[[linux-4.4.1/kzalloc()]] --[[linux-4.4.1/snd_soc_dapm_path]] path->node[SND_SOC_DAPM_DIR_IN] = wsource; path->node[SND_SOC_DAPM_DIR_OUT] = wsink; widgets[SND_SOC_DAPM_DIR_IN] = wsource; widgets[SND_SOC_DAPM_DIR_OUT] = wsink; path->connected = connected; INIT_LIST_HEAD(&path->list); INIT_LIST_HEAD(&path->list_kcontrol); if (wsource->is_supply || wsink->is_supply) path->is_supply = 1; /* connect static paths */ if (control == NULL) { path->connect = 1; } else { switch (wsource->id) { case snd_soc_dapm_demux: ret = dapm_connect_mux(dapm, path, control, wsource); if (ret) goto err; break; default: break; } - --[[linux-4.4.1/dapm_connect_mux()]] switch (wsink->id) { case snd_soc_dapm_mux: ret = dapm_connect_mux(dapm, path, control, wsink); if (ret != 0) goto err; break; case snd_soc_dapm_switch: case snd_soc_dapm_mixer: case snd_soc_dapm_mixer_named_ctl: ret = dapm_connect_mixer(dapm, path, control); if (ret != 0) goto err; break; default: break; } - --[[linux-4.4.1/dapm_connect_mixer()]] } list_add(&path->list, &dapm->card->paths); snd_soc_dapm_for_each_direction(dir) list_add(&path->list_node[dir], &widgets[dir]->edges[dir]); - --[[linux-4.4.1/list_add()]] --[[linux-4.4.1/snd_soc_dapm_for_each_direction()]] snd_soc_dapm_for_each_direction(dir) { dapm_update_widget_flags(widgets[dir]); dapm_mark_dirty(widgets[dir], "Route added"); } - --[[linux-4.4.1/dapm_update_widget_flags()]] --[[linux-4.4.1/dapm_mark_dirty()]] if (dapm->card->instantiated && path->connect) dapm_path_invalidate(path); - --[[linux-4.4.1/dapm_path_invalidate()]] return 0; err: kfree(path); return ret; - --[[linux-4.4.1/kfree()]] } *コメント [#s8682d0c]