auixpvar.h revision 1.8.42.1 1 /* $NetBSD: auixpvar.h,v 1.8.42.1 2019/04/21 05:11:22 isaki Exp $*/
2
3 /*
4 * Copyright (c) 2004, 2005 Reinoud Zandijk <reinoud (at) netbsd.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by the NetBSD
17 * Foundation, Inc. and its contributors.
18 * 4. Neither the name of The NetBSD Foundation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35
36 /*
37 * NetBSD audio driver for ATI IXP-{150,200,...} audio driver hardware.
38 */
39
40 #define DMA_DESC_CHAIN 255
41
42
43 /* audio format structure describing our hardware capabilities */
44 /* XXX min and max sample rates are for AD1888 codec XXX */
45 #define AUIXP_NFORMATS 6
46
47
48 #define AUIXP_MINRATE 7000
49 #define AUIXP_MAXRATE 48000
50
51
52 /* current AC'97 driver only supports SPDIF outputting channel 3&4 i.e. STEREO */
53 #define AUIXP_FORMAT(aumode, prec, ch, chmask) \
54 { \
55 .mode = (aumode), \
56 .encoding = AUDIO_ENCODING_SLINEAR_LE, \
57 .validbits = (prec), \
58 .precision = (prec), \
59 .channels = (ch), \
60 .channel_mask = (chmask), \
61 .frequency_type = 0, \
62 .frequency = { 7000, 48000 }, \
63 }
64 static const struct audio_format auixp_formats[AUIXP_NFORMATS] = {
65 AUIXP_FORMAT(AUMODE_PLAY | AUMODE_RECORD, 16, 2, AUFMT_STEREO),
66 AUIXP_FORMAT(AUMODE_PLAY | AUMODE_RECORD, 32, 2, AUFMT_STEREO),
67 AUIXP_FORMAT(AUMODE_PLAY , 16, 4, AUFMT_SURROUND4),
68 AUIXP_FORMAT(AUMODE_PLAY , 32, 4, AUFMT_SURROUND4),
69 AUIXP_FORMAT(AUMODE_PLAY , 16, 6, AUFMT_DOLBY_5_1),
70 AUIXP_FORMAT(AUMODE_PLAY , 32, 6, AUFMT_DOLBY_5_1),
71 };
72
73
74 /* auixp structures; used to record alloced DMA space */
75 struct auixp_dma {
76 /* bus mappings */
77 bus_dmamap_t map;
78 void * addr;
79 bus_dma_segment_t segs[1];
80 int nsegs;
81 size_t size;
82
83 /* audio feeder */
84 void (*intr)(void *); /* function to call when there is space */
85 void *intrarg;
86
87 /* status and setup bits */
88 int running;
89 uint32_t linkptr;
90 uint32_t dma_enable_bit;
91
92 /* linked list of all mapped area's */
93 SLIST_ENTRY(auixp_dma) dma_chain;
94 };
95
96
97 struct auixp_codec {
98 struct auixp_softc *sc;
99
100 int present;
101 int codec_nr;
102
103 struct ac97_codec_if *codec_if;
104 struct ac97_host_if host_if;
105 enum ac97_host_flags codec_flags;
106 };
107
108
109 struct auixp_softc {
110 device_t sc_dev;
111 kmutex_t sc_lock;
112 kmutex_t sc_intr_lock;
113
114 /* card id */
115 int type;
116 int delay1, delay2; /* nessisary? */
117
118 /* card properties */
119 int has_4ch, has_6ch, is_fixed, has_spdif;
120
121 /* bus tags */
122 bus_space_tag_t sc_iot;
123 bus_space_handle_t sc_ioh;
124 bus_addr_t sc_iob;
125 bus_size_t sc_ios;
126
127 pcitag_t sc_tag;
128 pci_chipset_tag_t sc_pct;
129
130 bus_dma_tag_t sc_dmat;
131
132 /* interrupts */
133 void *sc_ih;
134
135 /* DMA business */
136 struct auixp_dma *sc_output_dma; /* contains dma-safe chain */
137 struct auixp_dma *sc_input_dma;
138
139 /* list of allocated DMA pieces */
140 SLIST_HEAD(auixp_dma_list, auixp_dma) sc_dma_list;
141
142 /* audio formats supported */
143 struct audio_format sc_formats[AUIXP_NFORMATS];
144 struct audio_encoding_set *sc_encodings;
145
146 /* codecs */
147 int sc_num_codecs;
148 struct auixp_codec sc_codec[ATI_IXP_CODECS];
149 int sc_codec_not_ready_bits;
150
151 /* last set audio parameters */
152 struct audio_params sc_play_params;
153 struct audio_params sc_rec_params;
154 };
155
156
157