add driver for harmony audio. from openbsd, adapted for netbsd by me.

This commit is contained in:
chs 2004-09-19 23:03:34 +00:00
parent b42337cb2a
commit b242249052
6 changed files with 1592 additions and 8 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.31 2004/09/04 23:29:47 manu Exp $
# $NetBSD: GENERIC,v 1.32 2004/09/19 23:03:34 chs Exp $
#
# GENERIC machine description file
#
@ -23,7 +23,7 @@ include "arch/hp700/conf/std.hp700"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
options SYSCTL_INCLUDE_DESCR # Include sysctl descriptions in kernel
#ident "GENERIC-$Revision: 1.31 $"
#ident "GENERIC-$Revision: 1.32 $"
maxusers 32 # estimated number of users
@ -505,9 +505,9 @@ urlphy* at mii? phy ? # Realtek RTL8150L internal PHYs
# GSC audio devices
#aone* at gsc? # Audio Type 1 (PSB 2160-N)
#harmony* at gsc? # Audio Type 2 (CS4215)
harmony* at gsc? # Audio Type 2 (CS4215)
#com* at harmony? # Telephone add-in card
#audio* at audiobus?
audio* at audiobus?
# Pseudo-Devices

View File

@ -1,4 +1,4 @@
# $NetBSD: majors.hp700,v 1.13 2003/12/10 02:04:01 jmc Exp $
# $NetBSD: majors.hp700,v 1.14 2004/09/19 23:03:34 chs Exp $
#
# Device majors for hp700
#
@ -41,8 +41,9 @@ device-major systrace char 34 systrace
device-major cgd char 35 block 8 cgd
device-major ksyms char 36 ksyms
device-major wsfont char 37 wsfont
device-major clockctl char 39 clockctl
device-major scsibus char 38 scsibus
device-major clockctl char 39 clockctl
device-major audio char 40 audio
# Majors up to 143 are reserved for machine-dependant drivers.
# New machine-independant driver majors are assigned in

View File

@ -1,4 +1,4 @@
/* $NetBSD: asp.c,v 1.7 2003/11/23 17:09:29 chs Exp $ */
/* $NetBSD: asp.c,v 1.8 2004/09/19 23:03:34 chs Exp $ */
/* $OpenBSD: asp.c,v 1.5 2000/02/09 05:04:22 mickey Exp $ */
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: asp.c,v 1.7 2003/11/23 17:09:29 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: asp.c,v 1.8 2004/09/19 23:03:34 chs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -163,6 +163,7 @@ asp_fix_args(void *_sc, struct gsc_attach_args *ga)
ASP_IRQ(0x25000, 9); /* osiop */
ASP_IRQ(0x26000, 8); /* ie */
ASP_IRQ(0x30000, 3); /* siop */
ASP_IRQ(0x800000, 13); /* harmony */
#undef ASP_IRQ
}

1308
sys/arch/hp700/gsc/harmony.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,154 @@
/* $NetBSD: harmonyreg.h,v 1.1 2004/09/19 23:03:34 chs Exp $ */
/* $OpenBSD: harmonyreg.h,v 1.5 2003/06/02 19:54:29 jason Exp $ */
/*
* Copyright (c) 2003 Jason L. Wright (jason@thought.net)
* 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.
*/
/*
* Harmony CS4215/AD1849 register definitions based on:
* "712 I/O Subsystem ERS", Revision 1.1, 12 February 1993
*/
/* harmony always uses a 4K buffer */
#define HARMONY_BUFSIZE 4096
#define HARMONY_NREGS 0x40
#define HARMONY_ID 0x00 /* identification */
#define HARMONY_RESET 0x04 /* reset */
#define HARMONY_CNTL 0x08 /* control */
#define HARMONY_GAINCTL 0x0c /* gain control */
#define HARMONY_PNXTADD 0x10 /* play next address */
#define HARMONY_PCURADD 0x14 /* play current address */
#define HARMONY_RNXTADD 0x18 /* record next address */
#define HARMONY_RCURADD 0x1c /* record current address */
#define HARMONY_DSTATUS 0x20 /* device status */
#define HARMONY_OV 0x24 /* overrange input */
#define HARMONY_PIO 0x28 /* general purpose i/o */
#define HARMONY_DIAG 0x3c /* chi diagnostic */
/* HARMONY_ID */
#define ID_REV_MASK 0x00ff0000 /* revision mask: */
#define ID_REV_SHIFT 16
#define ID_REV_TS 0x00150000 /* teleshare installed */
#define ID_REV_NOTS 0x00140000 /* teleshare not installed */
#define ID_CHIID 0x0000f000 /* CHI identification */
#define ID_CHIID_SHIFT 12
/* HARMONY_RESET */
#define RESET_RST 0x00000001 /* reset codec */
/* HARMONY_CNTL */
#define CNTL_C 0x80000000 /* control mode */
#define CNTL_CODEC_REV_MASK 0x0ff00000 /* codec revision */
#define CNTL_CODEC_REV_SHIFT 20
#define CNTL_EXP_3 0x00020000 /* expansion bit 3 */
#define CNTL_EXP_2 0x00010000 /* expansion bit 2 */
#define CNTL_EXP_1 0x00008000 /* expansion bit 1 */
#define CNTL_EXP_0 0x00004000 /* expansion bit 0 */
#define CNTL_AC 0x00002000 /* autocalibration ad1849 */
#define CNTL_AD 0x00001000 /* ad1849 compat? */
#define CNTL_OLB 0x00000800 /* output level */
#define CNTL_ITS 0x00000400 /* codec immediate tristate */
#define CNTL_LS_MASK 0x00000300 /* loopback select: */
#define CNTL_LS_NONE 0x00000000 /* none */
#define CNTL_LS_INTERNAL 0x00000100 /* internal */
#define CNTL_LS_DIGITAL 0x00000200 /* digital */
#define CNTL_LS_ANALOG 0x00000300 /* analog */
#define CNTL_FORMAT_MASK 0x000000c0 /* encoding format: */
#define CNTL_FORMAT_SLINEAR16BE 0x00000000 /* 16 bit signed linear be */
#define CNTL_FORMAT_ULAW 0x00000040 /* 8 bit ulaw */
#define CNTL_FORMAT_ALAW 0x00000080 /* 8 bit alaw */
#define CNTL_FORMAT_ULINEAR8 0x000000c0 /* 8 bit unsigned linear */
#define CNTL_CHANS_MASK 0x00000020 /* number of channels: */
#define CNTL_CHANS_MONO 0x00000000 /* mono */
#define CNTL_CHANS_STEREO 0x00000020 /* stereo */
#define CNTL_RATE_MASK 0x0000001f /* sample rate (kHz): */
#define CNTL_RATE_5125 0x00000010 /* 5.5125 */
#define CNTL_RATE_6615 0x00000017 /* 6.615 */
#define CNTL_RATE_8000 0x00000008 /* 8 */
#define CNTL_RATE_9600 0x0000000f /* 9.6 */
#define CNTL_RATE_11025 0x00000011 /* 11.025 */
#define CNTL_RATE_16000 0x00000009 /* 16 */
#define CNTL_RATE_18900 0x00000012 /* 18.9 */
#define CNTL_RATE_22050 0x00000013 /* 22.05 */
#define CNTL_RATE_27428 0x0000000a /* 27.42857 */
#define CNTL_RATE_32000 0x0000000b /* 32 */
#define CNTL_RATE_33075 0x00000016 /* 33.075 */
#define CNTL_RATE_37800 0x00000014 /* 37.8 */
#define CNTL_RATE_44100 0x00000015 /* 44.1 */
#define CNTL_RATE_48000 0x0000000e /* 48 */
/* HARMONY_GAINCTL */
#define GAINCTL_HE 0x08000000 /* headphones enable */
#define GAINCTL_LE 0x04000000 /* line output enable */
#define GAINCTL_SE 0x02000000 /* speaker enable */
#define GAINCTL_IS_MASK 0x01000000 /* input select: */
#define GAINCTL_IS_LINE 0x00000000 /* line input */
#define GAINCTL_IS_MICROPHONE 0x01000000 /* microphone */
#define GAINCTL_INPUT_LEFT_M 0x0000f000 /* left input gain */
#define GAINCTL_INPUT_LEFT_S 12
#define GAINCTL_INPUT_RIGHT_M 0x000f0000 /* left input gain */
#define GAINCTL_INPUT_RIGHT_S 16
#define GAINCTL_INPUT_BITS 4
#define GAINCTL_MONITOR_M 0x00f00000 /* monitor gain (inverted) */
#define GAINCTL_MONITOR_S 20
#define GAINCTL_MONITOR_BITS 4
#define GAINCTL_OUTPUT_LEFT_M 0x00000fc0 /* left out gain (inverted) */
#define GAINCTL_OUTPUT_LEFT_S 6
#define GAINCTL_OUTPUT_RIGHT_M 0x0000003f /* right out gain (inverted) */
#define GAINCTL_OUTPUT_RIGHT_S 0
#define GAINCTL_OUTPUT_BITS 6
/* HARMONY_PCURADD */
#define PCURADD_BUFMASK (~(HARMONY_BUFSIZE - 1))
/* HARMONY_RCURADD */
#define PCURADD_BUFMASK (~(HARMONY_BUFSIZE - 1))
/* HARMONY_DSTATUS */
#define DSTATUS_IE 0x80000000 /* interrupt enable */
#define DSTATUS_PN 0x00000200 /* playback next empty */
#define DSTATUS_PC 0x00000100 /* playback dma active */
#define DSTATUS_RN 0x00000002 /* record next empty */
#define DSTATUS_RC 0x00000001 /* record dma active */
/* HARMONY_OV */
#define OV_OV 0x00000001 /* input over range */
/* HARMONY_PIO */
#define PIO_PO 0x00000002 /* parallel output */
#define PIO_PI 0x00000001 /* parallel input */
/* HARMONY_DIAG */
#define DIAG_CO 0x00000001 /* sclk from codec */
/* CS4215_REV */
#define CS4215_REV_VER 0x0f
#define CS4215_REV_VER_C 0x00 /* CS4215 rev C */
#define CS4215_REV_VER_D 0x01 /* CS4215 rev D */
#define CS4215_REV_VER_E 0x02 /* CS4215 rev E/AD1849K */

View File

@ -0,0 +1,120 @@
/* $NetBSD: harmonyvar.h,v 1.1 2004/09/19 23:03:34 chs Exp $ */
/* $OpenBSD: harmonyvar.h,v 1.8 2003/08/15 13:25:53 mickey Exp $ */
/*
* Copyright (c) 2003 Jason L. Wright (jason@thought.net)
* 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.
*/
#define HARMONY_PORT_INPUT_LVL 0
#define HARMONY_PORT_INPUT_OV 1
#define HARMONY_PORT_OUTPUT_LVL 2
#define HARMONY_PORT_OUTPUT_GAIN 3
#define HARMONY_PORT_MONITOR_LVL 4
#define HARMONY_PORT_RECORD_SOURCE 5
#define HARMONY_PORT_OUTPUT_SOURCE 6
#define HARMONY_PORT_INPUT_CLASS 7
#define HARMONY_PORT_OUTPUT_CLASS 8
#define HARMONY_PORT_MONITOR_CLASS 9
#define HARMONY_PORT_RECORD_CLASS 10
#define HARMONY_IN_MIC 0
#define HARMONY_IN_LINE 1
#define HARMONY_OUT_LINE 0
#define HARMONY_OUT_SPEAKER 1
#define HARMONY_OUT_HEADPHONE 2
#define PLAYBACK_EMPTYS 3 /* playback empty buffers */
#define CAPTURE_EMPTYS 3 /* capture empty buffers */
struct harmony_volume {
u_char left, right;
};
struct harmony_empty {
uint8_t playback[PLAYBACK_EMPTYS][HARMONY_BUFSIZE];
uint8_t capture[CAPTURE_EMPTYS][HARMONY_BUFSIZE];
};
struct harmony_dma {
struct harmony_dma *d_next;
bus_dmamap_t d_map;
bus_dma_segment_t d_seg;
caddr_t d_kva;
size_t d_size;
};
struct harmony_channel {
struct harmony_dma *c_current;
bus_size_t c_segsz;
bus_size_t c_cnt;
bus_size_t c_blksz;
bus_addr_t c_lastaddr;
void (*c_intr)(void *);
void *c_intrarg;
bus_addr_t c_theaddr;
};
struct harmony_softc {
struct device sc_dv;
struct audio_device sc_audev;
bus_dma_tag_t sc_dmat;
bus_space_tag_t sc_bt;
bus_space_handle_t sc_bh;
int sc_open;
uint32_t sc_cntlbits;
int sc_need_commit;
int sc_playback_empty;
bus_addr_t sc_playback_paddrs[PLAYBACK_EMPTYS];
int sc_capture_empty;
bus_addr_t sc_capture_paddrs[CAPTURE_EMPTYS];
bus_dmamap_t sc_empty_map;
bus_dma_segment_t sc_empty_seg;
int sc_empty_rseg;
struct harmony_empty *sc_empty_kva;
struct harmony_dma *sc_dmas;
int sc_playing, sc_capturing;
struct harmony_channel sc_playback, sc_capture;
struct harmony_volume sc_monitor_lvl, sc_input_lvl, sc_output_lvl;
int sc_in_port, sc_out_port, sc_hasulinear8;
int sc_micpreamp, sc_ov, sc_outputgain;
int sc_teleshare;
#if NRND > 0
rndsource_element_t sc_rnd_source;
struct callout sc_acc_tmo;
uint32_t sc_acc, sc_acc_num, sc_acc_cnt;
#endif
};
#define READ_REG(sc, reg) \
bus_space_read_4((sc)->sc_bt, (sc)->sc_bh, (reg))
#define WRITE_REG(sc, reg, val) \
bus_space_write_4((sc)->sc_bt, (sc)->sc_bh, (reg), (val))
#define SYNC_REG(sc, reg, flags) \
bus_space_barrier((sc)->sc_bt, (sc)->sc_bh, (reg), sizeof(uint32_t), \
(flags))