1 /* $NetBSD: auixpvar.h,v 1.8 2012/10/27 17:18:28 chs Exp $*/
2 
3 /*
4  * Copyright (c) 2004, 2005 Reinoud Zandijk <reinoud@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 static const struct audio_format auixp_formats[AUIXP_NFORMATS] = {
54 	{NULL, AUMODE_PLAY | AUMODE_RECORD, AUDIO_ENCODING_SLINEAR_LE, 16, 16, 2, AUFMT_STEREO, 0, {7000, 48000}},
55 	{NULL, AUMODE_PLAY | AUMODE_RECORD, AUDIO_ENCODING_SLINEAR_LE, 32, 32, 2, AUFMT_STEREO, 0, {7000, 48000}},
56 	{NULL, AUMODE_PLAY, AUDIO_ENCODING_SLINEAR_LE, 16, 16, 4, AUFMT_SURROUND4, 0, {7000, 48000}},
57 	{NULL, AUMODE_PLAY, AUDIO_ENCODING_SLINEAR_LE, 32, 32, 4, AUFMT_SURROUND4, 0, {7000, 48000}},
58 	{NULL, AUMODE_PLAY, AUDIO_ENCODING_SLINEAR_LE, 16, 16, 6, AUFMT_DOLBY_5_1, 0, {7000, 48000}},
59 	{NULL, AUMODE_PLAY, AUDIO_ENCODING_SLINEAR_LE, 32, 32, 6, AUFMT_DOLBY_5_1, 0, {7000, 48000}},
60 };
61 
62 
63 /* auixp structures; used to record alloced DMA space */
64 struct auixp_dma {
65 	/* bus mappings */
66 	bus_dmamap_t		 map;
67 	void *			 addr;
68 	bus_dma_segment_t	 segs[1];
69 	int			 nsegs;
70 	size_t			 size;
71 
72 	/* audio feeder */
73 	void			 (*intr)(void *);	/* function to call when there is space */
74 	void			*intrarg;
75 
76 	/* status and setup bits */
77 	int			 running;
78 	uint32_t		 linkptr;
79 	uint32_t		 dma_enable_bit;
80 
81 	/* linked list of all mapped area's */
82 	SLIST_ENTRY(auixp_dma)	 dma_chain;
83 };
84 
85 
86 struct auixp_codec {
87 	struct auixp_softc	*sc;
88 
89 	int			 present;
90 	int			 codec_nr;
91 
92 	struct ac97_codec_if	*codec_if;
93 	struct ac97_host_if	 host_if;
94 	enum ac97_host_flags	 codec_flags;
95 };
96 
97 
98 struct auixp_softc {
99 	device_t		sc_dev;
100 	kmutex_t		sc_lock;
101 	kmutex_t		sc_intr_lock;
102 
103 	/* card id */
104 	int			type;
105 	int			delay1, delay2;		/* nessisary? */
106 
107 	/* card properties */
108 	int			has_4ch, has_6ch, is_fixed, has_spdif;
109 
110 	/* bus tags */
111 	bus_space_tag_t		sc_iot;
112 	bus_space_handle_t	sc_ioh;
113 	bus_addr_t		sc_iob;
114 	bus_size_t		sc_ios;
115 
116 	pcitag_t		sc_tag;
117 	pci_chipset_tag_t	sc_pct;
118 
119 	bus_dma_tag_t		sc_dmat;
120 
121 	/* interrupts */
122 	void			*sc_ih;
123 
124 	/* DMA business */
125 	struct auixp_dma	*sc_output_dma;		/* contains dma-safe chain */
126 	struct auixp_dma	*sc_input_dma;
127 
128 	/* list of allocated DMA pieces */
129 	SLIST_HEAD(auixp_dma_list, auixp_dma) sc_dma_list;
130 
131 	/* audio formats supported */
132 	struct audio_format sc_formats[AUIXP_NFORMATS];
133 	struct audio_encoding_set *sc_encodings;
134 
135 	/* codecs */
136 	int			sc_num_codecs;
137 	struct auixp_codec	sc_codec[ATI_IXP_CODECS];
138 	int			sc_codec_not_ready_bits;
139 
140 	/* last set audio parameters */
141 	struct audio_params	sc_play_params;
142 	struct audio_params	sc_rec_params;
143 };
144 
145 
146