参照元†
- struct snd_soc_dapm_context *dapm
- struct snd_soc_dapm_path *path
- const char *control_name
- struct snd_soc_dapm_widget *w
返り値†
/* 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;
}
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 SOC_ENUM_SINGLE_DECL(sink_sel_enum,
REG_ADDR, REG_SHIFT,
sink_sel_text);
static const struct snd_soc_dapm_route foo_routes[] = {
// sink control source
{ "Sink", "ValueA", "SourceA" },
{ "Sink", "ValueB", "SourceB" },
{ "Sink", "ValueC", "SourceC" },
//...
};
if (i == item)
path->connect = 1;
else
path->connect = 0;
return 0;
}
}
return -ENODEV;
}
コメント†