CVS commit: [netbsd-8] src/sys/dev/pad
Module Name:src Committed By: martin Date: Wed Oct 3 17:50:57 UTC 2018 Modified Files: src/sys/dev/pad [netbsd-8]: pad.c Log Message: Pull up following revision(s) (requested by nakayama in ticket #1044): sys/dev/pad/pad.c: revision 1.58 pad(4) mixer has only 1 channel, so return EINVAL in the case other than 1. This fixes the following strange output of mixerctl(1): outputs.master=255,0 inputs.dac=255,0 To generate a diff of this commit: cvs rdiff -u -r1.32.2.2 -r1.32.2.3 src/sys/dev/pad/pad.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/dev/pad
Module Name:src Committed By: martin Date: Wed Oct 3 17:50:57 UTC 2018 Modified Files: src/sys/dev/pad [netbsd-8]: pad.c Log Message: Pull up following revision(s) (requested by nakayama in ticket #1044): sys/dev/pad/pad.c: revision 1.58 pad(4) mixer has only 1 channel, so return EINVAL in the case other than 1. This fixes the following strange output of mixerctl(1): outputs.master=255,0 inputs.dac=255,0 To generate a diff of this commit: cvs rdiff -u -r1.32.2.2 -r1.32.2.3 src/sys/dev/pad/pad.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/pad/pad.c diff -u src/sys/dev/pad/pad.c:1.32.2.2 src/sys/dev/pad/pad.c:1.32.2.3 --- src/sys/dev/pad/pad.c:1.32.2.2 Sat Dec 23 18:48:41 2017 +++ src/sys/dev/pad/pad.c Wed Oct 3 17:50:57 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pad.c,v 1.32.2.2 2017/12/23 18:48:41 snj Exp $ */ +/* $NetBSD: pad.c,v 1.32.2.3 2018/10/03 17:50:57 martin Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.32.2.2 2017/12/23 18:48:41 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.32.2.3 2018/10/03 17:50:57 martin Exp $"); #include #include @@ -572,6 +572,8 @@ pad_set_port(void *opaque, mixer_ctrl_t switch (mc->dev) { case PAD_OUTPUT_MASTER_VOLUME: case PAD_INPUT_DAC_VOLUME: + if (mc->un.value.num_channels != 1) + return EINVAL; sc->sc_swvol = mc->un.value.level[AUDIO_MIXER_LEVEL_MONO]; return 0; } @@ -591,6 +593,8 @@ pad_get_port(void *opaque, mixer_ctrl_t switch (mc->dev) { case PAD_OUTPUT_MASTER_VOLUME: case PAD_INPUT_DAC_VOLUME: + if (mc->un.value.num_channels != 1) + return EINVAL; mc->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_swvol; return 0; }
CVS commit: [netbsd-8] src/sys/dev/pad
Module Name:src Committed By: snj Date: Sat Dec 23 18:48:42 UTC 2017 Modified Files: src/sys/dev/pad [netbsd-8]: pad.c Log Message: Pull up following revision(s) (requested by pgoyette in ticket #450): sys/dev/pad/pad.c: revision 1.44 Rework so that module infrastructure is provided even when the module is built-in to the kernel. To generate a diff of this commit: cvs rdiff -u -r1.32.2.1 -r1.32.2.2 src/sys/dev/pad/pad.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/dev/pad
Module Name:src Committed By: snj Date: Sat Dec 23 18:48:42 UTC 2017 Modified Files: src/sys/dev/pad [netbsd-8]: pad.c Log Message: Pull up following revision(s) (requested by pgoyette in ticket #450): sys/dev/pad/pad.c: revision 1.44 Rework so that module infrastructure is provided even when the module is built-in to the kernel. To generate a diff of this commit: cvs rdiff -u -r1.32.2.1 -r1.32.2.2 src/sys/dev/pad/pad.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/pad/pad.c diff -u src/sys/dev/pad/pad.c:1.32.2.1 src/sys/dev/pad/pad.c:1.32.2.2 --- src/sys/dev/pad/pad.c:1.32.2.1 Sat Jun 10 06:05:47 2017 +++ src/sys/dev/pad/pad.c Sat Dec 23 18:48:41 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: pad.c,v 1.32.2.1 2017/06/10 06:05:47 snj Exp $ */ +/* $NetBSD: pad.c,v 1.32.2.2 2017/12/23 18:48:41 snj Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.32.2.1 2017/06/10 06:05:47 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.32.2.2 2017/12/23 18:48:41 snj Exp $"); #include #include @@ -719,10 +719,10 @@ pad_swvol_dtor(stream_filter_t *this) kmem_free(this, sizeof(auvolconv_filter_t)); } -#ifdef _MODULE - MODULE(MODULE_CLASS_DRIVER, pad, "audio"); +#ifdef _MODULE + static const struct cfiattrdata audiobuscf_iattrdata = { "audiobus", 0, { { NULL, NULL, 0 }, } }; @@ -746,18 +746,22 @@ static struct cfdata pad_cfdata[] = { }, { NULL, NULL, 0, 0, NULL, 0, NULL } }; +#endif static int pad_modcmd(modcmd_t cmd, void *arg) { +#ifdef _MODULE devmajor_t cmajor = NODEVMAJOR, bmajor = NODEVMAJOR; - int error; +#endif + int error = 0; switch (cmd) { case MODULE_CMD_INIT: +#ifdef _MODULE error = config_cfdriver_attach(_cd); if (error) { - return error; + break; } error = config_cfattach_attach(pad_cd.cd_name, _ca); @@ -766,7 +770,7 @@ pad_modcmd(modcmd_t cmd, void *arg) aprint_error("%s: unable to register cfattach\n", pad_cd.cd_name); - return error; + break; } error = config_cfdata_attach(pad_cfdata, 1); @@ -776,41 +780,41 @@ pad_modcmd(modcmd_t cmd, void *arg) aprint_error("%s: unable to register cfdata\n", pad_cd.cd_name); - return error; + break; } error = devsw_attach(pad_cd.cd_name, NULL, , _cdevsw, ); if (error) { - error = config_cfdata_detach(pad_cfdata); - if (error) { -return error; - } + config_cfdata_detach(pad_cfdata); config_cfattach_detach(pad_cd.cd_name, _ca); config_cfdriver_detach(_cd); aprint_error("%s: unable to register devsw\n", pad_cd.cd_name); - return error; + break; } (void)config_attach_pseudo(pad_cfdata); +#endif - return 0; + break; case MODULE_CMD_FINI: +#ifdef _MODULE error = config_cfdata_detach(pad_cfdata); if (error) { - return error; + break; } config_cfattach_detach(pad_cd.cd_name, _ca); config_cfdriver_detach(_cd); devsw_detach(NULL, _cdevsw); +#endif - return 0; + break; default: - return ENOTTY; + error = ENOTTY; } -} -#endif + return error; +}
CVS commit: [netbsd-8] src/sys/dev/pad
Module Name:src Committed By: snj Date: Sat Jun 10 06:05:48 UTC 2017 Modified Files: src/sys/dev/pad [netbsd-8]: pad.c padvar.h Log Message: Pull up following revision(s) (requested by nat in ticket #20): sys/dev/pad/pad.c: revisions 1.33-1.35 sys/dev/pad/padvar.h: revision 1.9 Express BYTESTOSLEEP as an 64 bit integer. Use BYTESTOSLEEP in expresson of BYTES_PER_SEC. -- sc_bytes_count needs to be set in pad_audio_open not pad_open. -- Simplification of rate limiter. It now works uni/multiprocessor. -- pad blocksize 1024 -> 8192. Helps when sleeping in rate limiter. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.32.2.1 src/sys/dev/pad/pad.c cvs rdiff -u -r1.8 -r1.8.2.1 src/sys/dev/pad/padvar.h 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/pad/pad.c diff -u src/sys/dev/pad/pad.c:1.32 src/sys/dev/pad/pad.c:1.32.2.1 --- src/sys/dev/pad/pad.c:1.32 Thu Jun 1 09:44:30 2017 +++ src/sys/dev/pad/pad.c Sat Jun 10 06:05:47 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: pad.c,v 1.32 2017/06/01 09:44:30 pgoyette Exp $ */ +/* $NetBSD: pad.c,v 1.32.2.1 2017/06/10 06:05:47 snj Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.32 2017/06/01 09:44:30 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.32.2.1 2017/06/10 06:05:47 snj Exp $"); #include #include @@ -322,10 +322,6 @@ pad_open(dev_t dev, int flags, int fmt, return EBUSY; } - getmicrotime(>sc_last); - sc->sc_bytes_count = 0; - sc->sc_remainder = 0; - return 0; } @@ -345,8 +341,8 @@ pad_close(dev_t dev, int flags, int fmt, } #define PAD_BYTES_PER_SEC (44100 * sizeof(int16_t) * 2) -#define TIMENEXTREAD (PAD_BLKSIZE * 100 / PAD_BYTES_PER_SEC) -#define BYTESTOSLEEP (PAD_BLKSIZE) +#define BYTESTOSLEEP (int64_t)(PAD_BLKSIZE) +#define TIMENEXTREAD (int64_t)(BYTESTOSLEEP * 100 / PAD_BYTES_PER_SEC) int pad_read(dev_t dev, struct uio *uio, int flags) @@ -374,10 +370,11 @@ pad_read(dev_t dev, struct uio *uio, int nowusec = (now.tv_sec * 100) + now.tv_usec; lastusec = (sc->sc_last.tv_sec * 100) + sc->sc_last.tv_usec; - if (lastusec + TIMENEXTREAD > nowusec && - sc->sc_bytes_count >= BYTESTOSLEEP) { - sc->sc_remainder += - ((lastusec + TIMENEXTREAD) - nowusec); + if (lastusec + TIMENEXTREAD > nowusec) { + if (sc->sc_bytes_count >= BYTESTOSLEEP) { +sc->sc_remainder += +((lastusec + TIMENEXTREAD) - nowusec); + } wait_ticks = (hz * sc->sc_remainder) / 100; if (wait_ticks > 0) { @@ -385,19 +382,14 @@ pad_read(dev_t dev, struct uio *uio, int kpause("padwait", TRUE, wait_ticks, >sc_lock); } + } + if (sc->sc_bytes_count >= BYTESTOSLEEP) sc->sc_bytes_count -= BYTESTOSLEEP; - getmicrotime(>sc_last); - } else if (sc->sc_bytes_count >= BYTESTOSLEEP) { - sc->sc_bytes_count -= BYTESTOSLEEP; - getmicrotime(>sc_last); - } else if (lastusec + TIMENEXTREAD <= nowusec) { - getmicrotime(>sc_last); - sc->sc_remainder = 0; - } err = pad_get_block(sc, , min(uio->uio_resid, PAD_BLKSIZE)); if (!err) { + getmicrotime(>sc_last); sc->sc_bytes_count += pb.pb_len; mutex_exit(>sc_lock); err = uiomove(pb.pb_ptr, pb.pb_len, uio); @@ -438,6 +430,7 @@ pad_audio_open(void *opaque, int flags) return EIO; getmicrotime(>sc_last); + sc->sc_bytes_count = 0; sc->sc_remainder = 0; return 0; Index: src/sys/dev/pad/padvar.h diff -u src/sys/dev/pad/padvar.h:1.8 src/sys/dev/pad/padvar.h:1.8.2.1 --- src/sys/dev/pad/padvar.h:1.8 Sat May 27 10:02:26 2017 +++ src/sys/dev/pad/padvar.h Sat Jun 10 06:05:47 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: padvar.h,v 1.8 2017/05/27 10:02:26 nat Exp $ */ +/* $NetBSD: padvar.h,v 1.8.2.1 2017/06/10 06:05:47 snj Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -44,7 +44,7 @@ typedef struct pad_softc { struct audio_softc *sc_audiodev; int sc_blksize; -#define PAD_BLKSIZE 1024 +#define PAD_BLKSIZE 8192 #define PAD_BUFSIZE 65536 uint8_t sc_audiobuf[PAD_BUFSIZE]; uint32_t sc_buflen;
CVS commit: [netbsd-8] src/sys/dev/pad
Module Name:src Committed By: snj Date: Sat Jun 10 06:05:48 UTC 2017 Modified Files: src/sys/dev/pad [netbsd-8]: pad.c padvar.h Log Message: Pull up following revision(s) (requested by nat in ticket #20): sys/dev/pad/pad.c: revisions 1.33-1.35 sys/dev/pad/padvar.h: revision 1.9 Express BYTESTOSLEEP as an 64 bit integer. Use BYTESTOSLEEP in expresson of BYTES_PER_SEC. -- sc_bytes_count needs to be set in pad_audio_open not pad_open. -- Simplification of rate limiter. It now works uni/multiprocessor. -- pad blocksize 1024 -> 8192. Helps when sleeping in rate limiter. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.32.2.1 src/sys/dev/pad/pad.c cvs rdiff -u -r1.8 -r1.8.2.1 src/sys/dev/pad/padvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.