From 15de74750099f64d786f4b9a2dcce0f0a5d7fef1 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Thu, 8 Dec 2016 17:23:34 +0000 Subject: Return ENODEV if playback is requested on devices with no DACs or recording is requested on devices with no ADCs. Many thanks to Bryan Vyhmeister for testing & debugging this. --- sys/dev/pci/azalia.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sys/dev/pci') diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c index 57ee558e308..50697901e2d 100644 --- a/sys/dev/pci/azalia.c +++ b/sys/dev/pci/azalia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia.c,v 1.229 2016/09/19 06:46:44 ratchov Exp $ */ +/* $OpenBSD: azalia.c,v 1.230 2016/12/08 17:23:33 ratchov Exp $ */ /* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */ /*- @@ -41,6 +41,7 @@ */ #include +#include #include #include #include @@ -3842,6 +3843,10 @@ azalia_open(void *v, int flags) DPRINTFN(1, ("%s: flags=0x%x\n", __func__, flags)); az = v; codec = &az->codecs[az->codecno]; + if ((flags & FWRITE) && codec->dacs.ngroups == 0) + return ENODEV; + if ((flags & FREAD) && codec->adcs.ngroups == 0) + return ENODEV; codec->running++; return 0; } -- cgit v1.2.3