cs4231var.h revision 1.2 1 1.2 uwe /* $NetBSD: cs4231var.h,v 1.2 2002/03/12 04:48:28 uwe Exp $ */
2 1.1 mrg
3 1.1 mrg /*-
4 1.1 mrg * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
5 1.1 mrg * All rights reserved.
6 1.1 mrg *
7 1.1 mrg * This code is derived from software contributed to The NetBSD Foundation
8 1.1 mrg * by Paul Kranenburg.
9 1.1 mrg *
10 1.1 mrg * Redistribution and use in source and binary forms, with or without
11 1.1 mrg * modification, are permitted provided that the following conditions
12 1.1 mrg * are met:
13 1.1 mrg * 1. Redistributions of source code must retain the above copyright
14 1.1 mrg * notice, this list of conditions and the following disclaimer.
15 1.1 mrg * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 mrg * notice, this list of conditions and the following disclaimer in the
17 1.1 mrg * documentation and/or other materials provided with the distribution.
18 1.1 mrg * 3. All advertising materials mentioning features or use of this software
19 1.1 mrg * must display the following acknowledgement:
20 1.1 mrg * This product includes software developed by the NetBSD
21 1.1 mrg * Foundation, Inc. and its contributors.
22 1.1 mrg * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 mrg * contributors may be used to endorse or promote products derived
24 1.1 mrg * from this software without specific prior written permission.
25 1.1 mrg *
26 1.1 mrg * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 mrg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 mrg * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 mrg * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 mrg * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 mrg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 mrg * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 mrg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 mrg * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 mrg * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 mrg * POSSIBILITY OF SUCH DAMAGE.
37 1.1 mrg */
38 1.1 mrg
39 1.2 uwe #ifndef _DEV_IC_CS4231VAR_H_
40 1.2 uwe #define _DEV_IC_CS4231VAR_H_
41 1.2 uwe
42 1.2 uwe #define AUDIOCS_PROM_NAME "SUNW,CS4231"
43 1.2 uwe
44 1.2 uwe /*
45 1.2 uwe * List of device memory allocations (see cs4231_malloc/cs4231_free).
46 1.2 uwe */
47 1.2 uwe struct cs_dma {
48 1.2 uwe struct cs_dma *next;
49 1.2 uwe caddr_t addr;
50 1.2 uwe bus_dmamap_t dmamap;
51 1.2 uwe bus_dma_segment_t segs[1];
52 1.2 uwe int nsegs;
53 1.2 uwe size_t size;
54 1.2 uwe };
55 1.2 uwe
56 1.2 uwe
57 1.2 uwe /*
58 1.2 uwe * DMA transfer to/from CS4231.
59 1.2 uwe */
60 1.2 uwe struct cs_transfer {
61 1.2 uwe int t_active; /* this transfer is currently active */
62 1.2 uwe struct cs_dma *t_dma; /* dma memory to transfer from/to */
63 1.2 uwe vsize_t t_segsz; /* size of the segment */
64 1.2 uwe vsize_t t_blksz; /* call audio(9) after this many bytes */
65 1.2 uwe vsize_t t_cnt; /* how far are we into the segment */
66 1.2 uwe
67 1.2 uwe void (*t_intr)(void*); /* audio(9) callback */
68 1.2 uwe void *t_arg;
69 1.2 uwe
70 1.2 uwe const char *t_name; /* for error/debug messages */
71 1.2 uwe
72 1.2 uwe struct evcnt t_intrcnt;
73 1.2 uwe struct evcnt t_ierrcnt;
74 1.2 uwe };
75 1.2 uwe
76 1.2 uwe
77 1.1 mrg /*
78 1.1 mrg * Software state, per CS4231 audio chip.
79 1.1 mrg */
80 1.1 mrg struct cs4231_softc {
81 1.1 mrg struct ad1848_softc sc_ad1848; /* base device */
82 1.2 uwe
83 1.1 mrg bus_space_tag_t sc_bustag;
84 1.2 uwe bus_dma_tag_t sc_dmatag;
85 1.2 uwe
86 1.2 uwe int sc_open; /* single use device */
87 1.2 uwe struct cs_dma *sc_dmas; /* allocated dma resources */
88 1.2 uwe
89 1.2 uwe struct evcnt sc_intrcnt; /* parent counter */
90 1.1 mrg
91 1.2 uwe struct cs_transfer sc_playback;
92 1.2 uwe struct cs_transfer sc_capture;
93 1.1 mrg };
94 1.1 mrg
95 1.2 uwe
96 1.2 uwe /*
97 1.2 uwe * Bus independent code shared by sbus and ebus attachments.
98 1.2 uwe */
99 1.2 uwe void cs4231_common_attach(struct cs4231_softc *, bus_space_handle_t);
100 1.2 uwe int cs4231_transfer_init(struct cs4231_softc *, struct cs_transfer *,
101 1.2 uwe bus_addr_t *, bus_size_t *,
102 1.2 uwe void *, void *, int, void (*)(void *), void *);
103 1.2 uwe void cs4231_transfer_advance(struct cs_transfer *,
104 1.2 uwe bus_addr_t *, bus_size_t *);
105 1.2 uwe
106 1.2 uwe
107 1.2 uwe /*
108 1.2 uwe * Bus independent audio(9) methods.
109 1.2 uwe */
110 1.2 uwe int cs4231_open(void *, int);
111 1.2 uwe void cs4231_close(void *);
112 1.2 uwe size_t cs4231_round_buffersize(void *, int, size_t);
113 1.2 uwe int cs4231_round_blocksize(void *, int);
114 1.2 uwe int cs4231_getdev(void *, struct audio_device *);
115 1.2 uwe int cs4231_set_port(void *, mixer_ctrl_t *);
116 1.2 uwe int cs4231_get_port(void *, mixer_ctrl_t *);
117 1.2 uwe int cs4231_query_devinfo(void *, mixer_devinfo_t *);
118 1.2 uwe int cs4231_get_props(void *);
119 1.2 uwe
120 1.2 uwe void *cs4231_malloc(void *, int, size_t, int, int);
121 1.2 uwe void cs4231_free(void *, void *, int);
122 1.2 uwe
123 1.2 uwe #endif /* _DEV_IC_CS4231VAR_H_ */
124