Deleted Added
sdiff udiff text old ( 52046 ) new ( 53413 )
full compact
1/*
2 * Support the ENSONIQ AudioPCI board based on the ES1370 and Codec
3 * AK4531.
4 *
5 * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
6 * Copyright (c) 1998 by Joachim Kuebart. 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 *
12 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

32 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
38 * OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * $FreeBSD: head/sys/dev/sound/pci/es137x.c 52046 1999-10-09 03:50:27Z imp $
41 */
42
43#include "pci.h"
44#include "pcm.h"
45
46#include <dev/pcm/sound.h>
47#include <dev/pcm/pci/es1370.h>
48
49#include <pci/pcireg.h>
50#include <pci/pcivar.h>
51
52#if NPCI != 0
53
54#define MEM_MAP_REG 0x14
55
56/* PCI IDs of supported chips */
57#define ES1370_PCI_ID 0x50001274
58
59/* device private data */
60struct es_info;
61
62struct es_chinfo {
63 struct es_info *parent;
64 pcm_channel *channel;
65 snd_dbuf *buffer;
66 int dir;
67 u_int32_t fmt;
68};
69
70struct es_info {
71 bus_space_tag_t st;
72 bus_space_handle_t sh;
73 bus_dma_tag_t parent_dmat;
74
75 /* Contents of board's registers */
76 u_long ctrl;
77 u_long sctrl;
78 struct es_chinfo pch, rch;
79};
80
81/* -------------------------------------------------------------------- */
82
83/* prototypes */
84static int es_init(struct es_info *);
85static void es_intr(void *);
86static int write_codec(struct es_info *, u_char, u_char);
87
88/* channel interface */
89static void *eschan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir);
90static int eschan_setdir(void *data, int dir);
91static int eschan_setformat(void *data, u_int32_t format);
92static int eschan_setspeed(void *data, u_int32_t speed);
93static int eschan_setblocksize(void *data, u_int32_t blocksize);
94static int eschan_trigger(void *data, int go);
95static int eschan_getptr(void *data);
96static pcmchan_caps *eschan_getcaps(void *data);
97
98static pcmchan_caps es_playcaps = {
99 4000, 48000,
100 AFMT_STEREO | AFMT_U8 | AFMT_S16_LE,
101 AFMT_STEREO | AFMT_S16_LE
102};
103

--- 282 unchanged lines hidden (view full) ---

386
387 bus_space_write_4(es->st, es->sh, ES1370_REG_SERIAL_CONTROL, sctrl);
388 bus_space_write_4(es->st, es->sh, ES1370_REG_SERIAL_CONTROL, es->sctrl);
389
390 if (intsrc & STAT_DAC2) chn_intr(es->pch.channel);
391 if (intsrc & STAT_ADC) chn_intr(es->rch.channel);
392}
393
394/* -------------------------------------------------------------------- */
395
396/*
397 * Probe and attach the card
398 */
399
400static int
401es_init(struct es_info *es)

--- 16 unchanged lines hidden (view full) ---

418}
419
420static int
421es_pci_probe(device_t dev)
422{
423 if (pci_get_devid(dev) == ES1370_PCI_ID) {
424 device_set_desc(dev, "AudioPCI ES1370");
425 return 0;
426 }
427 return ENXIO;
428}
429
430static int
431es_pci_attach(device_t dev)
432{
433 snddev_info *d;
434 u_int32_t data;
435 struct es_info *es = 0;
436 int type = 0;
437 int regid;
438 struct resource *reg = 0;
439 int mapped;
440 int irqid;
441 struct resource *irq = 0;
442 void *ih = 0;
443 char status[SND_STATUSLEN];
444
445 d = device_get_softc(dev);
446 if ((es = malloc(sizeof *es, M_DEVBUF, M_NOWAIT)) == NULL) {
447 device_printf(dev, "cannot allocate softc\n");
448 return ENXIO;
449 }
450 bzero(es, sizeof *es);
451

--- 20 unchanged lines hidden (view full) ---

472 es->sh = rman_get_bushandle(reg);
473 mapped++;
474 }
475 }
476 if (mapped == 0) {
477 device_printf(dev, "unable to map register space\n");
478 goto bad;
479 }
480
481 if (es_init(es) == -1) {
482 device_printf(dev, "unable to initialize the card\n");
483 goto bad;
484 }
485 mixer_init(d, &es_mixer, es);
486
487 irqid = 0;
488 irq = bus_alloc_resource(dev, SYS_RES_IRQ, &irqid,
489 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE);
490 if (!irq
491 || bus_setup_intr(dev, irq, INTR_TYPE_TTY, es_intr, es, &ih)) {
492 device_printf(dev, "unable to map interrupt\n");
493 goto bad;

--- 41 unchanged lines hidden (view full) ---

535 es_methods,
536 sizeof(snddev_info),
537};
538
539static devclass_t pcm_devclass;
540
541DRIVER_MODULE(es, pci, es_driver, pcm_devclass, 0, 0);
542
543#endif /* NPCI != 0 */