Module Name: src Committed By: nakayama Date: Mon May 13 08:50:25 UTC 2019
Modified Files: src/sys/dev/audio: audio.c Log Message: audio_open: On full duplex hardware, the flags passed to hw_if->open() is always (FREAD | FWRITE). But some devices (e.g. uaudio) check its capabilities at open(), so unidirection devices like USB speakers always return EACCES. Avoid open() failure on such devices by checking the capabilities of the device and changing the flags passed to hw_if->open(). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/audio/audio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/audio/audio.c diff -u src/sys/dev/audio/audio.c:1.6 src/sys/dev/audio/audio.c:1.7 --- src/sys/dev/audio/audio.c:1.6 Mon May 13 07:53:56 2019 +++ src/sys/dev/audio/audio.c Mon May 13 08:50:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: audio.c,v 1.6 2019/05/13 07:53:56 nakayama Exp $ */ +/* $NetBSD: audio.c,v 1.7 2019/05/13 08:50:25 nakayama Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -149,7 +149,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.6 2019/05/13 07:53:56 nakayama Exp $"); +__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.7 2019/05/13 08:50:25 nakayama Exp $"); #ifdef _KERNEL_OPT #include "audio.h" @@ -2046,12 +2046,17 @@ audio_open(dev_t dev, struct audio_softc * hw_if->open() is always (FREAD | FWRITE) * regardless of this open()'s flags. * see also dev/isa/aria.c + * but ckeck its playback or recording capability. * On half duplex hardware, the flags passed to * hw_if->open() is either FREAD or FWRITE. * see also arch/evbarm/mini2440/audio_mini2440.c */ if (fullduplex) { hwflags = FREAD | FWRITE; + if (!audio_can_playback(sc)) + hwflags &= ~FWRITE; + if (!audio_can_capture(sc)) + hwflags &= ~FREAD; } else { /* Construct hwflags from af->mode. */ hwflags = 0;