esmvar.h revision 1.1 1 1.1 rh /* $NetBSD: esmvar.h,v 1.1 2001/01/08 19:54:31 rh Exp $ */
2 1.1 rh
3 1.1 rh /*-
4 1.1 rh * Copyright (c) 2000, 2001 Rene Hexel <rh (at) netbsd.org>
5 1.1 rh * All rights reserved.
6 1.1 rh *
7 1.1 rh * Copyright (c) 2000 Taku YAMAMOTO <taku (at) cent.saitama-u.ac.jp>
8 1.1 rh * All rights reserved.
9 1.1 rh *
10 1.1 rh * Redistribution and use in source and binary forms, with or without
11 1.1 rh * modification, are permitted provided that the following conditions
12 1.1 rh * are met:
13 1.1 rh * 1. Redistributions of source code must retain the above copyright
14 1.1 rh * notice, this list of conditions and the following disclaimer.
15 1.1 rh * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 rh * notice, this list of conditions and the following disclaimer in the
17 1.1 rh * documentation and/or other materials provided with the distribution.
18 1.1 rh *
19 1.1 rh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 1.1 rh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 1.1 rh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 1.1 rh * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 1.1 rh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 1.1 rh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 1.1 rh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 1.1 rh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 1.1 rh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 1.1 rh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 1.1 rh * SUCH DAMAGE.
30 1.1 rh *
31 1.1 rh * Taku Id: maestro.c,v 1.12 2000/09/06 03:32:34 taku Exp
32 1.1 rh * FreeBSD: /c/ncvs/src/sys/dev/sound/pci/maestro.c,v 1.4 2000/12/18 01:36:35 cg Exp
33 1.1 rh *
34 1.1 rh */
35 1.1 rh
36 1.1 rh /*
37 1.1 rh * Credits:
38 1.1 rh *
39 1.1 rh * This code is based on the FreeBSD driver written by Taku YAMAMOTO
40 1.1 rh *
41 1.1 rh *
42 1.1 rh * Original credits from the FreeBSD driver:
43 1.1 rh *
44 1.1 rh * Part of this code (especially in many magic numbers) was heavily inspired
45 1.1 rh * by the Linux driver originally written by
46 1.1 rh * Alan Cox <alan.cox (at) linux.org>, modified heavily by
47 1.1 rh * Zach Brown <zab (at) zabbo.net>.
48 1.1 rh *
49 1.1 rh * busdma()-ize and buffer size reduction were suggested by
50 1.1 rh * Cameron Grant <gandalf (at) vilnya.demon.co.uk>.
51 1.1 rh * Also he showed me the way to use busdma() suite.
52 1.1 rh *
53 1.1 rh * Internal speaker problems on NEC VersaPro's and Dell Inspiron 7500
54 1.1 rh * were looked at by
55 1.1 rh * Munehiro Matsuda <haro (at) tk.kubota.co.jp>,
56 1.1 rh * who brought patches based on the Linux driver with some simplification.
57 1.1 rh */
58 1.1 rh
59 1.1 rh /* IRQ timer fequency limits */
60 1.1 rh #define MAESTRO_MINFREQ 24
61 1.1 rh #define MAESTRO_MAXFREQ 48000
62 1.1 rh
63 1.1 rh struct esm_dma {
64 1.1 rh bus_dmamap_t map;
65 1.1 rh caddr_t addr;
66 1.1 rh bus_dma_segment_t segs[1];
67 1.1 rh int nsegs;
68 1.1 rh size_t size;
69 1.1 rh struct esm_dma *next;
70 1.1 rh };
71 1.1 rh
72 1.1 rh #define DMAADDR(p) ((p)->map->dm_segs[0].ds_addr)
73 1.1 rh #define KERNADDR(p) ((void *)((p)->addr))
74 1.1 rh
75 1.1 rh struct esm_chinfo {
76 1.1 rh u_int32_t base; /* DMA base */
77 1.1 rh u_int32_t blocksize; /* block size in bytes */
78 1.1 rh unsigned num; /* logical channel number */
79 1.1 rh u_int16_t aputype; /* APU channel type */
80 1.1 rh u_int16_t apublk; /* blk size in samples per ch */
81 1.1 rh u_int16_t apubuf; /* buf size in samples per ch */
82 1.1 rh u_int16_t nextirq; /* pos to trigger next IRQ at */
83 1.1 rh u_int16_t wcreg_tpl; /* wavecache tag and format */
84 1.1 rh u_int16_t sample_rate;
85 1.1 rh };
86 1.1 rh
87 1.1 rh struct esm_softc {
88 1.1 rh struct device sc_dev;
89 1.1 rh
90 1.1 rh bus_space_tag_t st;
91 1.1 rh bus_space_handle_t sh;
92 1.1 rh
93 1.1 rh pcitag_t tag;
94 1.1 rh pci_chipset_tag_t pc;
95 1.1 rh bus_dma_tag_t dmat;
96 1.1 rh pcireg_t subid;
97 1.1 rh
98 1.1 rh void *ih;
99 1.1 rh
100 1.1 rh struct ac97_codec_if *codec_if;
101 1.1 rh struct ac97_host_if host_if;
102 1.1 rh
103 1.1 rh struct esm_dma *sc_dmas;
104 1.1 rh
105 1.1 rh int pactive, ractive;
106 1.1 rh struct esm_chinfo pch;
107 1.1 rh struct esm_chinfo rch;
108 1.1 rh
109 1.1 rh void (*sc_pintr)(void *);
110 1.1 rh void *sc_parg;
111 1.1 rh
112 1.1 rh void (*sc_rintr)(void *);
113 1.1 rh void *sc_rarg;
114 1.1 rh };
115 1.1 rh
116 1.1 rh int esm_read_codec(void *, u_int8_t, u_int16_t *);
117 1.1 rh int esm_write_codec(void *, u_int8_t, u_int16_t);
118 1.1 rh int esm_attach_codec(void *, struct ac97_codec_if *);
119 1.1 rh void esm_reset_codec(void *);
120 1.1 rh
121 1.1 rh void esm_power(struct esm_softc *, int);
122 1.1 rh void esm_init(struct esm_softc *);
123 1.1 rh void esm_initcodec(struct esm_softc *);
124 1.1 rh
125 1.1 rh int esm_init_output(void *, void *, int);
126 1.1 rh int esm_trigger_output(void *, void *, void *, int, void (*)(void *),
127 1.1 rh void *, struct audio_params *);
128 1.1 rh int esm_trigger_input(void *, void *, void *, int, void (*)(void *),
129 1.1 rh void *, struct audio_params *);
130 1.1 rh int esm_halt_output(void *);
131 1.1 rh int esm_halt_input(void *);
132 1.1 rh int esm_open(void *, int);
133 1.1 rh void esm_close(void *);
134 1.1 rh int esm_getdev(void *, struct audio_device *);
135 1.1 rh int esm_round_blocksize(void *, int);
136 1.1 rh int esm_query_encoding(void *, struct audio_encoding *);
137 1.1 rh int esm_set_params(void *, int, int, struct audio_params *,
138 1.1 rh struct audio_params *);
139 1.1 rh int esm_set_port(void *, mixer_ctrl_t *);
140 1.1 rh int esm_get_port(void *, mixer_ctrl_t *);
141 1.1 rh int esm_query_devinfo(void *, mixer_devinfo_t *);
142 1.1 rh void *esm_malloc(void *, int, size_t, int, int);
143 1.1 rh void esm_free(void *, void *, int);
144 1.1 rh size_t esm_round_buffersize(void *, int, size_t);
145 1.1 rh paddr_t esm_mappage(void *, void *, off_t, int);
146 1.1 rh int esm_get_props(void *);
147 1.1 rh
148 1.1 rh int esm_match(struct device *, struct cfdata *, void *);
149 1.1 rh void esm_attach(struct device *, struct device *, void *);
150 1.1 rh int esm_intr(void *);
151 1.1 rh
152 1.1 rh int esm_allocmem(struct esm_softc *, size_t, size_t,
153 1.1 rh struct esm_dma *);
154 1.1 rh int esm_freemem(struct esm_softc *, struct esm_dma *);
155 1.1 rh
156 1.1 rh int esm_suspend(struct esm_softc *);
157 1.1 rh int esm_resume(struct esm_softc *);
158 1.1 rh int esm_shutdown(struct esm_softc *);
159