Module Name: src Committed By: jmcneill Date: Thu Jul 25 00:30:45 UTC 2019
Modified Files: src/sys/arch/arm/nvidia: tegra_hdaudio.c src/sys/arch/evbarm/conf: GENERIC GENERIC64 src/sys/dev/hdaudio: files.hdaudio hdaudiovar.h Log Message: Replace the HDAUDIO_32BIT_ACCESS option with a runtime option. Set it for tegra_hdaudio, but not for the pci attachment. Add hdaudio@pci to GENERIC64 To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/nvidia/tegra_hdaudio.c cvs rdiff -u -r1.44 -r1.45 src/sys/arch/evbarm/conf/GENERIC cvs rdiff -u -r1.102 -r1.103 src/sys/arch/evbarm/conf/GENERIC64 cvs rdiff -u -r1.4 -r1.5 src/sys/dev/hdaudio/files.hdaudio cvs rdiff -u -r1.7 -r1.8 src/sys/dev/hdaudio/hdaudiovar.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/arch/arm/nvidia/tegra_hdaudio.c diff -u src/sys/arch/arm/nvidia/tegra_hdaudio.c:1.10 src/sys/arch/arm/nvidia/tegra_hdaudio.c:1.11 --- src/sys/arch/arm/nvidia/tegra_hdaudio.c:1.10 Mon Jul 16 23:11:47 2018 +++ src/sys/arch/arm/nvidia/tegra_hdaudio.c Thu Jul 25 00:30:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: tegra_hdaudio.c,v 1.10 2018/07/16 23:11:47 christos Exp $ */ +/* $NetBSD: tegra_hdaudio.c,v 1.11 2019/07/25 00:30:45 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcne...@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tegra_hdaudio.c,v 1.10 2018/07/16 23:11:47 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tegra_hdaudio.c,v 1.11 2019/07/25 00:30:45 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -156,6 +156,7 @@ tegra_hdaudio_attach(device_t parent, de size - TEGRA_HDAUDIO_OFFSET, &sc->sc.sc_memh); sc->sc.sc_memvalid = true; sc->sc.sc_dmat = faa->faa_dmat; + sc->sc.sc_flags = HDAUDIO_FLAG_32BIT; aprint_naive("\n"); aprint_normal(": HDA\n"); Index: src/sys/arch/evbarm/conf/GENERIC diff -u src/sys/arch/evbarm/conf/GENERIC:1.44 src/sys/arch/evbarm/conf/GENERIC:1.45 --- src/sys/arch/evbarm/conf/GENERIC:1.44 Tue Jul 23 12:32:40 2019 +++ src/sys/arch/evbarm/conf/GENERIC Thu Jul 25 00:30:45 2019 @@ -1,5 +1,5 @@ # -# $NetBSD: GENERIC,v 1.44 2019/07/23 12:32:40 jmcneill Exp $ +# $NetBSD: GENERIC,v 1.45 2019/07/25 00:30:45 jmcneill Exp $ # # GENERIC ARM (aarch32) kernel # @@ -507,7 +507,6 @@ h3codec* at fdt? # Allwinner H3 audio hdaudio* at fdt? # Intel HDA hdafg* at hdaudiobus? options HDAUDIOVERBOSE -options HDAUDIO_32BIT_ACCESS options HDAUDIO_ENABLE_HDMI options HDAUDIO_ENABLE_DISPLAYPORT sun8icodec* at fdt? # Audio codec (sun8i) Index: src/sys/arch/evbarm/conf/GENERIC64 diff -u src/sys/arch/evbarm/conf/GENERIC64:1.102 src/sys/arch/evbarm/conf/GENERIC64:1.103 --- src/sys/arch/evbarm/conf/GENERIC64:1.102 Tue Jul 16 09:47:41 2019 +++ src/sys/arch/evbarm/conf/GENERIC64 Thu Jul 25 00:30:45 2019 @@ -1,5 +1,5 @@ # -# $NetBSD: GENERIC64,v 1.102 2019/07/16 09:47:41 jmcneill Exp $ +# $NetBSD: GENERIC64,v 1.103 2019/07/25 00:30:45 jmcneill Exp $ # # GENERIC ARM (aarch64) kernel # @@ -403,9 +403,9 @@ spi* at spibus? # Audio support hdaudio* at fdt? # Intel HDA +hdaudio* at pci? dev ? function ? hdafg* at hdaudiobus? options HDAUDIOVERBOSE -options HDAUDIO_32BIT_ACCESS options HDAUDIO_ENABLE_HDMI options HDAUDIO_ENABLE_DISPLAYPORT ausoc* at fdt? # Simple SoC audio card Index: src/sys/dev/hdaudio/files.hdaudio diff -u src/sys/dev/hdaudio/files.hdaudio:1.4 src/sys/dev/hdaudio/files.hdaudio:1.5 --- src/sys/dev/hdaudio/files.hdaudio:1.4 Wed May 8 13:40:18 2019 +++ src/sys/dev/hdaudio/files.hdaudio Thu Jul 25 00:30:45 2019 @@ -1,4 +1,4 @@ -# $NetBSD: files.hdaudio,v 1.4 2019/05/08 13:40:18 isaki Exp $ +# $NetBSD: files.hdaudio,v 1.5 2019/07/25 00:30:45 jmcneill Exp $ # # Intel High Definition Audio (Revision 1.0) @@ -7,7 +7,6 @@ defflag HDAUDIOVERBOSE defflag opt_hdaudio.h HDAUDIO_ENABLE_HDMI defflag opt_hdaudio.h HDAUDIO_ENABLE_DISPLAYPORT defflag opt_hdaudio.h HDAUDIO_DEBUG -defflag opt_hdaudio.h HDAUDIO_32BIT_ACCESS defflag opt_hdaudio.h HDAFG_DEBUG defflag opt_hdaudio.h HDAFG_HDMI_DEBUG Index: src/sys/dev/hdaudio/hdaudiovar.h diff -u src/sys/dev/hdaudio/hdaudiovar.h:1.7 src/sys/dev/hdaudio/hdaudiovar.h:1.8 --- src/sys/dev/hdaudio/hdaudiovar.h:1.7 Wed May 8 13:40:18 2019 +++ src/sys/dev/hdaudio/hdaudiovar.h Thu Jul 25 00:30:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hdaudiovar.h,v 1.7 2019/05/08 13:40:18 isaki Exp $ */ +/* $NetBSD: hdaudiovar.h,v 1.8 2019/07/25 00:30:45 jmcneill Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd <supp...@precedence.co.uk> @@ -145,6 +145,9 @@ struct hdaudio_softc { bus_size_t sc_memsize; bool sc_memvalid; + uint32_t sc_flags; +#define HDAUDIO_FLAG_32BIT __BIT(0) + uint32_t sc_subsystem; kmutex_t sc_corb_mtx; @@ -184,58 +187,64 @@ void hdaudio_stream_reset(struct hdaudio int hdaudio_stream_tag(struct hdaudio_stream *); uint16_t hdaudio_stream_param(struct hdaudio_stream *, const audio_params_t *); -#ifdef HDAUDIO_32BIT_ACCESS static __inline uint8_t _hda_read1(struct hdaudio_softc *sc, bus_size_t off) { - return bus_space_read_4(sc->sc_memt, sc->sc_memh, off & -4) >> - (8 * (off & 3)); + if (ISSET(sc->sc_flags, HDAUDIO_FLAG_32BIT)) { + return bus_space_read_4(sc->sc_memt, sc->sc_memh, off & -4) >> + (8 * (off & 3)); + } else { + return bus_space_read_1(sc->sc_memt, sc->sc_memh, off); + } } + static __inline uint16_t _hda_read2(struct hdaudio_softc *sc, bus_size_t off) { - return bus_space_read_4(sc->sc_memt, sc->sc_memh, off & -4) >> - (8 * (off & 2)); + if (ISSET(sc->sc_flags, HDAUDIO_FLAG_32BIT)) { + return bus_space_read_4(sc->sc_memt, sc->sc_memh, off & -4) >> + (8 * (off & 2)); + } else { + return bus_space_read_2(sc->sc_memt, sc->sc_memh, off); + } } + #define hda_read1 _hda_read1 #define hda_read2 _hda_read2 #define hda_read4(sc, off) \ bus_space_read_4((sc)->sc_memt, (sc)->sc_memh, (off)) + static __inline void _hda_write1(struct hdaudio_softc *sc, bus_size_t off, uint8_t val) { - const size_t shift = 8 * (off & 3); - off &= -4; - uint32_t tmp = bus_space_read_4(sc->sc_memt, sc->sc_memh, off); - tmp = (val << shift) | (tmp & ~(0xff << shift)); - bus_space_write_4(sc->sc_memt, sc->sc_memh, off, tmp); + if (ISSET(sc->sc_flags, HDAUDIO_FLAG_32BIT)) { + const size_t shift = 8 * (off & 3); + off &= -4; + uint32_t tmp = bus_space_read_4(sc->sc_memt, sc->sc_memh, off); + tmp = (val << shift) | (tmp & ~(0xff << shift)); + bus_space_write_4(sc->sc_memt, sc->sc_memh, off, tmp); + } else { + bus_space_write_1(sc->sc_memt, sc->sc_memh, off, val); + } } + static __inline void _hda_write2(struct hdaudio_softc *sc, bus_size_t off, uint16_t val) { - const size_t shift = 8 * (off & 2); - off &= -4; - uint32_t tmp = bus_space_read_4(sc->sc_memt, sc->sc_memh, off); - tmp = (val << shift) | (tmp & ~(0xffff << shift)); - bus_space_write_4(sc->sc_memt, sc->sc_memh, off, tmp); + if (ISSET(sc->sc_flags, HDAUDIO_FLAG_32BIT)) { + const size_t shift = 8 * (off & 2); + off &= -4; + uint32_t tmp = bus_space_read_4(sc->sc_memt, sc->sc_memh, off); + tmp = (val << shift) | (tmp & ~(0xffff << shift)); + bus_space_write_4(sc->sc_memt, sc->sc_memh, off, tmp); + } else { + bus_space_write_2(sc->sc_memt, sc->sc_memh, off, val); + } } + #define hda_write1 _hda_write1 #define hda_write2 _hda_write2 #define hda_write4(sc, off, val) \ bus_space_write_4((sc)->sc_memt, (sc)->sc_memh, (off), (val)) -#else -#define hda_read1(sc, off) \ - bus_space_read_1((sc)->sc_memt, (sc)->sc_memh, (off)) -#define hda_read2(sc, off) \ - bus_space_read_2((sc)->sc_memt, (sc)->sc_memh, (off)) -#define hda_read4(sc, off) \ - bus_space_read_4((sc)->sc_memt, (sc)->sc_memh, (off)) -#define hda_write1(sc, off, val) \ - bus_space_write_1((sc)->sc_memt, (sc)->sc_memh, (off), (val)) -#define hda_write2(sc, off, val) \ - bus_space_write_2((sc)->sc_memt, (sc)->sc_memh, (off), (val)) -#define hda_write4(sc, off, val) \ - bus_space_write_4((sc)->sc_memt, (sc)->sc_memh, (off), (val)) -#endif #endif /* !_HDAUDIOVAR_H */