Module Name: src
Committed By: jmcneill
Date: Sat May 30 13:47:03 UTC 2015
Modified Files:
src/sys/dev/hdaudio: files.hdaudio hdaudiovar.h
Log Message:
add HDAUDIO_32BIT_ACCESS option, which wraps mmio read/writes to only use
32-bit accesses
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/hdaudio/files.hdaudio \
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/dev/hdaudio/files.hdaudio
diff -u src/sys/dev/hdaudio/files.hdaudio:1.2 src/sys/dev/hdaudio/files.hdaudio:1.3
--- src/sys/dev/hdaudio/files.hdaudio:1.2 Sat Mar 28 14:50:20 2015
+++ src/sys/dev/hdaudio/files.hdaudio Sat May 30 13:47:03 2015
@@ -1,4 +1,4 @@
-# $NetBSD: files.hdaudio,v 1.2 2015/03/28 14:50:20 jmcneill Exp $
+# $NetBSD: files.hdaudio,v 1.3 2015/05/30 13:47:03 jmcneill Exp $
#
# Intel High Definition Audio (Revision 1.0)
@@ -7,6 +7,7 @@ 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.2 src/sys/dev/hdaudio/hdaudiovar.h:1.3
--- src/sys/dev/hdaudio/hdaudiovar.h:1.2 Sat Mar 28 14:50:20 2015
+++ src/sys/dev/hdaudio/hdaudiovar.h Sat May 30 13:47:03 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudiovar.h,v 1.2 2015/03/28 14:50:20 jmcneill Exp $ */
+/* $NetBSD: hdaudiovar.h,v 1.3 2015/05/30 13:47:03 jmcneill Exp $ */
/*
* Copyright (c) 2009 Precedence Technologies Ltd <[email protected]>
@@ -40,18 +40,6 @@
#define HDAUDIO_MAX_CODECS 15
-#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))
#define hda_print(sc, ...) \
aprint_normal_dev((sc)->sc_dev, __VA_ARGS__)
#define hda_print1(sc, ...) \
@@ -70,14 +58,14 @@
#define hda_delay(us) \
delay((us))
-struct hdaudio_softc;
-
enum function_group_type {
HDAUDIO_GROUP_TYPE_UNKNOWN = 0,
HDAUDIO_GROUP_TYPE_AFG,
HDAUDIO_GROUP_TYPE_VSM_FG,
};
+struct hdaudio_softc;
+
struct hdaudio_function_group {
device_t fg_device;
struct hdaudio_codec *fg_codec;
@@ -196,4 +184,58 @@ 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));
+}
+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));
+}
+#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);
+}
+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);
+}
+#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 */