NetBSD Problem Report #52781

From bouyer@antioche.eu.org  Sun Dec  3 18:29:56 2017
Return-Path: <bouyer@antioche.eu.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 3713D7A1FE
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  3 Dec 2017 18:29:56 +0000 (UTC)
Message-Id: <201712031829.vB3ITYED002398@sandettie.soc.lip6.fr>
Date: Sun, 3 Dec 2017 19:29:34 +0100 (MET)
From: bouyer@antioche.eu.org
Reply-To: bouyer@antioche.eu.org
To: gnats-bugs@NetBSD.org
Subject: audioctl can't set output gain
X-Send-Pr-Version: 3.95

>Number:         52781
>Category:       kern
>Synopsis:       audioctl can't set output gain
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    isaki
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 03 18:30:00 +0000 2017
>Closed-Date:    Sat May 25 03:26:09 +0000 2019
>Last-Modified:  Sat May 25 09:20:01 +0000 2019
>Originator:     Manuel Bouyer
>Release:        NetBSD 8.99.6, netbsd-8 userland
>Organization:
>Environment:
System: NetBSD sandettie.soc.lip6.fr 8.99.6 NetBSD 8.99.6 (GENERIC) #73: Sun Dec 3 16:09:50 CET 2017 bouyer@bop.soc.lip6.fr:/dsk/l1/misc/bouyer/tmp/amd64/obj/dsk/l1/misc/bouyer/HEAD/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
hdaudio0 at pci0 dev 31 function 3: HD Audio Controller
allocated pic msi3 type edge pin 0 level 7 to cpu0 slot 20 idt entry 112
hdaudio0: interrupting at msi3 vec 0
hdafg0 at hdaudio0 vendor 0x10EC product 0x0256 nid 0x01: vendor 10ec product 02
56
hdafg0: DAC00 2ch: Speaker [Built-In]
    nid=14 [pin: Speaker (Built-In)]
           nid=02 [audio output] [source: dac]
hdafg0: DAC01 2ch: HP Out [Jack]
    nid=21 [pin: HP Out (Black Jack)]
           nid=03 [audio output] [source: dac]
hdafg0: ADC02 2ch: Mic In [Built-In]
    nid=12 [pin: Mic In (Built-In)]
hdafg0: 2ch/2ch 44100Hz 48000Hz 96000Hz 192000Hz PCM16 PCM20 PCM24 AC3
audio0 at hdafg0: full duplex, playback, capture, mmap, independent
hdafg0: Virtual format configured - Format SLINEAR, precision 16, channels 2, frequency 48000
hdafg0: Latency: 128 milliseconds
spkr0 at audio0: PC Speaker (synthesized)
wsbell at spkr0 not configured
hdafg1 at hdaudio0 vendor 0x8086 product 0x280B nid 0x01: vendor 8086 product 280b
hdafg1: DP00 8ch: Digital Out [Jack]
    nid=03 [pin: Digital Out (Jack)]
           nid=02 [audio output] [source: dac]
hdafg1: 8ch/0ch 48000Hz PCM16*

>Description:
	trying to set the audio output volume with audioctl fails:
sandettie# audioctl play.gain
play.gain=174
sandettie# audioctl -w play.gain=100
play.gain: -> 174
sandettie# audioctl play.gain
play.gain=174

	using mixerctl works around the problem:
sandettie# audioctl play.gain
play.gain=174
sandettie# mixerctl outputs.master
outputs.master=174,174
sandettie# mixerctl -w outputs.master=100,100
outputs.master: 174,174 -> 100,100
sandettie# mixerctl outputs.master
outputs.master=100,100
sandettie# audioctl play.gain
play.gain=100


>How-To-Repeat:
	try to use audioctl to change volume
>Fix:
	workaround: use mixerctl

>Release-Note:

>Audit-Trail:
From: Tetsuya Isaki <isaki@pastel-flower.jp>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org,
	gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: kern/52781: audioctl can't set output gain
Date: Fri, 27 Apr 2018 14:57:07 +0900

 This may not critical but is problematic to 8.0 release.
 How about revert audio.c 1.354 ?

 This revert revives 'audioctl -w play.gain=xxx'.
 Meanwhile, it disables audioctl's new software volume control.
 But 1) it is able to be done by mixerctl too.
 2) audio(4) manpage says that play.gain is shortcut for richer mixer
 (= mixerctl).

 I think it is better to revert.

 Thanks,
 ---
 Tetsuya Isaki <isaki@pastel-flower.jp / isaki@NetBSD.org>

 Index: audio.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/audio.c,v
 retrieving revision 1.354
 retrieving revision 1.353
 diff -u -r1.354 -r1.353
 --- audio.c	28 May 2017 21:12:59 -0000	1.354
 +++ audio.c	27 May 2017 13:55:58 -0000	1.353
 @@ -4734,11 +4734,18 @@
  		if (error)
  			goto cleanup;
  	}
 -	if (SPECIFIED(p->gain))
 -		vc->sc_swvol = p->gain;
 -
 -	if (SPECIFIED(r->gain))
 -		vc->sc_recswvol = r->gain;
 +	if (SPECIFIED(p->gain)) {
 +		au_get_gain(sc, &sc->sc_outports, &gain, &balance);
 +		error = au_set_gain(sc, &sc->sc_outports, p->gain, balance);
 +		if (error)
 +			goto cleanup;
 +	}
 +	if (SPECIFIED(r->gain)) {
 +		au_get_gain(sc, &sc->sc_inports, &gain, &balance);
 +		error = au_set_gain(sc, &sc->sc_inports, r->gain, balance);
 +		if (error)
 +			goto cleanup;
 +	}

  	if (SPECIFIED_CH(p->balance)) {
  		au_get_gain(sc, &sc->sc_outports, &gain, &balance);

From: Nathanial Sloss <nat@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/52781: audioctl can't set output gain
Date: Sat, 28 Apr 2018 20:03:26 +1000

 Hi,

 > This may not critical but is problematic to 8.0 release.
 > How about revert audio.c 1.354 ?


 I think it is not a good idea to revert this change as it was intended that 
 the play/record.gain will only set the gain the particular audio channel it is 
 applied to and mixerctl is used for setting the master volume which will effect 
 all channels.

 It is akin to having a mixer where by individual channel gains are set with 
 respect to each other and there is a master volume control (ie mixerctl -w 
 outputs.master) which will change the overall volume of all channels.

 It would be an unwanted side effect if the change was reverted to have setting 
 the gain on a particular channel influence other open channel's volume.

 I will update the documentation regarding how the gain fields work if the 
 current behavior is desired.

 Best regards,

 Nat

From: Nathanial Sloss <nat@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/52781: audioctl can't set output gain
Date: Sun, 29 Apr 2018 07:50:08 +1000

 --Boundary-00=_RyO5a9vm59yDUsS
 Content-Type: Text/Plain;
   charset="iso-8859-1"
 Content-Transfer-Encoding: 7bit

 Hi,

 The attached patch should fix the problem and return the relative gain for the 
 channel when the audioctl -p 1 play.gain is issued.

 To increase the overall master volume mixerctl -w outputs.master will have to 
 be used though.

 Best regards,

 Nat

 --Boundary-00=_RyO5a9vm59yDUsS
 Content-Type: text/x-patch;
   charset="ISO-8859-1";
   name="aud-gain.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename="aud-gain.diff"

 Index: audio.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/audio.c,v
 retrieving revision 1.452
 diff -u -p -r1.452 audio.c
 --- audio.c	6 Feb 2018 04:39:18 -0000	1.452
 +++ audio.c	28 Apr 2018 21:44:39 -0000
 @@ -4903,6 +4903,9 @@ audiogetinfo(struct audio_softc *sc, str

  		au_get_gain(sc, &sc->sc_inports, &r->gain, &r->balance);
  		au_get_gain(sc, &sc->sc_outports, &p->gain, &p->balance);
 +
 +		p->gain = vc->sc_swvol;
 +		r->gain = vc->sc_recswvol;
  	}

  	if (sc->sc_monitor_port != -1 && buf_only_mode == 0) {

 --Boundary-00=_RyO5a9vm59yDUsS--

From: Tetsuya Isaki <isaki@pastel-flower.jp>
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
	gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Cc: bouyer@antioche.eu.org
Subject: Re: kern/52781: audioctl can't set output gain
Date: Thu, 03 May 2018 16:11:57 +0900

 nat@,

 > It would be an unwanted side effect if the change was reverted to have
 > setting 
 > the gain on a particular channel influence other open channel's volume.

 Please don't use the word 'unwanted' or 'side effect',
 before defining/sharing the specification.

 > I will update the documentation regarding how the gain fields work if the 
 > current behavior is desired.

 > The attached patch should fix the problem and return the relative gain for
 > the 
 > channel when the audioctl -p 1 play.gain is issued.
 >
 > To increase the overall master volume mixerctl -w outputs.master will have to 
 > be used though.

 - What is the difference between "audioctl -p N play.gain" and
   "mixerctl -w vchan.dacN"?
   o (I don't know well about history between audioctl and mixerctl)
   o Although, mixerctl vchan has another problem.

 - How do I know about this N for audioctl -p?

 - How do you think about PR/52627 ?
   It allows unprivileged users to control privileged processes.

 - How does "audioctl {,-w} play.gain" (without -p) behave?

 - Assuming that the gain is controlled by software,
   why is the balance controlled by the mixer?  It means:
    "audioctl -p N -w play.gain" affects N-th VC's volume.
    "audioctl      -w play.gain" affects nothing? (as described in this PR)
    "audioctl -p N -w play.balance" affects HW balance.
    "audioctl      -w play.balance" affects HW balance.
   I don't think it's a good specification.

 - (and I also wonder inefficient implementation which reallocates
   mixer state arrays on every audio open/close.)

 > --- audio.c	6 Feb 2018 04:39:18 -0000	1.452
 > +++ audio.c	28 Apr 2018 21:44:39 -0000
 > @@ -4903,6 +4903,9 @@ audiogetinfo(struct audio_softc *sc, str
 >  
 >  		au_get_gain(sc, &sc->sc_inports, &r->gain, &r->balance);
 >  		au_get_gain(sc, &sc->sc_outports, &p->gain, &p->balance);
 > +
 > +		p->gain = vc->sc_swvol;
 > +		r->gain = vc->sc_recswvol;
 >  	}
 >  
 >  	if (sc->sc_monitor_port != -1 && buf_only_mode == 0) {

 I think it's not enough.
 - Many specifications are not fixed as above.
 - Again, What does "audioctl play.gain" (without -p) display in this
   case?
 - Assuming that the gain does not link the HW mixer, it should be also
   obtained with AUDIO_GETBUFINFO.

 Anyway, please propose and explain your desired specification first
 on public list.
 ---
 Tetsuya Isaki <isaki@pastel-flower.jp / isaki@NetBSD.org>

From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org, nat@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org, bouyer@antioche.eu.org
Subject: re: kern/52781: audioctl can't set output gain
Date: Sun, 20 May 2018 17:27:17 +1000

 hi Nat,

 old mail, i missed replying to earlier:

 >  > This may not critical but is problematic to 8.0 release.
 >  > How about revert audio.c 1.354 ?
 >  =

 >  I think it is not a good idea to revert this change as it was intended =
 that =

 >  the play/record.gain will only set the gain the particular audio channe=
 l it is =

 >  applied to and mixerctl is used for setting the master volume which wil=
 l effect =

 >  all channels.

 while i'm deleting your rationale for the above, i'd like
 disagree fundumentally with this.

 play.gain is the traditional way the "sun audio" interface has
 worked, so any other tool that thought this was a master volume
 (which it has been, until recently) has to be updated, whether
 it is a C program or a script.

 that's not particularly nice for the end users, so i would like
 to at least restore the original functionality if there is one
 vchan only, if not more generally.

 thanks.


 .mrg.

From: Nathanial Sloss <nat@netbsd.org>
To: matthew green <mrg@eterna.com.au>
Cc: gnats-bugs@netbsd.org,
 kern-bug-people@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org,
 bouyer@antioche.eu.org,
 matthew green <mrg@eterna.com.au>
Subject: Re: kern/52781: audioctl can't set output gain
Date: Sun, 20 May 2018 18:59:16 +1000

 --Boundary-00=_mjTAbY2peAxnZyL
 Content-Type: Text/Plain;
   charset="iso-8859-1"
 Content-Transfer-Encoding: 7bit

 Hi, 

 On Sun, 20 May 2018 17:27:17 matthew green wrote:
 > play.gain is the traditional way the "sun audio" interface has
 > worked, so any other tool that thought this was a master volume
 > (which it has been, until recently) has to be updated, whether
 > it is a C program or a script.

 I believe this is the way to go, but it's possibly too soon for those with 
 existing software.

 > 
 > that's not particularly nice for the end users, so i would like
 > to at least restore the original functionality if there is one
 > vchan only, if not more generally.
 > 

 How about the attached patch it will set the hw gain also if their is only one 
 channel open (recording or playback).  If this is good I'll document this 
 behaviour and update the spec.

 Best regards,

 Nat

 --Boundary-00=_mjTAbY2peAxnZyL
 Content-Type: text/x-patch;
   charset="ISO-8859-1";
   name="audio-1gain.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename="audio-1gain.diff"

 Index: audio.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/audio.c,v
 retrieving revision 1.456
 diff -u -p -r1.456 audio.c
 --- audio.c	17 May 2018 11:35:31 -0000	1.456
 +++ audio.c	20 May 2018 08:44:55 -0000
 @@ -4755,27 +4755,32 @@ done:
  			goto cleanup;
  	}
  	if (SPECIFIED(p->gain)) {
 -		if (!sc->sc_usemixer || vc == &sc->sc_mixring) {
 +		if (sc->sc_opens == 1 || !sc->sc_usemixer ||
 +						 vc == &sc->sc_mixring) {
  			au_get_gain(sc, &sc->sc_outports, &gain, &balance);
  			error = au_set_gain(sc, &sc->sc_outports, p->gain, balance);
  			if (error)
  				goto cleanup;
 -		} else
 +		}
 +		if (sc->sc_usemixer)
  			vc->sc_swvol = p->gain;
  	}

  	if (SPECIFIED(r->gain)) {
 -		if (!sc->sc_usemixer || vc == &sc->sc_mixring) {
 +		if (sc->sc_recopens == 1 || !sc->sc_usemixer ||
 +						 vc == &sc->sc_mixring) {
  			au_get_gain(sc, &sc->sc_inports, &gain, &balance);
  			error = au_set_gain(sc, &sc->sc_inports, r->gain, balance);
  			if (error)
  				goto cleanup;
 -		} else
 +		}
 +		if (sc->sc_usemixer)
  			vc->sc_recswvol = r->gain;
  	}

  	if (SPECIFIED_CH(p->balance)) {
 -		if (!sc->sc_usemixer || vc == &sc->sc_mixring) {
 +		if (sc->sc_opens == 1 || !sc->sc_usemixer ||
 +						 vc == &sc->sc_mixring) {
  			au_get_gain(sc, &sc->sc_outports, &gain, &balance);
  			error = au_set_gain(sc, &sc->sc_outports, gain, p->balance);
  			if (error)
 @@ -4783,7 +4788,8 @@ done:
  		}
  	}
  	if (SPECIFIED_CH(r->balance)) {
 -		if (!sc->sc_usemixer || vc == &sc->sc_mixring) {
 +		if (sc->sc_recopens == 1 || !sc->sc_usemixer ||
 +						 vc == &sc->sc_mixring) {
  			au_get_gain(sc, &sc->sc_inports, &gain, &balance);
  			error = au_set_gain(sc, &sc->sc_inports, gain, r->balance);
  			if (error)
 @@ -4932,13 +4938,17 @@ audiogetinfo(struct audio_softc *sc, str
  		r->avail_ports = sc->sc_inports.allports;
  		p->avail_ports = sc->sc_outports.allports;

 -		if (!sc->sc_usemixer || vc == &sc->sc_mixring) {
 +		if (sc->sc_recopens == 1 || !sc->sc_usemixer ||
 +						 vc == &sc->sc_mixring) {
  			au_get_gain(sc, &sc->sc_inports, &r->gain, &r->balance);
 +		} else
 +			r->gain = vc->sc_recswvol;
 +
 +		if (sc->sc_opens == 1 || !sc->sc_usemixer ||
 +						 vc == &sc->sc_mixring) {
  			au_get_gain(sc, &sc->sc_outports, &p->gain, &p->balance);
 -		} else {
 +		} else
  			p->gain = vc->sc_swvol;
 -			r->gain = vc->sc_recswvol;
 -		}
  	}

  	if (sc->sc_monitor_port != -1 && buf_only_mode == 0) {

 --Boundary-00=_mjTAbY2peAxnZyL--

From: Nathanial Sloss <nat@netbsd.org>
To: matthew green <mrg@eterna.com.au>
Cc: gnats-bugs@netbsd.org,
 kern-bug-people@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org,
 bouyer@antioche.eu.org,
 matthew green <mrg@eterna.com.au>
Subject: Re: kern/52781: audioctl can't set output gain
Date: Sun, 20 May 2018 20:27:59 +1000

 --Boundary-00=_w2UAbr4JjCIKqUu
 Content-Type: Text/Plain;
   charset="iso-8859-1"
 Content-Transfer-Encoding: 7bit

 Hi,

 I've come up with an alternative.  See attached.

 In this patch audioctl devices default to the mix ring allowig hw gain to be 
 adjusted (recording/ play back/ balance).  If one were to issue audioctl 
 without specifing -p vchan it would set the hw paramaters one could still issue 
 audioctl -p 0 to achieve the same thing.

 It would mean existing sun audio apps that set the master volume via 
 play/record->gain would not have to be changed and nor would scripts that want 
 to set the hw gain via audioctl(1) and don't specify the -p swich have to be 
 changed.


 Best regards,

 Nat

 --Boundary-00=_w2UAbr4JjCIKqUu
 Content-Type: text/x-patch;
   charset="ISO-8859-1";
   name="audio.c.audioctl.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename="audio.c.audioctl.diff"

 Index: audio.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/audio.c,v
 retrieving revision 1.456
 diff -u -p -r1.456 audio.c
 --- audio.c	17 May 2018 11:35:31 -0000	1.456
 +++ audio.c	20 May 2018 10:07:09 -0000
 @@ -234,6 +234,8 @@ int	audiosetinfo(struct audio_softc *, s
  int	audiogetinfo(struct audio_softc *, struct audio_info *, int,
  		     struct virtual_channel *);

 +int	audioctl_open(dev_t, struct audio_softc *, int, int, struct lwp *,
 +		   struct file **);
  int	audio_open(dev_t, struct audio_softc *, int, int, struct lwp *,
  		   struct file **);
  int	audio_close(struct audio_softc *, int, struct audio_chan *);
 @@ -1678,9 +1680,11 @@ audioopen(dev_t dev, int flags, int ifmt
  	switch (AUDIODEV(dev)) {
  	case SOUND_DEVICE:
  	case AUDIO_DEVICE:
 -	case AUDIOCTL_DEVICE:
  		error = audio_open(dev, sc, flags, ifmt, l, &fp);
  		break;
 +	case AUDIOCTL_DEVICE:
 +		error = audioctl_open(dev, sc, flags, ifmt, l, &fp);
 +		break;
  	case MIXER_DEVICE:
  		error = mixer_open(dev, sc, flags, ifmt, l, &fp);
  		break;
 @@ -1714,9 +1718,11 @@ audioclose(struct file *fp)
  	switch (AUDIODEV(dev)) {
  	case SOUND_DEVICE:
  	case AUDIO_DEVICE:
 -	case AUDIOCTL_DEVICE:
  		error = audio_close(sc, fp->f_flag, chan);
  		break;
 +	case AUDIOCTL_DEVICE:
 +		error = 0;
 +		break;
  	case MIXER_DEVICE:
  		error = mixer_close(sc, fp->f_flag, chan);
  		break;
 @@ -2144,6 +2150,50 @@ audio_calcwater(struct audio_softc *sc, 
  }

  int
 +audioctl_open(dev_t dev, struct audio_softc *sc, int flags, int ifmt,
 +    struct lwp *l, struct file **nfp)
 +{
 +	struct file *fp;
 +	int error, fd;
 +	const struct audio_hw_if *hw;
 +	struct virtual_channel *vc;
 +	struct audio_chan *chan;
 +
 +	KASSERT(mutex_owned(sc->sc_lock));
 +
 +	if (sc->sc_usemixer && !sc->sc_ready)
 +		return ENXIO;
 +
 +	hw = sc->hw_if;
 +	if (hw == NULL)
 +		return ENXIO;
 +
 +	chan = kmem_zalloc(sizeof(struct audio_chan), KM_SLEEP);
 +	if (sc->sc_usemixer)
 +		vc = &sc->sc_mixring;
 +	else
 +		vc = sc->sc_hwvc;
 +	chan->vc = vc;
 +
 +	error = fd_allocfile(&fp, &fd);
 +	if (error)
 +		goto bad;
 +
 +	chan->dev = dev;
 +	chan->chan = 0;
 +	chan->deschan = 0;
 +
 +	error = fd_clone(fp, fd, flags, &audio_fileops, chan);
 +	KASSERT(error == EMOVEFD);
 +
 +	*nfp = fp;
 +	return error;
 +bad:
 +	kmem_free(chan, sizeof(struct audio_chan));
 +	return error;
 +}
 +
 +int
  audio_open(dev_t dev, struct audio_softc *sc, int flags, int ifmt,
      struct lwp *l, struct file **nfp)
  {
 @@ -2175,9 +2225,6 @@ audio_open(dev_t dev, struct audio_softc
  		vc = sc->sc_hwvc;
  	chan->vc = vc;

 -	if (!sc->sc_usemixer && AUDIODEV(dev) == AUDIOCTL_DEVICE)
 -		goto audioctl_dev;
 -
  	if (sc->sc_usemixer) {
  		vc->sc_open = 0;
  		vc->sc_mode = 0;
 @@ -2295,12 +2342,9 @@ audio_open(dev_t dev, struct audio_softc
  	/* audio_close() decreases sc_mpr[n].usedlow, recalculate here */
  	audio_calcwater(sc, vc);

 -audioctl_dev:
  	error = fd_allocfile(&fp, &fd);
  	if (error)
  		goto bad;
 -	if (!sc->sc_usemixer && AUDIODEV(dev) == AUDIOCTL_DEVICE)
 -		goto setup_chan;

  	DPRINTF(("audio_open: done sc_mode = 0x%x\n", vc->sc_mode));

 @@ -2311,7 +2355,6 @@ audioctl_dev:
  	if (flags & FWRITE)
  		sc->sc_opens++;

 -setup_chan:
  	chan->dev = dev;
  	chan->chan = n;
  	chan->deschan = n;
 @@ -2488,9 +2531,6 @@ audio_close(struct audio_softc *sc, int 

  	KASSERT(mutex_owned(sc->sc_lock));

 -	if (!sc->sc_usemixer && AUDIODEV(chan->dev) == AUDIOCTL_DEVICE)
 -		return 0;
 -
  	if (sc->sc_opens == 0 && sc->sc_recopens == 0)
  		return ENXIO;


 --Boundary-00=_w2UAbr4JjCIKqUu--

Responsible-Changed-From-To: kern-bug-people->nat
Responsible-Changed-By: nat@NetBSD.org
Responsible-Changed-When: Sun, 20 May 2018 11:03:54 +0000
Responsible-Changed-Why:
I'll handle this.


From: christos@zoulas.com (Christos Zoulas)
To: Nathanial Sloss <nat@netbsd.org>, matthew green <mrg@eterna.com.au>
Cc: gnats-bugs@netbsd.org, kern-bug-people@netbsd.org, 
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, bouyer@antioche.eu.org
Subject: Re: kern/52781: audioctl can't set output gain
Date: Sun, 20 May 2018 09:08:39 -0400

 On May 20,  6:59pm, nat@netbsd.org (Nathanial Sloss) wrote:
 -- Subject: Re: kern/52781: audioctl can't set output gain

 | 
 | How about the attached patch it will set the hw gain also if their is only one 
 | channel open (recording or playback).  If this is good I'll document this 
 | behaviour and update the spec.
 | 
 | Best regards,
 | 
 | Nat

 I would write this:

 | +		if (sc->sc_opens == 1 || !sc->sc_usemixer ||
 | +						 vc == &sc->sc_mixring) {

 as a macro or inline function because we keep repeating it.

 christos

From: christos@zoulas.com (Christos Zoulas)
To: Nathanial Sloss <nat@netbsd.org>, matthew green <mrg@eterna.com.au>
Cc: gnats-bugs@netbsd.org, kern-bug-people@netbsd.org, 
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, bouyer@antioche.eu.org
Subject: Re: kern/52781: audioctl can't set output gain
Date: Sun, 20 May 2018 09:09:58 -0400

 On May 20,  8:27pm, nat@netbsd.org (Nathanial Sloss) wrote:
 -- Subject: Re: kern/52781: audioctl can't set output gain

 | Hi,
 | 
 | I've come up with an alternative.  See attached.
 | 
 | In this patch audioctl devices default to the mix ring allowig hw gain to be 
 | adjusted (recording/ play back/ balance).  If one were to issue audioctl 
 | without specifing -p vchan it would set the hw paramaters one could still issue 
 | audioctl -p 0 to achieve the same thing.
 | 
 | It would mean existing sun audio apps that set the master volume via 
 | play/record->gain would not have to be changed and nor would scripts that want 
 | to set the hw gain via audioctl(1) and don't specify the -p swich have to be 
 | changed.

 Sounds good!

 christos

From: "Nathanial Sloss" <nat@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52781 CVS commit: src
Date: Tue, 22 May 2018 01:35:49 +0000

 Module Name:	src
 Committed By:	nat
 Date:		Tue May 22 01:35:49 UTC 2018

 Modified Files:
 	src/share/man/man7: audio.7
 	src/sys/dev: audio.c

 Log Message:
 Using audioctl without the -p switch defaults to the mix ring.  This allows
 setting the hardware gain etc.

 Update the audio spec in audio.7 to reflect these changes.

 Addresses PR kern/52781.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.3 src/share/man/man7/audio.7
 cvs rdiff -u -r1.456 -r1.457 src/sys/dev/audio.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52781 CVS commit: [netbsd-8] src
Date: Thu, 7 Jun 2018 18:24:17 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Thu Jun  7 18:24:16 UTC 2018

 Modified Files:
 	src/distrib/sets/lists/comp [netbsd-8]: mi
 	src/distrib/sets/lists/man [netbsd-8]: mi
 	src/share/man/man4 [netbsd-8]: audio.4
 	src/share/man/man7 [netbsd-8]: Makefile intro.7
 	src/share/man/man9 [netbsd-8]: Makefile audio.9 intro.9
 	src/sys/dev [netbsd-8]: audio.c
 Added Files:
 	src/share/man/man9 [netbsd-8]: audio_system.9
 Removed Files:
 	src/share/man/man7 [netbsd-8]: audio.7

 Log Message:
 Pull up following revision(s) (requested by nat in ticket #848):

 	share/man/man9/Makefile: revision 1.422
 	distrib/sets/lists/comp/mi: revision 1.2198
 	share/man/man7/Makefile: revision 1.33
 	share/man/man9/audio.9: revision 1.47
 	share/man/man7/audio.7: file removal
 	sys/dev/audio.c: revision 1.456
 	sys/dev/audio.c: revision 1.457
 	distrib/sets/lists/man/mi: revision 1.1591
 	share/man/man9/intro.9: revision 1.20
 	share/man/man7/audio.7: revision 1.3
 	share/man/man9/audio_system.9: revision 1.1
 	share/man/man7/intro.7: revision 1.26
 	share/man/man4/audio.4: revision 1.86

 Fix a typo with sc_out/inports when setting the hardware recording gain on the
 mix ring.  Found by mrg@
 XXX pullup-8

 Using audioctl without the -p switch defaults to the mix ring.  This allows
 setting the hardware gain etc.

 Update the audio spec in audio.7 to reflect these changes.
 Addresses PR kern/52781.

 Move the audio specification to section 9 under audio_system.
 Ok wiz@


 To generate a diff of this commit:
 cvs rdiff -u -r1.2138.2.5 -r1.2138.2.6 src/distrib/sets/lists/comp/mi
 cvs rdiff -u -r1.1557.2.4 -r1.1557.2.5 src/distrib/sets/lists/man/mi
 cvs rdiff -u -r1.79.2.2 -r1.79.2.3 src/share/man/man4/audio.4
 cvs rdiff -u -r1.31.8.1 -r1.31.8.2 src/share/man/man7/Makefile
 cvs rdiff -u -r1.2.2.2 -r0 src/share/man/man7/audio.7
 cvs rdiff -u -r1.23.24.1 -r1.23.24.2 src/share/man/man7/intro.7
 cvs rdiff -u -r1.414 -r1.414.2.1 src/share/man/man9/Makefile
 cvs rdiff -u -r1.44.16.1 -r1.44.16.2 src/share/man/man9/audio.9
 cvs rdiff -u -r0 -r1.1.2.2 src/share/man/man9/audio_system.9
 cvs rdiff -u -r1.18 -r1.18.2.1 src/share/man/man9/intro.9
 cvs rdiff -u -r1.357.2.12 -r1.357.2.13 src/sys/dev/audio.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

Responsible-Changed-From-To: nat->kern-bug-people
Responsible-Changed-By: nat@NetBSD.org
Responsible-Changed-When: Wed, 08 May 2019 21:56:52 +0000
Responsible-Changed-Why:


Responsible-Changed-From-To: kern-bug-people->isaki
Responsible-Changed-By: isaki@NetBSD.org
Responsible-Changed-When: Sat, 25 May 2019 03:26:09 +0000
Responsible-Changed-Why:


State-Changed-From-To: open->closed
State-Changed-By: isaki@NetBSD.org
State-Changed-When: Sat, 25 May 2019 03:26:09 +0000
State-Changed-Why:
The problem described in subject is fixed.
(By merging isaki-audio2 branch, audioctl -p is obsoleted.)


From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/52781 (audioctl can't set output gain)
Date: Sat, 25 May 2019 09:15:51 +0000

 Sounds like isaki-audio2 is a massive regression then

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.