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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Purpose: Definitions for the Creative Audigy LS driver
*/
/*
* This file is part of Open Sound System
*
* Copyright (C) 4Front Technologies 1996-2009.
*
* This software is released under CDDL 1.0 source license.
* See the COPYING file included in the main directory of this source
* distribution for the license terms and conditions.
*/
#ifndef AUDIGYLS_H
#define AUDIGYLS_H
#define AUDIGYLS_NAME "audiols"
#define AUDIGYLS_NUM_PORT 2
#define AUDIGYLS_PLAY_PORT 0
#define AUDIGYLS_REC_PORT 1
#define PCI_VENDOR_ID_CREATIVE 0x1102
#define PCI_DEVICE_ID_CREATIVE_AUDIGYLS 0x0007
/*
* PCI registers
*/
#define PR 0x00
#define DR 0x04
#define IPR 0x08
#define IER 0x0C
#define INTR_PCI (1 << 0)
#define INTR_TXA (1 << 1) /* midi-a tx */
#define INTR_RXA (1 << 2) /* midi-a rx */
#define INTR_IT2 (1 << 3) /* timer 2, 44.1 kHz */
#define INTR_IT1 (1 << 4) /* timer 1, 192 kHz */
#define INTR_SS_ (1 << 5) /* spdif status */
#define INTR_SRT (1 << 6) /* sample rate status */
#define INTR_GP (1 << 7)
#define INTR_AI (1 << 8) /* audio pending interrupt */
#define INTR_I2CDAC (1 << 9)
#define INTR_I2CEE (1 << 10)
#define INTR_SPI (1 << 11)
#define INTR_SPF (1 << 12)
#define INTR_SUO (1 << 13)
#define INTR_SUI (1 << 14)
#define INTR_TXB (1 << 16) /* midi-b tx */
#define INTR_RXB (1 << 17) /* midi-b rx */
#define HC 0x14
#define HC_PF (1 << 11) /* play fmt 1 = 32b, 0 = 16b */
#define HC_RF (1 << 10) /* rec fmt 1 = 32b, 0 = 16b */
#define HC_AC97 (1 << 3)
#define HC_AEN (1 << 0) /* audio enable */
#define GPIO 0x18
#define AC97D 0x1C
#define AC97A 0x1E
/*
* Indirect registers
*/
#define PTBA 0x000 /* gather play table base address */
#define PTBS 0x001 /* gather play table buffer size */
#define PTCA 0x002 /* gather play table current addr ptr */
#define PFBA 0x004 /* play fifo base address */
#define PFBS 0x005 /* play fifo buffer size */
#define CPFA 0x006 /* current play fifo address */
#define PFEA 0x007 /* play fifo end address */
#define CPCAV 0x008 /* current play fifo offset/cache sz valid */
#define RFBA 0x010 /* record fifo base address */
#define RFBS 0x011 /* record fifo buffer size */
#define CRFA 0x012 /* current record fifo address */
#define CRCAV 0x013 /* current record fifo offset/cache sz valid */
#define CDL 0x020 /* play fifo cache data, 0x20-0x2f */
#define SA 0x040 /* start audio */
#define SCS3 0x041
#define SCS0 0x042
#define SCS1 0x043
#define SCS2 0x044
#define SPC 0x045 /* spdif output control */
#define WMARK 0x046 /* test purposes only */
#define SPSC 0x049 /* spdif input control */
#define RCD 0x050 /* record cache data, 0x50-0x5f */
#define P17RECSEL 0x060 /* record fifo map address */
#define P17RECVOLL 0x061 /* record fifo volume control (lo) */
#define P17RECVOLH 0x062 /* record fifo volume control (hi) */
#define HMIXMAP_SPDIF 0x063 /* spdif router map address */
#define SMIXMAP_SPDIF 0x064 /* spdif router map address */
#define MIXCTL_SPDIF 0x065 /* spdif mixer control */
#define MIXVOL_SPDIF 0x066 /* spdif mixer input volume control */
#define HMIXMAP_I2S 0x067 /* i2s router map address */
#define SMIXMAP_I2S 0x068 /* i2s router map address */
#define MIXCTL_I2S 0x069 /* i2s mixer control */
#define MIXVOL_I2S 0x06a /* i2s mixer input volume control */
/* MIDI UART */
#define MUDATA 0x06c /* midi uart a data */
#define MUCMDA 0x06d /* midi uart a command/status */
#define MUDATB 0x06e /* midi uart b data */
#define MUCMDB 0x06f /* midi uart b command/status */
#define SRT 0x070 /* sample rate tracker status */
#define SRCTL 0x071 /* sample rate control */
#define AUDCTL 0x072 /* audio output control */
#define CHIP_ID 0x074 /* chip id */
#define AIE 0x075 /* audio interrupt enable */
#define AIP 0x076 /* audio interrupt */
#define WALL192 0x077 /* wall clock @ 192 kHz */
#define WALL441 0x078 /* wall clock @ 44.1 kHz */
#define IT 0x079 /* interval timer */
#define SPI 0x07a /* spi interface */
#define I2C_A 0x07b /* i2c address */
#define I2C_0 0x07c /* i2c data */
#define I2C_1 0x07d /* i2c data */
/*
* Audio interrupt bits
*/
#define AI_PFH 0x00000001 /* playback fifo half loop */
#define AI_PFF 0x00000010 /* playback fifo loop */
#define AI_TFH 0x00000100 /* playback table half loop */
#define AI_TFF 0x00001000 /* playback table loop */
#define AI_RFH 0x00010000 /* capture table half loop */
#define AI_RFF 0x00100000 /* capture fifo loop */
#define AI_EAI 0x01000000 /* enables audio end interrupt */
#define SA_48K 0
#define SA_44K 1
#define SA_96K 2
#define SA_192K 3
#define SA_MIX_OUT_EN(ch) (1 << ((ch) + 28))
#define SA_MIX_IN_EN(ch) (1 << ((ch) + 24))
#define SA_PLAY_RATE(ch, rate) ((rate) << (((ch) * 2) + 16))
#define SA_PLAY_START(ch) (1 << (ch))
#define SA_RECORD_START(ch) (1 << ((ch) + 8))
#define SA_SPA(ch) (1U << (ch))
#define SA_SRA(ch) (1U << ((ch) + 8))
#define RECSEL_SPDIFOUT 0
#define RECSEL_I2SOUT 1
#define RECSEL_SPDIFIN 2
#define RECSEL_I2SIN 3
#define RECSEL_AC97 4
#define RECSEL_SRC 5
typedef struct _audigyls_dev_t audigyls_dev_t;
typedef struct _audigyls_port_t audigyls_port_t;
typedef enum {
CTL_FRONT = 0,
CTL_SURROUND,
CTL_CENTER,
CTL_LFE,
CTL_RECORDVOL,
CTL_MONGAIN,
CTL_RECSRC,
CTL_SPREAD,
CTL_LOOP,
CTL_NUM /* must be last */
} audigyls_ctrl_num_t;
typedef struct audigyls_ctrl
{
audigyls_dev_t *dev;
audio_ctrl_t *ctrl;
audigyls_ctrl_num_t num;
uint64_t val;
} audigyls_ctrl_t;
struct _audigyls_port_t
{
audigyls_dev_t *dev;
audio_engine_t *engine;
int direction;
unsigned nchan;
ddi_dma_handle_t buf_dmah; /* dma for buffers */
ddi_acc_handle_t buf_acch;
uint32_t buf_paddr;
caddr_t buf_kaddr;
uint32_t buf_size;
uint32_t buf_frames; /* Buffer size in frames */
uint32_t offset;
int syncdir;
uint64_t count;
};
struct _audigyls_dev_t
{
dev_info_t *dip;
audio_dev_t *adev;
ac97_t *ac97;
int nactive; /* Num active ports */
char digital_enable; /* Orange combo-jack mode */
ddi_acc_handle_t pcih;
ddi_acc_handle_t regsh;
caddr_t base;
kmutex_t mutex; /* For normal locking */
kmutex_t low_mutex; /* For low level routines */
audigyls_port_t *port[AUDIGYLS_NUM_PORT];
audigyls_ctrl_t controls[CTL_NUM];
ac97_ctrl_t *ac97_recgain;
ac97_ctrl_t *ac97_recsrc;
uint64_t recmask;
};
#define INB(dev, reg) \
ddi_get8(dev->regsh, (void *)(dev->base + reg))
#define OUTB(dev, reg, val) \
ddi_put8(dev->regsh, (void *)(dev->base + reg), (val))
#define INW(dev, reg) \
ddi_get16(dev->regsh, (void *)(dev->base + reg))
#define OUTW(dev, reg, val) \
ddi_put16(dev->regsh, (void *)(dev->base + reg), (val))
#define INL(dev, reg) \
ddi_get32(dev->regsh, (void *)(dev->base + reg))
#define OUTL(dev, reg, val) \
ddi_put32(dev->regsh, (void *)(dev->base + reg), (val))
#endif /* AUDIGYLS_H */
|