cs4231var.h revision 1.9 1 1.9 christos /* $NetBSD: cs4231var.h,v 1.9 2011/06/02 00:23:28 christos 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 *
19 1.1 mrg * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 mrg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 mrg * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 mrg * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 mrg * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 mrg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 mrg * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 mrg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 mrg * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 mrg * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 mrg * POSSIBILITY OF SUCH DAMAGE.
30 1.1 mrg */
31 1.1 mrg
32 1.2 uwe #ifndef _DEV_IC_CS4231VAR_H_
33 1.2 uwe #define _DEV_IC_CS4231VAR_H_
34 1.2 uwe
35 1.2 uwe #define AUDIOCS_PROM_NAME "SUNW,CS4231"
36 1.2 uwe
37 1.2 uwe /*
38 1.2 uwe * List of device memory allocations (see cs4231_malloc/cs4231_free).
39 1.2 uwe */
40 1.2 uwe struct cs_dma {
41 1.2 uwe struct cs_dma *next;
42 1.7 christos void * addr;
43 1.2 uwe bus_dmamap_t dmamap;
44 1.2 uwe bus_dma_segment_t segs[1];
45 1.2 uwe int nsegs;
46 1.2 uwe size_t size;
47 1.2 uwe };
48 1.2 uwe
49 1.2 uwe
50 1.2 uwe /*
51 1.2 uwe * DMA transfer to/from CS4231.
52 1.2 uwe */
53 1.2 uwe struct cs_transfer {
54 1.2 uwe int t_active; /* this transfer is currently active */
55 1.2 uwe struct cs_dma *t_dma; /* dma memory to transfer from/to */
56 1.2 uwe vsize_t t_segsz; /* size of the segment */
57 1.2 uwe vsize_t t_blksz; /* call audio(9) after this many bytes */
58 1.2 uwe vsize_t t_cnt; /* how far are we into the segment */
59 1.2 uwe
60 1.2 uwe void (*t_intr)(void*); /* audio(9) callback */
61 1.2 uwe void *t_arg;
62 1.2 uwe
63 1.2 uwe const char *t_name; /* for error/debug messages */
64 1.2 uwe
65 1.2 uwe struct evcnt t_intrcnt;
66 1.2 uwe struct evcnt t_ierrcnt;
67 1.2 uwe };
68 1.2 uwe
69 1.2 uwe
70 1.1 mrg /*
71 1.1 mrg * Software state, per CS4231 audio chip.
72 1.1 mrg */
73 1.1 mrg struct cs4231_softc {
74 1.1 mrg struct ad1848_softc sc_ad1848; /* base device */
75 1.2 uwe
76 1.1 mrg bus_space_tag_t sc_bustag;
77 1.2 uwe bus_dma_tag_t sc_dmatag;
78 1.2 uwe
79 1.2 uwe struct cs_dma *sc_dmas; /* allocated dma resources */
80 1.2 uwe
81 1.2 uwe struct evcnt sc_intrcnt; /* parent counter */
82 1.1 mrg
83 1.2 uwe struct cs_transfer sc_playback;
84 1.2 uwe struct cs_transfer sc_capture;
85 1.1 mrg };
86 1.1 mrg
87 1.2 uwe
88 1.2 uwe /*
89 1.2 uwe * Bus independent code shared by sbus and ebus attachments.
90 1.2 uwe */
91 1.9 christos void cs4231_common_attach(struct cs4231_softc *, device_t,
92 1.9 christos bus_space_handle_t);
93 1.2 uwe int cs4231_transfer_init(struct cs4231_softc *, struct cs_transfer *,
94 1.2 uwe bus_addr_t *, bus_size_t *,
95 1.2 uwe void *, void *, int, void (*)(void *), void *);
96 1.2 uwe void cs4231_transfer_advance(struct cs_transfer *,
97 1.2 uwe bus_addr_t *, bus_size_t *);
98 1.2 uwe
99 1.2 uwe
100 1.2 uwe /*
101 1.2 uwe * Bus independent audio(9) methods.
102 1.2 uwe */
103 1.2 uwe int cs4231_open(void *, int);
104 1.2 uwe void cs4231_close(void *);
105 1.2 uwe int cs4231_getdev(void *, struct audio_device *);
106 1.2 uwe int cs4231_set_port(void *, mixer_ctrl_t *);
107 1.2 uwe int cs4231_get_port(void *, mixer_ctrl_t *);
108 1.2 uwe int cs4231_query_devinfo(void *, mixer_devinfo_t *);
109 1.2 uwe int cs4231_get_props(void *);
110 1.2 uwe
111 1.3 martin void *cs4231_malloc(void *, int, size_t, struct malloc_type *, int);
112 1.3 martin void cs4231_free(void *, void *, struct malloc_type *);
113 1.2 uwe
114 1.2 uwe #endif /* _DEV_IC_CS4231VAR_H_ */
115