~~~{.html}
${find-card:field=name,regex='^acp$',return=number}
+${find-card:field=$FieldName,regex=$Pattern,return=number}
~~~
Arguments:
Argument | Description
---------------------|-----------------------
return | return value type (id, number), id is the default
-field | field for the lookup (id, driver, name, longname, mixername, components)
-regex | regex string for the field match
+field | field for the lookup (id, driver, name, longname, mixername, components) or variable name ($var) [**Syntax 9**]
+regex | regex string for the field match or variable name ($var) [**Syntax 9**]
#### Find device substitution
~~~{.html}
${find-device:type=pcm,field=name,regex='DMIC'}
+${find-device:type=$DevType,stream=$StreamType,field=$FieldName,regex=$Pattern}
~~~
Arguments:
Argument | Description
---------------------|-----------------------
-type | device type (pcm)
-stream | stream type (playback, capture), playback is default
-field | field for the lookup (id, name, subname)
-regex | regex string for the field match
+type | device type (pcm) or variable name ($var) [**Syntax 9**]
+stream | stream type (playback, capture), playback is default; variable name ($var) supported in **Syntax 9**
+field | field for the lookup (id, name, subname) or variable name ($var) [**Syntax 9**]
+regex | regex string for the field match or variable name ($var) [**Syntax 9**]
#### Card info substitution
snd_config_t *config, *d;
struct lookup_fcn *fcn;
struct lookup_iterate *curr;
- const char *s;
+ const char *s, *tmp;
char *result;
regmatch_t match[1];
regex_t re;
}
if (snd_config_get_string(d, &s))
goto null;
+ if (s[0] == '$' && uc_mgr->conf_format >= 9) {
+ tmp = s + 1;
+ s = uc_mgr_get_variable(uc_mgr, tmp);
+ if (s == NULL)
+ goto var_not_found;
+ }
for (fcn = iter->fcns ; fcn; fcn++) {
if (strcasecmp(fcn->name, s) == 0) {
iter->fcn = fcn->fcn;
}
if (snd_config_get_string(d, &s))
goto null;
+ if (s[0] == '$' && uc_mgr->conf_format >= 9) {
+ tmp = s + 1;
+ s = uc_mgr_get_variable(uc_mgr, tmp);
+ if (s == NULL)
+ goto var_not_found;
+ }
err = regcomp(&re, s, REG_EXTENDED | REG_ICASE);
if (err) {
snd_error(UCM, "Regex '%s' compilation failed (code %d)", s, err);
if (iter->done)
iter->done(iter);
return result;
+var_not_found:
+ snd_error(UCM, "lookup: variable '%s' not found", tmp);
null:
result = NULL;
goto fin;
return strdup(num);
}
-static int rval_pcm_lookup_init(struct lookup_iterate *iter,
+static int rval_pcm_lookup_init(snd_use_case_mgr_t *uc_mgr,
+ struct lookup_iterate *iter,
snd_config_t *config)
{
static struct lookup_fcn pcm_fcns[] = {
{ 0 },
};
snd_config_t *d;
- const char *s;
+ const char *s, *tmp;
snd_pcm_info_t *pcminfo;
snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK;
if (snd_config_search(config, "stream", &d) == 0 &&
snd_config_get_string(d, &s) == 0) {
+ if (s[0] == '$' && uc_mgr->conf_format >= 9) {
+ tmp = s + 1;
+ s = uc_mgr_get_variable(uc_mgr, tmp);
+ if (s == NULL) {
+ snd_error(UCM, "pcm lookup: variable '%s' not found", tmp);
+ return -EINVAL;
+ }
+ }
if (strcasecmp(s, "playback") == 0)
stream = SND_PCM_STREAM_PLAYBACK;
else if (strcasecmp(s, "capture") == 0)
{
static struct {
const char *name;
- int (*init)(struct lookup_iterate *iter, snd_config_t *config);
+ int (*init)(snd_use_case_mgr_t *uc_mgr, struct lookup_iterate *iter,
+ snd_config_t *config);
} *t, types[] = {
{ .name = "pcm", .init = rval_pcm_lookup_init },
{ 0 }
};
snd_config_t *d;
- const char *s;
+ const char *s, *tmp;
int err;
if (snd_config_search(config, "ctl", &d) || snd_config_get_string(d, &s)) {
snd_error(UCM, "Missing device type!");
return -EINVAL;
}
+ if (s[0] == '$' && uc_mgr->conf_format >= 9) {
+ tmp = s + 1;
+ s = uc_mgr_get_variable(uc_mgr, tmp);
+ if (s == NULL) {
+ snd_error(UCM, "device lookup: variable '%s' not found", tmp);
+ return -EINVAL;
+ }
+ }
for (t = types; t->name; t++)
if (strcasecmp(t->name, s) == 0)
- return t->init(iter, config);
+ return t->init(uc_mgr, iter, config);
snd_error(UCM, "Device type '%s' is invalid", s);
return -EINVAL;
}