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
131
132
133
134
135
136
137
|
/* $OpenBSD: esavar.h,v 1.2 2010/09/07 16:21:44 deraadt Exp $ */
/* $NetBSD: esavar.h,v 1.4 2002/03/16 14:34:01 jmcneill Exp $ */
/*
* Copyright (c) 2001, 2002 Jared D. McNeill <jmcneill@invisible.yi.org>
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* 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.
*/
/*
* ESS Allegro-1 / Maestro3 Audio Driver
*
* Based on the FreeBSD maestro3 driver
*
*/
/*
* Number of simultaneous voices
*
* NOTE: The current code attaches audio0 thru audioESA_NUM_VOICES-1
* to this driver, and a lot of people probably don't want that.
* So, we'll default to 1 but we'll allow for the possibility of
* more.
*
* The current MINISRC image limits us to a maximum of 4 simultaneous voices.
*/
#ifndef ESA_NUM_VOICES
#define ESA_NUM_VOICES 1
#endif
#define KERNADDR(p) ((void *)((p)->addr))
#define DMAADDR(p) ((p)->map->dm_segs[0].ds_addr)
#define ESA_MINRATE 8000
#define ESA_MAXRATE 48000
struct esa_list {
int currlen;
int mem_addr;
int max;
int indexmap[ESA_NUM_VOICES * 2];
};
struct esa_dma {
bus_dmamap_t map;
caddr_t addr;
bus_dma_segment_t segs[1];
int nsegs;
size_t size;
struct esa_dma *next;
};
struct esa_channel {
int active;
int data_offset;
int index;
size_t bufsize;
int blksize;
int pos;
void *buf;
u_int32_t start;
u_int32_t count;
/* mode settings */
struct audio_params mode;
void (*intr)(void *);
void *arg;
};
struct esa_voice {
struct device *parent; /* pointer to our parent */
struct esa_channel play;
struct esa_channel rec;
struct esa_dma *dma;
int inlist;
int index; /* 0: play, 1: record */
};
struct esa_softc
{
struct device sc_dev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
bus_addr_t sc_iob;
bus_size_t sc_ios;
pcitag_t sc_tag;
pci_chipset_tag_t sc_pct;
bus_dma_tag_t sc_dmat;
pcireg_t sc_pcireg;
void *sc_ih;
struct ac97_codec_if *codec_if;
struct ac97_host_if host_if;
enum ac97_host_flags codec_flags;
struct device *sc_audiodev[ESA_NUM_VOICES];
struct esa_voice voice[ESA_NUM_VOICES];
struct esa_dma *sc_dmas;
int count;
/* timer management */
int sc_ntimers;
/* packed list structures */
struct esa_list mixer_list;
struct esa_list adc1_list;
struct esa_list dma_list;
struct esa_list msrc_list;
int type; /* Allegro-1 or Maestro 3? */
int delay1, delay2;
u_int16_t *savemem;
};
|