Changeset 76 for GPL/trunk/lib32/irq.c


Ignore:
Timestamp:
Apr 9, 2006, 12:09:39 PM (19 years ago)
Author:
vladest
Message:

Latest ALSA patches
HDA patches
Patch for Intel from Rudy's
Fixes locks on NM256 chipsets
Fixes PM on Maestro3 chipsets

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk/lib32/irq.c

    r63 r76  
    4545
    4646static IRQ_SLOT         arSlots[MAX_IRQ_SLOTS] = { 0 };
     47static ULONG           eoiIrq[255] = {0};
    4748
    4849
     
    5152static IRQ_SLOT *FindSlot(unsigned irq)
    5253{
    53   IRQ_SLOT      *pSlot;
    54 
    55   for( pSlot = arSlots; pSlot != &arSlots[MAX_IRQ_SLOTS]; pSlot++ )
    56   {
    57     if( pSlot->irqNo == irq )   return pSlot;
    58   }
    59 
    60   return NULL;
     54    IRQ_SLOT      *pSlot;
     55
     56    for( pSlot = arSlots; pSlot != &arSlots[MAX_IRQ_SLOTS]; pSlot++ )
     57    {
     58        if( pSlot->irqNo == irq )   return pSlot;
     59    }
     60
     61    return NULL;
    6162}
    6263
     
    7172    IRQ_SLOT    *pSlot = FindSlot(irq);
    7273    unsigned    u, uSlotNo = (unsigned)-1;
    73   if( !pSlot )
    74   {
    75     // find empty slot
    76     for( uSlotNo = 0; uSlotNo < MAX_IRQ_SLOTS; uSlotNo++ )
    77     {
    78       if( arSlots[uSlotNo].flHandlers == 0 )
    79       {
    80         pSlot = &arSlots[uSlotNo];      break;
    81       }
    82     }
    83 
    84     }
    85 
    86   if( pSlot )
    87   {
    88     if(RMRequestIRQ(/*hResMgr,*/ irq, (x0 & SA_SHIRQ) != 0) == FALSE) {
    89         dprintf(("RMRequestIRQ failed for irq %d", irq));
    90 //      return 0;
    91     }
    92 
    93     for( u = 0; u < MAX_SHAREDIRQS; u++ )
    94     {
    95       if( pSlot->irqHandlers[u].handler == NULL )
    96       {
    97           pSlot->irqNo = irq;
    98         pSlot->irqHandlers[u].handler = handler;
    99         pSlot->irqHandlers[u].x0 = x0;
    100         pSlot->irqHandlers[u].x1 = (char *)x1;
    101         pSlot->irqHandlers[u].x2 = x2;
    102 
    103         if( pSlot->flHandlers != 0 ||
    104             ALSA_SetIrq(irq, uSlotNo, (x0 & SA_SHIRQ) != 0) )
     74    if( !pSlot )
     75    {
     76        // find empty slot
     77        for( uSlotNo = 0; uSlotNo < MAX_IRQ_SLOTS; uSlotNo++ )
     78        {
     79            if( arSlots[uSlotNo].flHandlers == 0 )
     80            {
     81                pSlot = &arSlots[uSlotNo];      break;
     82            }
     83        }
     84
     85    }
     86
     87    if( pSlot )
     88    {
     89        if(RMRequestIRQ(/*hResMgr,*/ irq, (x0 & SA_SHIRQ) != 0) == FALSE) {
     90            dprintf(("RMRequestIRQ failed for irq %d", irq));
     91            //  return 0;
     92        }
     93
     94        for( u = 0; u < MAX_SHAREDIRQS; u++ )
     95        {
     96            if( pSlot->irqHandlers[u].handler == NULL )
     97            {
     98                pSlot->irqNo = irq;
     99                pSlot->irqHandlers[u].handler = handler;
     100                pSlot->irqHandlers[u].x0 = x0;
     101                pSlot->irqHandlers[u].x1 = (char *)x1;
     102                pSlot->irqHandlers[u].x2 = x2;
     103
     104                if( pSlot->flHandlers != 0 ||
     105                   ALSA_SetIrq(irq, uSlotNo, (x0 & SA_SHIRQ) != 0) )
    105106                {
    106           pSlot->flHandlers |= 1 << u;
    107           return 0;
     107                    pSlot->flHandlers |= 1 << u;
     108                    return 0;
    108109                }
    109110
    110         break;
    111             }
    112         }
    113     }
    114 
    115   dprintf(("request_irq: Unable to register irq handler for irq %d\n", irq));
     111                break;
     112            }
     113        }
     114    }
     115
     116    dprintf(("request_irq: Unable to register irq handler for irq %d\n", irq));
    116117    return 1;
    117118}
     
    122123void free_irq(unsigned int irq, void *userdata)
    123124{
    124   unsigned      u;
    125   IRQ_SLOT      *pSlot;
    126 
    127   if( (pSlot = FindSlot(irq)) != NULL )
    128   {
    129     for( u = 0; u < MAX_SHAREDIRQS; u++ )
    130     {
    131       if( pSlot->irqHandlers[u].x2 == userdata )
    132       {
    133         pSlot->flHandlers &= ~(1 << u);
    134         if( pSlot->flHandlers == 0 )
    135         {
    136           ALSA_FreeIrq(pSlot->irqNo);
    137           pSlot->irqNo = 0;
    138 //        pSlot->fEOI = 0;
    139             }
    140 
    141         pSlot->irqHandlers[u].handler = NULL;
    142         pSlot->irqHandlers[u].x0 = 0;
    143         pSlot->irqHandlers[u].x1 = NULL;
    144         pSlot->irqHandlers[u].x2 = NULL;
    145 
    146         return;
    147 
    148       }
    149     }
    150 }
     125    unsigned    u;
     126    IRQ_SLOT    *pSlot;
     127
     128    if( (pSlot = FindSlot(irq)) != NULL )
     129    {
     130        for( u = 0; u < MAX_SHAREDIRQS; u++ )
     131        {
     132            if( pSlot->irqHandlers[u].x2 == userdata )
     133            {
     134                pSlot->flHandlers &= ~(1 << u);
     135                if( pSlot->flHandlers == 0 )
     136                {
     137                    ALSA_FreeIrq(pSlot->irqNo);
     138                    pSlot->irqNo = 0;
     139                    //    pSlot->fEOI = 0;
     140                }
     141
     142                pSlot->irqHandlers[u].handler = NULL;
     143                pSlot->irqHandlers[u].x0 = 0;
     144                pSlot->irqHandlers[u].x1 = NULL;
     145                pSlot->irqHandlers[u].x2 = NULL;
     146
     147                return;
     148
     149            }
     150        }
     151    }
    151152}
    152153
     
    156157void eoi_irq(unsigned int irq)
    157158{
    158   (void)irq;
    159 /*
    160   IRQ_SLOT      *pSlot = FindSlot(irq);
    161 
    162   if( pSlot )   pSlot->fEOI = 1;
    163 */
     159    /*(void)irq; */
     160    /*
     161     IRQ_SLOT   *pSlot = FindSlot(irq);
     162
     163     if( pSlot )        pSlot->fEOI = 1;
     164     */
     165    eoiIrq[irq]++;
    164166}
    165167
     
    169171BOOL process_interrupt(ULONG ulSlotNo, ULONG *pulIrq)
    170172{
    171   unsigned      u;
    172  int rc;
    173   IRQ_SLOT      *pSlot;
    174 
    175 #ifdef DEBUG
    176 // dprintf(("int proc"));
    177 #endif
    178 
    179     if(fSuspended) 
     173    unsigned    u;
     174    int rc;
     175    IRQ_SLOT    *pSlot;
     176
     177#ifdef DEBUG
     178    dprintf(("enter int proc %d %d",ulSlotNo, *pulIrq));
     179#endif
     180
     181    if(fSuspended)
    180182    {//If our device is suspended, then we can't receive interrupts, so it must
    181      //be for some other device
    182      //Don't pass it to the linux handler as the device doesn't respond as expected
     183        //be for some other device
     184        //Don't pass it to the linux handler as the device doesn't respond as expected
    183185        //when suspended
    184186#ifdef DEBUG
    185         dprintf(("IRQ %d suspended",irq));
     187        dprintf(("Slot %d IRQ %d suspended",ulSlotNo, *pulIrq));
    186188#endif
    187189        return FALSE;
    188190    }
    189191
    190   if( ulSlotNo < MAX_IRQ_SLOTS )
    191     {
    192     pSlot = &arSlots[ulSlotNo];
    193 
    194     for( u = 0; u < MAX_SHAREDIRQS; u++ )
    195     {
    196       if( pSlot->irqHandlers[u].handler )
    197         {
    198             fInInterrupt = TRUE;
    199         rc = pSlot->irqHandlers[u].handler(pSlot->irqNo,
    200                                            pSlot->irqHandlers[u].x2, 0);
    201             fInInterrupt = FALSE;
    202 
    203         if( rc /*== 1 || pSlot->fEOI*/ ) {
    204 
    205             *pulIrq = pSlot->irqNo;
    206 //          pSlot->fEOI = 0;
    207 
    208                 //ok, this interrupt was intended for us; notify the 16 bits MMPM/2 driver
    209                 OSS32_ProcessIRQ();
    210                 return TRUE;
    211             }
    212         }
    213     }
    214     }
     192    if( ulSlotNo < MAX_IRQ_SLOTS )
     193    {
     194        pSlot = &arSlots[ulSlotNo];
     195
     196        for( u = 0; u < MAX_SHAREDIRQS; u++ )
     197        {
     198            if(pSlot && pSlot->irqHandlers[u].handler )
     199            {
     200                fInInterrupt = TRUE;
     201                rc = pSlot->irqHandlers[u].handler(pSlot->irqNo,
     202                                                   pSlot->irqHandlers[u].x2, 0);
     203                if (rc == 1) eoi_irq(pSlot->irqNo);
     204                rc = (eoiIrq[pSlot->irqNo] > 0);
     205                fInInterrupt = FALSE;
     206
     207                if( rc /*== 1 || pSlot->fEOI*/ ) {
     208
     209                    *pulIrq = pSlot->irqNo;
     210                    //      pSlot->fEOI = 0;
     211
     212                    //ok, this interrupt was intended for us; notify the 16 bits MMPM/2 driver
     213                    OSS32_ProcessIRQ();
     214#ifdef DEBUG
     215                    dprintf(("exit(1) int proc %d %d",ulSlotNo, *pulIrq));
     216#endif
     217                    eoiIrq[pSlot->irqNo] = 0;
     218                    return TRUE;
     219                }
     220            }
     221        }
     222    }
     223#ifdef DEBUG
     224                    dprintf(("exit(0) int proc %d %d",ulSlotNo, *pulIrq));
     225#endif
    215226
    216227    return FALSE;
     
    236247//******************************************************************************
    237248
    238 
    239 
Note: See TracChangeset for help on using the changeset viewer.