xref: /freebsd/sys/dev/sound/pci/emu10kx.h (revision e1c4c8dd8d2d10b6104f06856a77bd5b4813a801)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
5  * Copyright (c) 2003-2006 Yuriy Tsibizov <yuriy.tsibizov@gfk.ru>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 #ifndef EMU10KX_H
31 #define	EMU10KX_H
32 
33 #define	SND_EMU10KX_MINVER	1
34 #define	SND_EMU10KX_PREFVER	1
35 #define	SND_EMU10KX_MAXVER	1
36 
37 #ifdef _KERNEL
38 
39 #define	EMUPAGESIZE	4096
40 #define	NUM_G		64
41 /* XXX some (empty) samples are played when play buffer is > EMUPAGESIZE */
42 #define	EMU_PLAY_BUFSZ	EMUPAGESIZE
43 /* Recording is limited by EMUPAGESIZE*16=64K buffer */
44 #define	EMU_REC_BUFSZ	EMUPAGESIZE*16
45 #define	EMU_MAX_BUFSZ	EMUPAGESIZE*16
46 #define	EMU_MAXPAGES	8192
47 
48 #define	EMU_VAR_FUNC		0
49 #define	EMU_VAR_ROUTE		1
50 #define	EMU_VAR_ISEMU10K1 	2
51 #define	EMU_VAR_MCH_DISABLED 	3
52 #define	EMU_VAR_MCH_REC 	4
53 
54 #define EMU_A_IOCFG_DISABLE_ANALOG	0x0040	/* = 'enable' for Audigy2 */
55 #define EMU_A_IOCFG_GPOUT2	0x0001
56 #define EMU_AC97SLOT_REAR_RIGHT	0x01
57 #define EMU_AC97SLOT_REAR_LEFT	0x02
58 #define EMU_HCFG_GPOUT0		0x00001000
59 #define EMU_HCFG_GPOUT1		0x00000800
60 #define EMU_HCFG_GPOUT2		0x00000400
61 
62 #define	RT_FRONT		0
63 #define	RT_REAR			1
64 #define	RT_CENTER		2
65 #define	RT_SUB			3
66 #define	RT_SIDE			4
67 #define	RT_MCHRECORD		5
68 #define	RT_COUNT		6
69 
70 /* mixer controls */
71 /* fx play */
72 #define	M_FX0_FRONT_L		0
73 #define	M_FX1_FRONT_R		1
74 #define	M_FX2_REAR_L		2
75 #define	M_FX3_REAR_R		3
76 #define	M_FX4_CENTER		4
77 #define	M_FX5_SUBWOOFER		5
78 #define	M_FX6_SIDE_L		6
79 #define	M_FX7_SIDE_R		7
80 /* fx rec */
81 #define	M_FX0_REC_L		8
82 #define	M_FX1_REC_R		9
83 /* inputs play */
84 #define	M_IN0_FRONT_L		10
85 #define	M_IN0_FRONT_R		11
86 #define	M_IN1_FRONT_L		12
87 #define	M_IN1_FRONT_R		13
88 #define	M_IN2_FRONT_L		14
89 #define	M_IN2_FRONT_R		15
90 #define	M_IN3_FRONT_L		16
91 #define	M_IN3_FRONT_R		17
92 #define	M_IN4_FRONT_L		18
93 #define	M_IN4_FRONT_R		19
94 #define	M_IN5_FRONT_L		20
95 #define	M_IN5_FRONT_R		21
96 #define	M_IN6_FRONT_L		22
97 #define	M_IN6_FRONT_R		23
98 #define	M_IN7_FRONT_L		24
99 #define	M_IN7_FRONT_R		25
100 /* inputs rec */
101 #define	M_IN0_REC_L		26
102 #define	M_IN0_REC_R		27
103 #define	M_IN1_REC_L		28
104 #define	M_IN1_REC_R		29
105 #define	M_IN2_REC_L		30
106 #define	M_IN2_REC_R		31
107 #define	M_IN3_REC_L		32
108 #define	M_IN3_REC_R		33
109 #define	M_IN4_REC_L		34
110 #define	M_IN4_REC_R		35
111 #define	M_IN5_REC_L		36
112 #define	M_IN5_REC_R		37
113 #define	M_IN6_REC_L		38
114 #define	M_IN6_REC_R		39
115 #define	M_IN7_REC_L		40
116 #define	M_IN7_REC_R		41
117 /* master volume */
118 #define	M_MASTER_FRONT_L	42
119 #define	M_MASTER_FRONT_R	43
120 #define	M_MASTER_REAR_L		44
121 #define	M_MASTER_REAR_R		45
122 #define	M_MASTER_CENTER		46
123 #define	M_MASTER_SUBWOOFER	47
124 #define	M_MASTER_SIDE_L		48
125 #define	M_MASTER_SIDE_R		49
126 /* master rec volume */
127 #define	M_MASTER_REC_L		50
128 #define	M_MASTER_REC_R		51
129 
130 #define	NUM_MIXERS		52
131 
132 struct emu_sc_info;
133 
134 /* MIDI device parameters */
135 struct emu_midiinfo {
136 	struct emu_sc_info *card;
137 	int		port;
138 	int		portnr;
139 };
140 
141 /* PCM device parameters */
142 struct emu_pcminfo {
143 	struct emu_sc_info *card;
144 	int		route;
145 };
146 
147 int	emu_intr_register(struct emu_sc_info *sc, uint32_t inte_mask, uint32_t intr_mask, uint32_t(*func) (void *softc, uint32_t irq), void *isc);
148 int	emu_intr_unregister(struct emu_sc_info *sc, int ihandle);
149 
150 uint32_t emu_rd(struct emu_sc_info *sc, unsigned int regno, unsigned int size);
151 void	emu_wr(struct emu_sc_info *sc, unsigned int regno, uint32_t data, unsigned int size);
152 
153 uint32_t emu_rdptr(struct emu_sc_info *sc, unsigned int chn, unsigned int reg);
154 void	emu_wrptr(struct emu_sc_info *sc, unsigned int chn, unsigned int reg, uint32_t data);
155 
156 uint32_t emu_rd_p16vptr(struct emu_sc_info *sc, uint16_t chn, uint16_t reg);
157 void	emu_wr_p16vptr(struct emu_sc_info *sc, uint16_t chn, uint16_t reg, uint32_t data);
158 
159 int	emu_timer_create(struct emu_sc_info *sc);
160 int	emu_timer_set(struct emu_sc_info *sc, int timer, int delay);
161 int	emu_timer_enable(struct emu_sc_info *sc, int timer, int go);
162 int	emu_timer_clear(struct emu_sc_info *sc, int timer);
163 
164 struct emu_voice;
165 
166 struct emu_route {
167 	int	routing_left[8];
168 	int	amounts_left[8];
169 	int	routing_right[8];
170 	int	amounts_right[8];
171 };
172 
173 struct emu_voice* emu_valloc(struct emu_sc_info *sc);
174 void 	emu_vfree(struct emu_sc_info *sc, struct emu_voice *v);
175 int	emu_vinit(struct emu_sc_info *sc, struct emu_voice *m, struct emu_voice *s,
176     uint32_t sz, struct snd_dbuf *b);
177 void	emu_vroute(struct emu_sc_info *sc, struct emu_route *rt,  struct emu_voice *v);
178 void	emu_vsetup(struct emu_voice *v, int fmt, int spd);
179 void	emu_vwrite(struct emu_sc_info *sc, struct emu_voice *v);
180 void	emu_vtrigger(struct emu_sc_info *sc, struct emu_voice *v, int go);
181 int	emu_vpos(struct emu_sc_info *sc, struct emu_voice *v);
182 
183 bus_dma_tag_t emu_gettag(struct emu_sc_info *sc);
184 
185 void	emumix_set_volume(struct emu_sc_info *sc, int mixer_idx, int volume);
186 int	emumix_get_volume(struct emu_sc_info *sc, int mixer_idx);
187 
188 void	emu_enable_ir(struct emu_sc_info *sc);
189 #endif				/* _KERNEL */
190 #endif				/* EMU10K1_H */
191