参照元

説明

  • パス: linux-4.4.1/sound/soc/soc-dapm.c?
  • FIXME: これは何?
    • 説明

引数

  • struct snd_soc_dapm_context *dapm
    • linux-4.4.1/snd_soc_dapm_context?
  • struct snd_soc_dapm_path *path
  • const char *control_name
  • struct snd_soc_dapm_widget *w
    • linux-4.4.1/snd_soc_dapm_widget?

返り値

  • int

参考

実装

/* 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;
	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 *sinkaaa_srcsel_text[] = {
      	"ValueA", "ValueB", "ValueC", //e->texts[i]
      };
      
      static SOC_ENUM_SINGLE_DECL(sinkaaa_srcsel_enum,
      	REG_ADDR, REG_SHIFT,
      	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
      	//            = 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;
}

コメント


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2018-06-22 (金) 12:20:59 (147d)