Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/hdaudio add HDAUDIO_32BIT_ACCESS option, which wraps...



details:   https://anonhg.NetBSD.org/src/rev/e71c3adf99bf
branches:  trunk
changeset: 808700:e71c3adf99bf
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat May 30 13:47:03 2015 +0000

description:
add HDAUDIO_32BIT_ACCESS option, which wraps mmio read/writes to only use 32-bit accesses

diffstat:

 sys/dev/hdaudio/files.hdaudio |   3 +-
 sys/dev/hdaudio/hdaudiovar.h  |  72 ++++++++++++++++++++++++++++++++++--------
 2 files changed, 59 insertions(+), 16 deletions(-)

diffs (121 lines):

diff -r 20df70dc4bad -r e71c3adf99bf sys/dev/hdaudio/files.hdaudio
--- a/sys/dev/hdaudio/files.hdaudio     Sat May 30 13:25:55 2015 +0000
+++ b/sys/dev/hdaudio/files.hdaudio     Sat May 30 13:47:03 2015 +0000
@@ -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 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
 
diff -r 20df70dc4bad -r e71c3adf99bf sys/dev/hdaudio/hdaudiovar.h
--- a/sys/dev/hdaudio/hdaudiovar.h      Sat May 30 13:25:55 2015 +0000
+++ b/sys/dev/hdaudio/hdaudiovar.h      Sat May 30 13:47:03 2015 +0000
@@ -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 <support%precedence.co.uk@localhost>
@@ -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 @@
 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 */



Home | Main Index | Thread Index | Old Index