*参照元 [#h9baa721]
#backlinks

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

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


**引数 [#l3c1acbf]
-struct snd_soc_dapm_context *dapm
--
--[[linux-4.4.1/snd_soc_dapm_context]]
-struct snd_soc_dapm_path *path
--
--[[linux-4.4.1/snd_soc_dapm_path]]
-const char *control_name
--
-struct snd_soc_dapm_widget *w
--
--[[linux-4.4.1/snd_soc_dapm_widget]]


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


**参考 [#e1c3c59b]


*実装 [#o1af2fba]
 /* connect mux widget to its interconnecting audio paths */
 static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
 	struct snd_soc_dapm_path *path, const char *control_name,
 	struct snd_soc_dapm_widget *w)
 {
 	const struct snd_kcontrol_new *kcontrol = &w->kcontrol_news[0];
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	unsigned int val, item;
 	int i;
 
-
--[[linux-4.4.1/snd_kcontrol_new]]
--[[linux-4.4.1/soc_enum]]

 	if (e->reg != SND_SOC_NOPM) {
 		soc_dapm_read(dapm, e->reg, &val);
 		val = (val >> e->shift_l) & e->mask;
 		item = snd_soc_enum_val_to_item(e, val);
 	} else {
 		/* since a virtual mux has no backing registers to
 		 * decide which path to connect, it will try to match
 		 * with the first enumeration.  This is to ensure
 		 * that the default mux choice (the first) will be
 		 * correctly powered up during initialization.
 		 */
 		item = 0;
 	}
 
-
--[[linux-4.4.1/soc_dapm_read()]]
--[[linux-4.4.1/snd_soc_enum_val_to_item()]]

 	for (i = 0; i < e->items; i++) {
 		if (!(strcmp(control_name, e->texts[i]))) {
 			path->name = e->texts[i];
-コントロール名と、列挙値の名前が一致していたら、パス名を設定する。
--具体例を書くと、
 static const char *sink_sel_text[] = {
 	"ValueA", "ValueB", "ValueC",
 static const char *sinkaaa_srcsel_text[] = {
 	"ValueA", "ValueB", "ValueC", //e->texts[i]
 };
 static SOC_ENUM_SINGLE_DECL(sink_sel_enum,
 
 static SOC_ENUM_SINGLE_DECL(sinkaaa_srcsel_enum,
 	REG_ADDR, REG_SHIFT,
 	sink_sel_text);
 	sinkaaa_srcsel_text);
 
 static const struct snd_kcontrol_new sinkaaa_mux[] = {
 	SOC_DAPM_ENUM("SinkAAA Source", sinkaaa_srcsel_enum),
 };
 
 static const struct snd_soc_dapm_route foo_routes[] = {
 	// sink    control   source
 	{ "Sink", "ValueA", "SourceA" },
 	{ "Sink", "ValueB", "SourceB" },
 	{ "Sink", "ValueC", "SourceC" },
 	// sink       control   source
 	//            = control_name
 	{ "SinkAAA", "ValueA", "SourceA" },
 	{ "SinkAAA", "ValueB", "SourceB" },
 	{ "SinkAAA", "ValueC", "SourceC" },
 
 	//...
 };
--snd_soc_dapm_route の control が、この関数の control_name に指定される。

 			if (i == item)
 				path->connect = 1;
 			else
 				path->connect = 0;
 			return 0;
 		}
 	}
 
 	return -ENODEV;
 }


*コメント [#ca3190d6]

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