mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-05 13:30:00 -05:00
Add workaround for conflicting IEC958 controls for HD-audio
When both an SPDIF and an HDMI output are present on HD-audio, both try to access IEC958 controls with index=0 although one of them must be wrong. For avoiding this conflict, the recent kernel code (3.9 and 3.8 stable) moves the IEC958 controls of an SPDIF with index=16 once when the conflict happens. In this patch, the corresponding support is added in alsa-lib side. The new "skip_rest" boolean flag is added to the hooked element definition which indicates that the rest of element array will be ignored once when this element is present and evaluated. With this new flag, the HD-audio config takes index=16 primarily, then take index=0 as fallback. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
8c6da54073
commit
f5f45589f8
2 changed files with 32 additions and 3 deletions
|
|
@ -111,6 +111,22 @@ HDA-Intel.pcm.iec958.0 {
|
|||
hooks.0 {
|
||||
type ctl_elems
|
||||
hook_args [
|
||||
{
|
||||
name "IEC958 Playback Default"
|
||||
index 16
|
||||
optional true
|
||||
lock true
|
||||
preserve true
|
||||
value [ $AES0 $AES1 $AES2 $AES3 ]
|
||||
}
|
||||
{
|
||||
name "IEC958 Playback Switch"
|
||||
index 16
|
||||
optional true
|
||||
value true
|
||||
# if this element is present, skip the rest
|
||||
skip_rest true
|
||||
}
|
||||
{
|
||||
name "IEC958 Playback Default"
|
||||
lock true
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ static int snd_config_get_ctl_elem_value(snd_config_t *conf,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_data)
|
||||
static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_data, int *quit)
|
||||
{
|
||||
snd_config_t *conf;
|
||||
snd_config_iterator_t i, next;
|
||||
|
|
@ -408,6 +408,7 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
|
|||
int lock = 0;
|
||||
int preserve = 0;
|
||||
int optional = 0;
|
||||
int skip_rest = 0;
|
||||
snd_config_t *value = NULL, *mask = NULL;
|
||||
snd_sctl_elem_t *elem = NULL;
|
||||
int err;
|
||||
|
|
@ -491,6 +492,13 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
|
|||
optional = err;
|
||||
continue;
|
||||
}
|
||||
if (strcmp(id, "skip_rest") == 0) {
|
||||
err = snd_config_get_bool(n);
|
||||
if (err < 0)
|
||||
goto _err;
|
||||
skip_rest = err;
|
||||
continue;
|
||||
}
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -539,6 +547,9 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
|
|||
if (! optional)
|
||||
SNDERR("Cannot obtain info for CTL elem (%s,'%s',%li,%li,%li): %s", snd_ctl_elem_iface_name(iface), name, index, device, subdevice, snd_strerror(err));
|
||||
goto _err;
|
||||
} else {
|
||||
if (skip_rest)
|
||||
*quit = 1;
|
||||
}
|
||||
snd_ctl_elem_value_set_id(elem->val, elem->id);
|
||||
snd_ctl_elem_value_set_id(elem->old, elem->id);
|
||||
|
|
@ -594,7 +605,7 @@ int snd_sctl_build(snd_sctl_t **sctl, snd_ctl_t *handle, snd_config_t *conf, snd
|
|||
{
|
||||
snd_sctl_t *h;
|
||||
snd_config_iterator_t i, next;
|
||||
int err;
|
||||
int err, quit = 0;
|
||||
|
||||
assert(sctl);
|
||||
assert(handle);
|
||||
|
|
@ -614,11 +625,13 @@ int snd_sctl_build(snd_sctl_t **sctl, snd_ctl_t *handle, snd_config_t *conf, snd
|
|||
INIT_LIST_HEAD(&h->elems);
|
||||
snd_config_for_each(i, next, conf) {
|
||||
snd_config_t *n = snd_config_iterator_entry(i);
|
||||
err = add_elem(h, n, private_data);
|
||||
err = add_elem(h, n, private_data, &quit);
|
||||
if (err < 0) {
|
||||
free_elems(h);
|
||||
return err;
|
||||
}
|
||||
if (quit)
|
||||
break;
|
||||
}
|
||||
*sctl = h;
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue