Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/allwinner add software volume controls
details: https://anonhg.NetBSD.org/src/rev/9fd9cb9cd491
branches: trunk
changeset: 333830:9fd9cb9cd491
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Tue Nov 18 01:53:53 2014 +0000
description:
add software volume controls
diffstat:
sys/arch/arm/allwinner/awin_hdmiaudio.c | 55 ++++++++++++++++++++++++++++----
sys/arch/arm/allwinner/files.awin | 4 +-
2 files changed, 49 insertions(+), 10 deletions(-)
diffs (153 lines):
diff -r c6921d33be23 -r 9fd9cb9cd491 sys/arch/arm/allwinner/awin_hdmiaudio.c
--- a/sys/arch/arm/allwinner/awin_hdmiaudio.c Tue Nov 18 01:53:17 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_hdmiaudio.c Tue Nov 18 01:53:53 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmiaudio.c,v 1.4 2014/11/17 01:38:00 jmcneill Exp $ */
+/* $NetBSD: awin_hdmiaudio.c,v 1.5 2014/11/18 01:53:53 jmcneill 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.4 2014/11/17 01:38:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_hdmiaudio.c,v 1.5 2014/11/18 01:53:53 jmcneill 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 c6921d33be23 -r 9fd9cb9cd491 sys/arch/arm/allwinner/files.awin
--- a/sys/arch/arm/allwinner/files.awin Tue Nov 18 01:53:17 2014 +0000
+++ b/sys/arch/arm/allwinner/files.awin Tue Nov 18 01:53:53 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.awin,v 1.25 2014/11/11 19:22:32 jmcneill Exp $
+# $NetBSD: files.awin,v 1.26 2014/11/18 01:53:53 jmcneill 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
Home |
Main Index |
Thread Index |
Old Index