xref: /openbsd/sys/dev/pci/auixpvar.h (revision 905646f0)
1 /* $OpenBSD: auixpvar.h,v 1.5 2020/06/27 00:33:59 jsg 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  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 
30 /*
31  * NetBSD audio driver for ATI IXP-{150,200,...} audio driver hardware.
32  */
33 
34 #define DMA_DESC_CHAIN	255
35 
36 /* audio format structure describing our hardware capabilities */
37 /* XXX min and max sample rates are for AD1888 codec XXX */
38 #define AUIXP_NFORMATS 6
39 
40 #define AUIXP_MINRATE  7000
41 #define AUIXP_MAXRATE 48000
42 
43 /* auixp structures; used to record alloced DMA space */
44 struct auixp_dma {
45 	/* bus mappings */
46 	bus_dmamap_t		 map;
47 	caddr_t			 addr;
48 	bus_dma_segment_t	 segs[1];
49 	int			 nsegs;
50 	size_t			 size;
51 
52 	/* audio feeder */
53 	void			 (*intr)(void *);
54 	void			*intrarg;
55 
56 	/* status and setup bits */
57 	int			 running;
58 	u_int32_t		 linkptr;
59 	u_int32_t		 dma_enable_bit;
60 
61 	/* linked list of all mapped area's */
62 	SLIST_ENTRY(auixp_dma)	 dma_chain;
63 };
64 
65 struct auixp_codec {
66 	struct auixp_softc	*sc;
67 
68 	int			 present;
69 	int			 codec_nr;
70 
71 	struct ac97_codec_if	*codec_if;
72 	struct ac97_host_if	 host_if;
73 	enum ac97_host_flags	 codec_flags;
74 };
75 
76 struct auixp_softc {
77 	struct device		sc_dev;
78 	void			*sc_ih;
79 
80 	/* card properties */
81 	int			has_4ch, has_6ch, is_fixed, has_spdif;
82 
83 	/* bus tags */
84 	bus_space_tag_t		sc_iot;
85 	bus_space_handle_t	sc_ioh;
86 	bus_addr_t		sc_iob;
87 	bus_size_t		sc_ios;
88 
89 	pcitag_t		sc_tag;
90 	pci_chipset_tag_t	sc_pct;
91 
92 	bus_dma_tag_t		sc_dmat;
93 
94 	/* DMA business */
95 	struct auixp_dma	*sc_output_dma;
96 	struct auixp_dma	*sc_input_dma;
97 
98 	/* list of allocated DMA pieces */
99 	SLIST_HEAD(auixp_dma_list, auixp_dma) sc_dma_list;
100 
101 	/* codec */
102 	struct auixp_codec	sc_codec;
103 	int			sc_codec_not_ready_bits;
104 
105 	/* last set audio parameters */
106 	struct audio_params	sc_play_params;
107 	struct audio_params	sc_rec_params;
108 };
109