mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-22 12:16:31 +01:00
Added support for IEC958
This commit is contained in:
parent
84f294a3b9
commit
66608d67ea
1 changed files with 46 additions and 31 deletions
|
@ -200,6 +200,9 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
case SND_CONTROL_TYPE_BYTES:
|
||||
s = "bytes";
|
||||
break;
|
||||
case SND_CONTROL_TYPE_IEC958:
|
||||
s = "iec958";
|
||||
break;
|
||||
default:
|
||||
s = "unknown";
|
||||
break;
|
||||
|
@ -311,11 +314,14 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
|
||||
switch (info.type) {
|
||||
case SND_CONTROL_TYPE_BYTES:
|
||||
case SND_CONTROL_TYPE_IEC958:
|
||||
{
|
||||
char buf[info.values_count * 2 + 1];
|
||||
int count = info.type == SND_CONTROL_TYPE_BYTES ?
|
||||
info.values_count : sizeof(snd_aes_iec958_t);
|
||||
char buf[count * 2 + 1];
|
||||
char *p = buf;
|
||||
char *hex = "0123456789abcdef";
|
||||
for (idx = 0; idx < info.values_count; idx++) {
|
||||
for (idx = 0; idx < count; idx++) {
|
||||
int v = ctl.value.bytes.data[idx];
|
||||
*p++ = hex[v >> 4];
|
||||
*p++ = hex[v & 0x0f];
|
||||
|
@ -328,9 +334,6 @@ static int get_control(snd_ctl_t *handle, snd_control_id_t *id, snd_config_t *to
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
case SND_CONTROL_TYPE_IEC958:
|
||||
error("An IEC958 control ignored");
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -748,19 +751,27 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
|||
goto _ok;
|
||||
}
|
||||
break;
|
||||
case SND_CONTROL_TYPE_BYTES:
|
||||
case SND_CONTROL_TYPE_IEC958:
|
||||
break;
|
||||
default:
|
||||
error("Unknow control type: %d", info.type);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
if (info.type == SND_CONTROL_TYPE_BYTES) {
|
||||
switch (info.type) {
|
||||
case SND_CONTROL_TYPE_BYTES:
|
||||
case SND_CONTROL_TYPE_IEC958:
|
||||
{
|
||||
char *buf;
|
||||
err = snd_config_string_get(value, &buf);
|
||||
if (err >= 0) {
|
||||
int c1 = 0;
|
||||
int len = strlen(buf);
|
||||
int idx = 0;
|
||||
if (info.values_count * 2 != len) {
|
||||
int count = info.type == SND_CONTROL_TYPE_BYTES ?
|
||||
info.values_count : sizeof(snd_aes_iec958_t);
|
||||
if (count * 2 != len) {
|
||||
error("bad control.%d.value contents\n", numid);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -785,6 +796,9 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
|||
goto _ok;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (snd_config_type(value) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
error("bad control.%d.value type", numid);
|
||||
return -EINVAL;
|
||||
|
@ -826,6 +840,7 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
|
|||
ctl.value.enumerated.item[idx] = val;
|
||||
break;
|
||||
case SND_CONTROL_TYPE_BYTES:
|
||||
case SND_CONTROL_TYPE_IEC958:
|
||||
err = snd_config_integer_get(n, &val);
|
||||
if (err < 0 || val < 0 || val > 255) {
|
||||
error("bad control.%d.value.%d content", numid, idx);
|
||||
|
|
Loading…
Reference in a new issue