Added support for IEC958

This commit is contained in:
Jaroslav Kysela 2000-12-22 11:25:11 +00:00
parent 84f294a3b9
commit 66608d67ea

View file

@ -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: case SND_CONTROL_TYPE_BYTES:
s = "bytes"; s = "bytes";
break; break;
case SND_CONTROL_TYPE_IEC958:
s = "iec958";
break;
default: default:
s = "unknown"; s = "unknown";
break; 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) { switch (info.type) {
case SND_CONTROL_TYPE_BYTES: 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 *p = buf;
char *hex = "0123456789abcdef"; char *hex = "0123456789abcdef";
for (idx = 0; idx < info.values_count; idx++) { for (idx = 0; idx < count; idx++) {
int v = ctl.value.bytes.data[idx]; int v = ctl.value.bytes.data[idx];
*p++ = hex[v >> 4]; *p++ = hex[v >> 4];
*p++ = hex[v & 0x0f]; *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; return 0;
} }
case SND_CONTROL_TYPE_IEC958:
error("An IEC958 control ignored");
return 0;
default: default:
break; break;
} }
@ -748,19 +751,27 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
goto _ok; goto _ok;
} }
break; break;
case SND_CONTROL_TYPE_BYTES:
case SND_CONTROL_TYPE_IEC958:
break;
default: default:
error("Unknow control type: %d", info.type); error("Unknow control type: %d", info.type);
return -EINVAL; return -EINVAL;
} }
} }
if (info.type == SND_CONTROL_TYPE_BYTES) { switch (info.type) {
case SND_CONTROL_TYPE_BYTES:
case SND_CONTROL_TYPE_IEC958:
{
char *buf; char *buf;
err = snd_config_string_get(value, &buf); err = snd_config_string_get(value, &buf);
if (err >= 0) { if (err >= 0) {
int c1 = 0; int c1 = 0;
int len = strlen(buf); int len = strlen(buf);
int idx = 0; 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); error("bad control.%d.value contents\n", numid);
return -EINVAL; return -EINVAL;
} }
@ -785,6 +796,9 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
goto _ok; goto _ok;
} }
} }
default:
break;
}
if (snd_config_type(value) != SND_CONFIG_TYPE_COMPOUND) { if (snd_config_type(value) != SND_CONFIG_TYPE_COMPOUND) {
error("bad control.%d.value type", numid); error("bad control.%d.value type", numid);
return -EINVAL; return -EINVAL;
@ -826,6 +840,7 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control)
ctl.value.enumerated.item[idx] = val; ctl.value.enumerated.item[idx] = val;
break; break;
case SND_CONTROL_TYPE_BYTES: case SND_CONTROL_TYPE_BYTES:
case SND_CONTROL_TYPE_IEC958:
err = snd_config_integer_get(n, &val); err = snd_config_integer_get(n, &val);
if (err < 0 || val < 0 || val > 255) { if (err < 0 || val < 0 || val > 255) {
error("bad control.%d.value.%d content", numid, idx); error("bad control.%d.value.%d content", numid, idx);