*参照元 [#paaf64be]
#backlinks

*説明 [#zc094550]
-パス: [[linux-4.4.1/sound/soc/soc-dapm.c]]

-FIXME: これは何?
--説明


**引数 [#s90553ba]
-struct snd_soc_dapm_context *dapm
--
--[[linux-4.4.1/snd_soc_dapm_context]]
-const struct snd_soc_dapm_route *route
--
--[[linux-4.4.1/snd_soc_dapm_route]]


**返り値 [#g158e223]
-int
--


**参考 [#n20f68f1]


*実装 [#r1717363]
 static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
 				  const struct snd_soc_dapm_route *route)
 {
 	struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w;
 	struct snd_soc_dapm_widget *wtsource = NULL, *wtsink = NULL;
 	const char *sink;
 	const char *source;
 	char prefixed_sink[80];
 	char prefixed_source[80];
 	const char *prefix;
 	int ret;
 
-
--[[linux-4.4.1/snd_soc_dapm_widget]]

 	prefix = soc_dapm_prefix(dapm);
 	if (prefix) {
 		snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s",
 			 prefix, route->sink);
 		sink = prefixed_sink;
 		snprintf(prefixed_source, sizeof(prefixed_source), "%s %s",
 			 prefix, route->source);
 		source = prefixed_source;
 	} else {
 		sink = route->sink;
 		source = route->source;
 	}
 
-
--[[linux-4.4.1/soc_dapm_prefix()]]
--[[linux-4.4.1/snprintf()]]

 	wsource = dapm_wcache_lookup(&dapm->path_source_cache, source);
 	wsink = dapm_wcache_lookup(&dapm->path_sink_cache, sink);
 
 	if (wsink && wsource)
 		goto skip_search;
 
-
--[[linux-4.4.1/dapm_wcache_lookup()]]

 	/*
 	 * find src and dest widgets over all widgets but favor a widget from
 	 * current DAPM context
 	 */
 	list_for_each_entry(w, &dapm->card->widgets, list) {
 		if (!wsink && !(strcmp(w->name, sink))) {
 			wtsink = w;
 			if (w->dapm == dapm) {
 				wsink = w;
 				if (wsource)
 					break;
 			}
 			continue;
 		}
 		if (!wsource && !(strcmp(w->name, source))) {
 			wtsource = w;
 			if (w->dapm == dapm) {
 				wsource = w;
 				if (wsink)
 					break;
 			}
 		}
 	}
-
--[[linux-4.4.1/list_for_each_entry()]]
--[[linux-4.4.1/strcmp()]]

 	/* use widget from another DAPM context if not found from this */
 	if (!wsink)
 		wsink = wtsink;
 	if (!wsource)
 		wsource = wtsource;
 
 	if (wsource == NULL) {
 		dev_err(dapm->dev, "ASoC: no source widget found for %s\n",
 			route->source);
 		return -ENODEV;
 	}
 	if (wsink == NULL) {
 		dev_err(dapm->dev, "ASoC: no sink widget found for %s\n",
 			route->sink);
 		return -ENODEV;
 	}
 
-
--[[linux-4.4.1/dev_err()]]

 skip_search:
 	dapm_wcache_update(&dapm->path_sink_cache, wsink);
 	dapm_wcache_update(&dapm->path_source_cache, wsource);
 
 	ret = snd_soc_dapm_add_path(dapm, wsource, wsink, route->control,
 		route->connected);
 	if (ret)
 		goto err;
 
-
--[[linux-4.4.1/dapm_wcache_update()]]
--[[linux-4.4.1/snd_soc_dapm_add_path()]]
-ドライバでは下記のように定義することが多い。
このとき route->control は「真ん中」のメンバに相当する。
 static const struct snd_soc_dapm_route foo_routes[] = {
 	// sink       control   source
 	{ "SinkAAA", "ValueA", "SourceA" },
 	{ "SinkAAA", "ValueB", "SourceB" },
 	{ "SinkAAA", "ValueC", "SourceC" },
 	{ "SinkBBB", NULL, "SourceD" },
 
 	//...
 };

 	return 0;
 err:
 	dev_warn(dapm->dev, "ASoC: no dapm match for %s --> %s --> %s\n",
 		 source, route->control, sink);
 	return ret;
-
--[[linux-4.4.1/dev_warn()]]

 }


*コメント [#qc4dc7a8]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS