xref: /openbsd/sys/dev/pci/auixpvar.h (revision d25d28bf)
1 /* $OpenBSD: auixpvar.h,v 1.4 2016/09/19 06:46:44 ratchov Exp $ */
2 /* $NetBSD: auixpvar.h,v 1.3 2005/01/12 15:54:34 kent Exp $*/
3 
4 /*
5  * Copyright (c) 2004, 2005 Reinoud Zandijk <reinoud@netbsd.org>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. The name of the author may not be used to endorse or promote products
14  *    derived from this software without specific prior written permission.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed by the NetBSD
18  *	Foundation, Inc. and its contributors.
19  * 4. Neither the name of The NetBSD Foundation nor the names of its
20  *    contributors may be used to endorse or promote products derived
21  *    from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  */
35 
36 
37 /*
38  * NetBSD audio driver for ATI IXP-{150,200,...} audio driver hardware.
39  */
40 
41 #define DMA_DESC_CHAIN	255
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 #define AUIXP_MINRATE  7000
48 #define AUIXP_MAXRATE 48000
49 
50 /* auixp structures; used to record alloced DMA space */
51 struct auixp_dma {
52 	/* bus mappings */
53 	bus_dmamap_t		 map;
54 	caddr_t			 addr;
55 	bus_dma_segment_t	 segs[1];
56 	int			 nsegs;
57 	size_t			 size;
58 
59 	/* audio feeder */
60 	void			 (*intr)(void *);
61 	void			*intrarg;
62 
63 	/* status and setup bits */
64 	int			 running;
65 	u_int32_t		 linkptr;
66 	u_int32_t		 dma_enable_bit;
67 
68 	/* linked list of all mapped area's */
69 	SLIST_ENTRY(auixp_dma)	 dma_chain;
70 };
71 
72 struct auixp_codec {
73 	struct auixp_softc	*sc;
74 
75 	int			 present;
76 	int			 codec_nr;
77 
78 	struct ac97_codec_if	*codec_if;
79 	struct ac97_host_if	 host_if;
80 	enum ac97_host_flags	 codec_flags;
81 };
82 
83 struct auixp_softc {
84 	struct device		sc_dev;
85 	void			*sc_ih;
86 
87 	/* card properties */
88 	int			has_4ch, has_6ch, is_fixed, has_spdif;
89 
90 	/* bus tags */
91 	bus_space_tag_t		sc_iot;
92 	bus_space_handle_t	sc_ioh;
93 	bus_addr_t		sc_iob;
94 	bus_size_t		sc_ios;
95 
96 	pcitag_t		sc_tag;
97 	pci_chipset_tag_t	sc_pct;
98 
99 	bus_dma_tag_t		sc_dmat;
100 
101 	/* DMA business */
102 	struct auixp_dma	*sc_output_dma;
103 	struct auixp_dma	*sc_input_dma;
104 
105 	/* list of allocated DMA pieces */
106 	SLIST_HEAD(auixp_dma_list, auixp_dma) sc_dma_list;
107 
108 	/* codec */
109 	struct auixp_codec	sc_codec;
110 	int			sc_codec_not_ready_bits;
111 
112 	/* last set audio parameters */
113 	struct audio_params	sc_play_params;
114 	struct audio_params	sc_rec_params;
115 };
116