UCM: Deprecate index on Section{Device,Modifier}

The previous supported "legacy" syntax was:

SectionDevice."Speaker".0 {
SectionModifier."Capture Voice".0 {

This change supports new syntax:

SectionDevice."Speaker" {
SectionModifier."Capture Voice" {

... but also allows the old syntax, iff the index is exactly "0". If an
index is present, but not exactly "0", parsing will appear to succeed,
but produce an empty device or modifier.

When naming devices and modifiers, even if the legacy format is used,
any index is not included in the name; i.e. both sets of syntax above
name the device just "Speaker".

The SupportedDevice list syntax still also accepts either "x" or "x.0",
but internally strips ".0" from the tail of any device name. Any other
name including "." is disallowed.

Finally, when comparing device or modifier names, a simple exact string
compare is now used, since no index data is ever present in device or
modifier names.

The one functional change introduced here is that a SupportedDevice
entry of just "x" will now only ever match a single device. It previously
acted as a wildcard for any device named "x.foo".

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Stephen Warren 2011-06-03 14:56:30 -06:00 committed by Takashi Iwai
parent e1c876a2f0
commit 866fa538d4
2 changed files with 114 additions and 85 deletions

View file

@ -484,33 +484,18 @@ static int is_modifier_supported(snd_use_case_mgr_t *uc_mgr,
struct dev_list *device;
struct use_case_device *adev;
struct list_head *pos, *pos1;
char *cpos;
int dlen, len;
list_for_each(pos, &modifier->dev_list) {
device = list_entry(pos, struct dev_list, list);
cpos = strchr(device->name, '.');
if (cpos) {
if (find(&uc_mgr->active_devices,
struct use_case_device, active_list,
name, device->name))
return 1;
} else {
dlen = strlen(device->name);
list_for_each(pos1, &uc_mgr->active_devices) {
adev = list_entry(pos1, struct use_case_device,
active_list);
cpos = strchr(adev->name, '.');
if (cpos)
len = cpos - adev->name;
else
len = strlen(adev->name);
if (len != dlen)
continue;
if (memcmp(adev->name, device->name, len))
continue;
return 1;
}
list_for_each(pos1, &uc_mgr->active_devices) {
adev = list_entry(pos1, struct use_case_device,
active_list);
if (strcmp(adev->name, device->name))
continue;
return 1;
}
}
return 0;
@ -528,19 +513,11 @@ static struct use_case_modifier *
struct use_case_modifier *modifier;
struct use_case_verb *verb = uc_mgr->active_verb;
struct list_head *pos;
char name[64], *cpos;
list_for_each(pos, &verb->modifier_list) {
modifier = list_entry(pos, struct use_case_modifier, list);
strncpy(name, modifier->name, sizeof(name));
name[sizeof(name)-1] = '\0';
cpos = strchr(name, '.');
if (!cpos)
continue;
*cpos= '\0';
if (strcmp(name, modifier_name))
if (strcmp(modifier->name, modifier_name))
continue;
if (is_modifier_supported(uc_mgr, modifier))