xref: /freebsd/sys/dev/sound/pci/solo.c (revision 933ce6fa4b31b9d080c403f981eb61fabd9cf496)
1fd1aaeccSCameron Grant /*
2fd1aaeccSCameron Grant  * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
3fd1aaeccSCameron Grant  *
4fd1aaeccSCameron Grant  * Redistribution and use in source and binary forms, with or without
5fd1aaeccSCameron Grant  * modification, are permitted provided that the following conditions
6fd1aaeccSCameron Grant  * are met:
7fd1aaeccSCameron Grant  * 1. Redistributions of source code must retain the above copyright
8fd1aaeccSCameron Grant  *    notice, this list of conditions and the following disclaimer.
9fd1aaeccSCameron Grant  * 2. Redistributions in binary form must reproduce the above copyright
10fd1aaeccSCameron Grant  *    notice, this list of conditions and the following disclaimer in the
11fd1aaeccSCameron Grant  *    documentation and/or other materials provided with the distribution.
12fd1aaeccSCameron Grant  *
13fd1aaeccSCameron Grant  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14fd1aaeccSCameron Grant  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15fd1aaeccSCameron Grant  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16fd1aaeccSCameron Grant  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17fd1aaeccSCameron Grant  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18fd1aaeccSCameron Grant  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19fd1aaeccSCameron Grant  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20fd1aaeccSCameron Grant  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21fd1aaeccSCameron Grant  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22fd1aaeccSCameron Grant  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23fd1aaeccSCameron Grant  * SUCH DAMAGE.
24fd1aaeccSCameron Grant  */
25fd1aaeccSCameron Grant 
26fd1aaeccSCameron Grant #include <dev/sound/pcm/sound.h>
27fd1aaeccSCameron Grant 
28fd1aaeccSCameron Grant #include <pci/pcireg.h>
29fd1aaeccSCameron Grant #include <pci/pcivar.h>
30fd1aaeccSCameron Grant 
31fd1aaeccSCameron Grant #include  <dev/sound/isa/sb.h>
32fd1aaeccSCameron Grant #include  <dev/sound/chip.h>
33fd1aaeccSCameron Grant 
340f55ac6cSCameron Grant #include "mixer_if.h"
350f55ac6cSCameron Grant 
3667b1dce3SCameron Grant SND_DECLARE_FILE("$FreeBSD$");
3767b1dce3SCameron Grant 
3839dbd126SCameron Grant #define SOLO_DEFAULT_BUFSZ 16384
39fd1aaeccSCameron Grant #define ABS(x) (((x) < 0)? -(x) : (x))
40fd1aaeccSCameron Grant 
413ac1ca33SNick Sayer /* if defined, playback always uses the 2nd channel and full duplex works */
42fd1aaeccSCameron Grant #undef ESS18XX_DUPLEX
43fd1aaeccSCameron Grant 
44fd1aaeccSCameron Grant /* more accurate clocks and split audio1/audio2 rates */
45fd1aaeccSCameron Grant #define ESS18XX_NEWSPEED
46fd1aaeccSCameron Grant 
47513693beSCameron Grant static u_int32_t ess_playfmt[] = {
48513693beSCameron Grant 	AFMT_U8,
49513693beSCameron Grant 	AFMT_STEREO | AFMT_U8,
50513693beSCameron Grant 	AFMT_S8,
51513693beSCameron Grant 	AFMT_STEREO | AFMT_S8,
52513693beSCameron Grant 	AFMT_S16_LE,
53513693beSCameron Grant 	AFMT_STEREO | AFMT_S16_LE,
54513693beSCameron Grant 	AFMT_U16_LE,
55513693beSCameron Grant 	AFMT_STEREO | AFMT_U16_LE,
56513693beSCameron Grant 	0
57fd1aaeccSCameron Grant };
5866ef8af5SCameron Grant static struct pcmchan_caps ess_playcaps = {5000, 49000, ess_playfmt, 0};
59fd1aaeccSCameron Grant 
603ac1ca33SNick Sayer /*
613ac1ca33SNick Sayer  * Recording output is byte-swapped
623ac1ca33SNick Sayer  */
63513693beSCameron Grant static u_int32_t ess_recfmt[] = {
64513693beSCameron Grant 	AFMT_U8,
65513693beSCameron Grant 	AFMT_STEREO | AFMT_U8,
66513693beSCameron Grant 	AFMT_S8,
67513693beSCameron Grant 	AFMT_STEREO | AFMT_S8,
68513693beSCameron Grant 	AFMT_S16_BE,
69513693beSCameron Grant 	AFMT_STEREO | AFMT_S16_BE,
70513693beSCameron Grant 	AFMT_U16_BE,
71513693beSCameron Grant 	AFMT_STEREO | AFMT_U16_BE,
72513693beSCameron Grant 	0
73fd1aaeccSCameron Grant };
7466ef8af5SCameron Grant static struct pcmchan_caps ess_reccaps = {5000, 49000, ess_recfmt, 0};
75fd1aaeccSCameron Grant 
76fd1aaeccSCameron Grant struct ess_info;
77fd1aaeccSCameron Grant 
78fd1aaeccSCameron Grant struct ess_chinfo {
79fd1aaeccSCameron Grant 	struct ess_info *parent;
8066ef8af5SCameron Grant 	struct pcm_channel *channel;
8166ef8af5SCameron Grant 	struct snd_dbuf *buffer;
82fd1aaeccSCameron Grant 	int dir, hwch, stopping;
83350a5fafSCameron Grant 	u_int32_t fmt, spd, blksz;
84fd1aaeccSCameron Grant };
85fd1aaeccSCameron Grant 
86fd1aaeccSCameron Grant struct ess_info {
87fd1aaeccSCameron Grant     	struct resource *io, *sb, *vc, *mpu, *gp;	/* I/O address for the board */
88fd1aaeccSCameron Grant     	struct resource *irq;
89306f91b6SCameron Grant 	void		*ih;
90fd1aaeccSCameron Grant     	bus_dma_tag_t parent_dmat;
91fd1aaeccSCameron Grant 
923ac1ca33SNick Sayer     	int simplex_dir, type, duplex:1, newspeed:1, dmasz[2];
9339dbd126SCameron Grant 	unsigned int bufsz;
9439dbd126SCameron Grant 
95fd1aaeccSCameron Grant     	struct ess_chinfo pch, rch;
96fd1aaeccSCameron Grant };
97fd1aaeccSCameron Grant 
98fd1aaeccSCameron Grant static int ess_rd(struct ess_info *sc, int reg);
99fd1aaeccSCameron Grant static void ess_wr(struct ess_info *sc, int reg, u_int8_t val);
100fd1aaeccSCameron Grant static int ess_dspready(struct ess_info *sc);
101fd1aaeccSCameron Grant static int ess_cmd(struct ess_info *sc, u_char val);
102fd1aaeccSCameron Grant static int ess_cmd1(struct ess_info *sc, u_char cmd, int val);
103fd1aaeccSCameron Grant static int ess_get_byte(struct ess_info *sc);
104fd1aaeccSCameron Grant static void ess_setmixer(struct ess_info *sc, u_int port, u_int value);
105fd1aaeccSCameron Grant static int ess_getmixer(struct ess_info *sc, u_int port);
106fd1aaeccSCameron Grant static int ess_reset_dsp(struct ess_info *sc);
107fd1aaeccSCameron Grant 
108fd1aaeccSCameron Grant static int ess_write(struct ess_info *sc, u_char reg, int val);
109fd1aaeccSCameron Grant static int ess_read(struct ess_info *sc, u_char reg);
110fd1aaeccSCameron Grant 
111fd1aaeccSCameron Grant static void ess_intr(void *arg);
112fd1aaeccSCameron Grant static int ess_setupch(struct ess_info *sc, int ch, int dir, int spd, u_int32_t fmt, int len);
113fd1aaeccSCameron Grant static int ess_start(struct ess_chinfo *ch);
114fd1aaeccSCameron Grant static int ess_stop(struct ess_chinfo *ch);
115fd1aaeccSCameron Grant 
116fd1aaeccSCameron Grant static int ess_dmasetup(struct ess_info *sc, int ch, u_int32_t base, u_int16_t cnt, int dir);
117fd1aaeccSCameron Grant static int ess_dmapos(struct ess_info *sc, int ch);
118fd1aaeccSCameron Grant static int ess_dmatrigger(struct ess_info *sc, int ch, int go);
119fd1aaeccSCameron Grant 
120fd1aaeccSCameron Grant /*
121fd1aaeccSCameron Grant  * Common code for the midi and pcm functions
122fd1aaeccSCameron Grant  *
123fd1aaeccSCameron Grant  * ess_cmd write a single byte to the CMD port.
124fd1aaeccSCameron Grant  * ess_cmd1 write a CMD + 1 byte arg
125fd1aaeccSCameron Grant  * ess_cmd2 write a CMD + 2 byte arg
126fd1aaeccSCameron Grant  * ess_get_byte returns a single byte from the DSP data port
127fd1aaeccSCameron Grant  *
128fd1aaeccSCameron Grant  * ess_write is actually ess_cmd1
129fd1aaeccSCameron Grant  * ess_read access ext. regs via ess_cmd(0xc0, reg) followed by ess_get_byte
130fd1aaeccSCameron Grant  */
131fd1aaeccSCameron Grant 
132fd1aaeccSCameron Grant static int
133fd1aaeccSCameron Grant port_rd(struct resource *port, int regno, int size)
134fd1aaeccSCameron Grant {
135fd1aaeccSCameron Grant 	bus_space_tag_t st = rman_get_bustag(port);
136fd1aaeccSCameron Grant 	bus_space_handle_t sh = rman_get_bushandle(port);
137fd1aaeccSCameron Grant 
138fd1aaeccSCameron Grant 	switch (size) {
139fd1aaeccSCameron Grant 	case 1:
140fd1aaeccSCameron Grant 		return bus_space_read_1(st, sh, regno);
141fd1aaeccSCameron Grant 	case 2:
142fd1aaeccSCameron Grant 		return bus_space_read_2(st, sh, regno);
143fd1aaeccSCameron Grant 	case 4:
144fd1aaeccSCameron Grant 		return bus_space_read_4(st, sh, regno);
145fd1aaeccSCameron Grant 	default:
146fd1aaeccSCameron Grant 		return 0xffffffff;
147fd1aaeccSCameron Grant 	}
148fd1aaeccSCameron Grant }
149fd1aaeccSCameron Grant 
150fd1aaeccSCameron Grant static void
151fd1aaeccSCameron Grant port_wr(struct resource *port, int regno, u_int32_t data, int size)
152fd1aaeccSCameron Grant {
153fd1aaeccSCameron Grant 	bus_space_tag_t st = rman_get_bustag(port);
154fd1aaeccSCameron Grant 	bus_space_handle_t sh = rman_get_bushandle(port);
155fd1aaeccSCameron Grant 
156fd1aaeccSCameron Grant 	switch (size) {
157fd1aaeccSCameron Grant 	case 1:
158fd1aaeccSCameron Grant 		bus_space_write_1(st, sh, regno, data);
159fd1aaeccSCameron Grant 		break;
160fd1aaeccSCameron Grant 	case 2:
161fd1aaeccSCameron Grant 		bus_space_write_2(st, sh, regno, data);
162fd1aaeccSCameron Grant 		break;
163fd1aaeccSCameron Grant 	case 4:
164fd1aaeccSCameron Grant 		bus_space_write_4(st, sh, regno, data);
165fd1aaeccSCameron Grant 		break;
166fd1aaeccSCameron Grant 	}
167fd1aaeccSCameron Grant }
168fd1aaeccSCameron Grant 
169fd1aaeccSCameron Grant static int
170fd1aaeccSCameron Grant ess_rd(struct ess_info *sc, int reg)
171fd1aaeccSCameron Grant {
172fd1aaeccSCameron Grant 	return port_rd(sc->sb, reg, 1);
173fd1aaeccSCameron Grant }
174fd1aaeccSCameron Grant 
175fd1aaeccSCameron Grant static void
176fd1aaeccSCameron Grant ess_wr(struct ess_info *sc, int reg, u_int8_t val)
177fd1aaeccSCameron Grant {
178fd1aaeccSCameron Grant 	port_wr(sc->sb, reg, val, 1);
179fd1aaeccSCameron Grant }
180fd1aaeccSCameron Grant 
181fd1aaeccSCameron Grant static int
182fd1aaeccSCameron Grant ess_dspready(struct ess_info *sc)
183fd1aaeccSCameron Grant {
184fd1aaeccSCameron Grant 	return ((ess_rd(sc, SBDSP_STATUS) & 0x80) == 0);
185fd1aaeccSCameron Grant }
186fd1aaeccSCameron Grant 
187fd1aaeccSCameron Grant static int
188fd1aaeccSCameron Grant ess_dspwr(struct ess_info *sc, u_char val)
189fd1aaeccSCameron Grant {
190fd1aaeccSCameron Grant     	int  i;
191fd1aaeccSCameron Grant 
192fd1aaeccSCameron Grant     	for (i = 0; i < 1000; i++) {
193fd1aaeccSCameron Grant 		if (ess_dspready(sc)) {
194fd1aaeccSCameron Grant 	    		ess_wr(sc, SBDSP_CMD, val);
195fd1aaeccSCameron Grant 	    		return 1;
196fd1aaeccSCameron Grant 		}
197fd1aaeccSCameron Grant 		if (i > 10) DELAY((i > 100)? 1000 : 10);
198fd1aaeccSCameron Grant     	}
199fd1aaeccSCameron Grant     	printf("ess_dspwr(0x%02x) timed out.\n", val);
200fd1aaeccSCameron Grant     	return 0;
201fd1aaeccSCameron Grant }
202fd1aaeccSCameron Grant 
203fd1aaeccSCameron Grant static int
204fd1aaeccSCameron Grant ess_cmd(struct ess_info *sc, u_char val)
205fd1aaeccSCameron Grant {
206a7e11506SNick Sayer 	DEB(printf("ess_cmd: %x\n", val));
207fd1aaeccSCameron Grant     	return ess_dspwr(sc, val);
208fd1aaeccSCameron Grant }
209fd1aaeccSCameron Grant 
210fd1aaeccSCameron Grant static int
211fd1aaeccSCameron Grant ess_cmd1(struct ess_info *sc, u_char cmd, int val)
212fd1aaeccSCameron Grant {
213a7e11506SNick Sayer     	DEB(printf("ess_cmd1: %x, %x\n", cmd, val));
214fd1aaeccSCameron Grant     	if (ess_dspwr(sc, cmd)) {
215fd1aaeccSCameron Grant 		return ess_dspwr(sc, val & 0xff);
216fd1aaeccSCameron Grant     	} else return 0;
217fd1aaeccSCameron Grant }
218fd1aaeccSCameron Grant 
219fd1aaeccSCameron Grant static void
220fd1aaeccSCameron Grant ess_setmixer(struct ess_info *sc, u_int port, u_int value)
221fd1aaeccSCameron Grant {
222fd1aaeccSCameron Grant     	u_long   flags;
223fd1aaeccSCameron Grant 
224fd1aaeccSCameron Grant 	DEB(printf("ess_setmixer: reg=%x, val=%x\n", port, value);)
225fd1aaeccSCameron Grant     	flags = spltty();
226fd1aaeccSCameron Grant     	ess_wr(sc, SB_MIX_ADDR, (u_char) (port & 0xff)); /* Select register */
227fd1aaeccSCameron Grant     	DELAY(10);
228fd1aaeccSCameron Grant     	ess_wr(sc, SB_MIX_DATA, (u_char) (value & 0xff));
229fd1aaeccSCameron Grant     	DELAY(10);
230fd1aaeccSCameron Grant     	splx(flags);
231fd1aaeccSCameron Grant }
232fd1aaeccSCameron Grant 
233fd1aaeccSCameron Grant static int
234fd1aaeccSCameron Grant ess_getmixer(struct ess_info *sc, u_int port)
235fd1aaeccSCameron Grant {
236fd1aaeccSCameron Grant     	int val;
237fd1aaeccSCameron Grant     	u_long flags;
238fd1aaeccSCameron Grant 
239fd1aaeccSCameron Grant     	flags = spltty();
240fd1aaeccSCameron Grant     	ess_wr(sc, SB_MIX_ADDR, (u_char) (port & 0xff)); /* Select register */
241fd1aaeccSCameron Grant     	DELAY(10);
242fd1aaeccSCameron Grant     	val = ess_rd(sc, SB_MIX_DATA);
243fd1aaeccSCameron Grant     	DELAY(10);
244fd1aaeccSCameron Grant     	splx(flags);
245fd1aaeccSCameron Grant 
246fd1aaeccSCameron Grant     	return val;
247fd1aaeccSCameron Grant }
248fd1aaeccSCameron Grant 
249fd1aaeccSCameron Grant static int
250fd1aaeccSCameron Grant ess_get_byte(struct ess_info *sc)
251fd1aaeccSCameron Grant {
252fd1aaeccSCameron Grant     	int i;
253fd1aaeccSCameron Grant 
254fd1aaeccSCameron Grant     	for (i = 1000; i > 0; i--) {
2550edeb3dcSNick Sayer 		if (ess_rd(sc, 0xc) & 0x40)
256fd1aaeccSCameron Grant 			return ess_rd(sc, DSP_READ);
257fd1aaeccSCameron Grant 		else
258fd1aaeccSCameron Grant 			DELAY(20);
259fd1aaeccSCameron Grant     	}
260fd1aaeccSCameron Grant     	return -1;
261fd1aaeccSCameron Grant }
262fd1aaeccSCameron Grant 
263fd1aaeccSCameron Grant static int
264fd1aaeccSCameron Grant ess_write(struct ess_info *sc, u_char reg, int val)
265fd1aaeccSCameron Grant {
266fd1aaeccSCameron Grant     	return ess_cmd1(sc, reg, val);
267fd1aaeccSCameron Grant }
268fd1aaeccSCameron Grant 
269fd1aaeccSCameron Grant static int
270fd1aaeccSCameron Grant ess_read(struct ess_info *sc, u_char reg)
271fd1aaeccSCameron Grant {
272fd1aaeccSCameron Grant     	return (ess_cmd(sc, 0xc0) && ess_cmd(sc, reg))? ess_get_byte(sc) : -1;
273fd1aaeccSCameron Grant }
274fd1aaeccSCameron Grant 
275fd1aaeccSCameron Grant static int
276fd1aaeccSCameron Grant ess_reset_dsp(struct ess_info *sc)
277fd1aaeccSCameron Grant {
278a7e11506SNick Sayer 	DEB(printf("ess_reset_dsp\n"));
279fd1aaeccSCameron Grant     	ess_wr(sc, SBDSP_RST, 3);
280fd1aaeccSCameron Grant     	DELAY(100);
281fd1aaeccSCameron Grant     	ess_wr(sc, SBDSP_RST, 0);
282fd1aaeccSCameron Grant     	if (ess_get_byte(sc) != 0xAA) {
283a7e11506SNick Sayer         	DEB(printf("ess_reset_dsp failed\n"));
284a7e11506SNick Sayer /*
285fd1aaeccSCameron Grant 			   rman_get_start(d->io_base)));
286a7e11506SNick Sayer */
287fd1aaeccSCameron Grant 		return ENXIO;	/* Sorry */
288fd1aaeccSCameron Grant     	}
289fd1aaeccSCameron Grant     	ess_cmd(sc, 0xc6);
290fd1aaeccSCameron Grant     	return 0;
291fd1aaeccSCameron Grant }
292fd1aaeccSCameron Grant 
293fd1aaeccSCameron Grant static void
294fd1aaeccSCameron Grant ess_intr(void *arg)
295fd1aaeccSCameron Grant {
296fd1aaeccSCameron Grant     	struct ess_info *sc = (struct ess_info *)arg;
2973ac1ca33SNick Sayer 	int src, pirq = 0, rirq = 0;
298fd1aaeccSCameron Grant 
299fd1aaeccSCameron Grant 	src = 0;
300fd1aaeccSCameron Grant 	if (ess_getmixer(sc, 0x7a) & 0x80)
301fd1aaeccSCameron Grant 		src |= 2;
302fd1aaeccSCameron Grant 	if (ess_rd(sc, 0x0c) & 0x01)
303fd1aaeccSCameron Grant 		src |= 1;
304fd1aaeccSCameron Grant 
3054e77c048SCameron Grant 	if (src == 0)
3064e77c048SCameron Grant 		return;
3074e77c048SCameron Grant 
3083ac1ca33SNick Sayer 	if (sc->duplex) {
309fd1aaeccSCameron Grant 		pirq = (src & sc->pch.hwch)? 1 : 0;
310fd1aaeccSCameron Grant 		rirq = (src & sc->rch.hwch)? 1 : 0;
3113ac1ca33SNick Sayer 	} else {
3123ac1ca33SNick Sayer 		if (sc->simplex_dir == PCMDIR_PLAY)
3133ac1ca33SNick Sayer 			pirq = 1;
3143ac1ca33SNick Sayer 		if (sc->simplex_dir == PCMDIR_REC)
3153ac1ca33SNick Sayer 			rirq = 1;
3163ac1ca33SNick Sayer 		if (!pirq && !rirq)
3173ac1ca33SNick Sayer 			printf("solo: IRQ neither playback nor rec!\n");
3183ac1ca33SNick Sayer 	}
319fd1aaeccSCameron Grant 
320a7e11506SNick Sayer 	DEB(printf("ess_intr: pirq:%d rirq:%d\n",pirq,rirq));
321a7e11506SNick Sayer 
322fd1aaeccSCameron Grant 	if (pirq) {
323fd1aaeccSCameron Grant 		if (sc->pch.stopping) {
324fd1aaeccSCameron Grant 			ess_dmatrigger(sc, sc->pch.hwch, 0);
325fd1aaeccSCameron Grant 			sc->pch.stopping = 0;
326fd1aaeccSCameron Grant 			if (sc->pch.hwch == 1)
327fd1aaeccSCameron Grant 				ess_write(sc, 0xb8, ess_read(sc, 0xb8) & ~0x01);
328fd1aaeccSCameron Grant 			else
329fd1aaeccSCameron Grant 				ess_setmixer(sc, 0x78, ess_getmixer(sc, 0x78) & ~0x03);
330fd1aaeccSCameron Grant 		}
331fd1aaeccSCameron Grant 		chn_intr(sc->pch.channel);
332fd1aaeccSCameron Grant 	}
333fd1aaeccSCameron Grant 
334fd1aaeccSCameron Grant 	if (rirq) {
335fd1aaeccSCameron Grant 		if (sc->rch.stopping) {
336fd1aaeccSCameron Grant 			ess_dmatrigger(sc, sc->rch.hwch, 0);
337fd1aaeccSCameron Grant 			sc->rch.stopping = 0;
338fd1aaeccSCameron Grant 			/* XXX: will this stop audio2? */
339fd1aaeccSCameron Grant 			ess_write(sc, 0xb8, ess_read(sc, 0xb8) & ~0x01);
340fd1aaeccSCameron Grant 		}
341fd1aaeccSCameron Grant 		chn_intr(sc->rch.channel);
342fd1aaeccSCameron Grant 	}
343fd1aaeccSCameron Grant 
344fd1aaeccSCameron Grant 	if (src & 2)
345fd1aaeccSCameron Grant 		ess_setmixer(sc, 0x7a, ess_getmixer(sc, 0x7a) & ~0x80);
346fd1aaeccSCameron Grant 	if (src & 1)
347fd1aaeccSCameron Grant     		ess_rd(sc, DSP_DATA_AVAIL);
348fd1aaeccSCameron Grant }
349fd1aaeccSCameron Grant 
350fd1aaeccSCameron Grant /* utility functions for ESS */
351fd1aaeccSCameron Grant static u_int8_t
352fd1aaeccSCameron Grant ess_calcspeed8(int *spd)
353fd1aaeccSCameron Grant {
354fd1aaeccSCameron Grant 	int speed = *spd;
355fd1aaeccSCameron Grant 	u_int32_t t;
356fd1aaeccSCameron Grant 
357fd1aaeccSCameron Grant 	if (speed > 22000) {
358fd1aaeccSCameron Grant 		t = (795500 + speed / 2) / speed;
359fd1aaeccSCameron Grant 		speed = (795500 + t / 2) / t;
360fd1aaeccSCameron Grant 		t = (256 - t) | 0x80;
361fd1aaeccSCameron Grant 	} else {
362fd1aaeccSCameron Grant 		t = (397700 + speed / 2) / speed;
363fd1aaeccSCameron Grant 		speed = (397700 + t / 2) / t;
364fd1aaeccSCameron Grant 		t = 128 - t;
365fd1aaeccSCameron Grant 	}
366fd1aaeccSCameron Grant 	*spd = speed;
367fd1aaeccSCameron Grant 	return t & 0x000000ff;
368fd1aaeccSCameron Grant }
369fd1aaeccSCameron Grant 
370fd1aaeccSCameron Grant static u_int8_t
371fd1aaeccSCameron Grant ess_calcspeed9(int *spd)
372fd1aaeccSCameron Grant {
373fd1aaeccSCameron Grant 	int speed, s0, s1, use0;
374fd1aaeccSCameron Grant 	u_int8_t t0, t1;
375fd1aaeccSCameron Grant 
376fd1aaeccSCameron Grant 	/* rate = source / (256 - divisor) */
377fd1aaeccSCameron Grant 	/* divisor = 256 - (source / rate) */
378fd1aaeccSCameron Grant 	speed = *spd;
379fd1aaeccSCameron Grant 	t0 = 128 - (793800 / speed);
380fd1aaeccSCameron Grant 	s0 = 793800 / (128 - t0);
381fd1aaeccSCameron Grant 
382fd1aaeccSCameron Grant 	t1 = 128 - (768000 / speed);
383fd1aaeccSCameron Grant 	s1 = 768000 / (128 - t1);
384fd1aaeccSCameron Grant 	t1 |= 0x80;
385fd1aaeccSCameron Grant 
386fd1aaeccSCameron Grant 	use0 = (ABS(speed - s0) < ABS(speed - s1))? 1 : 0;
387fd1aaeccSCameron Grant 
388fd1aaeccSCameron Grant 	*spd = use0? s0 : s1;
389fd1aaeccSCameron Grant 	return use0? t0 : t1;
390fd1aaeccSCameron Grant }
391fd1aaeccSCameron Grant 
392fd1aaeccSCameron Grant static u_int8_t
393fd1aaeccSCameron Grant ess_calcfilter(int spd)
394fd1aaeccSCameron Grant {
395fd1aaeccSCameron Grant 	int cutoff;
396fd1aaeccSCameron Grant 
397fd1aaeccSCameron Grant 	/* cutoff = 7160000 / (256 - divisor) */
398fd1aaeccSCameron Grant 	/* divisor = 256 - (7160000 / cutoff) */
399fd1aaeccSCameron Grant 	cutoff = (spd * 9 * 82) / 20;
400fd1aaeccSCameron Grant 	return (256 - (7160000 / cutoff));
401fd1aaeccSCameron Grant }
402fd1aaeccSCameron Grant 
403fd1aaeccSCameron Grant static int
404fd1aaeccSCameron Grant ess_setupch(struct ess_info *sc, int ch, int dir, int spd, u_int32_t fmt, int len)
405fd1aaeccSCameron Grant {
406fd1aaeccSCameron Grant 	int play = (dir == PCMDIR_PLAY)? 1 : 0;
407fd1aaeccSCameron Grant 	int b16 = (fmt & AFMT_16BIT)? 1 : 0;
408fd1aaeccSCameron Grant 	int stereo = (fmt & AFMT_STEREO)? 1 : 0;
4093ac1ca33SNick Sayer 	int unsign = (fmt == AFMT_U8 || fmt == AFMT_U16_LE || fmt == AFMT_U16_BE)? 1 : 0;
410fd1aaeccSCameron Grant 	u_int8_t spdval, fmtval;
411fd1aaeccSCameron Grant 
412a7e11506SNick Sayer 	DEB(printf("ess_setupch\n"));
413fd1aaeccSCameron Grant 	spdval = (sc->newspeed)? ess_calcspeed9(&spd) : ess_calcspeed8(&spd);
414fd1aaeccSCameron Grant 
4153ac1ca33SNick Sayer 	sc->simplex_dir = play ? PCMDIR_PLAY : PCMDIR_REC ;
4163ac1ca33SNick Sayer 
417fd1aaeccSCameron Grant 	if (ch == 1) {
418fd1aaeccSCameron Grant 		KASSERT((dir == PCMDIR_PLAY) || (dir == PCMDIR_REC), ("ess_setupch: dir1 bad"));
419fd1aaeccSCameron Grant 		len = -len;
420fd1aaeccSCameron Grant 		/* transfer length low */
421fd1aaeccSCameron Grant 		ess_write(sc, 0xa4, len & 0x00ff);
422fd1aaeccSCameron Grant 		/* transfer length high */
423fd1aaeccSCameron Grant 		ess_write(sc, 0xa5, (len & 0xff00) >> 8);
424fd1aaeccSCameron Grant 		/* autoinit, dma dir */
425a7e11506SNick Sayer 		ess_write(sc, 0xb8, 0x04 | (play? 0x00 : 0x0a));
426fd1aaeccSCameron Grant 		/* mono/stereo */
427fd1aaeccSCameron Grant 		ess_write(sc, 0xa8, (ess_read(sc, 0xa8) & ~0x03) | (stereo? 0x01 : 0x02));
428fd1aaeccSCameron Grant 		/* demand mode, 4 bytes/xfer */
429fd1aaeccSCameron Grant 		ess_write(sc, 0xb9, 0x02);
430fd1aaeccSCameron Grant 		/* sample rate */
431fd1aaeccSCameron Grant         	ess_write(sc, 0xa1, spdval);
432fd1aaeccSCameron Grant 		/* filter cutoff */
433fd1aaeccSCameron Grant 		ess_write(sc, 0xa2, ess_calcfilter(spd));
434fd1aaeccSCameron Grant 		/* setup dac/adc */
435fd1aaeccSCameron Grant 		/*
436fd1aaeccSCameron Grant 		if (play)
437fd1aaeccSCameron Grant 			ess_write(sc, 0xb6, unsign? 0x80 : 0x00);
438fd1aaeccSCameron Grant 		*/
439fd1aaeccSCameron Grant 		/* mono, b16: signed, load signal */
440fd1aaeccSCameron Grant 		/*
441fd1aaeccSCameron Grant 		ess_write(sc, 0xb7, 0x51 | (unsign? 0x00 : 0x20));
442fd1aaeccSCameron Grant 		*/
443fd1aaeccSCameron Grant 		/* setup fifo */
444a7e11506SNick Sayer 		ess_write(sc, 0xb7, 0x91 | (unsign? 0x00 : 0x20) |
445fd1aaeccSCameron Grant 					   (b16? 0x04 : 0x00) |
446fd1aaeccSCameron Grant 					   (stereo? 0x08 : 0x40));
447fd1aaeccSCameron Grant 		/* irq control */
448fd1aaeccSCameron Grant 		ess_write(sc, 0xb1, (ess_read(sc, 0xb1) & 0x0f) | 0x50);
449fd1aaeccSCameron Grant 		/* drq control */
450fd1aaeccSCameron Grant 		ess_write(sc, 0xb2, (ess_read(sc, 0xb2) & 0x0f) | 0x50);
451fd1aaeccSCameron Grant 	} else if (ch == 2) {
452fd1aaeccSCameron Grant 		KASSERT(dir == PCMDIR_PLAY, ("ess_setupch: dir2 bad"));
453fd1aaeccSCameron Grant 		len >>= 1;
454fd1aaeccSCameron Grant 		len = -len;
455fd1aaeccSCameron Grant 		/* transfer length low */
456fd1aaeccSCameron Grant 		ess_setmixer(sc, 0x74, len & 0x00ff);
457fd1aaeccSCameron Grant 		/* transfer length high */
458fd1aaeccSCameron Grant 		ess_setmixer(sc, 0x76, (len & 0xff00) >> 8);
459fd1aaeccSCameron Grant 		/* autoinit, 4 bytes/req */
460fd1aaeccSCameron Grant 		ess_setmixer(sc, 0x78, 0x10);
46180a8e065SNick Sayer 		fmtval = b16 | (stereo << 1) | ((!unsign) << 2);
462fd1aaeccSCameron Grant 		/* enable irq, set format */
463fd1aaeccSCameron Grant 		ess_setmixer(sc, 0x7a, 0x40 | fmtval);
464fd1aaeccSCameron Grant 		if (sc->newspeed) {
465fd1aaeccSCameron Grant 			/* sample rate */
466fd1aaeccSCameron Grant 			ess_setmixer(sc, 0x70, spdval);
467fd1aaeccSCameron Grant 			/* filter cutoff */
468fd1aaeccSCameron Grant 			ess_setmixer(sc, 0x72, ess_calcfilter(spd));
469fd1aaeccSCameron Grant 		}
470fd1aaeccSCameron Grant 
471fd1aaeccSCameron Grant 	}
472fd1aaeccSCameron Grant 	return 0;
473fd1aaeccSCameron Grant }
474fd1aaeccSCameron Grant static int
475fd1aaeccSCameron Grant ess_start(struct ess_chinfo *ch)
476fd1aaeccSCameron Grant {
477fd1aaeccSCameron Grant 	struct ess_info *sc = ch->parent;
478fd1aaeccSCameron Grant 
479a7e11506SNick Sayer 	DEB(printf("ess_start\n"););
480350a5fafSCameron Grant 	ess_setupch(sc, ch->hwch, ch->dir, ch->spd, ch->fmt, ch->blksz);
481fd1aaeccSCameron Grant 	ch->stopping = 0;
48219a0702eSNick Sayer 	if (ch->hwch == 1) {
483fd1aaeccSCameron Grant 		ess_write(sc, 0xb8, ess_read(sc, 0xb8) | 0x01);
48419a0702eSNick Sayer 		if (ch->dir == PCMDIR_PLAY) {
4850edeb3dcSNick Sayer #if 0
48619a0702eSNick Sayer 			DELAY(100000); /* 100 ms */
4870edeb3dcSNick Sayer #endif
48819a0702eSNick Sayer 			ess_cmd(sc, 0xd1);
48919a0702eSNick Sayer 		}
49019a0702eSNick Sayer 	} else
491fd1aaeccSCameron Grant 		ess_setmixer(sc, 0x78, ess_getmixer(sc, 0x78) | 0x03);
492fd1aaeccSCameron Grant 	return 0;
493fd1aaeccSCameron Grant }
494fd1aaeccSCameron Grant 
495fd1aaeccSCameron Grant static int
496fd1aaeccSCameron Grant ess_stop(struct ess_chinfo *ch)
497fd1aaeccSCameron Grant {
498fd1aaeccSCameron Grant 	struct ess_info *sc = ch->parent;
499fd1aaeccSCameron Grant 
500a7e11506SNick Sayer 	DEB(printf("ess_stop\n"));
501fd1aaeccSCameron Grant 	ch->stopping = 1;
502fd1aaeccSCameron Grant 	if (ch->hwch == 1)
503fd1aaeccSCameron Grant 		ess_write(sc, 0xb8, ess_read(sc, 0xb8) & ~0x04);
504fd1aaeccSCameron Grant 	else
505fd1aaeccSCameron Grant 		ess_setmixer(sc, 0x78, ess_getmixer(sc, 0x78) & ~0x10);
506a7e11506SNick Sayer 	DEB(printf("done with stop\n"));
507fd1aaeccSCameron Grant 	return 0;
508fd1aaeccSCameron Grant }
509fd1aaeccSCameron Grant 
5100f55ac6cSCameron Grant /* -------------------------------------------------------------------- */
511fd1aaeccSCameron Grant /* channel interface for ESS18xx */
512fd1aaeccSCameron Grant static void *
51366ef8af5SCameron Grant esschan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
514fd1aaeccSCameron Grant {
515fd1aaeccSCameron Grant 	struct ess_info *sc = devinfo;
516fd1aaeccSCameron Grant 	struct ess_chinfo *ch = (dir == PCMDIR_PLAY)? &sc->pch : &sc->rch;
517fd1aaeccSCameron Grant 
518a7e11506SNick Sayer 	DEB(printf("esschan_init\n"));
519fd1aaeccSCameron Grant 	ch->parent = sc;
520fd1aaeccSCameron Grant 	ch->channel = c;
521fd1aaeccSCameron Grant 	ch->buffer = b;
522306f91b6SCameron Grant 	ch->dir = dir;
52339dbd126SCameron Grant 	if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) == -1)
524fd1aaeccSCameron Grant 		return NULL;
525fd1aaeccSCameron Grant 	ch->hwch = 1;
526fd1aaeccSCameron Grant 	if ((dir == PCMDIR_PLAY) && (sc->duplex))
527fd1aaeccSCameron Grant 		ch->hwch = 2;
528fd1aaeccSCameron Grant 	return ch;
529fd1aaeccSCameron Grant }
530fd1aaeccSCameron Grant 
531fd1aaeccSCameron Grant static int
5320f55ac6cSCameron Grant esschan_setformat(kobj_t obj, void *data, u_int32_t format)
533fd1aaeccSCameron Grant {
534fd1aaeccSCameron Grant 	struct ess_chinfo *ch = data;
535fd1aaeccSCameron Grant 
536fd1aaeccSCameron Grant 	ch->fmt = format;
537fd1aaeccSCameron Grant 	return 0;
538fd1aaeccSCameron Grant }
539fd1aaeccSCameron Grant 
540fd1aaeccSCameron Grant static int
5410f55ac6cSCameron Grant esschan_setspeed(kobj_t obj, void *data, u_int32_t speed)
542fd1aaeccSCameron Grant {
543fd1aaeccSCameron Grant 	struct ess_chinfo *ch = data;
544fd1aaeccSCameron Grant 	struct ess_info *sc = ch->parent;
545fd1aaeccSCameron Grant 
546fd1aaeccSCameron Grant 	ch->spd = speed;
547fd1aaeccSCameron Grant 	if (sc->newspeed)
548fd1aaeccSCameron Grant 		ess_calcspeed9(&ch->spd);
549fd1aaeccSCameron Grant 	else
550fd1aaeccSCameron Grant 		ess_calcspeed8(&ch->spd);
551fd1aaeccSCameron Grant 	return ch->spd;
552fd1aaeccSCameron Grant }
553fd1aaeccSCameron Grant 
554fd1aaeccSCameron Grant static int
5550f55ac6cSCameron Grant esschan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
556fd1aaeccSCameron Grant {
557350a5fafSCameron Grant 	struct ess_chinfo *ch = data;
558350a5fafSCameron Grant 
559350a5fafSCameron Grant 	ch->blksz = blocksize;
560350a5fafSCameron Grant 	return ch->blksz;
561fd1aaeccSCameron Grant }
562fd1aaeccSCameron Grant 
563fd1aaeccSCameron Grant static int
5640f55ac6cSCameron Grant esschan_trigger(kobj_t obj, void *data, int go)
565fd1aaeccSCameron Grant {
566fd1aaeccSCameron Grant 	struct ess_chinfo *ch = data;
567fd1aaeccSCameron Grant 	struct ess_info *sc = ch->parent;
568fd1aaeccSCameron Grant 
569a7e11506SNick Sayer 	DEB(printf("esschan_trigger: %d\n",go));
570fd1aaeccSCameron Grant 	if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD)
571fd1aaeccSCameron Grant 		return 0;
572fd1aaeccSCameron Grant 
573fd1aaeccSCameron Grant 	switch (go) {
574fd1aaeccSCameron Grant 	case PCMTRIG_START:
575350a5fafSCameron Grant 		ess_dmasetup(sc, ch->hwch, vtophys(sndbuf_getbuf(ch->buffer)), sndbuf_getsize(ch->buffer), ch->dir);
576fd1aaeccSCameron Grant 		ess_dmatrigger(sc, ch->hwch, 1);
577fd1aaeccSCameron Grant 		ess_start(ch);
578fd1aaeccSCameron Grant 		break;
579fd1aaeccSCameron Grant 
580fd1aaeccSCameron Grant 	case PCMTRIG_STOP:
581fd1aaeccSCameron Grant 	case PCMTRIG_ABORT:
582fd1aaeccSCameron Grant 	default:
583fd1aaeccSCameron Grant 		ess_stop(ch);
584fd1aaeccSCameron Grant 		break;
585fd1aaeccSCameron Grant 	}
586fd1aaeccSCameron Grant 	return 0;
587fd1aaeccSCameron Grant }
588fd1aaeccSCameron Grant 
589fd1aaeccSCameron Grant static int
5900f55ac6cSCameron Grant esschan_getptr(kobj_t obj, void *data)
591fd1aaeccSCameron Grant {
592fd1aaeccSCameron Grant 	struct ess_chinfo *ch = data;
593fd1aaeccSCameron Grant 	struct ess_info *sc = ch->parent;
594fd1aaeccSCameron Grant 
595fd1aaeccSCameron Grant 	return ess_dmapos(sc, ch->hwch);
596fd1aaeccSCameron Grant }
597fd1aaeccSCameron Grant 
59866ef8af5SCameron Grant static struct pcmchan_caps *
5990f55ac6cSCameron Grant esschan_getcaps(kobj_t obj, void *data)
600fd1aaeccSCameron Grant {
601fd1aaeccSCameron Grant 	struct ess_chinfo *ch = data;
602fd1aaeccSCameron Grant 
603fd1aaeccSCameron Grant 	return (ch->dir == PCMDIR_PLAY)? &ess_playcaps : &ess_reccaps;
604fd1aaeccSCameron Grant }
605fd1aaeccSCameron Grant 
6060f55ac6cSCameron Grant static kobj_method_t esschan_methods[] = {
6070f55ac6cSCameron Grant     	KOBJMETHOD(channel_init,		esschan_init),
6080f55ac6cSCameron Grant     	KOBJMETHOD(channel_setformat,		esschan_setformat),
6090f55ac6cSCameron Grant     	KOBJMETHOD(channel_setspeed,		esschan_setspeed),
6100f55ac6cSCameron Grant     	KOBJMETHOD(channel_setblocksize,	esschan_setblocksize),
6110f55ac6cSCameron Grant     	KOBJMETHOD(channel_trigger,		esschan_trigger),
6120f55ac6cSCameron Grant     	KOBJMETHOD(channel_getptr,		esschan_getptr),
6130f55ac6cSCameron Grant     	KOBJMETHOD(channel_getcaps,		esschan_getcaps),
6140f55ac6cSCameron Grant 	{ 0, 0 }
6150f55ac6cSCameron Grant };
6160f55ac6cSCameron Grant CHANNEL_DECLARE(esschan);
6170f55ac6cSCameron Grant 
618fd1aaeccSCameron Grant /************************************************************/
619fd1aaeccSCameron Grant 
620fd1aaeccSCameron Grant static int
62166ef8af5SCameron Grant essmix_init(struct snd_mixer *m)
622fd1aaeccSCameron Grant {
623fd1aaeccSCameron Grant     	struct ess_info *sc = mix_getdevinfo(m);
624fd1aaeccSCameron Grant 
625fd1aaeccSCameron Grant 	mix_setrecdevs(m, SOUND_MASK_CD | SOUND_MASK_MIC | SOUND_MASK_LINE |
626fd1aaeccSCameron Grant 			  SOUND_MASK_IMIX);
627fd1aaeccSCameron Grant 
628fd1aaeccSCameron Grant 	mix_setdevs(m, SOUND_MASK_SYNTH | SOUND_MASK_PCM | SOUND_MASK_LINE |
629fd1aaeccSCameron Grant 		       SOUND_MASK_MIC | SOUND_MASK_CD | SOUND_MASK_VOLUME |
630fd1aaeccSCameron Grant 		       SOUND_MASK_LINE1);
631fd1aaeccSCameron Grant 
632fd1aaeccSCameron Grant 	ess_setmixer(sc, 0, 0); /* reset */
633fd1aaeccSCameron Grant 
634fd1aaeccSCameron Grant 	return 0;
635fd1aaeccSCameron Grant }
636fd1aaeccSCameron Grant 
637fd1aaeccSCameron Grant static int
63866ef8af5SCameron Grant essmix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
639fd1aaeccSCameron Grant {
640fd1aaeccSCameron Grant     	struct ess_info *sc = mix_getdevinfo(m);
641fd1aaeccSCameron Grant     	int preg = 0, rreg = 0, l, r;
642fd1aaeccSCameron Grant 
643fd1aaeccSCameron Grant 	l = (left * 15) / 100;
644fd1aaeccSCameron Grant 	r = (right * 15) / 100;
645fd1aaeccSCameron Grant 	switch (dev) {
646fd1aaeccSCameron Grant 	case SOUND_MIXER_SYNTH:
647fd1aaeccSCameron Grant 		preg = 0x36;
648fd1aaeccSCameron Grant 		rreg = 0x6b;
649fd1aaeccSCameron Grant 		break;
650fd1aaeccSCameron Grant 
651fd1aaeccSCameron Grant 	case SOUND_MIXER_PCM:
652fd1aaeccSCameron Grant 		preg = 0x14;
653fd1aaeccSCameron Grant 		rreg = 0x7c;
654fd1aaeccSCameron Grant 		break;
655fd1aaeccSCameron Grant 
656fd1aaeccSCameron Grant 	case SOUND_MIXER_LINE:
657fd1aaeccSCameron Grant 		preg = 0x3e;
658fd1aaeccSCameron Grant 		rreg = 0x6e;
659fd1aaeccSCameron Grant 		break;
660fd1aaeccSCameron Grant 
661fd1aaeccSCameron Grant 	case SOUND_MIXER_MIC:
662fd1aaeccSCameron Grant 		preg = 0x1a;
663fd1aaeccSCameron Grant 		rreg = 0x68;
664fd1aaeccSCameron Grant 		break;
665fd1aaeccSCameron Grant 
666fd1aaeccSCameron Grant 	case SOUND_MIXER_LINE1:
667fd1aaeccSCameron Grant 		preg = 0x3a;
668fd1aaeccSCameron Grant 		rreg = 0x6c;
669fd1aaeccSCameron Grant 		break;
670fd1aaeccSCameron Grant 
671fd1aaeccSCameron Grant 	case SOUND_MIXER_CD:
672fd1aaeccSCameron Grant 		preg = 0x38;
673fd1aaeccSCameron Grant 		rreg = 0x6a;
674fd1aaeccSCameron Grant 		break;
675fd1aaeccSCameron Grant 
676fd1aaeccSCameron Grant 	case SOUND_MIXER_VOLUME:
677fd1aaeccSCameron Grant 		l = left? (left * 63) / 100 : 64;
678fd1aaeccSCameron Grant 		r = right? (right * 63) / 100 : 64;
679fd1aaeccSCameron Grant 		ess_setmixer(sc, 0x60, l);
680fd1aaeccSCameron Grant 		ess_setmixer(sc, 0x62, r);
681fd1aaeccSCameron Grant 		left = (l == 64)? 0 : (l * 100) / 63;
682fd1aaeccSCameron Grant 		right = (r == 64)? 0 : (r * 100) / 63;
683fd1aaeccSCameron Grant     		return left | (right << 8);
684fd1aaeccSCameron Grant 	}
685fd1aaeccSCameron Grant 
686fd1aaeccSCameron Grant 	if (preg)
687fd1aaeccSCameron Grant 		ess_setmixer(sc, preg, (l << 4) | r);
688fd1aaeccSCameron Grant 	if (rreg)
689fd1aaeccSCameron Grant 		ess_setmixer(sc, rreg, (l << 4) | r);
690fd1aaeccSCameron Grant 
691fd1aaeccSCameron Grant 	left = (l * 100) / 15;
692fd1aaeccSCameron Grant 	right = (r * 100) / 15;
693fd1aaeccSCameron Grant 
694fd1aaeccSCameron Grant     	return left | (right << 8);
695fd1aaeccSCameron Grant }
696fd1aaeccSCameron Grant 
697fd1aaeccSCameron Grant static int
69866ef8af5SCameron Grant essmix_setrecsrc(struct snd_mixer *m, u_int32_t src)
699fd1aaeccSCameron Grant {
700fd1aaeccSCameron Grant     	struct ess_info *sc = mix_getdevinfo(m);
701fd1aaeccSCameron Grant     	u_char recdev;
702fd1aaeccSCameron Grant 
703fd1aaeccSCameron Grant     	switch (src) {
704fd1aaeccSCameron Grant 	case SOUND_MASK_CD:
705fd1aaeccSCameron Grant 		recdev = 0x02;
706fd1aaeccSCameron Grant 		break;
707fd1aaeccSCameron Grant 
708fd1aaeccSCameron Grant 	case SOUND_MASK_LINE:
709fd1aaeccSCameron Grant 		recdev = 0x06;
710fd1aaeccSCameron Grant 		break;
711fd1aaeccSCameron Grant 
712fd1aaeccSCameron Grant 	case SOUND_MASK_IMIX:
713fd1aaeccSCameron Grant 		recdev = 0x05;
714fd1aaeccSCameron Grant 		break;
715fd1aaeccSCameron Grant 
716fd1aaeccSCameron Grant 	case SOUND_MASK_MIC:
717fd1aaeccSCameron Grant 	default:
718fd1aaeccSCameron Grant 		recdev = 0x00;
719fd1aaeccSCameron Grant 		src = SOUND_MASK_MIC;
720fd1aaeccSCameron Grant 		break;
721fd1aaeccSCameron Grant 	}
722fd1aaeccSCameron Grant 
723fd1aaeccSCameron Grant 	ess_setmixer(sc, 0x1c, recdev);
724fd1aaeccSCameron Grant 
725fd1aaeccSCameron Grant 	return src;
726fd1aaeccSCameron Grant }
727fd1aaeccSCameron Grant 
7280f55ac6cSCameron Grant static kobj_method_t solomixer_methods[] = {
7290f55ac6cSCameron Grant     	KOBJMETHOD(mixer_init,		essmix_init),
7300f55ac6cSCameron Grant     	KOBJMETHOD(mixer_set,		essmix_set),
7310f55ac6cSCameron Grant     	KOBJMETHOD(mixer_setrecsrc,	essmix_setrecsrc),
7320f55ac6cSCameron Grant 	{ 0, 0 }
7330f55ac6cSCameron Grant };
7340f55ac6cSCameron Grant MIXER_DECLARE(solomixer);
7350f55ac6cSCameron Grant 
736fd1aaeccSCameron Grant /************************************************************/
737fd1aaeccSCameron Grant 
738fd1aaeccSCameron Grant static int
739fd1aaeccSCameron Grant ess_dmasetup(struct ess_info *sc, int ch, u_int32_t base, u_int16_t cnt, int dir)
740fd1aaeccSCameron Grant {
741fd1aaeccSCameron Grant 	KASSERT(ch == 1 || ch == 2, ("bad ch"));
742fd1aaeccSCameron Grant 	sc->dmasz[ch - 1] = cnt;
743fd1aaeccSCameron Grant 	if (ch == 1) {
74419a0702eSNick Sayer 		port_wr(sc->vc, 0x8, 0xc4, 1); /* command */
745fd1aaeccSCameron Grant 		port_wr(sc->vc, 0xd, 0xff, 1); /* reset */
746fd1aaeccSCameron Grant 		port_wr(sc->vc, 0xf, 0x01, 1); /* mask */
74719a0702eSNick Sayer 		port_wr(sc->vc, 0xb, dir == PCMDIR_PLAY? 0x58 : 0x54, 1); /* mode */
748fd1aaeccSCameron Grant 		port_wr(sc->vc, 0x0, base, 4);
749bb7f26c3SNick Sayer 		port_wr(sc->vc, 0x4, cnt - 1, 2);
750fd1aaeccSCameron Grant 
751fd1aaeccSCameron Grant 	} else if (ch == 2) {
752fd1aaeccSCameron Grant 		port_wr(sc->io, 0x6, 0x08, 1); /* autoinit */
753fd1aaeccSCameron Grant 		port_wr(sc->io, 0x0, base, 4);
754fd1aaeccSCameron Grant 		port_wr(sc->io, 0x4, cnt, 2);
755fd1aaeccSCameron Grant 	}
756fd1aaeccSCameron Grant 	return 0;
757fd1aaeccSCameron Grant }
758fd1aaeccSCameron Grant 
759fd1aaeccSCameron Grant static int
760fd1aaeccSCameron Grant ess_dmapos(struct ess_info *sc, int ch)
761fd1aaeccSCameron Grant {
7626ba60b3cSNick Sayer 	int p = 0, i = 0, j = 0;
7630edeb3dcSNick Sayer 	u_long flags;
764fd1aaeccSCameron Grant 
765fd1aaeccSCameron Grant 	KASSERT(ch == 1 || ch == 2, ("bad ch"));
7660edeb3dcSNick Sayer 	flags = spltty();
7670edeb3dcSNick Sayer 	if (ch == 1) {
7680edeb3dcSNick Sayer 
7690edeb3dcSNick Sayer /*
7700edeb3dcSNick Sayer  * During recording, this register is known to give back
7710edeb3dcSNick Sayer  * garbage if it's not quiescent while being read. That's
7726ba60b3cSNick Sayer  * why we spl, stop the DMA, and try over and over until
7736ba60b3cSNick Sayer  * adjacent reads are "close", in the right order and not
7746ba60b3cSNick Sayer  * bigger than is otherwise possible.
7750edeb3dcSNick Sayer  */
7760edeb3dcSNick Sayer 		ess_dmatrigger(sc, ch, 0);
7770edeb3dcSNick Sayer 		DELAY(20);
7786ba60b3cSNick Sayer 		do {
7796ba60b3cSNick Sayer 			DELAY(10);
7806ba60b3cSNick Sayer 			if (j > 1)
7816ba60b3cSNick Sayer 				printf("DMA count reg bogus: %04x & %04x\n",
7826ba60b3cSNick Sayer 					i, p);
7836ba60b3cSNick Sayer 			i = port_rd(sc->vc, 0x4, 2) + 1;
784fd1aaeccSCameron Grant 			p = port_rd(sc->vc, 0x4, 2) + 1;
7856ba60b3cSNick Sayer 		} while ((p > sc->dmasz[ch - 1] || i < p || (p - i) > 0x8) && j++ < 1000);
7860edeb3dcSNick Sayer 		ess_dmatrigger(sc, ch, 1);
7870edeb3dcSNick Sayer 	}
788fd1aaeccSCameron Grant 	else if (ch == 2)
789fd1aaeccSCameron Grant 		p = port_rd(sc->io, 0x4, 2);
7900edeb3dcSNick Sayer 	splx(flags);
791fd1aaeccSCameron Grant 	return sc->dmasz[ch - 1] - p;
792fd1aaeccSCameron Grant }
793fd1aaeccSCameron Grant 
794fd1aaeccSCameron Grant static int
795fd1aaeccSCameron Grant ess_dmatrigger(struct ess_info *sc, int ch, int go)
796fd1aaeccSCameron Grant {
797fd1aaeccSCameron Grant 	KASSERT(ch == 1 || ch == 2, ("bad ch"));
798fd1aaeccSCameron Grant 	if (ch == 1)
7998eb3acc9SNick Sayer 		port_wr(sc->vc, 0xf, go? 0x00 : 0x01, 1); /* mask */
800fd1aaeccSCameron Grant 	else if (ch == 2)
801fd1aaeccSCameron Grant 		port_wr(sc->io, 0x6, 0x08 | (go? 0x02 : 0x00), 1); /* autoinit */
802fd1aaeccSCameron Grant 	return 0;
803fd1aaeccSCameron Grant }
804fd1aaeccSCameron Grant 
805fd1aaeccSCameron Grant static void
806fd1aaeccSCameron Grant ess_release_resources(struct ess_info *sc, device_t dev)
807fd1aaeccSCameron Grant {
808fd1aaeccSCameron Grant     	if (sc->irq) {
809306f91b6SCameron Grant 		if (sc->ih)
810306f91b6SCameron Grant 			bus_teardown_intr(dev, sc->irq, sc->ih);
811fd1aaeccSCameron Grant 		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq);
812fd1aaeccSCameron Grant 		sc->irq = 0;
813fd1aaeccSCameron Grant     	}
814fd1aaeccSCameron Grant     	if (sc->io) {
815fd1aaeccSCameron Grant 		bus_release_resource(dev, SYS_RES_IOPORT, 0 * 4 + PCIR_MAPS, sc->io);
816fd1aaeccSCameron Grant 		sc->io = 0;
817fd1aaeccSCameron Grant     	}
818fd1aaeccSCameron Grant 
819fd1aaeccSCameron Grant     	if (sc->sb) {
820fd1aaeccSCameron Grant 		bus_release_resource(dev, SYS_RES_IOPORT, 1 * 4 + PCIR_MAPS, sc->sb);
821fd1aaeccSCameron Grant 		sc->sb = 0;
822fd1aaeccSCameron Grant     	}
823fd1aaeccSCameron Grant 
824fd1aaeccSCameron Grant     	if (sc->vc) {
825fd1aaeccSCameron Grant 		bus_release_resource(dev, SYS_RES_IOPORT, 2 * 4 + PCIR_MAPS, sc->vc);
826fd1aaeccSCameron Grant 		sc->vc = 0;
827fd1aaeccSCameron Grant     	}
828fd1aaeccSCameron Grant 
829fd1aaeccSCameron Grant     	if (sc->mpu) {
830fd1aaeccSCameron Grant 		bus_release_resource(dev, SYS_RES_IOPORT, 3 * 4 + PCIR_MAPS, sc->mpu);
831fd1aaeccSCameron Grant 		sc->mpu = 0;
832fd1aaeccSCameron Grant     	}
833fd1aaeccSCameron Grant 
834fd1aaeccSCameron Grant     	if (sc->gp) {
835fd1aaeccSCameron Grant 		bus_release_resource(dev, SYS_RES_IOPORT, 4 * 4 + PCIR_MAPS, sc->gp);
836fd1aaeccSCameron Grant 		sc->gp = 0;
837fd1aaeccSCameron Grant     	}
838fd1aaeccSCameron Grant 
839306f91b6SCameron Grant 	if (sc->parent_dmat) {
840306f91b6SCameron Grant 		bus_dma_tag_destroy(sc->parent_dmat);
841306f91b6SCameron Grant 		sc->parent_dmat = 0;
842306f91b6SCameron Grant     	}
843306f91b6SCameron Grant 
844fd1aaeccSCameron Grant     	free(sc, M_DEVBUF);
845fd1aaeccSCameron Grant }
846fd1aaeccSCameron Grant 
847fd1aaeccSCameron Grant static int
848fd1aaeccSCameron Grant ess_alloc_resources(struct ess_info *sc, device_t dev)
849fd1aaeccSCameron Grant {
850fd1aaeccSCameron Grant 	int rid;
851fd1aaeccSCameron Grant 
852fd1aaeccSCameron Grant 	rid = 0 * 4 + PCIR_MAPS;
853fd1aaeccSCameron Grant     	sc->io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE);
854fd1aaeccSCameron Grant 
855fd1aaeccSCameron Grant 	rid = 1 * 4 + PCIR_MAPS;
856fd1aaeccSCameron Grant     	sc->sb = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE);
857fd1aaeccSCameron Grant 
858fd1aaeccSCameron Grant 	rid = 2 * 4 + PCIR_MAPS;
859fd1aaeccSCameron Grant     	sc->vc = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE);
860fd1aaeccSCameron Grant 
861fd1aaeccSCameron Grant 	rid = 3 * 4 + PCIR_MAPS;
862fd1aaeccSCameron Grant     	sc->mpu = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE);
863fd1aaeccSCameron Grant 
864fd1aaeccSCameron Grant 	rid = 4 * 4 + PCIR_MAPS;
865fd1aaeccSCameron Grant     	sc->gp = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE);
866fd1aaeccSCameron Grant 
867fd1aaeccSCameron Grant 	rid = 0;
868fd1aaeccSCameron Grant 	sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE);
869fd1aaeccSCameron Grant 
870fd1aaeccSCameron Grant 	return (sc->irq && sc->io && sc->sb && sc->vc && sc->mpu && sc->gp)? 0 : ENXIO;
871fd1aaeccSCameron Grant }
872fd1aaeccSCameron Grant 
873fd1aaeccSCameron Grant static int
874fd1aaeccSCameron Grant ess_probe(device_t dev)
875fd1aaeccSCameron Grant {
876fd1aaeccSCameron Grant 	char *s = NULL;
877fd1aaeccSCameron Grant 	u_int32_t subdev;
878fd1aaeccSCameron Grant 
879fd1aaeccSCameron Grant 	subdev = (pci_get_subdevice(dev) << 16) | pci_get_subvendor(dev);
880fd1aaeccSCameron Grant 	switch (pci_get_devid(dev)) {
881fd1aaeccSCameron Grant 	case 0x1969125d:
882fd1aaeccSCameron Grant 		if (subdev == 0x8888125d)
883fd1aaeccSCameron Grant 			s = "ESS Solo-1E";
884fd1aaeccSCameron Grant 		else if (subdev == 0x1818125d)
885fd1aaeccSCameron Grant 			s = "ESS Solo-1";
886fd1aaeccSCameron Grant 		else
887fd1aaeccSCameron Grant 			s = "ESS Solo-1 (unknown vendor)";
888fd1aaeccSCameron Grant 		break;
889fd1aaeccSCameron Grant 	}
890fd1aaeccSCameron Grant 
891fd1aaeccSCameron Grant 	if (s)
892fd1aaeccSCameron Grant 		device_set_desc(dev, s);
893fd1aaeccSCameron Grant 	return s? 0 : ENXIO;
894fd1aaeccSCameron Grant }
895fd1aaeccSCameron Grant 
896933ce6faSOrion Hodson #define ESS_PCI_LEGACYCONTROL       0x40
897933ce6faSOrion Hodson #define ESS_PCI_CONFIG              0x50
898933ce6faSOrion Hodson #define ESS_PCI_DDMACONTROL      	0x60
899933ce6faSOrion Hodson 
900933ce6faSOrion Hodson static int
901933ce6faSOrion Hodson ess_suspend(device_t dev)
902933ce6faSOrion Hodson {
903933ce6faSOrion Hodson   return 0;
904933ce6faSOrion Hodson }
905933ce6faSOrion Hodson 
906933ce6faSOrion Hodson static int
907933ce6faSOrion Hodson ess_resume(device_t dev)
908933ce6faSOrion Hodson {
909933ce6faSOrion Hodson 	uint16_t ddma;
910933ce6faSOrion Hodson 	uint32_t data;
911933ce6faSOrion Hodson 	struct ess_info *sc = pcm_getdevinfo(dev);
912933ce6faSOrion Hodson 
913933ce6faSOrion Hodson 	data = pci_read_config(dev, PCIR_COMMAND, 2);
914933ce6faSOrion Hodson 	data |= PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN;
915933ce6faSOrion Hodson 	pci_write_config(dev, PCIR_COMMAND, data, 2);
916933ce6faSOrion Hodson 	data = pci_read_config(dev, PCIR_COMMAND, 2);
917933ce6faSOrion Hodson 
918933ce6faSOrion Hodson 	ddma = rman_get_start(sc->vc) | 1;
919933ce6faSOrion Hodson 	pci_write_config(dev, ESS_PCI_LEGACYCONTROL, 0x805f, 2);
920933ce6faSOrion Hodson 	pci_write_config(dev, ESS_PCI_DDMACONTROL, ddma, 2);
921933ce6faSOrion Hodson 	pci_write_config(dev, ESS_PCI_CONFIG, 0, 2);
922933ce6faSOrion Hodson 
923933ce6faSOrion Hodson     	if (ess_reset_dsp(sc))
924933ce6faSOrion Hodson 		goto no;
925933ce6faSOrion Hodson     	if (mixer_reinit(dev))
926933ce6faSOrion Hodson 		goto no;
927933ce6faSOrion Hodson 	if (sc->newspeed)
928933ce6faSOrion Hodson 		ess_setmixer(sc, 0x71, 0x2a);
929933ce6faSOrion Hodson 
930933ce6faSOrion Hodson 	port_wr(sc->io, 0x7, 0xb0, 1); /* enable irqs */
931933ce6faSOrion Hodson 
932933ce6faSOrion Hodson 	return 0;
933933ce6faSOrion Hodson  no:
934933ce6faSOrion Hodson 	return EIO;
935933ce6faSOrion Hodson }
936fd1aaeccSCameron Grant 
937fd1aaeccSCameron Grant static int
938fd1aaeccSCameron Grant ess_attach(device_t dev)
939fd1aaeccSCameron Grant {
940fd1aaeccSCameron Grant     	struct ess_info *sc;
941fd1aaeccSCameron Grant     	char status[SND_STATUSLEN];
942fd1aaeccSCameron Grant 	u_int16_t ddma;
943fd1aaeccSCameron Grant 	u_int32_t data;
944fd1aaeccSCameron Grant 
945733a4ea7SGeorge C A Reid 	sc = (struct ess_info *)malloc(sizeof *sc, M_DEVBUF, M_NOWAIT | M_ZERO);
946fd1aaeccSCameron Grant     	if (!sc)
947fd1aaeccSCameron Grant 		return ENXIO;
948fd1aaeccSCameron Grant 
949fd1aaeccSCameron Grant 	data = pci_read_config(dev, PCIR_COMMAND, 2);
950fd1aaeccSCameron Grant 	data |= PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN;
951fd1aaeccSCameron Grant 	pci_write_config(dev, PCIR_COMMAND, data, 2);
952fd1aaeccSCameron Grant 	data = pci_read_config(dev, PCIR_COMMAND, 2);
953fd1aaeccSCameron Grant 
954fd1aaeccSCameron Grant     	if (ess_alloc_resources(sc, dev))
955fd1aaeccSCameron Grant 		goto no;
956fd1aaeccSCameron Grant 
95739dbd126SCameron Grant 	sc->bufsz = pcm_getbuffersize(dev, 4096, SOLO_DEFAULT_BUFSZ, 65536);
95839dbd126SCameron Grant 
959fd1aaeccSCameron Grant 	ddma = rman_get_start(sc->vc) | 1;
960933ce6faSOrion Hodson 	pci_write_config(dev, ESS_PCI_LEGACYCONTROL, 0x805f, 2);
961933ce6faSOrion Hodson 	pci_write_config(dev, ESS_PCI_DDMACONTROL, ddma, 2);
962933ce6faSOrion Hodson 	pci_write_config(dev, ESS_PCI_CONFIG, 0, 2);
963fd1aaeccSCameron Grant 
964fd1aaeccSCameron Grant     	if (ess_reset_dsp(sc))
965fd1aaeccSCameron Grant 		goto no;
9660f55ac6cSCameron Grant     	if (mixer_init(dev, &solomixer_class, sc))
9670f55ac6cSCameron Grant 		goto no;
968fd1aaeccSCameron Grant 
969fd1aaeccSCameron Grant 	port_wr(sc->io, 0x7, 0xb0, 1); /* enable irqs */
9703ac1ca33SNick Sayer #ifdef ESS18XX_DUPLEX
971fd1aaeccSCameron Grant 	sc->duplex = 1;
9723ac1ca33SNick Sayer #else
9733ac1ca33SNick Sayer 	sc->duplex = 0;
9743ac1ca33SNick Sayer #endif
975fd1aaeccSCameron Grant 
9763ac1ca33SNick Sayer #ifdef ESS18XX_NEWSPEED
9773ac1ca33SNick Sayer 	sc->newspeed = 1;
9783ac1ca33SNick Sayer #else
9793ac1ca33SNick Sayer 	sc->newspeed = 0;
9803ac1ca33SNick Sayer #endif
981fd1aaeccSCameron Grant 	if (sc->newspeed)
982fd1aaeccSCameron Grant 		ess_setmixer(sc, 0x71, 0x2a);
983fd1aaeccSCameron Grant 
98466ef8af5SCameron Grant 	snd_setup_intr(dev, sc->irq, 0, ess_intr, sc, &sc->ih);
985fd1aaeccSCameron Grant     	if (!sc->duplex)
986fd1aaeccSCameron Grant 		pcm_setflags(dev, pcm_getflags(dev) | SD_F_SIMPLEX);
987fd1aaeccSCameron Grant 
988bb7f26c3SNick Sayer     	if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/65536, /*boundary*/0,
989fd1aaeccSCameron Grant 			/*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
990fd1aaeccSCameron Grant 			/*highaddr*/BUS_SPACE_MAXADDR,
991fd1aaeccSCameron Grant 			/*filter*/NULL, /*filterarg*/NULL,
99239dbd126SCameron Grant 			/*maxsize*/sc->bufsz, /*nsegments*/1,
993fd1aaeccSCameron Grant 			/*maxsegz*/0x3ffff,
994fd1aaeccSCameron Grant 			/*flags*/0, &sc->parent_dmat) != 0) {
995fd1aaeccSCameron Grant 		device_printf(dev, "unable to create dma tag\n");
996fd1aaeccSCameron Grant 		goto no;
997fd1aaeccSCameron Grant     	}
998fd1aaeccSCameron Grant 
999fd1aaeccSCameron Grant     	snprintf(status, SND_STATUSLEN, "at io 0x%lx,0x%lx,0x%lx irq %ld",
1000fd1aaeccSCameron Grant     	     	rman_get_start(sc->io), rman_get_start(sc->sb), rman_get_start(sc->vc),
1001fd1aaeccSCameron Grant 		rman_get_start(sc->irq));
1002fd1aaeccSCameron Grant 
1003fd1aaeccSCameron Grant     	if (pcm_register(dev, sc, 1, 1))
1004fd1aaeccSCameron Grant 		goto no;
10050f55ac6cSCameron Grant       	pcm_addchan(dev, PCMDIR_REC, &esschan_class, sc);
10060f55ac6cSCameron Grant 	pcm_addchan(dev, PCMDIR_PLAY, &esschan_class, sc);
1007fd1aaeccSCameron Grant 	pcm_setstatus(dev, status);
1008fd1aaeccSCameron Grant 
1009fd1aaeccSCameron Grant     	return 0;
1010fd1aaeccSCameron Grant 
1011fd1aaeccSCameron Grant no:
1012fd1aaeccSCameron Grant     	ess_release_resources(sc, dev);
1013fd1aaeccSCameron Grant     	return ENXIO;
1014fd1aaeccSCameron Grant }
1015fd1aaeccSCameron Grant 
1016306f91b6SCameron Grant static int
1017306f91b6SCameron Grant ess_detach(device_t dev)
1018306f91b6SCameron Grant {
1019306f91b6SCameron Grant 	int r;
10207dfc9325SCameron Grant 	struct ess_info *sc;
1021306f91b6SCameron Grant 
1022306f91b6SCameron Grant 	r = pcm_unregister(dev);
1023306f91b6SCameron Grant 	if (r)
1024306f91b6SCameron Grant 		return r;
1025306f91b6SCameron Grant 
1026306f91b6SCameron Grant 	sc = pcm_getdevinfo(dev);
1027306f91b6SCameron Grant     	ess_release_resources(sc, dev);
1028306f91b6SCameron Grant 	return 0;
1029306f91b6SCameron Grant }
1030306f91b6SCameron Grant 
1031fd1aaeccSCameron Grant static device_method_t ess_methods[] = {
1032fd1aaeccSCameron Grant 	/* Device interface */
1033fd1aaeccSCameron Grant 	DEVMETHOD(device_probe,		ess_probe),
1034fd1aaeccSCameron Grant 	DEVMETHOD(device_attach,	ess_attach),
1035306f91b6SCameron Grant 	DEVMETHOD(device_detach,	ess_detach),
1036933ce6faSOrion Hodson 	DEVMETHOD(device_resume,	ess_resume),
1037933ce6faSOrion Hodson 	DEVMETHOD(device_suspend,	ess_suspend),
1038fd1aaeccSCameron Grant 
1039fd1aaeccSCameron Grant 	{ 0, 0 }
1040fd1aaeccSCameron Grant };
1041fd1aaeccSCameron Grant 
1042fd1aaeccSCameron Grant static driver_t ess_driver = {
1043fd1aaeccSCameron Grant 	"pcm",
1044fd1aaeccSCameron Grant 	ess_methods,
104567b1dce3SCameron Grant 	PCM_SOFTC_SIZE,
1046fd1aaeccSCameron Grant };
1047fd1aaeccSCameron Grant 
1048fd1aaeccSCameron Grant DRIVER_MODULE(snd_solo, pci, ess_driver, pcm_devclass, 0, 0);
1049fd1aaeccSCameron Grant MODULE_DEPEND(snd_solo, snd_pcm, PCM_MINVER, PCM_PREFVER, PCM_MAXVER);
1050fd1aaeccSCameron Grant MODULE_VERSION(snd_solo, 1);
1051fd1aaeccSCameron Grant 
1052fd1aaeccSCameron Grant 
1053fd1aaeccSCameron Grant 
1054