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