Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/sys Pull up following revision(s) (requested by jmcneill ...
details: https://anonhg.NetBSD.org/src/rev/25d92fbd52e7
branches: netbsd-7
changeset: 798610:25d92fbd52e7
user: martin <martin%NetBSD.org@localhost>
date: Sun Nov 23 13:07:04 2014 +0000
description:
Pull up following revision(s) (requested by jmcneill in ticket #249):
sys/modules/pad/Makefile: revision 1.2
sys/arch/arm/allwinner/awin_hdmiaudio.c: revision 1.5
sys/dev/pad/pad.c: revision 1.22
sys/dev/pad/padvol.c: file removal
sys/dev/pad/files.pad: revision 1.5
sys/dev/auvolconv.c: revision 1.1
sys/dev/pad/padvol.h: file removal
sys/dev/audio.c: revision 1.266
sys/dev/files.audio: revision 1.3 (via patch: sys/conf/files)
sys/dev/auvolconv.h: revision 1.1
sys/dev/pad/padvar.h: revision 1.5
sys/dev/audio_if.h: revision 1.70
sys/arch/arm/allwinner/files.awin: revision 1.26
Add common audio converters for software volume control. Only supports
slinear16_le and slinear16_be for now.
Convert pad(4) and awin_hdmiaudio to use the new converters.
diffstat:
sys/arch/arm/allwinner/awin_hdmiaudio.c | 55 ++++++++++++--
sys/arch/arm/allwinner/files.awin | 4 +-
sys/conf/files | 4 +-
sys/dev/audio.c | 12 ++-
sys/dev/audio_if.h | 5 +-
sys/dev/auvolconv.c | 94 ++++++++++++++++++++++++
sys/dev/auvolconv.h | 42 ++++++++++
sys/dev/pad/files.pad | 5 +-
sys/dev/pad/pad.c | 59 +++++++++++++-
sys/dev/pad/padvar.h | 4 +-
sys/dev/pad/padvol.c | 125 --------------------------------
sys/dev/pad/padvol.h | 53 -------------
sys/modules/pad/Makefile | 3 +-
13 files changed, 261 insertions(+), 204 deletions(-)
diffs (truncated from 711 to 300 lines):
diff -r 6d279244c39b -r 25d92fbd52e7 sys/arch/arm/allwinner/awin_hdmiaudio.c
--- a/sys/arch/arm/allwinner/awin_hdmiaudio.c Thu Nov 20 10:09:20 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_hdmiaudio.c Sun Nov 23 13:07:04 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmiaudio.c,v 1.3.2.3 2014/11/18 18:19:09 snj Exp $ */
+/* $NetBSD: awin_hdmiaudio.c,v 1.3.2.4 2014/11/23 13:07:04 martin Exp $ */
/*-
* Copyright (c) 2014 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_hdmiaudio.c,v 1.3.2.3 2014/11/18 18:19:09 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_hdmiaudio.c,v 1.3.2.4 2014/11/23 13:07:04 martin Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -39,6 +39,7 @@
#include <sys/audioio.h>
#include <dev/audio_if.h>
#include <dev/auconv.h>
+#include <dev/auvolconv.h>
#include <arm/allwinner/awin_reg.h>
#include <arm/allwinner/awin_var.h>
@@ -73,7 +74,6 @@
struct audio_format sc_format;
struct audio_encoding_set *sc_encodings;
- audio_params_t sc_pparam;
struct awin_dma_channel *sc_pdma;
void (*sc_pint)(void *);
void *sc_pintarg;
@@ -81,6 +81,8 @@
bus_addr_t sc_pend;
bus_addr_t sc_pcur;
int sc_pblksize;
+
+ uint8_t sc_swvol;
};
static int awin_hdmiaudio_match(device_t, cfdata_t, void *);
@@ -129,6 +131,10 @@
const audio_params_t *);
static void awin_hdmiaudio_get_locks(void *, kmutex_t **, kmutex_t **);
+static stream_filter_t *awin_hdmiaudio_swvol_filter(struct audio_softc *,
+ const audio_params_t *, const audio_params_t *);
+static void awin_hdmiaudio_swvol_dtor(stream_filter_t *);
+
static const struct audio_hw_if awin_hdmiaudio_hw_if = {
.open = awin_hdmiaudio_open,
.close = awin_hdmiaudio_close,
@@ -235,6 +241,8 @@
return;
}
+ sc->sc_swvol = 255;
+
awin_hdmiaudio_rescan(self, NULL, NULL);
}
@@ -385,9 +393,9 @@
AUMODE_PLAY, play, true, pfil);
if (index < 0)
return EINVAL;
- sc->sc_pparam = pfil->req_size > 0 ?
- pfil->filters[0].param :
- *play;
+ if (pfil->req_size > 0)
+ play = &pfil->filters[0].param;
+ pfil->prepend(pfil, awin_hdmiaudio_swvol_filter, play);
}
return 0;
@@ -415,9 +423,12 @@
static int
awin_hdmiaudio_set_port(void *priv, mixer_ctrl_t *mc)
{
+ struct awin_hdmiaudio_softc *sc = priv;
+
switch (mc->dev) {
case HDMIAUDIO_OUTPUT_MASTER_VOLUME:
case HDMIAUDIO_INPUT_DHDMIAUDIO_VOLUME:
+ sc->sc_swvol = mc->un.value.level[AUDIO_MIXER_LEVEL_MONO];
return 0;
}
@@ -427,11 +438,14 @@
static int
awin_hdmiaudio_get_port(void *priv, mixer_ctrl_t *mc)
{
+ struct awin_hdmiaudio_softc *sc = priv;
+ uint8_t vol = sc->sc_swvol;
+
switch (mc->dev) {
case HDMIAUDIO_OUTPUT_MASTER_VOLUME:
case HDMIAUDIO_INPUT_DHDMIAUDIO_VOLUME:
- mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = 255;
- mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = 255;
+ mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = vol;
+ mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = vol;
return 0;
}
@@ -679,3 +693,28 @@
*intr = &sc->sc_intr_lock;
*thread = &sc->sc_lock;
}
+
+static stream_filter_t *
+awin_hdmiaudio_swvol_filter(struct audio_softc *asc,
+ const audio_params_t *from, const audio_params_t *to)
+{
+ auvolconv_filter_t *this;
+ device_t dev = audio_get_device(asc);
+ struct awin_hdmiaudio_softc *sc = device_private(dev);
+
+ this = kmem_alloc(sizeof(auvolconv_filter_t), KM_SLEEP);
+ this->base.base.fetch_to = auvolconv_slinear16_le_fetch_to;
+ this->base.dtor = awin_hdmiaudio_swvol_dtor;
+ this->base.set_fetcher = stream_filter_set_fetcher;
+ this->base.set_inputbuffer = stream_filter_set_inputbuffer;
+ this->vol = &sc->sc_swvol;
+
+ return (stream_filter_t *)this;
+}
+
+static void
+awin_hdmiaudio_swvol_dtor(stream_filter_t *this)
+{
+ if (this)
+ kmem_free(this, sizeof(auvolconv_filter_t));
+}
diff -r 6d279244c39b -r 25d92fbd52e7 sys/arch/arm/allwinner/files.awin
--- a/sys/arch/arm/allwinner/files.awin Thu Nov 20 10:09:20 2014 +0000
+++ b/sys/arch/arm/allwinner/files.awin Sun Nov 23 13:07:04 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.awin,v 1.8.10.3 2014/11/14 13:37:39 martin Exp $
+# $NetBSD: files.awin,v 1.8.10.4 2014/11/23 13:07:04 martin Exp $
#
# Configuration info for Allwinner ARM Peripherals
#
@@ -144,7 +144,7 @@
file arch/arm/allwinner/awin_hdmi.c awin_hdmi
# A20/A31 HDMI audio (HDMIAUDIO)
-device awinhdmiaudio: audiobus, auconv, mulaw, aurateconv
+device awinhdmiaudio: audiobus, auconv, mulaw, aurateconv, auvolconv
attach awinhdmiaudio at awinio with awin_hdmiaudio
file arch/arm/allwinner/awin_hdmiaudio.c awin_hdmiaudio
diff -r 6d279244c39b -r 25d92fbd52e7 sys/conf/files
--- a/sys/conf/files Thu Nov 20 10:09:20 2014 +0000
+++ b/sys/conf/files Sun Nov 23 13:07:04 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files,v 1.1096.2.3 2014/11/12 19:54:46 martin Exp $
+# $NetBSD: files,v 1.1096.2.4 2014/11/23 13:07:05 martin Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
version 20100430
@@ -317,6 +317,7 @@
define mulaw
define auconv
define aurateconv
+define auvolconv
# audio and midi devices, attaches to audio hardware driver
#
@@ -1491,6 +1492,7 @@
file dev/audio.c audio | midi | midibus needs-flag
file dev/audiobell.c audiobell
file dev/aurateconv.c aurateconv needs-flag
+file dev/auvolconv.c auvolconv
file dev/bio.c bio needs-flag
file dev/ccd.c ccd
file dev/cgd.c cgd
diff -r 6d279244c39b -r 25d92fbd52e7 sys/dev/audio.c
--- a/sys/dev/audio.c Thu Nov 20 10:09:20 2014 +0000
+++ b/sys/dev/audio.c Sun Nov 23 13:07:04 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.263 2014/07/25 08:10:35 dholland Exp $ */
+/* $NetBSD: audio.c,v 1.263.2.1 2014/11/23 13:07:05 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -155,7 +155,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.263 2014/07/25 08:10:35 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.263.2.1 2014/11/23 13:07:05 martin Exp $");
#include "audio.h"
#if NAUDIO > 0
@@ -4246,6 +4246,14 @@
#endif /* NAUDIO > 0 || (NMIDI > 0 || NMIDIBUS > 0) */
#if NAUDIO > 0
+device_t
+audio_get_device(struct audio_softc *sc)
+{
+ return sc->sc_dev;
+}
+#endif
+
+#if NAUDIO > 0
static void
audio_mixer_capture(struct audio_softc *sc)
{
diff -r 6d279244c39b -r 25d92fbd52e7 sys/dev/audio_if.h
--- a/sys/dev/audio_if.h Thu Nov 20 10:09:20 2014 +0000
+++ b/sys/dev/audio_if.h Sun Nov 23 13:07:04 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio_if.h,v 1.67 2011/11/23 23:07:31 jmcneill Exp $ */
+/* $NetBSD: audio_if.h,v 1.67.24.1 2014/11/23 13:07:05 martin Exp $ */
/*
* Copyright (c) 1994 Havard Eidnes.
@@ -258,6 +258,9 @@
device_t audio_attach_mi(const struct audio_hw_if *, void *, device_t);
int audioprint(void *, const char *);
+/* Get the hw device from an audio softc */
+device_t audio_get_device(struct audio_softc *);
+
/* Device identity flags */
#define SOUND_DEVICE 0
#define AUDIO_DEVICE 0x80
diff -r 6d279244c39b -r 25d92fbd52e7 sys/dev/auvolconv.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/auvolconv.c Sun Nov 23 13:07:04 2014 +0000
@@ -0,0 +1,94 @@
+/* $NetBSD: auvolconv.c,v 1.2.2.2 2014/11/23 13:07:05 martin Exp $ */
+
+/*-
+ * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: auvolconv.c,v 1.2.2.2 2014/11/23 13:07:05 martin Exp $");
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/select.h>
+#include <sys/condvar.h>
+#include <sys/kmem.h>
+#include <sys/device.h>
+#include <sys/endian.h>
+
+#include <dev/audiovar.h>
+#include <dev/auconv.h>
+#include <dev/auvolconv.h>
+
+int
+auvolconv_slinear16_le_fetch_to(struct audio_softc *asc,
+ stream_fetcher_t *self, audio_stream_t *dst, int max_used)
+{
+ auvolconv_filter_t *pf;
+ stream_filter_t *this;
+ int16_t j, *wp;
+ int m, err;
+
+ pf = (auvolconv_filter_t *)self;
+ this = &pf->base;
+ max_used = (max_used + 1) & ~1;
+
+ if ((err = this->prev->fetch_to(asc, this->prev, this->src, max_used)))
+ return err;
+ m = (dst->end - dst->start) & ~1;
+ m = min(m, max_used);
+ FILTER_LOOP_PROLOGUE(this->src, 2, dst, 2, m) {
+ j = le16dec(s);
+ wp = (int16_t *)d;
+ le16enc(wp, (j * *pf->vol) / 255);
+ } FILTER_LOOP_EPILOGUE(this->src, dst);
+
Home |
Main Index |
Thread Index |
Old Index