Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/audio audio_open:



details:   https://anonhg.NetBSD.org/src/rev/d581f3e5f2e1
branches:  trunk
changeset: 451276:d581f3e5f2e1
user:      nakayama <nakayama%NetBSD.org@localhost>
date:      Mon May 13 08:50:25 2019 +0000

description:
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().

diffstat:

 sys/dev/audio/audio.c |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (36 lines):

diff -r 55365e833700 -r d581f3e5f2e1 sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c     Mon May 13 08:38:45 2019 +0000
+++ b/sys/dev/audio/audio.c     Mon May 13 08:50:25 2019 +0000
@@ -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 @@
                         * 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;



Home | Main Index | Thread Index | Old Index