summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/sndioctl/sndioctl.c54
-rw-r--r--usr.bin/sndiod/dev.c5
-rw-r--r--usr.bin/sndiod/dev.h3
3 files changed, 47 insertions, 15 deletions
diff --git a/usr.bin/sndioctl/sndioctl.c b/usr.bin/sndioctl/sndioctl.c
index ca98add3d13..2403f85be9d 100644
--- a/usr.bin/sndioctl/sndioctl.c
+++ b/usr.bin/sndioctl/sndioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sndioctl.c,v 1.13 2020/06/18 05:33:16 ratchov Exp $ */
+/* $OpenBSD: sndioctl.c,v 1.14 2020/06/28 05:17:26 ratchov Exp $ */
/*
* Copyright (c) 2014-2020 Alexandre Ratchov <alex@caoua.org>
*
@@ -103,7 +103,8 @@ cmpdesc(struct sioctl_desc *d1, struct sioctl_desc *d2)
if (res != 0)
return res;
res = d1->node0.unit - d2->node0.unit;
- if (d1->type == SIOCTL_VEC ||
+ if (d1->type == SIOCTL_SEL ||
+ d1->type == SIOCTL_VEC ||
d1->type == SIOCTL_LIST) {
if (res != 0)
return res;
@@ -293,6 +294,7 @@ ismono(struct info *g)
return 0;
}
break;
+ case SIOCTL_SEL:
case SIOCTL_VEC:
case SIOCTL_LIST:
for (p2 = g; p2 != NULL; p2 = nextpar(p2)) {
@@ -341,6 +343,7 @@ print_desc(struct info *p, int mono)
case SIOCTL_SW:
printf("*");
break;
+ case SIOCTL_SEL:
case SIOCTL_VEC:
case SIOCTL_LIST:
more = 0;
@@ -354,7 +357,8 @@ print_desc(struct info *p, int mono)
if (more)
printf(",");
print_node(&e->desc.node1, mono);
- printf(":*");
+ if (p->desc.type != SIOCTL_SEL)
+ printf(":*");
more = 1;
}
}
@@ -390,6 +394,7 @@ print_ent(struct info *e, char *comment)
case SIOCTL_NONE:
printf("<removed>\n");
break;
+ case SIOCTL_SEL:
case SIOCTL_VEC:
case SIOCTL_LIST:
print_node(&e->desc.node1, 0);
@@ -418,6 +423,7 @@ print_val(struct info *p, int mono)
case SIOCTL_SW:
print_num(p);
break;
+ case SIOCTL_SEL:
case SIOCTL_VEC:
case SIOCTL_LIST:
more = 0;
@@ -617,6 +623,9 @@ dump(void)
case SIOCTL_SW:
printf("0..%d (%u)", i->desc.maxval, i->curval);
break;
+ case SIOCTL_SEL:
+ print_node(&i->desc.node1, 0);
+ break;
case SIOCTL_VEC:
case SIOCTL_LIST:
print_node(&i->desc.node1, 0);
@@ -696,6 +705,7 @@ cmd(char *line)
npar++;
}
break;
+ case SIOCTL_SEL:
case SIOCTL_VEC:
case SIOCTL_LIST:
for (i = g; i != NULL; i = nextpar(i)) {
@@ -853,6 +863,7 @@ ondesc(void *arg, struct sioctl_desc *d, int curval)
case SIOCTL_SW:
case SIOCTL_VEC:
case SIOCTL_LIST:
+ case SIOCTL_SEL:
break;
default:
return;
@@ -892,17 +903,36 @@ ondesc(void *arg, struct sioctl_desc *d, int curval)
void
onctl(void *arg, unsigned addr, unsigned val)
{
- struct info *i;
+ struct info *i, *j;
- for (i = infolist; i != NULL; i = i->next) {
- if (i->ctladdr != addr)
- continue;
- if (i->curval != val) {
- i->curval = val;
- if (m_flag)
- print_ent(i, "changed");
- }
+ i = infolist;
+ for (;;) {
+ if (i == NULL)
+ return;
+ if (i->ctladdr == addr)
+ break;
+ i = i->next;
}
+
+ if (i->curval == val) {
+ print_ent(i, "eq");
+ return;
+ }
+
+ if (i->desc.type == SIOCTL_SEL) {
+ for (j = infolist; j != NULL; j = j->next) {
+ if (strcmp(i->desc.group, j->desc.group) != 0 ||
+ strcmp(i->desc.node0.name, j->desc.node0.name) != 0 ||
+ strcmp(i->desc.func, j->desc.func) != 0 ||
+ i->desc.node0.unit != j->desc.node0.unit)
+ continue;
+ j->curval = (i->ctladdr == j->ctladdr);
+ }
+ } else
+ i->curval = val;
+
+ if (m_flag)
+ print_ent(i, "changed");
}
int
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c
index 4b02f1831e2..0866098c9d8 100644
--- a/usr.bin/sndiod/dev.c
+++ b/usr.bin/sndiod/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.73 2020/06/18 05:11:13 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.74 2020/06/28 05:17:25 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -2296,6 +2296,7 @@ ctl_log(struct ctl *c)
break;
case CTL_VEC:
case CTL_LIST:
+ case CTL_SEL:
ctl_node_log(&c->node1);
log_puts(":");
log_putu(c->curval);
@@ -2320,7 +2321,7 @@ dev_addctl(struct dev *d, char *gstr, int type, int addr,
strlcpy(c->group, gstr, CTL_NAMEMAX);
strlcpy(c->node0.name, str0, CTL_NAMEMAX);
c->node0.unit = unit0;
- if (c->type == CTL_VEC || c->type == CTL_LIST) {
+ if (c->type == CTL_VEC || c->type == CTL_LIST || c->type == CTL_SEL) {
strlcpy(c->node1.name, str1, CTL_NAMEMAX);
c->node1.unit = unit1;
} else
diff --git a/usr.bin/sndiod/dev.h b/usr.bin/sndiod/dev.h
index 73414622e5e..3a879b8b3be 100644
--- a/usr.bin/sndiod/dev.h
+++ b/usr.bin/sndiod/dev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.h,v 1.27 2020/06/18 05:11:13 ratchov Exp $ */
+/* $OpenBSD: dev.h,v 1.28 2020/06/28 05:17:26 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -126,6 +126,7 @@ struct ctl {
#define CTL_SW 3 /* on/off switch, only bit 7 counts */
#define CTL_VEC 4 /* number, element of vector */
#define CTL_LIST 5 /* switch, element of a list */
+#define CTL_SEL 6 /* element of a selector */
unsigned int type; /* one of above */
unsigned int addr; /* control address */
#define CTL_NAMEMAX 16 /* max name lenght */