summaryrefslogtreecommitdiff
path: root/chips/audio_config.h
blob: bd2c0a07eec1f5e7e999e163c9a708976bcb96cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/* 
 * Mach Operating System
 * Copyright (c) 1992 Carnegie Mellon University
 * All Rights Reserved.
 * 
 * Permission to use, copy, modify and distribute this software and its
 * documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 * 
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 * 
 * Carnegie Mellon requests users of this software to return to
 * 
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 * 
 * any improvements or extensions that they make and grant Carnegie Mellon
 * the rights to redistribute these changes.
 */
/*
 *  Here platform specific code to define sample_t & co
 *  [to cope with weird DMA engines], and other customs
 */
#ifdef	FLAMINGO
#define splaudio	splbio
#define	sample_t	unsigned char	/* later */
#define	samples_to_chars	bcopy
#define	chars_to_samples	bcopy
/* Sparse space ! */
typedef struct {
	volatile unsigned long	cr;	/* command register (wo) */
/*#define ir cr				/* interrupt register (ro) */
	volatile unsigned long	dr;	/* data register (rw) */
	volatile unsigned long	dsr1;	/* D-channel status register 1 (ro) */
	volatile unsigned long	der;	/* D-channel error register (ro) */
	volatile unsigned long	dctb;	/* D-channel transmit register (wo) */
/*#define dcrb dctb			/* D-channel receive register (ro) */
	volatile unsigned long	bbtb;	/* Bb-channel transmit register (wo) */
/*#define bbrb bbtb			/* Bb-channel receive register (ro) */
	volatile unsigned long	bctb;	/* Bc-channel transmit register (wo)*/
/*#define bcrb bctb			/* Bc-channel receive register (ro) */
	volatile unsigned long	dsr2;	/* D-channel status register 2 (ro) */
} amd79c30_padded_regs_t;

/* give the chip 400ns in between accesses */
#define	read_reg(r,v)				\
	{ (v) = ((r) >> 8) & 0xff; delay(1); }

#define write_reg(r,v)				\
	{ (r) = (((v) & 0xff) << 8) |		\
		 0x200000000L; /*bytemask*/	\
		delay(1); wbflush();		\
	}

/* Write 16 bits of data from variable v to the data port of the audio chip */
#define	WAMD16(regs, v)				\
	{ write_reg((regs)->dr,v);		\
	  write_reg((regs)->dr,v>>8); }

#define mb() wbflush()

#endif	/* FLAMINGO */


#ifdef	MAXINE
#define splaudio	splhigh
typedef struct {
	volatile unsigned char	cr;	/* command register (wo) */
/*#define ir cr				/* interrupt register (ro) */
	char				pad0[63];
	volatile unsigned char	dr;	/* data register (rw) */
	char				pad1[63];
	volatile unsigned char	dsr1;	/* D-channel status register 1 (ro) */
	char				pad2[63];
	volatile unsigned char	der;	/* D-channel error register (ro) */
	char				pad3[63];
	volatile unsigned char	dctb;	/* D-channel transmit register (wo) */
/*#define dcrb dctb			/* D-channel receive register (ro) */
	char				pad4[63];
	volatile unsigned char	bbtb;	/* Bb-channel transmit register (wo) */
/*#define bbrb bbtb			/* Bb-channel receive register (ro) */
	char				pad5[63];
	volatile unsigned char	bctb;	/* Bc-channel transmit register (wo)*/
/*#define bcrb bctb			/* Bc-channel receive register (ro) */
	char				pad6[63];
	volatile unsigned char	dsr2;	/* D-channel status register 2 (ro) */
	char				pad7[63];
} amd79c30_padded_regs_t;

/* give the chip 400ns in between accesses */
#define	read_reg(r,v)				\
	{ (v) = (r); delay(1); }

#define write_reg(r,v)				\
	{ (r) = (v); delay(1); wbflush(); }

/* Write 16 bits of data from variable v to the data port of the audio chip */
#define	WAMD16(regs, v)				\
	{ write_reg((regs)->dr,v);		\
	  write_reg((regs)->dr,v>>8); }

#define mb()

#endif	/* MAXINE */


#ifndef	sample_t
#define	sample_t	unsigned char
#define	samples_to_chars	bcopy
#define	chars_to_samples	bcopy
#endif

/*
 * More architecture-specific customizations
 */
#ifdef	alpha
#define sample_rpt_int(x)	(((x)<<24)|((x)<<16)|((x)<<8)|((x)<<0))
#define sample_rpt_long(x)	((sample_rpt_int(x)<<32)|sample_rpt_int(x))
#endif

#ifndef	sample_rpt_long
#define sample_rpt_long(x)	(((x)<<24)|((x)<<16)|((x)<<8)|((x)<<0))
#endif