cs428x.h revision 1.1 1 1.1 augustss /* $NetBSD: cs428x.h,v 1.1 2001/01/22 01:34:42 augustss Exp $ */
2 1.1 augustss /* $Tera: cs428x.h,v 1.1 2000/12/22 07:07:58 tacha Exp $ */
3 1.1 augustss
4 1.1 augustss /*
5 1.1 augustss * Copyright (c) 2000 Tatoku Ogaito. All rights reserved.
6 1.1 augustss *
7 1.1 augustss * Redistribution and use in source and binary forms, with or without
8 1.1 augustss * modification, are permitted provided that the following conditions
9 1.1 augustss * are met:
10 1.1 augustss * 1. Redistributions of source code must retain the above copyright
11 1.1 augustss * notice, this list of conditions and the following disclaimer.
12 1.1 augustss * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 augustss * notice, this list of conditions and the following disclaimer in the
14 1.1 augustss * documentation and/or other materials provided with the distribution.
15 1.1 augustss * 3. All advertising materials mentioning features or use of this software
16 1.1 augustss * must display the following acknowledgement:
17 1.1 augustss * This product includes software developed by Tatoku Ogaito
18 1.1 augustss * for the NetBSD Project.
19 1.1 augustss * 4. The name of the author may not be used to endorse or promote products
20 1.1 augustss * derived from this software without specific prior written permission
21 1.1 augustss *
22 1.1 augustss * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.1 augustss * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.1 augustss * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1 augustss * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 1.1 augustss * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 1.1 augustss * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 1.1 augustss * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 1.1 augustss * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 1.1 augustss * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 1.1 augustss * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 augustss */
33 1.1 augustss
34 1.1 augustss /* Common functions and variables for CS4280 and CS4281 */
35 1.1 augustss
36 1.1 augustss #ifndef _CS428X_H_
37 1.1 augustss #define _CS428X_H_
38 1.1 augustss
39 1.1 augustss #define PCI_BA0 (0x10)
40 1.1 augustss #define PCI_BA1 (0x14)
41 1.1 augustss
42 1.1 augustss #define CS428X_SAVE_REG_MAX (0x10)
43 1.1 augustss #define TYPE_CS4280 (0x4280)
44 1.1 augustss #define TYPE_CS4281 (0x4281)
45 1.1 augustss
46 1.1 augustss #define BA0READ4(sc, r) bus_space_read_4((sc)->ba0t, (sc)->ba0h, (r))
47 1.1 augustss #define BA0WRITE4(sc, r, x) bus_space_write_4((sc)->ba0t, (sc)->ba0h, (r), (x))
48 1.1 augustss
49 1.1 augustss /* DMA */
50 1.1 augustss struct cs428x_dma {
51 1.1 augustss bus_dmamap_t map;
52 1.1 augustss caddr_t addr; /* real dma buffer */
53 1.1 augustss caddr_t dum; /* dummy buffer for audio driver */
54 1.1 augustss bus_dma_segment_t segs[1];
55 1.1 augustss int nsegs;
56 1.1 augustss size_t size;
57 1.1 augustss struct cs428x_dma *next;
58 1.1 augustss };
59 1.1 augustss #define DMAADDR(p) ((p)->map->dm_segs[0].ds_addr)
60 1.1 augustss #define KERNADDR(p) ((void *)((p)->addr)) /* buffer for real dma */
61 1.1 augustss #define BUFADDR(p) ((void *)((p)->dum)) /* buffer for audio driver */
62 1.1 augustss
63 1.1 augustss /*
64 1.1 augustss * Software state
65 1.1 augustss */
66 1.1 augustss struct cs428x_softc {
67 1.1 augustss struct device sc_dev;
68 1.1 augustss
69 1.1 augustss pci_intr_handle_t * sc_ih;
70 1.1 augustss
71 1.1 augustss /* I/O (BA0) */
72 1.1 augustss bus_space_tag_t ba0t;
73 1.1 augustss bus_space_handle_t ba0h;
74 1.1 augustss
75 1.1 augustss /* BA1 */
76 1.1 augustss bus_space_tag_t ba1t;
77 1.1 augustss bus_space_handle_t ba1h;
78 1.1 augustss
79 1.1 augustss /* DMA */
80 1.1 augustss bus_dma_tag_t sc_dmatag;
81 1.1 augustss struct cs428x_dma *sc_dmas;
82 1.1 augustss size_t dma_size;
83 1.1 augustss size_t dma_align;
84 1.1 augustss
85 1.1 augustss int hw_blocksize;
86 1.1 augustss int type;
87 1.1 augustss
88 1.1 augustss /* playback */
89 1.1 augustss void (*sc_pintr)(void *); /* dma completion intr handler */
90 1.1 augustss void *sc_parg; /* arg for sc_intr() */
91 1.1 augustss char *sc_ps, *sc_pe, *sc_pn;
92 1.1 augustss int sc_pcount;
93 1.1 augustss int sc_pi;
94 1.1 augustss struct cs428x_dma *sc_pdma;
95 1.1 augustss char *sc_pbuf;
96 1.1 augustss int (*halt_output)__P((void *));
97 1.1 augustss #ifdef DIAGNOSTIC
98 1.1 augustss char sc_prun;
99 1.1 augustss #endif
100 1.1 augustss
101 1.1 augustss /* capturing */
102 1.1 augustss void (*sc_rintr)(void *); /* dma completion intr handler */
103 1.1 augustss void *sc_rarg; /* arg for sc_intr() */
104 1.1 augustss char *sc_rs, *sc_re, *sc_rn;
105 1.1 augustss int sc_rcount;
106 1.1 augustss int sc_ri;
107 1.1 augustss struct cs428x_dma *sc_rdma;
108 1.1 augustss char *sc_rbuf;
109 1.1 augustss int sc_rparam; /* record format */
110 1.1 augustss int (*halt_input)__P((void *));
111 1.1 augustss #ifdef DIAGNOSTIC
112 1.1 augustss char sc_rrun;
113 1.1 augustss #endif
114 1.1 augustss
115 1.1 augustss #if NMIDI > 0
116 1.1 augustss void (*sc_iintr)(void *, int); /* midi input ready handler */
117 1.1 augustss void (*sc_ointr)(void *); /* midi output ready handler */
118 1.1 augustss void *sc_arg;
119 1.1 augustss #endif
120 1.1 augustss
121 1.1 augustss /*
122 1.1 augustss * XXX
123 1.1 augustss * Actually thease 2 variables are needed only for CS4280.
124 1.1 augustss */
125 1.1 augustss u_int32_t pctl;
126 1.1 augustss u_int32_t cctl;
127 1.1 augustss
128 1.1 augustss /* AC97 CODEC */
129 1.1 augustss struct ac97_codec_if *codec_if;
130 1.1 augustss struct ac97_host_if host_if;
131 1.1 augustss
132 1.1 augustss /* Power Management */
133 1.1 augustss char sc_suspend;
134 1.1 augustss void *sc_powerhook; /* Power Hook */
135 1.1 augustss u_int16_t ac97_reg[CS428X_SAVE_REG_MAX + 1]; /* Save ac97 registers */
136 1.1 augustss };
137 1.1 augustss
138 1.1 augustss
139 1.1 augustss int cs428x_open(void *, int);
140 1.1 augustss void cs428x_close(void *);
141 1.1 augustss int cs428x_round_blocksize(void *, int);
142 1.1 augustss int cs428x_get_props(void *);
143 1.1 augustss int cs428x_attach_codec(void *, struct ac97_codec_if *);
144 1.1 augustss int cs428x_read_codec(void *, u_int8_t , u_int16_t *);
145 1.1 augustss int cs428x_write_codec(void *, u_int8_t, u_int16_t);
146 1.1 augustss void cs428x_reset_codec(void *);
147 1.1 augustss
148 1.1 augustss int cs428x_mixer_set_port(void *, mixer_ctrl_t *);
149 1.1 augustss int cs428x_mixer_get_port(void *, mixer_ctrl_t *);
150 1.1 augustss int cs428x_query_devinfo(void *, mixer_devinfo_t *);
151 1.1 augustss void *cs428x_malloc(void *, int, size_t, int, int);
152 1.1 augustss size_t cs428x_round_buffersize(void *, int, size_t);
153 1.1 augustss void cs428x_free(void *, void *, int);
154 1.1 augustss paddr_t cs428x_mappage(void *, void *, off_t, int);
155 1.1 augustss
156 1.1 augustss /* internal functions */
157 1.1 augustss int cs428x_allocmem(struct cs428x_softc*, size_t, int, int, struct cs428x_dma *);
158 1.1 augustss int cs428x_src_wait(struct cs428x_softc *);
159 1.1 augustss
160 1.1 augustss
161 1.1 augustss /* DEBUG */
162 1.1 augustss /*#define CS4280_DEBUG*/
163 1.1 augustss /*#define CS4281_DEBUG*/
164 1.1 augustss
165 1.1 augustss #if defined(CS4280_DEBUG) || defined(CS4281_DEBUG)
166 1.1 augustss #define DPRINTF(x) if (cs428x_debug) printf x
167 1.1 augustss #define DPRINTFN(n,x) if (cs428x_debug>(n)) printf x
168 1.1 augustss extern int cs428x_debug;
169 1.1 augustss #if CS4280_DEBUG + 0 == 0
170 1.1 augustss #undef CS4280_DEBUG
171 1.1 augustss #define CS4280_DEBUG 0
172 1.1 augustss #endif
173 1.1 augustss #else
174 1.1 augustss #define DPRINTF(x)
175 1.1 augustss #define DPRINTFN(n,x)
176 1.1 augustss #endif
177 1.1 augustss
178 1.1 augustss #endif /* _CS428X_H_ */
179