Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/dev Pull up following revision(s) (requested by nat i...
details: https://anonhg.NetBSD.org/src/rev/c25441d675e6
branches: netbsd-8
changeset: 434916:c25441d675e6
user: martin <martin%NetBSD.org@localhost>
date: Mon Apr 16 14:11:44 2018 +0000
description:
Pull up following revision(s) (requested by nat in ticket #759):
sys/dev/audio.c: revision 1.367
sys/dev/audio.c: revision 1.369
sys/dev/audio.c: revision 1.376 (patch)
sys/dev/audio.c: revision 1.377 (patch)
sys/dev/audio.c: revision 1.378
sys/dev/audio.c: revision 1.382 (patch)
sys/dev/audio.c: revision 1.383 (patch)
sys/dev/audio.c: revision 1.384
sys/dev/audio.c: revision 1.388
sys/dev/audio.c: revision 1.389
sys/dev/audio.c: revision 1.395
sys/dev/audio.c: revision 1.396 (patch)
sys/dev/audio.c: revision 1.397
sys/dev/audio.c: revision 1.403
sys/dev/audio.c: revision 1.451
sys/dev/audio.c: revision 1.452
sys/dev/audiovar.h: revision 1.59 (patch)
sys/dev/aurateconv.c: revision 1.21 (patch)
sys/dev/auconv.c: revision 1.31 (patch)
sys/dev/audiovar.h: revision 1.60 (patch)
Broadcast all conditional variables if in being deactivated so no readers
or writers get stuck.
Fix a panic caused by opening pad(4)'s mixer before the corresponding
audio device has attached.
Addresses PR kern/52424.
Improve audio_set_vchan_defaults().
- Correct confused input/output parameters.
- Remove sc->{sc_channels, sc_precision, sc_frequency}. They are
the same as sc->sc_vchan_params.{channels, precision, sample_rate}.
The input parameter of audio_set_vchan_defaults() is now only
sc->sc_vchan_params.
Fix PR kern/52437
const-ify.
0 -> NULL in audioattach()
"bits" sounds better than "name" for argument name.
I feel expression (name / NBBY) a little strange.
The audio module will now compile with WARNS=5.
Typo in debug message.
Remove a duplicated line.
Add missing initialization of sc_rfilters in audioattach().
Remove dead codes.
sc->sc_opens never changes in this loop and as a result of
previous sc_audiochan cleanup "sc_opens == 0" is the same as
"sc_audiochan is empty".
Clean up audio_allocbufs().
As a result of sc_audiochan cleanup, it is easy to access sc_hwvc.
Clean up audio_open().
As a result of sc_audiochan cleanup, this loop is the same as last + 1.
hw_if->set_params is mandatory, so it will never be NULL.
CID-1427745: kill possible buffer overflows.
Revert my wrong r1.380 and add a comment instead.
diffstat:
sys/dev/auconv.c | 6 +-
sys/dev/audio.c | 161 ++++++++++++++++++++++++++------------------------
sys/dev/audiovar.h | 6 +-
sys/dev/aurateconv.c | 16 ++--
4 files changed, 99 insertions(+), 90 deletions(-)
diffs (truncated from 555 to 300 lines):
diff -r 83540113e8ea -r c25441d675e6 sys/dev/auconv.c
--- a/sys/dev/auconv.c Mon Apr 16 13:31:33 2018 +0000
+++ b/sys/dev/auconv.c Mon Apr 16 14:11:44 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auconv.c,v 1.26.2.4 2018/01/09 19:35:03 snj Exp $ */
+/* $NetBSD: auconv.c,v 1.26.2.5 2018/04/16 14:11:44 martin Exp $ */
/*
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auconv.c,v 1.26.2.4 2018/01/09 19:35:03 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auconv.c,v 1.26.2.5 2018/04/16 14:11:44 martin Exp $");
#include <sys/types.h>
#include <sys/audioio.h>
@@ -2115,7 +2115,7 @@
if (formats[i].frequency[1] > maxrate)
maxrate = formats[i].frequency[1];
} else {
- for (j = 0; j < formats[i].frequency_type; j++) {
+ for (j = 0; j < (int)formats[i].frequency_type; j++) {
if (formats[i].frequency[j] < minrate)
minrate = formats[i].frequency[j];
if (formats[i].frequency[j] > maxrate)
diff -r 83540113e8ea -r c25441d675e6 sys/dev/audio.c
--- a/sys/dev/audio.c Mon Apr 16 13:31:33 2018 +0000
+++ b/sys/dev/audio.c Mon Apr 16 14:11:44 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.357.2.10 2018/01/15 00:08:55 snj Exp $ */
+/* $NetBSD: audio.c,v 1.357.2.11 2018/04/16 14:11:44 martin Exp $ */
/*-
* Copyright (c) 2016 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
@@ -148,7 +148,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.357.2.10 2018/01/15 00:08:55 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.357.2.11 2018/04/16 14:11:44 martin Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -209,7 +209,7 @@
#define PREFILL_BLOCKS 3 /* no. audioblocks required to start stream */
#define ROUNDSIZE(x) (x) &= -16 /* round to nice boundary */
-#define SPECIFIED(x) ((x) != ~0)
+#define SPECIFIED(x) ((int)(x) != ~0)
#define SPECIFIED_CH(x) ((x) != (u_char)~0)
/* #define AUDIO_PM_IDLE */
@@ -282,10 +282,10 @@
static void audio_setblksize(struct audio_softc *,
struct virtual_channel *, int, int);
int audio_calc_blksize(struct audio_softc *, const audio_params_t *);
-void audio_fill_silence(struct audio_params *, uint8_t *, int);
+void audio_fill_silence(const struct audio_params *, uint8_t *, int);
int audio_silence_copyout(struct audio_softc *, int, struct uio *);
-static int audio_allocbufs(struct audio_softc *, struct virtual_channel *);
+static int audio_allocbufs(struct audio_softc *);
void audio_init_ringbuffer(struct audio_softc *,
struct audio_ringbuffer *, int);
int audio_initbufs(struct audio_softc *, struct virtual_channel *);
@@ -396,7 +396,7 @@
static int audio_set_params (struct audio_softc *, int, int,
audio_params_t *, audio_params_t *,
stream_filter_list_t *, stream_filter_list_t *,
- struct virtual_channel *);
+ const struct virtual_channel *);
static int
audio_query_encoding(struct audio_softc *, struct audio_encoding *);
static int audio_set_vchan_defaults(struct audio_softc *, u_int);
@@ -527,8 +527,9 @@
vc->sc_open = 0;
vc->sc_mode = 0;
vc->sc_npfilters = 0;
- memset(vc->sc_pfilters, 0,
- sizeof(vc->sc_pfilters));
+ vc->sc_nrfilters = 0;
+ memset(vc->sc_pfilters, 0, sizeof(vc->sc_pfilters));
+ memset(vc->sc_rfilters, 0, sizeof(vc->sc_rfilters));
vc->sc_lastinfovalid = false;
vc->sc_swvol = 255;
vc->sc_recswvol = 255;
@@ -545,7 +546,7 @@
cv_init(&sc->sc_condvar,"play");
cv_init(&sc->sc_rcondvar,"record");
- if (hwp == 0 || hwp->get_locks == 0) {
+ if (hwp == NULL || hwp->get_locks == NULL) {
aprint_error(": missing method\n");
panic("audioattach");
}
@@ -553,17 +554,17 @@
hwp->get_locks(hdlp, &sc->sc_intr_lock, &sc->sc_lock);
#ifdef DIAGNOSTIC
- if (hwp->query_encoding == 0 ||
- hwp->set_params == 0 ||
- (hwp->start_output == 0 && hwp->trigger_output == 0) ||
- (hwp->start_input == 0 && hwp->trigger_input == 0) ||
- hwp->halt_output == 0 ||
- hwp->halt_input == 0 ||
- hwp->getdev == 0 ||
- hwp->set_port == 0 ||
- hwp->get_port == 0 ||
- hwp->query_devinfo == 0 ||
- hwp->get_props == 0) {
+ if (hwp->query_encoding == NULL ||
+ hwp->set_params == NULL ||
+ (hwp->start_output == NULL && hwp->trigger_output == NULL) ||
+ (hwp->start_input == NULL && hwp->trigger_input == NULL) ||
+ hwp->halt_output == NULL ||
+ hwp->halt_input == NULL ||
+ hwp->getdev == NULL ||
+ hwp->set_port == NULL ||
+ hwp->get_port == NULL ||
+ hwp->query_devinfo == NULL ||
+ hwp->get_props == NULL) {
aprint_error(": missing method\n");
return;
}
@@ -595,7 +596,7 @@
aprint_normal("\n");
mutex_enter(sc->sc_lock);
- if (audio_allocbufs(sc, vc) != 0) {
+ if (audio_allocbufs(sc) != 0) {
aprint_error_dev(sc->sc_dev,
"could not allocate ring buffer\n");
mutex_exit(sc->sc_lock);
@@ -869,6 +870,10 @@
sc->sc_dying = true;
mutex_enter(sc->sc_intr_lock);
cv_broadcast(&sc->sc_condvar);
+ cv_broadcast(&sc->sc_rcondvar);
+ cv_broadcast(&sc->sc_wchan);
+ cv_broadcast(&sc->sc_rchan);
+ cv_broadcast(&sc->sc_lchan);
mutex_exit(sc->sc_intr_lock);
mutex_exit(sc->sc_lock);
return 0;
@@ -1125,10 +1130,13 @@
/* Allocate all ring buffers. called from audioattach() */
static int
-audio_allocbufs(struct audio_softc *sc, struct virtual_channel *vc)
+audio_allocbufs(struct audio_softc *sc)
{
+ struct virtual_channel *vc;
int error;
+ vc = sc->sc_hwvc;
+
sc->sc_mixring.sc_mpr.s.start = NULL;
vc->sc_mpr.s.start = NULL;
sc->sc_mixring.sc_mrr.s.start = NULL;
@@ -1224,7 +1232,7 @@
false, 0);
if (error) {
uvm_unmap(kernel_map, vstart, vstart + vsize);
- uao_detach(r->uobj);
+ /* uvm_unmap also detach uobj */
r->uobj = NULL; /* paranoia */
return error;
}
@@ -1420,7 +1428,7 @@
#ifdef AUDIO_DEBUG
if (audiodebug) {
- printf("%s: HW-buffer=%p pustream=%p\n",
+ printf("%s: HW-buffer=%p rustream=%p\n",
__func__, &vc->sc_mrr.s, vc->sc_rustream);
audio_print_params("[HW]", &vc->sc_mrr.s.param);
for (i = 0; i < rfilters->req_size; i++) {
@@ -1834,7 +1842,6 @@
if ((error = audio_enter(dev, rw, &sc)) != 0)
return error;
- chan = fp->f_audioctx;
switch (AUDIODEV(dev)) {
case SOUND_DEVICE:
@@ -2005,7 +2012,7 @@
blksize = rp->blksize;
if (blksize < AUMINBLK)
blksize = AUMINBLK;
- if (blksize > rp->s.bufsize / AUMINNOBLK)
+ if (blksize > (int)(rp->s.bufsize / AUMINNOBLK))
blksize = rp->s.bufsize / AUMINNOBLK;
ROUNDSIZE(blksize);
DPRINTF(("audio_init_ringbuffer: MI blksize=%d\n", blksize));
@@ -2154,12 +2161,11 @@
hw = sc->hw_if;
if (hw == NULL)
return ENXIO;
+
n = 1;
- SIMPLEQ_FOREACH(chan, &sc->sc_audiochan, entries) {
+ chan = SIMPLEQ_LAST(&sc->sc_audiochan, audio_chan, entries);
+ if (chan != NULL)
n = chan->chan + 1;
- }
- if (n < 0)
- return ENOMEM;
chan = kmem_zalloc(sizeof(struct audio_chan), KM_SLEEP);
if (sc->sc_usemixer)
@@ -2377,8 +2383,8 @@
audio_drain(struct audio_softc *sc, struct virtual_channel *vc)
{
struct audio_ringbuffer *cb;
- int error, drops;
- int cc, i, used;
+ int error, cc, i, used;
+ uint drops;
bool hw = false;
KASSERT(mutex_owned(sc->sc_lock));
@@ -2569,7 +2575,8 @@
struct audio_ringbuffer *cb;
const uint8_t *outp;
uint8_t *inp;
- int error, used, cc, n;
+ int error, used, n;
+ uint cc;
KASSERT(mutex_owned(sc->sc_lock));
@@ -2750,7 +2757,7 @@
}
void
-audio_fill_silence(struct audio_params *params, uint8_t *p, int n)
+audio_fill_silence(const struct audio_params *params, uint8_t *p, int n)
{
uint8_t auzero0, auzero1;
int nfill;
@@ -3498,7 +3505,7 @@
cb = &vc->sc_mpr;
#endif
- if (len > cb->s.bufsize || *offp > cb->s.bufsize - len)
+ if (len > cb->s.bufsize || *offp > (uint)(cb->s.bufsize - len))
return EOVERFLOW;
if (!cb->mmapped) {
@@ -3735,9 +3742,6 @@
blksize = sc->sc_mixring.sc_mpr.blksize;
SIMPLEQ_FOREACH(chan, &sc->sc_audiochan, entries) {
- if (!sc->sc_opens)
- break; /* ignore interrupt if not open */
-
vc = chan->vc;
if (!vc->sc_open)
@@ -3953,9 +3957,6 @@
blksize = sc->sc_mixring.sc_mrr.blksize;
SIMPLEQ_FOREACH(chan, &sc->sc_audiochan, entries) {
- if (!sc->sc_opens)
- break; /* ignore interrupt if not open */
-
vc = chan->vc;
if (!(vc->sc_open & AUOPEN_READ))
@@ -4172,12 +4173,12 @@
ai.play.pause = false;
ai.mode = mode;
- sc->sc_format->encoding = sc->sc_vchan_params.encoding;
- sc->sc_format->channels = sc->sc_vchan_params.channels;
- sc->sc_format->precision = sc->sc_vchan_params.precision;
- sc->sc_format->validbits = sc->sc_vchan_params.precision;
- sc->sc_format->frequency_type = 1;
- sc->sc_format->frequency[0] = sc->sc_vchan_params.sample_rate;
+ sc->sc_format[0].encoding = sc->sc_vchan_params.encoding;
+ sc->sc_format[0].channels = sc->sc_vchan_params.channels;
+ sc->sc_format[0].precision = sc->sc_vchan_params.precision;
+ sc->sc_format[0].validbits = sc->sc_vchan_params.precision;
+ sc->sc_format[0].frequency_type = 1;
+ sc->sc_format[0].frequency[0] = sc->sc_vchan_params.sample_rate;
auconv_delete_encodings(sc->sc_encodings);
error = auconv_create_encodings(sc->sc_format, VAUDIO_NFORMATS,
@@ -4523,7 +4524,7 @@
int setmode;
int error;
int np, nr;
- unsigned int blks;
+ int blks;
u_int gain;
bool rbus, pbus;
bool cleared, modechange, pausechange;
@@ -5577,9 +5578,9 @@
Home |
Main Index |
Thread Index |
Old Index