FreeBSD kernel sound device code
ad1816.c
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
5 * Copyright (c) 1997,1998 Luigi Rizzo
6 * Copyright (c) 1994,1995 Hannu Savolainen
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#ifdef HAVE_KERNEL_OPTION_HEADERS
32#include "opt_snd.h"
33#endif
34
35#include <dev/sound/pcm/sound.h>
37
38#include <isa/isavar.h>
39
40#include "mixer_if.h"
41
42SND_DECLARE_FILE("$FreeBSD$");
43
44struct ad1816_info;
45
50 int dir, blksz;
51};
52
54 struct resource *io_base; /* primary I/O address for the board */
55 int io_rid;
56 struct resource *irq;
58 struct resource *drq1; /* play */
60 struct resource *drq2; /* rec */
62 void *ih;
63 bus_dma_tag_t parent_dmat;
64 struct mtx *lock;
65
66 unsigned int bufsize;
67 struct ad1816_chinfo pch, rch;
68};
69
70static u_int32_t ad1816_fmt[] = {
71 SND_FORMAT(AFMT_U8, 1, 0),
72 SND_FORMAT(AFMT_U8, 2, 0),
73 SND_FORMAT(AFMT_S16_LE, 1, 0),
74 SND_FORMAT(AFMT_S16_LE, 2, 0),
75 SND_FORMAT(AFMT_MU_LAW, 1, 0),
76 SND_FORMAT(AFMT_MU_LAW, 2, 0),
77 SND_FORMAT(AFMT_A_LAW, 1, 0),
78 SND_FORMAT(AFMT_A_LAW, 2, 0),
79 0
80};
81
82static struct pcmchan_caps ad1816_caps = {4000, 55200, ad1816_fmt, 0};
83
84#define AD1816_MUTE 31 /* value for mute */
85
86static void
87ad1816_lock(struct ad1816_info *ad1816)
88{
89 snd_mtxlock(ad1816->lock);
90}
91
92static void
94{
95 snd_mtxunlock(ad1816->lock);
96}
97
98static int
99port_rd(struct resource *port, int off)
100{
101 if (port)
102 return bus_space_read_1(rman_get_bustag(port),
103 rman_get_bushandle(port),
104 off);
105 else
106 return -1;
107}
108
109static void
110port_wr(struct resource *port, int off, u_int8_t data)
111{
112 if (port)
113 bus_space_write_1(rman_get_bustag(port),
114 rman_get_bushandle(port),
115 off, data);
116}
117
118static int
119io_rd(struct ad1816_info *ad1816, int reg)
120{
121 return port_rd(ad1816->io_base, reg);
122}
123
124static void
125io_wr(struct ad1816_info *ad1816, int reg, u_int8_t data)
126{
127 port_wr(ad1816->io_base, reg, data);
128}
129
130static void
131ad1816_intr(void *arg)
132{
133 struct ad1816_info *ad1816 = (struct ad1816_info *)arg;
134 unsigned char c, served = 0;
135
136 ad1816_lock(ad1816);
137 /* get interrupt status */
138 c = io_rd(ad1816, AD1816_INT);
139
140 /* check for stray interrupts */
141 if (c & ~(AD1816_INTRCI | AD1816_INTRPI)) {
142 printf("pcm: stray int (%x)\n", c);
144 }
145 /* check for capture interrupt */
146 if (sndbuf_runsz(ad1816->rch.buffer) && (c & AD1816_INTRCI)) {
147 ad1816_unlock(ad1816);
148 chn_intr(ad1816->rch.channel);
149 ad1816_lock(ad1816);
150 served |= AD1816_INTRCI; /* cp served */
151 }
152 /* check for playback interrupt */
153 if (sndbuf_runsz(ad1816->pch.buffer) && (c & AD1816_INTRPI)) {
154 ad1816_unlock(ad1816);
155 chn_intr(ad1816->pch.channel);
156 ad1816_lock(ad1816);
157 served |= AD1816_INTRPI; /* pb served */
158 }
159 if (served == 0) {
160 /* this probably means this is not a (working) ad1816 chip, */
161 /* or an error in dma handling */
162 printf("pcm: int without reason (%x)\n", c);
163 c = 0;
164 } else c &= ~served;
165 io_wr(ad1816, AD1816_INT, c);
166 c = io_rd(ad1816, AD1816_INT);
167 if (c != 0) printf("pcm: int clear failed (%x)\n", c);
168 ad1816_unlock(ad1816);
169}
170
171static int
172ad1816_wait_init(struct ad1816_info *ad1816, int x)
173{
174 int n = 0; /* to shut up the compiler... */
175
176 for (; x--;)
177 if ((n = (io_rd(ad1816, AD1816_ALE) & AD1816_BUSY)) == 0) DELAY(10);
178 else return n;
179 printf("ad1816_wait_init failed 0x%02x.\n", n);
180 return -1;
181}
182
183static unsigned short
184ad1816_read(struct ad1816_info *ad1816, unsigned int reg)
185{
186 u_short x = 0;
187
188 if (ad1816_wait_init(ad1816, 100) == -1) return 0;
189 io_wr(ad1816, AD1816_ALE, 0);
190 io_wr(ad1816, AD1816_ALE, (reg & AD1816_ALEMASK));
191 if (ad1816_wait_init(ad1816, 100) == -1) return 0;
192 x = (io_rd(ad1816, AD1816_HIGH) << 8) | io_rd(ad1816, AD1816_LOW);
193 return x;
194}
195
196static void
197ad1816_write(struct ad1816_info *ad1816, unsigned int reg, unsigned short data)
198{
199 if (ad1816_wait_init(ad1816, 100) == -1) return;
200 io_wr(ad1816, AD1816_ALE, (reg & AD1816_ALEMASK));
201 io_wr(ad1816, AD1816_LOW, (data & 0x000000ff));
202 io_wr(ad1816, AD1816_HIGH, (data & 0x0000ff00) >> 8);
203}
204
205/* -------------------------------------------------------------------- */
206
207static int
209{
212 return 0;
213}
214
215static int
216ad1816mix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
217{
218 struct ad1816_info *ad1816 = mix_getdevinfo(m);
219 u_short reg = 0;
220
221 /* Scale volumes */
222 left = AD1816_MUTE - (AD1816_MUTE * left) / 100;
223 right = AD1816_MUTE - (AD1816_MUTE * right) / 100;
224
225 reg = (left << 8) | right;
226
227 /* do channel selective muting if volume is zero */
228 if (left == AD1816_MUTE) reg |= 0x8000;
229 if (right == AD1816_MUTE) reg |= 0x0080;
230
231 ad1816_lock(ad1816);
232 switch (dev) {
233 case SOUND_MIXER_VOLUME: /* Register 14 master volume */
234 ad1816_write(ad1816, 14, reg);
235 break;
236
237 case SOUND_MIXER_CD: /* Register 15 cd */
238 case SOUND_MIXER_LINE1:
239 ad1816_write(ad1816, 15, reg);
240 break;
241
242 case SOUND_MIXER_SYNTH: /* Register 16 synth */
243 ad1816_write(ad1816, 16, reg);
244 break;
245
246 case SOUND_MIXER_PCM: /* Register 4 pcm */
247 ad1816_write(ad1816, 4, reg);
248 break;
249
250 case SOUND_MIXER_LINE:
251 case SOUND_MIXER_LINE3: /* Register 18 line in */
252 ad1816_write(ad1816, 18, reg);
253 break;
254
255 case SOUND_MIXER_MIC: /* Register 19 mic volume */
256 ad1816_write(ad1816, 19, reg & ~0xff); /* mic is mono */
257 break;
258
259 case SOUND_MIXER_IGAIN:
260 /* and now to something completely different ... */
261 ad1816_write(ad1816, 20, ((ad1816_read(ad1816, 20) & ~0x0f0f)
262 | (((AD1816_MUTE - left) / 2) << 8) /* four bits of adc gain */
263 | ((AD1816_MUTE - right) / 2)));
264 break;
265
266 default:
267 printf("ad1816_mixer_set(): unknown device.\n");
268 break;
269 }
270 ad1816_unlock(ad1816);
271
272 left = ((AD1816_MUTE - left) * 100) / AD1816_MUTE;
273 right = ((AD1816_MUTE - right) * 100) / AD1816_MUTE;
274
275 return left | (right << 8);
276}
277
278static u_int32_t
280{
281 struct ad1816_info *ad1816 = mix_getdevinfo(m);
282 int dev;
283
284 switch (src) {
285 case SOUND_MASK_LINE:
286 case SOUND_MASK_LINE3:
287 dev = 0x00;
288 break;
289
290 case SOUND_MASK_CD:
291 case SOUND_MASK_LINE1:
292 dev = 0x20;
293 break;
294
295 case SOUND_MASK_MIC:
296 default:
297 dev = 0x50;
298 src = SOUND_MASK_MIC;
299 }
300
301 dev |= dev << 8;
302 ad1816_lock(ad1816);
303 ad1816_write(ad1816, 20, (ad1816_read(ad1816, 20) & ~0x7070) | dev);
304 ad1816_unlock(ad1816);
305 return src;
306}
307
308static kobj_method_t ad1816mixer_methods[] = {
309 KOBJMETHOD(mixer_init, ad1816mix_init),
310 KOBJMETHOD(mixer_set, ad1816mix_set),
313};
314MIXER_DECLARE(ad1816mixer);
315
316/* -------------------------------------------------------------------- */
317/* channel interface */
318static void *
319ad1816chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
320{
321 struct ad1816_info *ad1816 = devinfo;
322 struct ad1816_chinfo *ch = (dir == PCMDIR_PLAY)? &ad1816->pch : &ad1816->rch;
323
324 ch->dir = dir;
325 ch->parent = ad1816;
326 ch->channel = c;
327 ch->buffer = b;
328 if (sndbuf_alloc(ch->buffer, ad1816->parent_dmat, 0, ad1816->bufsize) != 0)
329 return NULL;
330
331 sndbuf_dmasetup(ch->buffer, (dir == PCMDIR_PLAY) ? ad1816->drq1 :
332 ad1816->drq2);
333 if (SND_DMA(ch->buffer))
335
336 return ch;
337}
338
339static int
340ad1816chan_setformat(kobj_t obj, void *data, u_int32_t format)
341{
342 struct ad1816_chinfo *ch = data;
343 struct ad1816_info *ad1816 = ch->parent;
344 int fmt = AD1816_U8, reg;
345
346 ad1816_lock(ad1816);
347 if (ch->dir == PCMDIR_PLAY) {
349 ad1816_write(ad1816, 8, 0x0000); /* reset base and current counter */
350 ad1816_write(ad1816, 9, 0x0000); /* for playback and capture */
351 } else {
353 ad1816_write(ad1816, 10, 0x0000);
354 ad1816_write(ad1816, 11, 0x0000);
355 }
356 switch (AFMT_ENCODING(format)) {
357 case AFMT_A_LAW:
359 break;
360
361 case AFMT_MU_LAW:
363 break;
364
365 case AFMT_S16_LE:
367 break;
368
369 case AFMT_S16_BE:
371 break;
372
373 case AFMT_U8:
374 fmt = AD1816_U8;
375 break;
376 }
378 io_wr(ad1816, reg, fmt);
379 ad1816_unlock(ad1816);
380#if 0
381 return format;
382#else
383 return 0;
384#endif
385}
386
387static u_int32_t
388ad1816chan_setspeed(kobj_t obj, void *data, u_int32_t speed)
389{
390 struct ad1816_chinfo *ch = data;
391 struct ad1816_info *ad1816 = ch->parent;
392
393 RANGE(speed, 4000, 55200);
394 ad1816_lock(ad1816);
395 ad1816_write(ad1816, (ch->dir == PCMDIR_PLAY)? 2 : 3, speed);
396 ad1816_unlock(ad1816);
397 return speed;
398}
399
400static u_int32_t
401ad1816chan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
402{
403 struct ad1816_chinfo *ch = data;
404
405 ch->blksz = blocksize;
406 return ch->blksz;
407}
408
409static int
410ad1816chan_trigger(kobj_t obj, void *data, int go)
411{
412 struct ad1816_chinfo *ch = data;
413 struct ad1816_info *ad1816 = ch->parent;
414 int wr, reg;
415
416 if (!PCMTRIG_COMMON(go))
417 return 0;
418
419 sndbuf_dma(ch->buffer, go);
420 wr = (ch->dir == PCMDIR_PLAY);
422 ad1816_lock(ad1816);
423 switch (go) {
424 case PCMTRIG_START:
425 /* start only if not already running */
426 if (!(io_rd(ad1816, reg) & AD1816_ENABLE)) {
427 int cnt = ((ch->blksz) >> 2) - 1;
428 ad1816_write(ad1816, wr? 8 : 10, cnt); /* count */
429 ad1816_write(ad1816, wr? 9 : 11, 0); /* reset cur cnt */
430 ad1816_write(ad1816, 1, ad1816_read(ad1816, 1) |
431 (wr? 0x8000 : 0x4000)); /* enable int */
432 /* enable playback */
433 io_wr(ad1816, reg, io_rd(ad1816, reg) | AD1816_ENABLE);
434 if (!(io_rd(ad1816, reg) & AD1816_ENABLE))
435 printf("ad1816: failed to start %s DMA!\n",
436 wr? "play" : "rec");
437 }
438 break;
439
440 case PCMTRIG_STOP:
441 case PCMTRIG_ABORT: /* XXX check this... */
442 /* we don't test here if it is running... */
443 if (wr) {
444 ad1816_write(ad1816, 1, ad1816_read(ad1816, 1) &
445 ~(wr? 0x8000 : 0x4000));
446 /* disable int */
447 io_wr(ad1816, reg, io_rd(ad1816, reg) & ~AD1816_ENABLE);
448 /* disable playback */
449 if (io_rd(ad1816, reg) & AD1816_ENABLE)
450 printf("ad1816: failed to stop %s DMA!\n",
451 wr? "play" : "rec");
452 ad1816_write(ad1816, wr? 8 : 10, 0); /* reset base cnt */
453 ad1816_write(ad1816, wr? 9 : 11, 0); /* reset cur cnt */
454 }
455 break;
456 }
457 ad1816_unlock(ad1816);
458 return 0;
459}
460
461static u_int32_t
462ad1816chan_getptr(kobj_t obj, void *data)
463{
464 struct ad1816_chinfo *ch = data;
465 return sndbuf_dmaptr(ch->buffer);
466}
467
468static struct pcmchan_caps *
469ad1816chan_getcaps(kobj_t obj, void *data)
470{
471 return &ad1816_caps;
472}
473
474static kobj_method_t ad1816chan_methods[] = {
475 KOBJMETHOD(channel_init, ad1816chan_init),
476 KOBJMETHOD(channel_setformat, ad1816chan_setformat),
477 KOBJMETHOD(channel_setspeed, ad1816chan_setspeed),
478 KOBJMETHOD(channel_setblocksize, ad1816chan_setblocksize),
479 KOBJMETHOD(channel_trigger, ad1816chan_trigger),
480 KOBJMETHOD(channel_getptr, ad1816chan_getptr),
481 KOBJMETHOD(channel_getcaps, ad1816chan_getcaps),
483};
484CHANNEL_DECLARE(ad1816chan);
485
486/* -------------------------------------------------------------------- */
487
488static void
489ad1816_release_resources(struct ad1816_info *ad1816, device_t dev)
490{
491 if (ad1816->irq) {
492 if (ad1816->ih)
493 bus_teardown_intr(dev, ad1816->irq, ad1816->ih);
494 bus_release_resource(dev, SYS_RES_IRQ, ad1816->irq_rid, ad1816->irq);
495 ad1816->irq = NULL;
496 }
497 if (ad1816->drq1) {
498 isa_dma_release(rman_get_start(ad1816->drq1));
499 bus_release_resource(dev, SYS_RES_DRQ, ad1816->drq1_rid, ad1816->drq1);
500 ad1816->drq1 = NULL;
501 }
502 if (ad1816->drq2) {
503 isa_dma_release(rman_get_start(ad1816->drq2));
504 bus_release_resource(dev, SYS_RES_DRQ, ad1816->drq2_rid, ad1816->drq2);
505 ad1816->drq2 = NULL;
506 }
507 if (ad1816->io_base) {
508 bus_release_resource(dev, SYS_RES_IOPORT, ad1816->io_rid, ad1816->io_base);
509 ad1816->io_base = NULL;
510 }
511 if (ad1816->parent_dmat) {
512 bus_dma_tag_destroy(ad1816->parent_dmat);
513 ad1816->parent_dmat = 0;
514 }
515 if (ad1816->lock)
516 snd_mtxfree(ad1816->lock);
517
518 free(ad1816, M_DEVBUF);
519}
520
521static int
522ad1816_alloc_resources(struct ad1816_info *ad1816, device_t dev)
523{
524 int ok = 1, pdma, rdma;
525
526 if (!ad1816->io_base)
527 ad1816->io_base = bus_alloc_resource_any(dev,
528 SYS_RES_IOPORT, &ad1816->io_rid, RF_ACTIVE);
529 if (!ad1816->irq)
530 ad1816->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ,
531 &ad1816->irq_rid, RF_ACTIVE);
532 if (!ad1816->drq1)
533 ad1816->drq1 = bus_alloc_resource_any(dev, SYS_RES_DRQ,
534 &ad1816->drq1_rid, RF_ACTIVE);
535 if (!ad1816->drq2)
536 ad1816->drq2 = bus_alloc_resource_any(dev, SYS_RES_DRQ,
537 &ad1816->drq2_rid, RF_ACTIVE);
538
539 if (!ad1816->io_base || !ad1816->drq1 || !ad1816->irq) ok = 0;
540
541 if (ok) {
542 pdma = rman_get_start(ad1816->drq1);
543 isa_dma_acquire(pdma);
544 isa_dmainit(pdma, ad1816->bufsize);
545 if (ad1816->drq2) {
546 rdma = rman_get_start(ad1816->drq2);
547 isa_dma_acquire(rdma);
548 isa_dmainit(rdma, ad1816->bufsize);
549 } else
550 rdma = pdma;
551 if (pdma == rdma)
553 }
554
555 return ok;
556}
557
558static int
559ad1816_init(struct ad1816_info *ad1816, device_t dev)
560{
561 ad1816_write(ad1816, 1, 0x2); /* disable interrupts */
562 ad1816_write(ad1816, 32, 0x90F0); /* SoundSys Mode, split fmt */
563
564 ad1816_write(ad1816, 5, 0x8080); /* FM volume mute */
565 ad1816_write(ad1816, 6, 0x8080); /* I2S1 volume mute */
566 ad1816_write(ad1816, 7, 0x8080); /* I2S0 volume mute */
567 ad1816_write(ad1816, 17, 0x8888); /* VID Volume mute */
568 ad1816_write(ad1816, 20, 0x5050); /* recsrc mic, agc off */
569 /* adc gain is set to 0 */
570
571 return 0;
572}
573
574static int
576{
577 char *s = NULL;
578 u_int32_t logical_id = isa_get_logicalid(dev);
579
580 switch (logical_id) {
581 case 0x80719304: /* ADS7180 */
582 s = "AD1816";
583 break;
584 case 0x50719304: /* ADS7150 */
585 s = "AD1815";
586 break;
587 }
588
589 if (s) {
590 device_set_desc(dev, s);
591 return BUS_PROBE_DEFAULT;
592 }
593 return ENXIO;
594}
595
596static int
598{
599 struct ad1816_info *ad1816;
600 char status[SND_STATUSLEN], status2[SND_STATUSLEN];
601
602 gone_in_dev(dev, 14, "ISA sound driver");
603 ad1816 = malloc(sizeof(*ad1816), M_DEVBUF, M_WAITOK | M_ZERO);
604 ad1816->lock = snd_mtxcreate(device_get_nameunit(dev),
605 "snd_ad1816 softc");
606 ad1816->io_rid = 2;
607 ad1816->irq_rid = 0;
608 ad1816->drq1_rid = 0;
609 ad1816->drq2_rid = 1;
610 ad1816->bufsize = pcm_getbuffersize(dev, 4096, DSP_BUFFSIZE, 65536);
611
612 if (!ad1816_alloc_resources(ad1816, dev)) goto no;
613 ad1816_init(ad1816, dev);
614 if (mixer_init(dev, &ad1816mixer_class, ad1816)) goto no;
615
616 snd_setup_intr(dev, ad1816->irq, 0, ad1816_intr, ad1816, &ad1816->ih);
617 if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
618 /*boundary*/0,
619 /*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
620 /*highaddr*/BUS_SPACE_MAXADDR,
621 /*filter*/NULL, /*filterarg*/NULL,
622 /*maxsize*/ad1816->bufsize, /*nsegments*/1,
623 /*maxsegz*/0x3ffff,
624 /*flags*/0, /*lockfunc*/NULL, /*lockarg*/NULL,
625 &ad1816->parent_dmat) != 0) {
626 device_printf(dev, "unable to create dma tag\n");
627 goto no;
628 }
629 if (ad1816->drq2)
630 snprintf(status2, SND_STATUSLEN, ":%jd", rman_get_start(ad1816->drq2));
631 else
632 status2[0] = '\0';
633
634 snprintf(status, SND_STATUSLEN, "at io 0x%jx irq %jd drq %jd%s bufsz %u %s",
635 rman_get_start(ad1816->io_base),
636 rman_get_start(ad1816->irq),
637 rman_get_start(ad1816->drq1),
638 status2,
639 ad1816->bufsize,
640 PCM_KLDSTRING(snd_ad1816));
641
642 if (pcm_register(dev, ad1816, 1, 1)) goto no;
643 pcm_addchan(dev, PCMDIR_REC, &ad1816chan_class, ad1816);
644 pcm_addchan(dev, PCMDIR_PLAY, &ad1816chan_class, ad1816);
646
647 return 0;
648no:
650
651 return ENXIO;
652
653}
654
655static int
657{
658 int r;
659 struct ad1816_info *ad1816;
660
662 if (r)
663 return r;
664
665 ad1816 = pcm_getdevinfo(dev);
667 return 0;
668}
669
670static device_method_t ad1816_methods[] = {
671 /* Device interface */
672 DEVMETHOD(device_probe, ad1816_probe),
673 DEVMETHOD(device_attach, ad1816_attach),
674 DEVMETHOD(device_detach, ad1816_detach),
675 { 0, 0 }
676};
677
678static driver_t ad1816_driver = {
679 "pcm",
682};
683
684DRIVER_MODULE(snd_ad1816, isa, ad1816_driver, pcm_devclass, 0, 0);
685DRIVER_MODULE(snd_ad1816, acpi, ad1816_driver, pcm_devclass, 0, 0);
687MODULE_VERSION(snd_ad1816, 1);
u_int32_t data
Definition: ac97_if.m:60
void * devinfo
Definition: ac97_if.m:47
static struct pcmchan_caps * ad1816chan_getcaps(kobj_t obj, void *data)
Definition: ad1816.c:469
static device_method_t ad1816_methods[]
Definition: ad1816.c:670
static u_int32_t ad1816_fmt[]
Definition: ad1816.c:70
static int ad1816_alloc_resources(struct ad1816_info *ad1816, device_t dev)
Definition: ad1816.c:522
static int ad1816_probe(device_t dev)
Definition: ad1816.c:575
static u_int32_t ad1816chan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
Definition: ad1816.c:401
static void * ad1816chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
Definition: ad1816.c:319
static int port_rd(struct resource *port, int off)
Definition: ad1816.c:99
static struct pcmchan_caps ad1816_caps
Definition: ad1816.c:82
static int ad1816_attach(device_t dev)
Definition: ad1816.c:597
static int ad1816chan_setformat(kobj_t obj, void *data, u_int32_t format)
Definition: ad1816.c:340
static int ad1816mix_init(struct snd_mixer *m)
Definition: ad1816.c:208
static void ad1816_release_resources(struct ad1816_info *ad1816, device_t dev)
Definition: ad1816.c:489
static int ad1816chan_trigger(kobj_t obj, void *data, int go)
Definition: ad1816.c:410
static u_int32_t ad1816mix_setrecsrc(struct snd_mixer *m, u_int32_t src)
Definition: ad1816.c:279
static kobj_method_t ad1816mixer_methods[]
Definition: ad1816.c:308
SND_DECLARE_FILE("$FreeBSD$")
static void port_wr(struct resource *port, int off, u_int8_t data)
Definition: ad1816.c:110
DRIVER_MODULE(snd_ad1816, isa, ad1816_driver, pcm_devclass, 0, 0)
static kobj_method_t ad1816chan_methods[]
Definition: ad1816.c:474
static driver_t ad1816_driver
Definition: ad1816.c:678
static void ad1816_write(struct ad1816_info *ad1816, unsigned int reg, unsigned short data)
Definition: ad1816.c:197
static void ad1816_intr(void *arg)
Definition: ad1816.c:131
static int ad1816_init(struct ad1816_info *ad1816, device_t dev)
Definition: ad1816.c:559
static void io_wr(struct ad1816_info *ad1816, int reg, u_int8_t data)
Definition: ad1816.c:125
#define AD1816_MUTE
Definition: ad1816.c:84
static u_int32_t ad1816chan_getptr(kobj_t obj, void *data)
Definition: ad1816.c:462
static u_int32_t ad1816chan_setspeed(kobj_t obj, void *data, u_int32_t speed)
Definition: ad1816.c:388
static int ad1816_wait_init(struct ad1816_info *ad1816, int x)
Definition: ad1816.c:172
CHANNEL_DECLARE(ad1816chan)
static int io_rd(struct ad1816_info *ad1816, int reg)
Definition: ad1816.c:119
static void ad1816_lock(struct ad1816_info *ad1816)
Definition: ad1816.c:87
static unsigned short ad1816_read(struct ad1816_info *ad1816, unsigned int reg)
Definition: ad1816.c:184
static void ad1816_unlock(struct ad1816_info *ad1816)
Definition: ad1816.c:93
MIXER_DECLARE(ad1816mixer)
static int ad1816mix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
Definition: ad1816.c:216
static int ad1816_detach(device_t dev)
Definition: ad1816.c:656
MODULE_DEPEND(snd_ad1816, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
MODULE_VERSION(snd_ad1816, 1)
#define AD1816_ALE
Definition: ad1816.h:38
#define AD1816_LOW
Definition: ad1816.h:40
#define AD1816_CAPT
Definition: ad1816.h:62
#define AD1816_STEREO
Definition: ad1816.h:82
#define AD1816_INT
Definition: ad1816.h:39
#define AD1816_BUSY
Definition: ad1816.h:64
#define AD1816_PLAY
Definition: ad1816.h:61
#define AD1816_ALAW
Definition: ad1816.h:86
#define AD1816_MIXER_DEVICES
Definition: ad1816.h:94
#define AD1816_ENABLE
Definition: ad1816.h:80
#define AD1816_INTRCI
Definition: ad1816.h:76
#define AD1816_HIGH
Definition: ad1816.h:41
#define AD1816_S16BE
Definition: ad1816.h:88
#define AD1816_REC_DEVICES
Definition: ad1816.h:91
#define AD1816_INTRPI
Definition: ad1816.h:77
#define AD1816_ALEMASK
Definition: ad1816.h:65
#define AD1816_MULAW
Definition: ad1816.h:85
#define AD1816_S16LE
Definition: ad1816.h:87
#define AD1816_U8
Definition: ad1816.h:84
uint32_t format
Definition: audio_dai_if.m:39
uint32_t speed
Definition: audio_dai_if.m:86
int go
Definition: audio_dai_if.m:64
unsigned int fmt
Definition: audio_soc.c:91
int sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, int dmaflags, unsigned int size)
Definition: buffer.c:93
unsigned int sndbuf_runsz(struct snd_dbuf *b)
Definition: buffer.c:453
#define SND_DMA(b)
Definition: buffer.h:31
void chn_intr(struct pcm_channel *c)
Definition: channel.c:660
#define PCMDIR_PLAY
Definition: channel.h:339
#define PCMTRIG_START
Definition: channel.h:344
#define PCMTRIG_STOP
Definition: channel.h:347
#define PCMDIR_REC
Definition: channel.h:341
#define PCMTRIG_COMMON(x)
Definition: channel.h:350
#define PCMTRIG_ABORT
Definition: channel.h:348
struct pcm_channel * c
Definition: channel_if.m:106
METHOD int free
Definition: channel_if.m:110
u_int32_t blocksize
Definition: channel_if.m:140
struct pcmchan_matrix * m
Definition: channel_if.m:232
struct snd_dbuf * b
Definition: channel_if.m:105
unsigned right
Definition: es137x.c:261
unsigned left
Definition: es137x.c:260
uint8_t reg
Definition: hdac.c:211
int dir
Definition: hdac_if.m:45
uint8_t r
uint8_t n
#define KOBJMETHOD_END
Definition: midi.c:76
static int mixer_setrecsrc(struct snd_mixer *mixer, u_int32_t src)
Definition: mixer.c:373
int mixer_init(device_t dev, kobj_class_t cls, void *devinfo)
Definition: mixer.c:725
static int mixer_set(struct snd_mixer *m, u_int dev, u_int32_t muted, u_int lev)
Definition: mixer.c:247
void mix_setdevs(struct snd_mixer *m, u_int32_t v)
Definition: mixer.c:489
void * mix_getdevinfo(struct snd_mixer *m)
Definition: mixer.c:645
void mix_setrecdevs(struct snd_mixer *m, u_int32_t v)
Record mask of available recording devices.
Definition: mixer.c:529
unsigned dev
Definition: mixer_if.m:59
u_int32_t src
Definition: mixer_if.m:66
bool * status
#define RANGE(var, low, high)
Definition: sequencer.h:45
int sndbuf_dmasetup(struct snd_dbuf *b, struct resource *drq)
Definition: sndbuf_dma.c:40
void sndbuf_dma(struct snd_dbuf *b, int go)
Definition: sndbuf_dma.c:63
int sndbuf_dmaptr(struct snd_dbuf *b)
Definition: sndbuf_dma.c:88
int sndbuf_dmasetdir(struct snd_dbuf *b, int dir)
Definition: sndbuf_dma.c:53
void * snd_mtxcreate(const char *desc, const char *type)
Definition: sound.c:88
void pcm_setflags(device_t dev, uint32_t val)
Definition: sound.c:824
void * pcm_getdevinfo(device_t dev)
Definition: sound.c:832
uint32_t pcm_getflags(device_t dev)
Definition: sound.c:816
int pcm_setstatus(device_t dev, char *str)
Definition: sound.c:766
devclass_t pcm_devclass
Definition: sound.c:49
void snd_mtxfree(void *m)
Definition: sound.c:98
int pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo)
Definition: sound.c:692
int pcm_unregister(device_t dev)
Definition: sound.c:1170
int pcm_register(device_t dev, void *devinfo, int numplay, int numrec)
Definition: sound.c:1080
int snd_setup_intr(device_t dev, struct resource *res, int flags, driver_intr_t hand, void *param, void **cookiep)
Definition: sound.c:117
unsigned int pcm_getbuffersize(device_t dev, unsigned int minbufsz, unsigned int deflt, unsigned int maxbufsz)
Definition: sound.c:840
#define AFMT_ENCODING(v)
Definition: sound.h:222
#define PCM_KLDSTRING(a)
Definition: sound.h:619
#define SND_FORMAT(f, c, e)
Definition: sound.h:238
#define SOUND_PREFVER
Definition: sound.h:103
#define SOUND_MAXVER
Definition: sound.h:104
#define DSP_BUFFSIZE
Definition: sound.h:186
#define snd_mtxlock(m)
Definition: sound.h:347
#define AFMT_CHANNEL(v)
Definition: sound.h:227
#define SD_F_SIMPLEX
Definition: sound.h:132
#define snd_mtxunlock(m)
Definition: sound.h:348
#define SOUND_MINVER
Definition: sound.h:102
#define PCM_SOFTC_SIZE
Definition: sound.h:96
#define SND_STATUSLEN
Definition: sound.h:98
struct ad1816_info * parent
Definition: ad1816.c:47
struct snd_dbuf * buffer
Definition: ad1816.c:49
int blksz
Definition: ad1816.c:50
struct pcm_channel * channel
Definition: ad1816.c:48
struct mtx * lock
Definition: ad1816.c:64
int irq_rid
Definition: ad1816.c:57
struct resource * io_base
Definition: ad1816.c:54
int drq1_rid
Definition: ad1816.c:59
int io_rid
Definition: ad1816.c:55
struct resource * drq2
Definition: ad1816.c:60
bus_dma_tag_t parent_dmat
Definition: ad1816.c:63
void * ih
Definition: ad1816.c:62
struct resource * irq
Definition: ad1816.c:56
struct resource * drq1
Definition: ad1816.c:58
int drq2_rid
Definition: ad1816.c:61
struct ad1816_chinfo pch rch
Definition: ad1816.c:67
unsigned int bufsize
Definition: ad1816.c:66