| 1 | /* $Id: irqmgr.c,v 1.1 2000/04/23 14:55:44 ktk Exp $ */
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 | /*
|
|---|
| 5 | **********************************************************************
|
|---|
| 6 | * irqmgr.c - IRQ manager for emu10k1 driver
|
|---|
| 7 | * Copyright 1999, 2000 Creative Labs, Inc.
|
|---|
| 8 | *
|
|---|
| 9 | **********************************************************************
|
|---|
| 10 | *
|
|---|
| 11 | * Date Author Summary of changes
|
|---|
| 12 | * ---- ------ ------------------
|
|---|
| 13 | * October 20, 1999 Bertrand Lee base code release
|
|---|
| 14 | *
|
|---|
| 15 | **********************************************************************
|
|---|
| 16 | *
|
|---|
| 17 | * This program is free software; you can redistribute it and/or
|
|---|
| 18 | * modify it under the terms of the GNU General Public License as
|
|---|
| 19 | * published by the Free Software Foundation; either version 2 of
|
|---|
| 20 | * the License, or (at your option) any later version.
|
|---|
| 21 | *
|
|---|
| 22 | * This program is distributed in the hope that it will be useful,
|
|---|
| 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 25 | * GNU General Public License for more details.
|
|---|
| 26 | *
|
|---|
| 27 | * You should have received a copy of the GNU General Public
|
|---|
| 28 | * License along with this program; if not, write to the Free
|
|---|
| 29 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
|
|---|
| 30 | * USA.
|
|---|
| 31 | *
|
|---|
| 32 | **********************************************************************
|
|---|
| 33 | */
|
|---|
| 34 |
|
|---|
| 35 | #include "hwaccess.h"
|
|---|
| 36 | #include "cardmi.h"
|
|---|
| 37 | #include "cardmo.h"
|
|---|
| 38 | #include "irqmgr.h"
|
|---|
| 39 |
|
|---|
| 40 | /* Interrupt handler */
|
|---|
| 41 |
|
|---|
| 42 | void emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
|
|---|
| 43 | {
|
|---|
| 44 | struct emu10k1_card *card = (struct emu10k1_card *) dev_id;
|
|---|
| 45 | u32 irqstatus, ptr, tmp;
|
|---|
| 46 | #ifdef TARGET_OS2
|
|---|
| 47 | int fOurIrq = FALSE;
|
|---|
| 48 | #endif
|
|---|
| 49 |
|
|---|
| 50 | if (!(irqstatus = sblive_readfn0(card, IPR)))
|
|---|
| 51 | return;
|
|---|
| 52 |
|
|---|
| 53 | DPD(4, "emu10k1_interrupt called, irq = %u\n", irq);
|
|---|
| 54 |
|
|---|
| 55 | /* Preserve PTR register */
|
|---|
| 56 | ptr = sblive_readfn0(card, PTR);
|
|---|
| 57 |
|
|---|
| 58 | /*
|
|---|
| 59 | ** NOTE :
|
|---|
| 60 | ** We do a 'while loop' here cos on certain machines, with both
|
|---|
| 61 | ** playback and recording going on at the same time, IRQs will
|
|---|
| 62 | ** stop coming in after a while. Checking IPND indeed shows that
|
|---|
| 63 | ** there are interrupts pending but the PIC says no IRQs pending.
|
|---|
| 64 | ** I suspect that some boards need edge-triggered IRQs but are not
|
|---|
| 65 | ** getting that condition if we don't completely clear the IPND
|
|---|
| 66 | ** (make sure no more interrupts are pending).
|
|---|
| 67 | ** - Eric
|
|---|
| 68 | */
|
|---|
| 69 |
|
|---|
| 70 | do {
|
|---|
| 71 | DPD(4, "irq status %x\n", irqstatus);
|
|---|
| 72 |
|
|---|
| 73 | tmp = irqstatus;
|
|---|
| 74 |
|
|---|
| 75 | #ifdef TARGET_OS2
|
|---|
| 76 | if (irqstatus & (IRQTYPE_PCIBUSERROR|IRQTYPE_MIXERBUTTON|IRQTYPE_VOICE|IRQTYPE_RECORD|IRQTYPE_MPUIN|IRQTYPE_TIMER|IRQTYPE_MPUOUT|IRQTYPE_DSP|IRQTYPE_SPDIF))
|
|---|
| 77 | {
|
|---|
| 78 | fOurIrq = TRUE;
|
|---|
| 79 | }
|
|---|
| 80 | #endif
|
|---|
| 81 |
|
|---|
| 82 | if (irqstatus & IRQTYPE_TIMER) {
|
|---|
| 83 | emu10k1_timer_irqhandler(card);
|
|---|
| 84 | irqstatus &= ~IRQTYPE_TIMER;
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | if (irqstatus & IRQTYPE_MPUIN) {
|
|---|
| 88 | emu10k1_mpuin_irqhandler(card);
|
|---|
| 89 | irqstatus &= ~IRQTYPE_MPUIN;
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | if (irqstatus & IRQTYPE_MPUOUT) {
|
|---|
| 93 | emu10k1_mpuout_irqhandler(card);
|
|---|
| 94 | irqstatus &= ~IRQTYPE_MPUOUT;
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | if (irqstatus)
|
|---|
| 98 | emu10k1_irq_disable(card, irqstatus);
|
|---|
| 99 |
|
|---|
| 100 | sblive_writefn0(card, IPR, tmp);
|
|---|
| 101 |
|
|---|
| 102 | } while ((irqstatus = sblive_readfn0(card, IPR)));
|
|---|
| 103 |
|
|---|
| 104 | #ifdef TARGET_OS2
|
|---|
| 105 | if (fOurIrq) {
|
|---|
| 106 | eoi_irq(irq);
|
|---|
| 107 | }
|
|---|
| 108 | #endif //TARGET_OS2
|
|---|
| 109 | sblive_writefn0(card, PTR, ptr);
|
|---|
| 110 |
|
|---|
| 111 | return;
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | /* Enables the specified irq service */
|
|---|
| 115 |
|
|---|
| 116 | int emu10k1_irq_enable(struct emu10k1_card *card, u32 irqtype)
|
|---|
| 117 | {
|
|---|
| 118 | /*
|
|---|
| 119 | * TODO :
|
|---|
| 120 | * put protection here so that we don't accidentally
|
|---|
| 121 | * screw-up another cardxxx objects irqs
|
|---|
| 122 | */
|
|---|
| 123 |
|
|---|
| 124 | DPD(4, "emu10k1_irq_enable %x\n", irqtype);
|
|---|
| 125 | sblive_wrtmskfn0(card, INTE, irqtype, ENABLE);
|
|---|
| 126 |
|
|---|
| 127 | return CTSTATUS_SUCCESS;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | /* Disables the specified irq service */
|
|---|
| 131 |
|
|---|
| 132 | int emu10k1_irq_disable(struct emu10k1_card *card, u32 irqtype)
|
|---|
| 133 | {
|
|---|
| 134 | /*
|
|---|
| 135 | * TODO :
|
|---|
| 136 | * put protection here so that we don't accidentally
|
|---|
| 137 | * screw-up another cardxxx objects irqs
|
|---|
| 138 | */
|
|---|
| 139 |
|
|---|
| 140 | DPD(4, "emu10k1_irq_disable %x\n", irqtype);
|
|---|
| 141 | sblive_wrtmskfn0(card, INTE, irqtype, DISABLE);
|
|---|
| 142 |
|
|---|
| 143 | return CTSTATUS_SUCCESS;
|
|---|
| 144 | }
|
|---|