Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/sys/arch Pull up following revision(s) (requested by jmcn...
details: https://anonhg.NetBSD.org/src/rev/79a16f62730e
branches: netbsd-7
changeset: 798571:79a16f62730e
user: martin <martin%NetBSD.org@localhost>
date: Fri Nov 14 13:37:39 2014 +0000
description:
Pull up following revision(s) (requested by jmcneill in ticket #214):
sys/arch/evbarm/conf/BPI: revision 1.11
sys/arch/arm/allwinner/awin_hdmi.c: revision 1.10
sys/arch/arm/allwinner/awin_hdmiaudio.c: revision 1.1
sys/arch/arm/allwinner/awin_hdmiaudio.c: revision 1.2
sys/arch/arm/allwinner/awin_hdmiaudio.c: revision 1.3
sys/arch/evbarm/conf/CUBIEBOARD: revision 1.34
sys/arch/arm/allwinner/awin_io.c: revision 1.28
sys/arch/arm/allwinner/awin_reg.h: revision 1.48
sys/arch/arm/allwinner/awin_debe.c: revision 1.5
sys/arch/arm/allwinner/awin_dma_a10.c: revision 1.3
sys/arch/evbarm/conf/HUMMINGBIRD_A31: revision 1.19
sys/arch/arm/allwinner/files.awin: revision 1.24
sys/arch/arm/allwinner/awin_board.c: revision 1.28
sys/arch/arm/allwinner/awin_hdmi.c: revision 1.7
sys/arch/arm/allwinner/awin_hdmi.c: revision 1.8
HDMI audio driver for Allwinner boards.
diffstat:
sys/arch/arm/allwinner/awin_board.c | 6 +-
sys/arch/arm/allwinner/awin_dma_a10.c | 24 +-
sys/arch/arm/allwinner/awin_hdmi.c | 92 ++++-
sys/arch/arm/allwinner/awin_hdmiaudio.c | 655 ++++++++++++++++++++++++++++++++
sys/arch/arm/allwinner/awin_io.c | 4 +-
sys/arch/arm/allwinner/awin_reg.h | 41 ++
sys/arch/arm/allwinner/files.awin | 9 +-
sys/arch/evbarm/conf/BPI | 4 +-
sys/arch/evbarm/conf/CUBIEBOARD | 4 +-
9 files changed, 817 insertions(+), 22 deletions(-)
diffs (truncated from 1034 to 300 lines):
diff -r 562c8536595c -r 79a16f62730e sys/arch/arm/allwinner/awin_board.c
--- a/sys/arch/arm/allwinner/awin_board.c Fri Nov 14 13:26:46 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_board.c Fri Nov 14 13:37:39 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_board.c,v 1.14.6.2 2014/11/14 13:26:46 martin Exp $ */
+/* $NetBSD: awin_board.c,v 1.14.6.3 2014/11/14 13:37:39 martin Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.14.6.2 2014/11/14 13:26:46 martin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.14.6.3 2014/11/14 13:37:39 martin Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -518,7 +518,7 @@
AWIN_CCM_OFFSET + AWIN_PLL5_CFG_REG);
n = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_N);
- k = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_K);
+ k = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_K) + 1;
p = __SHIFTOUT(cfg, AWIN_PLL5_OUT_EXT_DIV_P);
return (AWIN_REF_FREQ * n * k) >> p;
diff -r 562c8536595c -r 79a16f62730e sys/arch/arm/allwinner/awin_dma_a10.c
--- a/sys/arch/arm/allwinner/awin_dma_a10.c Fri Nov 14 13:26:46 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_dma_a10.c Fri Nov 14 13:37:39 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_dma_a10.c,v 1.2.2.2 2014/11/09 14:42:33 martin Exp $ */
+/* $NetBSD: awin_dma_a10.c,v 1.2.2.3 2014/11/14 13:37:39 martin Exp $ */
/*-
* Copyright (c) 2014 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "opt_ddb.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_dma_a10.c,v 1.2.2.2 2014/11/09 14:42:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_dma_a10.c,v 1.2.2.3 2014/11/14 13:37:39 martin Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -179,7 +179,8 @@
uint32_t irqen;
uint8_t ch_count, index;
- if (strcmp(type, "ddma") == 0) {
+ if (strcmp(type, "ddma") == 0 ||
+ strcmp(type, "hdmiaudio") == 0) {
ch_list = awin_ddma_channels;
ch_count = DDMA_CHANNELS;
} else {
@@ -239,7 +240,11 @@
{
struct awin_dma_a10_channel *ch = priv;
- return DMACH_READ(ch, AWIN_NDMA_CTL_REG);
+ if (ch->ch_type == CH_NDMA) {
+ return DMACH_READ(ch, AWIN_NDMA_CTL_REG);
+ } else {
+ return DMACH_READ(ch, AWIN_DDMA_CTL_REG);
+ }
}
static void
@@ -247,7 +252,11 @@
{
struct awin_dma_a10_channel *ch = priv;
- DMACH_WRITE(ch, AWIN_NDMA_CTL_REG, val);
+ if (ch->ch_type == CH_NDMA) {
+ DMACH_WRITE(ch, AWIN_NDMA_CTL_REG, val);
+ } else {
+ DMACH_WRITE(ch, AWIN_DDMA_CTL_REG, val);
+ }
}
static int
@@ -275,6 +284,11 @@
DMACH_WRITE(ch, AWIN_DDMA_SRC_START_ADDR_REG, src);
DMACH_WRITE(ch, AWIN_DDMA_DEST_START_ADDR_REG, dst);
DMACH_WRITE(ch, AWIN_DDMA_BC_REG, nbytes);
+ DMACH_WRITE(ch, AWIN_DDMA_PARA_REG,
+ __SHIFTIN(31, AWIN_DDMA_PARA_DST_DATA_BLK_SIZ) |
+ __SHIFTIN(7, AWIN_DDMA_PARA_DST_WAIT_CYC) |
+ __SHIFTIN(31, AWIN_DDMA_PARA_SRC_DATA_BLK_SIZ) |
+ __SHIFTIN(7, AWIN_DDMA_PARA_SRC_WAIT_CYC));
cfg |= AWIN_DDMA_CTL_DMA_LOADING;
awin_dma_a10_set_config(ch, cfg);
diff -r 562c8536595c -r 79a16f62730e sys/arch/arm/allwinner/awin_hdmi.c
--- a/sys/arch/arm/allwinner/awin_hdmi.c Fri Nov 14 13:26:46 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_hdmi.c Fri Nov 14 13:37:39 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmi.c,v 1.4.2.3 2014/11/14 13:26:46 martin Exp $ */
+/* $NetBSD: awin_hdmi.c,v 1.4.2.4 2014/11/14 13:37:39 martin Exp $ */
/*-
* Copyright (c) 2014 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -32,7 +32,7 @@
#define AWIN_HDMI_PLL 3 /* PLL7 or PLL3 */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_hdmi.c,v 1.4.2.3 2014/11/14 13:26:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_hdmi.c,v 1.4.2.4 2014/11/14 13:37:39 martin Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -101,6 +101,7 @@
#if 0
static int awin_hdmi_intr(void *);
#endif
+
#if defined(DDB)
void awin_hdmi_dump_regs(void);
#endif
@@ -536,7 +537,8 @@
}
static void
-awin_hdmi_set_videomode(struct awin_hdmi_softc *sc, const struct videomode *mode)
+awin_hdmi_set_videomode(struct awin_hdmi_softc *sc,
+ const struct videomode *mode)
{
uint32_t val;
const u_int dblscan_p = !!(mode->flags & VID_DBLSCAN);
@@ -601,8 +603,8 @@
#endif
val = HDMI_READ(sc, AWIN_HDMI_VID_CTRL_REG);
- val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_HDMI_MODE_HDMI,
- AWIN_HDMI_VID_CTRL_HDMI_MODE);
+ val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_HDMI_MODE_HDMI,
+ AWIN_HDMI_VID_CTRL_HDMI_MODE);
val &= ~AWIN_HDMI_VID_CTRL_OUTPUT_FMT;
if (dblscan_p) {
val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_REPEATER_SEL_2X,
@@ -648,13 +650,85 @@
val |= __SHIFTIN(AWIN_HDMI_VID_TIMING_4_TX_CLOCK_NORMAL,
AWIN_HDMI_VID_TIMING_4_TX_CLOCK);
HDMI_WRITE(sc, AWIN_HDMI_VID_TIMING_4_REG, val);
+
+ /* Packet control */
+ HDMI_WRITE(sc, AWIN_HDMI_PKT_CTRL0_REG, 0x00005321);
+ HDMI_WRITE(sc, AWIN_HDMI_PKT_CTRL1_REG, 0x0000000f);
}
static void
-awin_hdmi_set_audiomode(struct awin_hdmi_softc *sc, const struct videomode *mode)
+awin_hdmi_set_audiomode(struct awin_hdmi_softc *sc,
+ const struct videomode *mode)
{
- /* TODO */
- HDMI_WRITE(sc, AWIN_HDMI_AUD_CTRL_REG, 0);
+ uint32_t cts, n, val;
+
+ /*
+ * Before changing audio parameters, disable and reset the
+ * audio module. Wait for the soft reset bit to clear before
+ * configuring the audio parameters.
+ */
+ val = HDMI_READ(sc, AWIN_HDMI_AUD_CTRL_REG);
+ val &= ~AWIN_HDMI_AUD_CTRL_EN;
+ val |= AWIN_HDMI_AUD_CTRL_RST;
+ HDMI_WRITE(sc, AWIN_HDMI_AUD_CTRL_REG, val);
+ do {
+ val = HDMI_READ(sc, AWIN_HDMI_AUD_CTRL_REG);
+ } while (val & AWIN_HDMI_AUD_CTRL_RST);
+
+ /* DMA & FIFO control */
+ val = HDMI_READ(sc, AWIN_HDMI_ADMA_CTRL_REG);
+ if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+ val |= AWIN_HDMI_ADMA_CTRL_SRC_DMA_MODE; /* NDMA */
+ } else {
+ val &= ~AWIN_HDMI_ADMA_CTRL_SRC_DMA_MODE; /* DDMA */
+ }
+ val &= ~AWIN_HDMI_ADMA_CTRL_SRC_DMA_SAMPLE_RATE;
+ val &= ~AWIN_HDMI_ADMA_CTRL_SRC_SAMPLE_LAYOUT;
+ val &= ~AWIN_HDMI_ADMA_CTRL_SRC_WORD_LEN;
+ val &= ~AWIN_HDMI_ADMA_CTRL_DATA_SEL;
+ HDMI_WRITE(sc, AWIN_HDMI_ADMA_CTRL_REG, val);
+
+ /* Audio format control */
+ val = HDMI_READ(sc, AWIN_HDMI_AUD_FMT_REG);
+ val &= ~AWIN_HDMI_AUD_FMT_SRC_SEL;
+ val &= ~AWIN_HDMI_AUD_FMT_SEL;
+ val &= ~AWIN_HDMI_AUD_FMT_DSD_FMT;
+ val &= ~AWIN_HDMI_AUD_FMT_LAYOUT;
+ val &= ~AWIN_HDMI_AUD_FMT_SRC_CH_CFG;
+ val |= __SHIFTIN(1, AWIN_HDMI_AUD_FMT_SRC_CH_CFG);
+ HDMI_WRITE(sc, AWIN_HDMI_AUD_FMT_REG, val);
+
+ /* PCM control (channel map) */
+ HDMI_WRITE(sc, AWIN_HDMI_AUD_PCM_CTRL_REG, 0x76543210);
+
+ /* Clock setup */
+ n = 6144; /* 48 kHz */
+ cts = ((mode->dot_clock * 10) * (n / 128)) / 480;
+ HDMI_WRITE(sc, AWIN_HDMI_AUD_CTS_REG, cts);
+ HDMI_WRITE(sc, AWIN_HDMI_AUD_N_REG, n);
+
+ /* Audio PCM channel status 0 */
+ val = __SHIFTIN(AWIN_HDMI_AUD_CH_STATUS0_FS_FREQ_48,
+ AWIN_HDMI_AUD_CH_STATUS0_FS_FREQ);
+ HDMI_WRITE(sc, AWIN_HDMI_AUD_CH_STATUS0_REG, val);
+
+ /* Audio PCM channel status 1 */
+ val = HDMI_READ(sc, AWIN_HDMI_AUD_CH_STATUS1_REG);
+ val &= ~AWIN_HDMI_AUD_CH_STATUS1_CGMS_A;
+ val &= ~AWIN_HDMI_AUD_CH_STATUS1_ORIGINAL_FS;
+ val &= ~AWIN_HDMI_AUD_CH_STATUS1_WORD_LEN;
+ val |= __SHIFTIN(5, AWIN_HDMI_AUD_CH_STATUS1_WORD_LEN);
+ val |= AWIN_HDMI_AUD_CH_STATUS1_WORD_LEN_MAX;
+ HDMI_WRITE(sc, AWIN_HDMI_AUD_CH_STATUS1_REG, val);
+
+ /* Re-enable */
+ val = HDMI_READ(sc, AWIN_HDMI_AUD_CTRL_REG);
+ val |= AWIN_HDMI_AUD_CTRL_EN;
+ HDMI_WRITE(sc, AWIN_HDMI_AUD_CTRL_REG, val);
+
+#if defined(AWIN_HDMI_DEBUG) && defined(DDB)
+ awin_hdmi_dump_regs();
+#endif
}
static void
@@ -695,7 +769,7 @@
uint32_t intsts;
intsts = HDMI_READ(sc, AWIN_HDMI_INT_STATUS_REG);
- if (!intsts)
+ if (!(intsts & 0x73))
return 0;
HDMI_WRITE(sc, AWIN_HDMI_INT_STATUS_REG, intsts);
diff -r 562c8536595c -r 79a16f62730e sys/arch/arm/allwinner/awin_hdmiaudio.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/allwinner/awin_hdmiaudio.c Fri Nov 14 13:37:39 2014 +0000
@@ -0,0 +1,655 @@
+/* $NetBSD: awin_hdmiaudio.c,v 1.3.2.2 2014/11/14 13:37:39 martin Exp $ */
+
+/*-
+ * Copyright (c) 2014 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 AUTHOR ``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 AUTHOR 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: awin_hdmiaudio.c,v 1.3.2.2 2014/11/14 13:37:39 martin Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/intr.h>
+#include <sys/systm.h>
+#include <sys/kmem.h>
+
+#include <sys/audioio.h>
+#include <dev/audio_if.h>
+#include <dev/auconv.h>
+
+#include <arm/allwinner/awin_reg.h>
+#include <arm/allwinner/awin_var.h>
+
+struct awin_hdmiaudio_dma {
+ LIST_ENTRY(awin_hdmiaudio_dma) dma_list;
+ bus_dmamap_t dma_map;
+ void *dma_addr;
+ size_t dma_size;
+ bus_dma_segment_t dma_segs[1];
+ int dma_nsegs;
+};
+
+struct awin_hdmiaudio_softc {
+ device_t sc_dev;
+ device_t sc_audiodev;
+
Home |
Main Index |
Thread Index |
Old Index