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