Deleted Added
full compact
sbc.c (64845) sbc.c (65644)
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 64845 2000-08-19 18:17:15Z cg $
26 * $FreeBSD: head/sys/dev/sound/isa/sbc.c 65644 2000-09-09 19:21:04Z cg $
27 */
28
29#include <dev/sound/chip.h>
30#include <dev/sound/pcm/sound.h>
31#include <dev/sound/isa/sb.h>
32
33#define IO_MAX 3
34#define IRQ_MAX 1

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

53 int irq_alloced[IRQ_MAX]; /* irq alloc flag */
54
55 int drq_rid[DRQ_MAX]; /* drq rids */
56 struct resource *drq[DRQ_MAX]; /* drq resources */
57 int drq_alloced[DRQ_MAX]; /* drq alloc flag */
58
59 struct sbc_ihl ihl[IRQ_MAX];
60
27 */
28
29#include <dev/sound/chip.h>
30#include <dev/sound/pcm/sound.h>
31#include <dev/sound/isa/sb.h>
32
33#define IO_MAX 3
34#define IRQ_MAX 1

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

53 int irq_alloced[IRQ_MAX]; /* irq alloc flag */
54
55 int drq_rid[DRQ_MAX]; /* drq rids */
56 struct resource *drq[DRQ_MAX]; /* drq resources */
57 int drq_alloced[DRQ_MAX]; /* drq alloc flag */
58
59 struct sbc_ihl ihl[IRQ_MAX];
60
61 void *ih;
61 void *ih[IRQ_MAX];
62
63 u_int32_t bd_ver;
64};
65
66static int sbc_probe(device_t dev);
67static int sbc_attach(device_t dev);
68static void sbc_intr(void *p);
69

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

367 else if (irq == 10) x = 8;
368 if (x == -1) {
369 err = "bad irq (5/7/9/10 valid)";
370 goto bad;
371 }
372 else sb_setmixer(scp->io[0], IRQ_NR, x);
373 sb_setmixer(scp->io[0], DMA_NR, (1 << dh) | (1 << dl));
374#endif
62
63 u_int32_t bd_ver;
64};
65
66static int sbc_probe(device_t dev);
67static int sbc_attach(device_t dev);
68static void sbc_intr(void *p);
69

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

367 else if (irq == 10) x = 8;
368 if (x == -1) {
369 err = "bad irq (5/7/9/10 valid)";
370 goto bad;
371 }
372 else sb_setmixer(scp->io[0], IRQ_NR, x);
373 sb_setmixer(scp->io[0], DMA_NR, (1 << dh) | (1 << dl));
374#endif
375 device_printf(dev, "setting card to irq %d, drq %d", irq, dl);
376 if (dl != dh) printf(", %d", dh);
377 printf("\n");
375 if (bootverbose) {
376 device_printf(dev, "setting card to irq %d, drq %d", irq, dl);
377 if (dl != dh) printf(", %d", dh);
378 printf("\n");
379 }
378 break;
379 }
380
381 switch (logical_id) {
382 case 0x43008c0e: /* CTL0043 */
383 case 0x01200000:
384 case 0x01000000:
385 f |= BD_F_SB16X;
386 break;
387 }
388 scp->bd_ver |= f << 16;
389
390 err = "setup_intr";
391 for (i = 0; i < IRQ_MAX; i++) {
380 break;
381 }
382
383 switch (logical_id) {
384 case 0x43008c0e: /* CTL0043 */
385 case 0x01200000:
386 case 0x01000000:
387 f |= BD_F_SB16X;
388 break;
389 }
390 scp->bd_ver |= f << 16;
391
392 err = "setup_intr";
393 for (i = 0; i < IRQ_MAX; i++) {
392 if (bus_setup_intr(dev, scp->irq[i], INTR_TYPE_TTY, sbc_intr, &scp->ihl[i], &scp->ih))
394 if (bus_setup_intr(dev, scp->irq[i], INTR_TYPE_TTY, sbc_intr, &scp->ihl[i], &scp->ih[i]))
393 goto bad;
394 }
395
396 /* PCM Audio */
397 func = malloc(sizeof(struct sndcard_func), M_DEVBUF, M_NOWAIT);
398 if (func == NULL) goto bad;
399 bzero(func, sizeof(*func));
400 func->func = SCF_PCM;

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

422
423 return (0);
424
425bad: if (err) device_printf(dev, "%s\n", err);
426 release_resource(scp);
427 return (ENXIO);
428}
429
395 goto bad;
396 }
397
398 /* PCM Audio */
399 func = malloc(sizeof(struct sndcard_func), M_DEVBUF, M_NOWAIT);
400 if (func == NULL) goto bad;
401 bzero(func, sizeof(*func));
402 func->func = SCF_PCM;

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

424
425 return (0);
426
427bad: if (err) device_printf(dev, "%s\n", err);
428 release_resource(scp);
429 return (ENXIO);
430}
431
432static int
433sbc_detach(device_t dev)
434{
435 struct sbc_softc *scp = device_get_softc(dev);
436
437 release_resource(scp);
438 return bus_generic_detach(dev);
439}
440
430static void
431sbc_intr(void *p)
432{
433 struct sbc_ihl *ihl = p;
434 int i;
435
436 i = 0;
437 while (i < INTR_MAX) {

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

643 scp->drq[i] = bus_alloc_resource(scp->dev, SYS_RES_DRQ, &scp->drq_rid[i],
644 0, ~0, 1, RF_ACTIVE);
645 if (i == 0 && scp->drq[i] == NULL)
646 return (1);
647 scp->drq_alloced[i] = 0;
648 }
649 }
650 for (i = 0 ; i < IRQ_MAX ; i++) {
441static void
442sbc_intr(void *p)
443{
444 struct sbc_ihl *ihl = p;
445 int i;
446
447 i = 0;
448 while (i < INTR_MAX) {

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

654 scp->drq[i] = bus_alloc_resource(scp->dev, SYS_RES_DRQ, &scp->drq_rid[i],
655 0, ~0, 1, RF_ACTIVE);
656 if (i == 0 && scp->drq[i] == NULL)
657 return (1);
658 scp->drq_alloced[i] = 0;
659 }
660 }
661 for (i = 0 ; i < IRQ_MAX ; i++) {
651 if (scp->irq[i] == NULL) {
662 if (scp->irq[i] == NULL) {
652 scp->irq_rid[i] = i;
653 scp->irq[i] = bus_alloc_resource(scp->dev, SYS_RES_IRQ, &scp->irq_rid[i],
654 0, ~0, 1, RF_ACTIVE);
655 if (i == 0 && scp->irq[i] == NULL)
656 return (1);
657 scp->irq_alloced[i] = 0;
658 }
659 }

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

674 for (i = 0 ; i < DRQ_MAX ; i++) {
675 if (scp->drq[i] != NULL) {
676 bus_release_resource(scp->dev, SYS_RES_DRQ, scp->drq_rid[i], scp->drq[i]);
677 scp->drq[i] = NULL;
678 }
679 }
680 for (i = 0 ; i < IRQ_MAX ; i++) {
681 if (scp->irq[i] != NULL) {
663 scp->irq_rid[i] = i;
664 scp->irq[i] = bus_alloc_resource(scp->dev, SYS_RES_IRQ, &scp->irq_rid[i],
665 0, ~0, 1, RF_ACTIVE);
666 if (i == 0 && scp->irq[i] == NULL)
667 return (1);
668 scp->irq_alloced[i] = 0;
669 }
670 }

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

685 for (i = 0 ; i < DRQ_MAX ; i++) {
686 if (scp->drq[i] != NULL) {
687 bus_release_resource(scp->dev, SYS_RES_DRQ, scp->drq_rid[i], scp->drq[i]);
688 scp->drq[i] = NULL;
689 }
690 }
691 for (i = 0 ; i < IRQ_MAX ; i++) {
692 if (scp->irq[i] != NULL) {
693 if (scp->ih[i] != NULL)
694 bus_teardown_intr(scp->dev, scp->irq[i], scp->ih[i]);
695 scp->ih[i] = NULL;
682 bus_release_resource(scp->dev, SYS_RES_IRQ, scp->irq_rid[i], scp->irq[i]);
683 scp->irq[i] = NULL;
684 }
685 }
686 return (0);
687}
688
689static device_method_t sbc_methods[] = {
690 /* Device interface */
691 DEVMETHOD(device_probe, sbc_probe),
692 DEVMETHOD(device_attach, sbc_attach),
696 bus_release_resource(scp->dev, SYS_RES_IRQ, scp->irq_rid[i], scp->irq[i]);
697 scp->irq[i] = NULL;
698 }
699 }
700 return (0);
701}
702
703static device_method_t sbc_methods[] = {
704 /* Device interface */
705 DEVMETHOD(device_probe, sbc_probe),
706 DEVMETHOD(device_attach, sbc_attach),
693 DEVMETHOD(device_detach, bus_generic_detach),
707 DEVMETHOD(device_detach, sbc_detach),
694 DEVMETHOD(device_shutdown, bus_generic_shutdown),
695 DEVMETHOD(device_suspend, bus_generic_suspend),
696 DEVMETHOD(device_resume, bus_generic_resume),
697
698 /* Bus interface */
699 DEVMETHOD(bus_read_ivar, sbc_read_ivar),
700 DEVMETHOD(bus_write_ivar, sbc_write_ivar),
701 DEVMETHOD(bus_print_child, bus_generic_print_child),

--- 22 unchanged lines hidden ---
708 DEVMETHOD(device_shutdown, bus_generic_shutdown),
709 DEVMETHOD(device_suspend, bus_generic_suspend),
710 DEVMETHOD(device_resume, bus_generic_resume),
711
712 /* Bus interface */
713 DEVMETHOD(bus_read_ivar, sbc_read_ivar),
714 DEVMETHOD(bus_write_ivar, sbc_write_ivar),
715 DEVMETHOD(bus_print_child, bus_generic_print_child),

--- 22 unchanged lines hidden ---