Say hello to a sound system update from FreeBSD. This includes the long
[dragonfly.git] / sys / dev / sound / pci / au88x0.h
1 /*-
2  * Copyright (c) 2003 Dag-Erling Coïdan Smørgrav
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer
10  *    in this position and unchanged.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * $FreeBSD: src/sys/dev/sound/pci/au88x0.h,v 1.2 2003/10/12 11:33:39 des Exp $
29  * $DragonFly: src/sys/dev/sound/pci/au88x0.h,v 1.1 2007/01/04 21:47:02 corecode Exp $
30  */
31
32 #ifndef _AU88X0_H_INCLUDED
33 #define _AU88X0_H_INCLUDED
34
35 /*
36  * Chipset parameters
37  */
38 struct au88x0_chipset {
39         const char              *auc_name;
40         uint32_t                 auc_pci_id;
41
42         /* General control register */
43         uint32_t                 auc_control;
44 #define AU88X0_CTL_MIDI_ENABLE          0x0001
45 #define AU88X0_CTL_GAME_ENABLE          0x0008
46 #define AU88X0_CTL_IRQ_ENABLE           0x4000
47
48         /* IRQ control register */
49         uint32_t                 auc_irq_source;
50 #define AU88X0_IRQ_FATAL_ERR            0x0001
51 #define AU88X0_IRQ_PARITY_ERR           0x0002
52 #define AU88X0_IRQ_REG_ERR              0x0004
53 #define AU88X0_IRQ_FIFO_ERR             0x0008
54 #define AU88X0_IRQ_DMA_ERR              0x0010
55 #define AU88X0_IRQ_PCMOUT               0x0020
56 #define AU88X0_IRQ_TIMER                0x1000
57 #define AU88X0_IRQ_MIDI                 0x2000
58 #define AU88X0_IRQ_MODEM                0x4000
59         uint32_t                 auc_irq_mask;
60         uint32_t                 auc_irq_control;
61 #define         AU88X0_IRQ_PENDING_BIT          0x0001
62         uint32_t                 auc_irq_status;
63
64         /* DMA control registers */
65         uint32_t                 auc_dma_control;
66
67         /* FIFOs */
68         int                      auc_fifo_size;
69         int                      auc_wt_fifos;
70         uint32_t                 auc_wt_fifo_base;
71         uint32_t                 auc_wt_fifo_ctl;
72         uint32_t                 auc_wt_dma_ctl;
73         int                      auc_adb_fifos;
74         uint32_t                 auc_adb_fifo_base;
75         uint32_t                 auc_adb_fifo_ctl;
76         uint32_t                 auc_adb_dma_ctl;
77
78         /* Routing */
79         uint32_t                 auc_adb_route_base;
80         int                      auc_adb_route_bits;
81         int                      auc_adb_codec_in;
82         int                      auc_adb_codec_out;
83 };
84
85 /*
86  * Channel information
87  */
88 struct au88x0_chan_info {
89         struct au88x0_info      *auci_aui;
90         struct pcm_channel      *auci_pcmchan;
91         struct snd_dbuf         *auci_buf;
92         int                      auci_dir;
93 };
94
95 /*
96  * Device information
97  */
98 struct au88x0_info {
99         /* the device we're associated with */
100         device_t                 aui_dev;
101         uint32_t                 aui_model;
102         struct au88x0_chipset   *aui_chipset;
103
104         /* parameters */
105         bus_size_t               aui_bufsize;
106         int                      aui_wt_fifos;
107         int                      aui_wt_fifo_ctl;
108         int                      aui_adb_fifos;
109         int                      aui_adb_fifo_ctl;
110         int                      aui_fifo_size;
111         uint32_t                 aui_chanbase;
112
113         /* bus_space tag and handle */
114         bus_space_tag_t          aui_spct;
115         bus_space_handle_t       aui_spch;
116
117         /* register space */
118         int                      aui_regtype;
119         int                      aui_regid;
120         struct resource         *aui_reg;
121
122         /* irq */
123         int                      aui_irqtype;
124         int                      aui_irqid;
125         struct resource         *aui_irq;
126         void                    *aui_irqh;
127
128         /* dma */
129         bus_dma_tag_t            aui_dmat;
130
131         /* codec */
132         struct ac97_info        *aui_ac97i;
133
134         /* channels */
135         struct au88x0_chan_info  aui_chan[2];
136 };
137
138 /*
139  * Common parameters
140  */
141 #define AU88X0_SETTLE_DELAY     1000
142 #define AU88X0_RETRY_COUNT      10
143 #define AU88X0_BUFSIZE_MIN      0x1000
144 #define AU88X0_BUFSIZE_DFLT     0x4000
145 #define AU88X0_BUFSIZE_MAX      0x4000
146
147 /*
148  * Codec control registers
149  *
150  * AU88X0_CODEC_CHANNEL array of 32 32-bit words
151  *
152  * AU88X0_CODEC_CONTROL control register
153  *
154  *    bit     16        ready
155  *
156  * AU88X0_CODEC_IO      I/O register
157  *
158  *    bits  0-15        contents of codec register
159  *    bits 16-22        address of codec register
160  *    bit     23        0 for read, 1 for write
161  */
162 #define AU88X0_CODEC_CHANNEL    0x29080
163 #define AU88X0_CODEC_CONTROL    0x29184
164 #define         AU88X0_CDCTL_WROK       0x00000100
165 #define AU88X0_CODEC_IO         0x29188
166 #define         AU88X0_CDIO_DATA_SHIFT  0
167 #define         AU88X0_CDIO_DATA_MASK   0x0000ffff
168 #define         AU88X0_CDIO_ADDR_SHIFT  16
169 #define         AU88X0_CDIO_ADDR_MASK   0x007f0000
170 #define         AU88X0_CDIO_RDBIT       0x00000000
171 #define         AU88X0_CDIO_WRBIT       0x00800000
172 #define AU88X0_CDIO_READ(a) (AU88X0_CDIO_RDBIT | \
173          (((a) << AU88X0_CDIO_ADDR_SHIFT) & AU88X0_CDIO_ADDR_MASK))
174 #define AU88X0_CDIO_WRITE(a, d) (AU88X0_CDIO_WRBIT | \
175          (((a) << AU88X0_CDIO_ADDR_SHIFT) & AU88X0_CDIO_ADDR_MASK) | \
176          (((d) << AU88X0_CDIO_DATA_SHIFT) & AU88X0_CDIO_DATA_MASK))
177 #define AU88X0_CODEC_ENABLE     0x29190
178
179 #endif