FreeBSD/Linux Kernel Cross Reference
sys/dev/ic/ad1848var.h
1 /* $NetBSD: ad1848var.h,v 1.12 2005/01/15 15:19:52 kent Exp $ */
2
3 /*-
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Ken Hornstein and John Kohl.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38 /*
39 * Copyright (c) 1994 John Brezak
40 * Copyright (c) 1991-1993 Regents of the University of California.
41 * All rights reserved.
42 *
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
45 * are met:
46 * 1. Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution.
51 * 3. All advertising materials mentioning features or use of this software
52 * must display the following acknowledgement:
53 * This product includes software developed by the Computer Systems
54 * Engineering Group at Lawrence Berkeley Laboratory.
55 * 4. Neither the name of the University nor of the Laboratory may be used
56 * to endorse or promote products derived from this software without
57 * specific prior written permission.
58 *
59 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * SUCH DAMAGE.
70 *
71 */
72
73
74 #define MUTE_LEFT 1
75 #define MUTE_RIGHT 2
76 #define MUTE_ALL (MUTE_LEFT | MUTE_RIGHT)
77 #define MUTE_MONO MUTE_ALL
78
79 #define WAVE_MUTE0 1 /* force mute (overrides UNMUTE1) */
80 #define WAVE_UNMUTE1 2 /* unmute (overrides MUTE2) */
81 #define WAVE_MUTE2 4 /* weak mute */
82 #define WAVE_MUTE2_INIT 0 /* init and MUTE2 */
83
84 /*
85 * Don't change this ordering without seriously looking around.
86 * These are indexes into mute[] array and into a register
87 * information array.
88 */
89 #define AD1848_AUX2_CHANNEL 0
90 #define AD1848_AUX1_CHANNEL 1
91 #define AD1848_DAC_CHANNEL 2
92 #define AD1848_LINE_CHANNEL 3
93 #define AD1848_MONO_CHANNEL 4
94 #define AD1848_OUT_CHANNEL 5
95 #define AD1848_MONITOR_CHANNEL 6 /* Doesn't seem to be on all later chips */
96
97 #define AD1848_NUM_CHANNELS 7
98
99 struct ad1848_volume {
100 u_char left;
101 u_char right;
102 };
103
104 struct ad1848_softc {
105 struct device sc_dev; /* base device */
106 bus_space_tag_t sc_iot; /* tag */
107 bus_space_handle_t sc_ioh; /* handle */
108
109 int (*sc_readreg)(struct ad1848_softc *, int);
110 void (*sc_writereg)(struct ad1848_softc *, int, int);
111 #define ADREAD(sc, index) (*(sc)->sc_readreg)(sc, index)
112 #define ADWRITE(sc, index, data) (*(sc)->sc_writereg)(sc, index, data)
113
114 void *parent;
115
116 /* We keep track of these */
117 struct ad1848_volume gains[AD1848_NUM_CHANNELS];
118 struct ad1848_volume rec_gain;
119
120 int rec_port; /* recording port */
121
122 /* ad1848 */
123 u_char MCE_bit;
124 char mic_gain_on; /* CS4231 only */
125 char mute[AD1848_NUM_CHANNELS];
126
127 char *chip_name;
128 int mode;
129 int is_ad1845;
130
131 u_int precision; /* 8/16 bits */
132 int channels;
133
134 u_char speed_bits;
135 u_char format_bits;
136 u_char need_commit;
137
138 u_char wave_mute_status;
139 int open_mode;
140 };
141
142 /*
143 * Ad1848 registers.
144 */
145 #define MIC_IN_PORT 0
146 #define LINE_IN_PORT 1
147 #define AUX1_IN_PORT 2
148 #define DAC_IN_PORT 3
149
150 #define AD1848_KIND_LVL 0
151 #define AD1848_KIND_MUTE 1
152 #define AD1848_KIND_RECORDGAIN 2
153 #define AD1848_KIND_MICGAIN 3
154 #define AD1848_KIND_RECORDSOURCE 4
155
156 typedef struct ad1848_devmap {
157 int id;
158 int kind;
159 int dev;
160 } ad1848_devmap_t;
161
162 #ifdef _KERNEL
163
164 int ad_read(struct ad1848_softc *, int);
165 int ad_xread(struct ad1848_softc *, int);
166 void ad_write(struct ad1848_softc *, int, int);
167 void ad_xwrite(struct ad1848_softc *, int, int);
168
169 void ad1848_attach(struct ad1848_softc *);
170 void ad1848_reset(struct ad1848_softc *);
171 int ad1848_open(void *, int);
172 void ad1848_close(void *);
173
174 int ad1848_mixer_get_port(struct ad1848_softc *, ad1848_devmap_t *,
175 int, mixer_ctrl_t *);
176 int ad1848_mixer_set_port(struct ad1848_softc *, ad1848_devmap_t *,
177 int, mixer_ctrl_t *);
178 int ad1848_set_speed(struct ad1848_softc *, u_int *);
179 void ad1848_mute_wave_output(struct ad1848_softc *, int, int);
180 int ad1848_query_encoding(void *, struct audio_encoding *);
181 int ad1848_set_params(void *, int, int, audio_params_t *,
182 audio_params_t *, stream_filter_list_t *,
183 stream_filter_list_t *);
184 int ad1848_round_blocksize(void *, int, int, const audio_params_t *);
185 int ad1848_commit_settings(void *);
186 int ad1848_set_rec_port(struct ad1848_softc *, int);
187 int ad1848_get_rec_port(struct ad1848_softc *);
188 int ad1848_set_channel_gain(struct ad1848_softc *, int,
189 struct ad1848_volume *);
190 int ad1848_get_device_gain(struct ad1848_softc *, int,
191 struct ad1848_volume *);
192 int ad1848_set_rec_gain(struct ad1848_softc *, struct ad1848_volume *);
193 int ad1848_get_rec_gain(struct ad1848_softc *, struct ad1848_volume *);
194 /* Note: The mic pre-MUX gain is not a variable gain, it's 20dB or 0dB */
195 int ad1848_set_mic_gain(struct ad1848_softc *, struct ad1848_volume *);
196 int ad1848_get_mic_gain(struct ad1848_softc *, struct ad1848_volume *);
197 void ad1848_mute_channel(struct ad1848_softc *, int, int);
198 int ad1848_to_vol(mixer_ctrl_t *, struct ad1848_volume *);
199 int ad1848_from_vol(mixer_ctrl_t *, struct ad1848_volume *);
200
201 int ad1848_halt_output(void *);
202 int ad1848_halt_input(void *);
203 paddr_t ad1848_mappage(void *, void *, off_t, int);
204
205 #ifdef AUDIO_DEBUG
206 void ad1848_dump_regs(struct ad1848_softc *);
207 #endif
208
209 #endif
Cache object: 9d1f062d9bd8c4a0c14de9f3605d49ff
|