Deleted Added
full compact
sbc.c (58385) sbc.c (60711)
1/*-
2 * Copyright (c) 1999 Seigo Tanimura
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1999 Seigo Tanimura
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/dev/sound/isa/sbc.c 58385 2000-03-20 15:34:27Z cg $
26 * $FreeBSD: head/sys/dev/sound/isa/sbc.c 60711 2000-05-19 15:41:52Z nyan $
27 */
28
29#include "isa.h"
30
31#include <dev/sound/chip.h>
32#include <dev/sound/pcm/sound.h>
33#include <dev/sound/isa/sb.h>
34

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

81
82static int alloc_resource(struct sbc_softc *scp);
83static int release_resource(struct sbc_softc *scp);
84
85static devclass_t sbc_devclass;
86
87static int io_range[3] = {0x10, 0x2, 0x4};
88
27 */
28
29#include "isa.h"
30
31#include <dev/sound/chip.h>
32#include <dev/sound/pcm/sound.h>
33#include <dev/sound/isa/sb.h>
34

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

81
82static int alloc_resource(struct sbc_softc *scp);
83static int release_resource(struct sbc_softc *scp);
84
85static devclass_t sbc_devclass;
86
87static int io_range[3] = {0x10, 0x2, 0x4};
88
89#ifdef PC98 /* I/O address table for PC98 */
90static bus_addr_t pcm_iat[] = {
91 0x000, 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700,
92 0x800, 0x900, 0xa00, 0xb00, 0xc00, 0xd00, 0xe00, 0xf00
93};
94static bus_addr_t midi_iat[] = {
95 0x000, 0x100
96};
97static bus_addr_t opl_iat[] = {
98 0x000, 0x100, 0x200, 0x300
99};
100static bus_addr_t *sb_iat[] = { pcm_iat, midi_iat, opl_iat };
101#endif
102
89static int sb_rd(struct resource *io, int reg);
90static void sb_wr(struct resource *io, int reg, u_int8_t val);
91static int sb_dspready(struct resource *io);
92static int sb_cmd(struct resource *io, u_char val);
93static u_int sb_get_byte(struct resource *io);
94static void sb_setmixer(struct resource *io, u_int port, u_int value);
95
96static int

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

229 if (lid == 0x01000000 && vid != 0x01009305) /* ALS0001 */
230 return ENXIO;
231 /* Check pnp ids */
232 return ISA_PNP_PROBE(device_get_parent(dev), dev, sbc_ids);
233 } else {
234 int rid = 0, ver;
235 struct resource *io;
236
103static int sb_rd(struct resource *io, int reg);
104static void sb_wr(struct resource *io, int reg, u_int8_t val);
105static int sb_dspready(struct resource *io);
106static int sb_cmd(struct resource *io, u_char val);
107static u_int sb_get_byte(struct resource *io);
108static void sb_setmixer(struct resource *io, u_int port, u_int value);
109
110static int

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

243 if (lid == 0x01000000 && vid != 0x01009305) /* ALS0001 */
244 return ENXIO;
245 /* Check pnp ids */
246 return ISA_PNP_PROBE(device_get_parent(dev), dev, sbc_ids);
247 } else {
248 int rid = 0, ver;
249 struct resource *io;
250
251#ifdef PC98
252 io = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid,
253 pcm_iat, 16, RF_ACTIVE);
254#else
237 io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
238 0, ~0, 16, RF_ACTIVE);
255 io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
256 0, ~0, 16, RF_ACTIVE);
257#endif
239 if (!io) goto bad;
258 if (!io) goto bad;
259#ifdef PC98
260 isa_load_resourcev(io, pcm_iat, 16);
261#endif
240 if (sb_reset_dsp(io)) goto bad2;
241 ver = sb_identify_board(io);
242 if (ver == 0) goto bad2;
243 switch ((ver & 0x00000f00) >> 8) {
244 case 1:
245 case 2:
246 s = "Soundblaster";
247 break;

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

319 scp->drq[0] = scp->drq[1];
320 scp->drq[1] = r;
321 dl = rman_get_start(scp->drq[0]);
322 dh = rman_get_start(scp->drq[1]);
323 }
324 /* soft irq/dma configuration */
325 x = -1;
326 irq = rman_get_start(scp->irq[0]);
262 if (sb_reset_dsp(io)) goto bad2;
263 ver = sb_identify_board(io);
264 if (ver == 0) goto bad2;
265 switch ((ver & 0x00000f00) >> 8) {
266 case 1:
267 case 2:
268 s = "Soundblaster";
269 break;

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

341 scp->drq[0] = scp->drq[1];
342 scp->drq[1] = r;
343 dl = rman_get_start(scp->drq[0]);
344 dh = rman_get_start(scp->drq[1]);
345 }
346 /* soft irq/dma configuration */
347 x = -1;
348 irq = rman_get_start(scp->irq[0]);
349#ifdef PC98
350 /* SB16 in PC98 use different IRQ table */
351 if (irq == 3) x = 1;
352 else if (irq == 5) x = 8;
353 else if (irq == 10) x = 2;
354 else if (irq == 12) x = 4;
355 if (x == -1) {
356 err = "bad irq (3/5/10/12 valid)";
357 goto bad;
358 }
359 else sb_setmixer(scp->io[0], IRQ_NR, x);
360 /* SB16 in PC98 use different dma setting */
361 sb_setmixer(scp->io[0], DMA_NR, dh == 0 ? 1 : 2);
362#else
327 if (irq == 5) x = 2;
328 else if (irq == 7) x = 4;
329 else if (irq == 9) x = 1;
330 else if (irq == 10) x = 8;
331 if (x == -1) {
332 err = "bad irq (5/7/9/10 valid)";
333 goto bad;
334 }
335 else sb_setmixer(scp->io[0], IRQ_NR, x);
336 sb_setmixer(scp->io[0], DMA_NR, (1 << dh) | (1 << dl));
363 if (irq == 5) x = 2;
364 else if (irq == 7) x = 4;
365 else if (irq == 9) x = 1;
366 else if (irq == 10) x = 8;
367 if (x == -1) {
368 err = "bad irq (5/7/9/10 valid)";
369 goto bad;
370 }
371 else sb_setmixer(scp->io[0], IRQ_NR, x);
372 sb_setmixer(scp->io[0], DMA_NR, (1 << dh) | (1 << dl));
373#endif
337 device_printf(dev, "setting card to irq %d, drq %d", irq, dl);
338 if (dl != dh) printf(", %d", dh);
339 printf("\n");
340 break;
341 }
342
343 switch (logical_id) {
344 case 0x43008c0e: /* CTL0043 */

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

458
459static struct resource *
460sbc_alloc_resource(device_t bus, device_t child, int type, int *rid,
461 u_long start, u_long end, u_long count, u_int flags)
462{
463 struct sbc_softc *scp;
464 int *alloced, rid_max, alloced_max;
465 struct resource **res;
374 device_printf(dev, "setting card to irq %d, drq %d", irq, dl);
375 if (dl != dh) printf(", %d", dh);
376 printf("\n");
377 break;
378 }
379
380 switch (logical_id) {
381 case 0x43008c0e: /* CTL0043 */

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

495
496static struct resource *
497sbc_alloc_resource(device_t bus, device_t child, int type, int *rid,
498 u_long start, u_long end, u_long count, u_int flags)
499{
500 struct sbc_softc *scp;
501 int *alloced, rid_max, alloced_max;
502 struct resource **res;
503#ifdef PC98
504 int i;
505#endif
466
467 scp = device_get_softc(bus);
468 switch (type) {
469 case SYS_RES_IOPORT:
470 alloced = scp->io_alloced;
471 res = scp->io;
506
507 scp = device_get_softc(bus);
508 switch (type) {
509 case SYS_RES_IOPORT:
510 alloced = scp->io_alloced;
511 res = scp->io;
512#ifdef PC98
513 rid_max = 0;
514 for (i = 0; i < IO_MAX; i++)
515 rid_max += io_range[i];
516#else
472 rid_max = IO_MAX - 1;
517 rid_max = IO_MAX - 1;
518#endif
473 alloced_max = 1;
474 break;
475 case SYS_RES_DRQ:
476 alloced = scp->drq_alloced;
477 res = scp->drq;
478 rid_max = DRQ_MAX - 1;
479 alloced_max = 1;
480 break;

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

565
566static int
567alloc_resource(struct sbc_softc *scp)
568{
569 int i;
570
571 for (i = 0 ; i < IO_MAX ; i++) {
572 if (scp->io[i] == NULL) {
519 alloced_max = 1;
520 break;
521 case SYS_RES_DRQ:
522 alloced = scp->drq_alloced;
523 res = scp->drq;
524 rid_max = DRQ_MAX - 1;
525 alloced_max = 1;
526 break;

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

611
612static int
613alloc_resource(struct sbc_softc *scp)
614{
615 int i;
616
617 for (i = 0 ; i < IO_MAX ; i++) {
618 if (scp->io[i] == NULL) {
619#ifdef PC98
620 scp->io_rid[i] = i > 0 ?
621 scp->io_rid[i - 1] + io_range[i - 1] : 0;
622 scp->io[i] = isa_alloc_resourcev(scp->dev,
623 SYS_RES_IOPORT,
624 &scp->io_rid[i],
625 sb_iat[i],
626 io_range[i],
627 RF_ACTIVE);
628 if (scp->io[i] != NULL)
629 isa_load_resourcev(scp->io[i], sb_iat[i],
630 io_range[i]);
631#else
573 scp->io_rid[i] = i;
574 scp->io[i] = bus_alloc_resource(scp->dev, SYS_RES_IOPORT, &scp->io_rid[i],
575 0, ~0, io_range[i], RF_ACTIVE);
632 scp->io_rid[i] = i;
633 scp->io[i] = bus_alloc_resource(scp->dev, SYS_RES_IOPORT, &scp->io_rid[i],
634 0, ~0, io_range[i], RF_ACTIVE);
635#endif
576 if (i == 0 && scp->io[i] == NULL)
577 return (1);
578 scp->io_alloced[i] = 0;
579 }
580 }
581 for (i = 0 ; i < DRQ_MAX ; i++) {
582 if (scp->drq[i] == NULL) {
583 scp->drq_rid[i] = i;

--- 77 unchanged lines hidden ---
636 if (i == 0 && scp->io[i] == NULL)
637 return (1);
638 scp->io_alloced[i] = 0;
639 }
640 }
641 for (i = 0 ; i < DRQ_MAX ; i++) {
642 if (scp->drq[i] == NULL) {
643 scp->drq_rid[i] = i;

--- 77 unchanged lines hidden ---