Ignore:
Timestamp:
Dec 11, 2005, 5:57:39 PM (20 years ago)
Author:
vladest
Message:

Latest update from ALSA. some intial > 15 interrupts support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1x.c

    r33 r34  
    196196 */
    197197
    198 typedef struct snd_emu10k1x_voice emu10k1x_voice_t;
    199 typedef struct snd_emu10k1x emu10k1x_t;
    200 typedef struct snd_emu10k1x_pcm emu10k1x_pcm_t;
    201 
    202 struct snd_emu10k1x_voice {
    203         emu10k1x_t *emu;
     198struct emu10k1x_voice {
     199        struct emu10k1x *emu;
    204200        int number;
    205201        int use;
    206202 
    207         emu10k1x_pcm_t *epcm;
     203        struct emu10k1x_pcm *epcm;
    208204};
    209205
    210 struct snd_emu10k1x_pcm {
    211         emu10k1x_t *emu;
    212         snd_pcm_substream_t *substream;
    213         emu10k1x_voice_t *voice;
     206struct emu10k1x_pcm {
     207        struct emu10k1x *emu;
     208        struct snd_pcm_substream *substream;
     209        struct emu10k1x_voice *voice;
    214210        unsigned short running;
    215211};
    216212
    217 typedef struct {
    218         struct snd_emu10k1x *emu;
    219         snd_rawmidi_t *rmidi;
    220         snd_rawmidi_substream_t *substream_input;
    221         snd_rawmidi_substream_t *substream_output;
     213struct emu10k1x_midi {
     214        struct emu10k1x *emu;
     215        struct snd_rawmidi *rmidi;
     216        struct snd_rawmidi_substream *substream_input;
     217        struct snd_rawmidi_substream *substream_output;
    222218        unsigned int midi_mode;
    223219        spinlock_t input_lock;
     
    227223        int port;
    228224        int ipr_tx, ipr_rx;
    229         void (*interrupt)(emu10k1x_t *emu, unsigned int status);
    230 } emu10k1x_midi_t;
     225        void (*interrupt)(struct emu10k1x *emu, unsigned int status);
     226};
    231227
    232228// definition of the chip-specific record
    233 struct snd_emu10k1x {
    234         snd_card_t *card;
     229struct emu10k1x {
     230        struct snd_card *card;
    235231        struct pci_dev *pci;
    236232
     
    246242        spinlock_t voice_lock;
    247243
    248         ac97_t *ac97;
    249         snd_pcm_t *pcm;
    250 
    251         emu10k1x_voice_t voices[3];
    252         emu10k1x_voice_t capture_voice;
     244        struct snd_ac97 *ac97;
     245        struct snd_pcm *pcm;
     246
     247        struct emu10k1x_voice voices[3];
     248        struct emu10k1x_voice capture_voice;
    253249        u32 spdif_bits[3]; // SPDIF out setup
    254250
    255251        struct snd_dma_buffer dma_buffer;
    256252
    257         emu10k1x_midi_t midi;
     253        struct emu10k1x_midi midi;
    258254};
    259255
    260256/* hardware definition */
    261 static snd_pcm_hardware_t snd_emu10k1x_playback_hw = {
    262         /*.info =              */  (SNDRV_PCM_INFO_MMAP |
     257static struct snd_pcm_hardware snd_emu10k1x_playback_hw = {
     258        .info =                 (SNDRV_PCM_INFO_MMAP |
    263259                                 SNDRV_PCM_INFO_INTERLEAVED |
    264260                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
    265261                                 SNDRV_PCM_INFO_MMAP_VALID),
    266         /*.formats =           */ SNDRV_PCM_FMTBIT_S16_LE,
    267         /*.rates =             */ SNDRV_PCM_RATE_48000,
    268         /*.rate_min =          */ 48000,
    269         /*.rate_max =          */ 48000,
    270         /*.channels_min =      */       2,
    271         /*.channels_max =      */       2,
    272         /*.buffer_bytes_max =  */ (32*1024),
    273         /*.period_bytes_min =  */ 64,
    274         /*.period_bytes_max =  */ (16*1024),
    275         /*.periods_min =       */       2,
    276         /*.periods_max =       */       8,
    277         /*.fifo_size =         */ 0
     262        .formats =              SNDRV_PCM_FMTBIT_S16_LE,
     263        .rates =                SNDRV_PCM_RATE_48000,
     264        .rate_min =             48000,
     265        .rate_max =             48000,
     266        .channels_min =         2,
     267        .channels_max =         2,
     268        .buffer_bytes_max =     (32*1024),
     269        .period_bytes_min =     64,
     270        .period_bytes_max =     (16*1024),
     271        .periods_min =          2,
     272        .periods_max =          8,
     273        .fifo_size =            0,
    278274};
    279275
    280 static snd_pcm_hardware_t snd_emu10k1x_capture_hw = {
    281         /*.info =              */       (SNDRV_PCM_INFO_MMAP |
     276static struct snd_pcm_hardware snd_emu10k1x_capture_hw = {
     277        .info =                 (SNDRV_PCM_INFO_MMAP |
    282278                                 SNDRV_PCM_INFO_INTERLEAVED |
    283279                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
    284280                                 SNDRV_PCM_INFO_MMAP_VALID),
    285         /*.formats =           */ SNDRV_PCM_FMTBIT_S16_LE,
    286         /*.rates =             */ SNDRV_PCM_RATE_48000,
    287         /*.rate_min =          */ 48000,
    288         /*.rate_max =          */ 48000,
    289         /*.channels_min =      */       2,
    290         /*.channels_max =      */       2,
    291         /*.buffer_bytes_max =  */ (32*1024),
    292         /*.period_bytes_min =  */ 64,
    293         /*.period_bytes_max =  */ (16*1024),
    294         /*.periods_min =       */       2,
    295         /*.periods_max =       */       2,
    296         /*.fifo_size =         */ 0
     281        .formats =              SNDRV_PCM_FMTBIT_S16_LE,
     282        .rates =                SNDRV_PCM_RATE_48000,
     283        .rate_min =             48000,
     284        .rate_max =             48000,
     285        .channels_min =         2,
     286        .channels_max =         2,
     287        .buffer_bytes_max =     (32*1024),
     288        .period_bytes_min =     64,
     289        .period_bytes_max =     (16*1024),
     290        .periods_min =          2,
     291        .periods_max =          2,
     292        .fifo_size =            0,
    297293};
    298294
    299 static unsigned int snd_emu10k1x_ptr_read(emu10k1x_t * emu,
     295static unsigned int snd_emu10k1x_ptr_read(struct emu10k1x * emu,
    300296                                          unsigned int reg,
    301297                                          unsigned int chn)
     
    313309}
    314310
    315 static void snd_emu10k1x_ptr_write(emu10k1x_t *emu,
     311static void snd_emu10k1x_ptr_write(struct emu10k1x *emu,
    316312                                   unsigned int reg,
    317313                                   unsigned int chn,
     
    329325}
    330326
    331 static void snd_emu10k1x_intr_enable(emu10k1x_t *emu, unsigned int intrenb)
     327static void snd_emu10k1x_intr_enable(struct emu10k1x *emu, unsigned int intrenb)
    332328{
    333329        unsigned long flags;
     
    340336}
    341337
    342 static void snd_emu10k1x_intr_disable(emu10k1x_t *emu, unsigned int intrenb)
     338static void snd_emu10k1x_intr_disable(struct emu10k1x *emu, unsigned int intrenb)
    343339{
    344340        unsigned long flags;
     
    351347}
    352348
    353 static void snd_emu10k1x_gpio_write(emu10k1x_t *emu, unsigned int value)
     349static void snd_emu10k1x_gpio_write(struct emu10k1x *emu, unsigned int value)
    354350{
    355351        unsigned long flags;
     
    360356}
    361357
    362 static void snd_emu10k1x_pcm_free_substream(snd_pcm_runtime_t *runtime)
    363 {
    364         emu10k1x_pcm_t *epcm = runtime->private_data;
    365  
    366         if (epcm)
    367                 kfree(epcm);
    368 }
    369 
    370 static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice)
    371 {
    372         emu10k1x_pcm_t *epcm;
     358static void snd_emu10k1x_pcm_free_substream(struct snd_pcm_runtime *runtime)
     359{
     360        kfree(runtime->private_data);
     361}
     362
     363static void snd_emu10k1x_pcm_interrupt(struct emu10k1x *emu, struct emu10k1x_voice *voice)
     364{
     365        struct emu10k1x_pcm *epcm;
    373366
    374367        if ((epcm = voice->epcm) == NULL)
     
    386379
    387380/* open callback */
    388 static int snd_emu10k1x_playback_open(snd_pcm_substream_t *substream)
    389 {
    390         emu10k1x_t *chip = snd_pcm_substream_chip(substream);
    391         emu10k1x_pcm_t *epcm;
    392         snd_pcm_runtime_t *runtime = substream->runtime;
     381static int snd_emu10k1x_playback_open(struct snd_pcm_substream *substream)
     382{
     383        struct emu10k1x *chip = snd_pcm_substream_chip(substream);
     384        struct emu10k1x_pcm *epcm;
     385        struct snd_pcm_runtime *runtime = substream->runtime;
    393386        int err;
    394387
     
    399392                return err;
    400393
    401         epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
     394        epcm = (struct emu10k1x_pcm *)kzalloc(sizeof(*epcm), GFP_KERNEL);
    402395        if (epcm == NULL)
    403396                return -ENOMEM;
     
    414407
    415408/* close callback */
    416 static int snd_emu10k1x_playback_close(snd_pcm_substream_t *substream)
     409static int snd_emu10k1x_playback_close(struct snd_pcm_substream *substream)
    417410{
    418411        return 0;
     
    420413
    421414/* hw_params callback */
    422 static int snd_emu10k1x_pcm_hw_params(snd_pcm_substream_t *substream,
    423                                       snd_pcm_hw_params_t * hw_params)
    424 {
    425         snd_pcm_runtime_t *runtime = substream->runtime;
    426         emu10k1x_pcm_t *epcm = runtime->private_data;
     415static int snd_emu10k1x_pcm_hw_params(struct snd_pcm_substream *substream,
     416                                      struct snd_pcm_hw_params *hw_params)
     417{
     418        struct snd_pcm_runtime *runtime = substream->runtime;
     419        struct emu10k1x_pcm *epcm = runtime->private_data;
    427420
    428421        if (! epcm->voice) {
     
    437430
    438431/* hw_free callback */
    439 static int snd_emu10k1x_pcm_hw_free(snd_pcm_substream_t *substream)
    440 {
    441         snd_pcm_runtime_t *runtime = substream->runtime;
    442         emu10k1x_pcm_t *epcm;
     432static int snd_emu10k1x_pcm_hw_free(struct snd_pcm_substream *substream)
     433{
     434        struct snd_pcm_runtime *runtime = substream->runtime;
     435        struct emu10k1x_pcm *epcm;
    443436
    444437        if (runtime->private_data == NULL)
     
    457450
    458451/* prepare callback */
    459 static int snd_emu10k1x_pcm_prepare(snd_pcm_substream_t *substream)
    460 {
    461         emu10k1x_t *emu = snd_pcm_substream_chip(substream);
    462         snd_pcm_runtime_t *runtime = substream->runtime;
    463         emu10k1x_pcm_t *epcm = runtime->private_data;
     452static int snd_emu10k1x_pcm_prepare(struct snd_pcm_substream *substream)
     453{
     454        struct emu10k1x *emu = snd_pcm_substream_chip(substream);
     455        struct snd_pcm_runtime *runtime = substream->runtime;
     456        struct emu10k1x_pcm *epcm = runtime->private_data;
    464457        int voice = epcm->voice->number;
    465458        u32 *table_base = (u32 *)(emu->dma_buffer.area+1024*voice);
     
    486479
    487480/* trigger callback */
    488 static int snd_emu10k1x_pcm_trigger(snd_pcm_substream_t *substream,
     481static int snd_emu10k1x_pcm_trigger(struct snd_pcm_substream *substream,
    489482                                    int cmd)
    490483{
    491         emu10k1x_t *emu = snd_pcm_substream_chip(substream);
    492         snd_pcm_runtime_t *runtime = substream->runtime;
    493         emu10k1x_pcm_t *epcm = runtime->private_data;
     484        struct emu10k1x *emu = snd_pcm_substream_chip(substream);
     485        struct snd_pcm_runtime *runtime = substream->runtime;
     486        struct emu10k1x_pcm *epcm = runtime->private_data;
    494487        int channel = epcm->voice->number;
    495488        int result = 0;
     
    520513/* pointer callback */
    521514static snd_pcm_uframes_t
    522 snd_emu10k1x_pcm_pointer(snd_pcm_substream_t *substream)
    523 {
    524         emu10k1x_t *emu = snd_pcm_substream_chip(substream);
    525         snd_pcm_runtime_t *runtime = substream->runtime;
    526         emu10k1x_pcm_t *epcm = runtime->private_data;
     515snd_emu10k1x_pcm_pointer(struct snd_pcm_substream *substream)
     516{
     517        struct emu10k1x *emu = snd_pcm_substream_chip(substream);
     518        struct snd_pcm_runtime *runtime = substream->runtime;
     519        struct emu10k1x_pcm *epcm = runtime->private_data;
    527520        int channel = epcm->voice->number;
    528521        snd_pcm_uframes_t ptr = 0, ptr1 = 0, ptr2= 0,ptr3 = 0,ptr4 = 0;
     
    551544
    552545/* operators */
    553 static snd_pcm_ops_t snd_emu10k1x_playback_ops = {
    554         /*.open =       */ snd_emu10k1x_playback_open,
    555         /*.close =      */ snd_emu10k1x_playback_close,
    556         /*.ioctl =      */ snd_pcm_lib_ioctl,
    557         /*.hw_params =  */ snd_emu10k1x_pcm_hw_params,
    558         /*.hw_free =    */ snd_emu10k1x_pcm_hw_free,
    559         /*.prepare =    */ snd_emu10k1x_pcm_prepare,
    560         /*.trigger =    */ snd_emu10k1x_pcm_trigger,
    561         /*.pointer =    */ snd_emu10k1x_pcm_pointer,
    562         0,0,0,0
     546static struct snd_pcm_ops snd_emu10k1x_playback_ops = {
     547        .open =        snd_emu10k1x_playback_open,
     548        .close =       snd_emu10k1x_playback_close,
     549        .ioctl =       snd_pcm_lib_ioctl,
     550        .hw_params =   snd_emu10k1x_pcm_hw_params,
     551        .hw_free =     snd_emu10k1x_pcm_hw_free,
     552        .prepare =     snd_emu10k1x_pcm_prepare,
     553        .trigger =     snd_emu10k1x_pcm_trigger,
     554        .pointer =     snd_emu10k1x_pcm_pointer,
    563555};
    564556
    565557/* open_capture callback */
    566 static int snd_emu10k1x_pcm_open_capture(snd_pcm_substream_t *substream)
    567 {
    568         emu10k1x_t *chip = snd_pcm_substream_chip(substream);
    569         emu10k1x_pcm_t *epcm;
    570         snd_pcm_runtime_t *runtime = substream->runtime;
     558static int snd_emu10k1x_pcm_open_capture(struct snd_pcm_substream *substream)
     559{
     560        struct emu10k1x *chip = snd_pcm_substream_chip(substream);
     561        struct emu10k1x_pcm *epcm;
     562        struct snd_pcm_runtime *runtime = substream->runtime;
    571563        int err;
    572564
     
    576568                return err;
    577569
    578         epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
     570        epcm = (struct emu10k1x_pcm *)kzalloc(sizeof(*epcm), GFP_KERNEL);
    579571        if (epcm == NULL)
    580572                return -ENOMEM;
     
    592584
    593585/* close callback */
    594 static int snd_emu10k1x_pcm_close_capture(snd_pcm_substream_t *substream)
     586static int snd_emu10k1x_pcm_close_capture(struct snd_pcm_substream *substream)
    595587{
    596588        return 0;
     
    598590
    599591/* hw_params callback */
    600 static int snd_emu10k1x_pcm_hw_params_capture(snd_pcm_substream_t *substream,
    601                                               snd_pcm_hw_params_t * hw_params)
    602 {
    603         snd_pcm_runtime_t *runtime = substream->runtime;
    604         emu10k1x_pcm_t *epcm = runtime->private_data;
     592static int snd_emu10k1x_pcm_hw_params_capture(struct snd_pcm_substream *substream,
     593                                              struct snd_pcm_hw_params *hw_params)
     594{
     595        struct snd_pcm_runtime *runtime = substream->runtime;
     596        struct emu10k1x_pcm *epcm = runtime->private_data;
    605597
    606598        if (! epcm->voice) {
     
    617609
    618610/* hw_free callback */
    619 static int snd_emu10k1x_pcm_hw_free_capture(snd_pcm_substream_t *substream)
    620 {
    621         snd_pcm_runtime_t *runtime = substream->runtime;
    622 
    623         emu10k1x_pcm_t *epcm;
     611static int snd_emu10k1x_pcm_hw_free_capture(struct snd_pcm_substream *substream)
     612{
     613        struct snd_pcm_runtime *runtime = substream->runtime;
     614
     615        struct emu10k1x_pcm *epcm;
    624616
    625617        if (runtime->private_data == NULL)
     
    637629
    638630/* prepare capture callback */
    639 static int snd_emu10k1x_pcm_prepare_capture(snd_pcm_substream_t *substream)
    640 {
    641         emu10k1x_t *emu = snd_pcm_substream_chip(substream);
    642         snd_pcm_runtime_t *runtime = substream->runtime;
     631static int snd_emu10k1x_pcm_prepare_capture(struct snd_pcm_substream *substream)
     632{
     633        struct emu10k1x *emu = snd_pcm_substream_chip(substream);
     634        struct snd_pcm_runtime *runtime = substream->runtime;
    643635
    644636        snd_emu10k1x_ptr_write(emu, CAPTURE_DMA_ADDR, 0, runtime->dma_addr);
     
    651643
    652644/* trigger_capture callback */
    653 static int snd_emu10k1x_pcm_trigger_capture(snd_pcm_substream_t *substream,
     645static int snd_emu10k1x_pcm_trigger_capture(struct snd_pcm_substream *substream,
    654646                                            int cmd)
    655647{
    656         emu10k1x_t *emu = snd_pcm_substream_chip(substream);
    657         snd_pcm_runtime_t *runtime = substream->runtime;
    658         emu10k1x_pcm_t *epcm = runtime->private_data;
     648        struct emu10k1x *emu = snd_pcm_substream_chip(substream);
     649        struct snd_pcm_runtime *runtime = substream->runtime;
     650        struct emu10k1x_pcm *epcm = runtime->private_data;
    659651        int result = 0;
    660652
     
    681673/* pointer_capture callback */
    682674static snd_pcm_uframes_t
    683 snd_emu10k1x_pcm_pointer_capture(snd_pcm_substream_t *substream)
    684 {
    685         emu10k1x_t *emu = snd_pcm_substream_chip(substream);
    686         snd_pcm_runtime_t *runtime = substream->runtime;
    687         emu10k1x_pcm_t *epcm = runtime->private_data;
     675snd_emu10k1x_pcm_pointer_capture(struct snd_pcm_substream *substream)
     676{
     677        struct emu10k1x *emu = snd_pcm_substream_chip(substream);
     678        struct snd_pcm_runtime *runtime = substream->runtime;
     679        struct emu10k1x_pcm *epcm = runtime->private_data;
    688680        snd_pcm_uframes_t ptr;
    689681
     
    698690}
    699691
    700 static snd_pcm_ops_t snd_emu10k1x_capture_ops = {
    701         /*.open =       */ snd_emu10k1x_pcm_open_capture,
    702         /*.close =      */ snd_emu10k1x_pcm_close_capture,
    703         /*.ioctl =      */ snd_pcm_lib_ioctl,
    704         /*.hw_params =  */ snd_emu10k1x_pcm_hw_params_capture,
    705         /*.hw_free =    */ snd_emu10k1x_pcm_hw_free_capture,
    706         /*.prepare =    */ snd_emu10k1x_pcm_prepare_capture,
    707         /*.trigger =    */ snd_emu10k1x_pcm_trigger_capture,
    708         /*.pointer =    */ snd_emu10k1x_pcm_pointer_capture,
    709         0,0,0,0
     692static struct snd_pcm_ops snd_emu10k1x_capture_ops = {
     693        .open =        snd_emu10k1x_pcm_open_capture,
     694        .close =       snd_emu10k1x_pcm_close_capture,
     695        .ioctl =       snd_pcm_lib_ioctl,
     696        .hw_params =   snd_emu10k1x_pcm_hw_params_capture,
     697        .hw_free =     snd_emu10k1x_pcm_hw_free_capture,
     698        .prepare =     snd_emu10k1x_pcm_prepare_capture,
     699        .trigger =     snd_emu10k1x_pcm_trigger_capture,
     700        .pointer =     snd_emu10k1x_pcm_pointer_capture,
    710701};
    711702
    712 static unsigned short snd_emu10k1x_ac97_read(ac97_t *ac97,
     703static unsigned short snd_emu10k1x_ac97_read(struct snd_ac97 *ac97,
    713704                                             unsigned short reg)
    714705{
    715         emu10k1x_t *emu = ac97->private_data;
     706        struct emu10k1x *emu = ac97->private_data;
    716707        unsigned long flags;
    717708        unsigned short val;
     
    724715}
    725716
    726 static void snd_emu10k1x_ac97_write(ac97_t *ac97,
     717static void snd_emu10k1x_ac97_write(struct snd_ac97 *ac97,
    727718                                    unsigned short reg, unsigned short val)
    728719{
    729         emu10k1x_t *emu = ac97->private_data;
     720        struct emu10k1x *emu = ac97->private_data;
    730721        unsigned long flags;
    731722 
     
    736727}
    737728
    738 static int snd_emu10k1x_ac97(emu10k1x_t *chip)
    739 {
    740         ac97_bus_t *pbus;
    741         ac97_template_t ac97;
     729static int snd_emu10k1x_ac97(struct emu10k1x *chip)
     730{
     731        struct snd_ac97_bus *pbus;
     732        struct snd_ac97_template ac97;
    742733        int err;
    743         static ac97_bus_ops_t ops = {
    744             0,
    745             /*.write = */snd_emu10k1x_ac97_write,
    746             /*.read = */snd_emu10k1x_ac97_read, 0,0
     734        static struct snd_ac97_bus_ops ops = {
     735                .write = snd_emu10k1x_ac97_write,
     736                .read = snd_emu10k1x_ac97_read,
    747737        };
    748738 
     
    757747}
    758748
    759 static int snd_emu10k1x_free(emu10k1x_t *chip)
     749static int snd_emu10k1x_free(struct emu10k1x *chip)
    760750{
    761751        snd_emu10k1x_ptr_write(chip, TRIGGER_CHANNEL, 0, 0);
     
    766756
    767757        // release the i/o port
    768         if (chip->res_port) {
    769                 release_resource(chip->res_port);
    770                 kfree_nocheck(chip->res_port);
    771         }
     758        release_and_free_resource(chip->res_port);
     759
    772760        // release the irq
    773761        if (chip->irq >= 0)
     
    786774}
    787775
    788 static int snd_emu10k1x_dev_free(snd_device_t *device)
    789 {
    790         emu10k1x_t *chip = device->device_data;
     776static int snd_emu10k1x_dev_free(struct snd_device *device)
     777{
     778        struct emu10k1x *chip = device->device_data;
    791779        return snd_emu10k1x_free(chip);
    792780}
     
    797785        unsigned int status;
    798786
    799         emu10k1x_t *chip = dev_id;
    800         emu10k1x_voice_t *pvoice = chip->voices;
     787        struct emu10k1x *chip = dev_id;
     788        struct emu10k1x_voice *pvoice = chip->voices;
    801789        int i;
    802790        int mask;
     
    804792        status = inl(chip->port + IPR);
    805793
    806         if(status) {
    807                 // capture interrupt
    808                 if(status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) {
    809                         emu10k1x_voice_t *pvoice = &chip->capture_voice;
    810                         if(pvoice->use)
     794        if (! status)
     795                return IRQ_NONE;
     796
     797        // capture interrupt
     798        if (status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) {
     799                struct emu10k1x_voice *pvoice = &chip->capture_voice;
     800                if (pvoice->use)
     801                        snd_emu10k1x_pcm_interrupt(chip, pvoice);
     802                else
     803                        snd_emu10k1x_intr_disable(chip,
     804                                                  INTE_CAP_0_LOOP |
     805                                                  INTE_CAP_0_HALF_LOOP);
     806        }
     807               
     808        mask = IPR_CH_0_LOOP|IPR_CH_0_HALF_LOOP;
     809        for (i = 0; i < 3; i++) {
     810                if (status & mask) {
     811                        if (pvoice->use)
    811812                                snd_emu10k1x_pcm_interrupt(chip, pvoice);
    812                         else
    813                                 snd_emu10k1x_intr_disable(chip,
    814                                                           INTE_CAP_0_LOOP |
    815                                                           INTE_CAP_0_HALF_LOOP);
     813                        else
     814                                snd_emu10k1x_intr_disable(chip, mask);
    816815                }
     816                pvoice++;
     817                mask <<= 1;
     818        }
    817819               
    818                 mask = IPR_CH_0_LOOP|IPR_CH_0_HALF_LOOP;
    819                 for(i = 0; i < 3; i++) {
    820                         if(status & mask) {
    821                                 if(pvoice->use)
    822                                         snd_emu10k1x_pcm_interrupt(chip, pvoice);
    823                                 else
    824                                         snd_emu10k1x_intr_disable(chip, mask);
    825                         }
    826                         pvoice++;
    827                         mask <<= 1;
    828                 }
     820        if (status & (IPR_MIDITRANSBUFEMPTY|IPR_MIDIRECVBUFEMPTY)) {
     821                if (chip->midi.interrupt)
     822                        chip->midi.interrupt(chip, status);
     823                else
     824                        snd_emu10k1x_intr_disable(chip, INTE_MIDITXENABLE|INTE_MIDIRXENABLE);
     825        }
    829826               
    830                 if (status & (IPR_MIDITRANSBUFEMPTY|IPR_MIDIRECVBUFEMPTY)) {
    831                         if (chip->midi.interrupt)
    832                                 chip->midi.interrupt(chip, status);
    833                         else
    834                                 snd_emu10k1x_intr_disable(chip, INTE_MIDITXENABLE|INTE_MIDIRXENABLE);
    835                 }
    836                
    837                 // acknowledge the interrupt if necessary
    838                 if(status)
    839                         outl(status, chip->port+IPR);
    840 
    841 //              snd_printk(KERN_INFO "interrupt %08x\n", status);
    842         }
    843 
     827        // acknowledge the interrupt if necessary
     828        outl(status, chip->port + IPR);
     829
     830        // snd_printk(KERN_INFO "interrupt %08x\n", status);
    844831        return IRQ_HANDLED;
    845832}
    846833
    847 static void snd_emu10k1x_pcm_free(snd_pcm_t *pcm)
    848 {
    849         emu10k1x_t *emu = pcm->private_data;
    850         emu->pcm = NULL;
    851         snd_pcm_lib_preallocate_free_for_all(pcm);
    852 }
    853 
    854 static int __devinit snd_emu10k1x_pcm(emu10k1x_t *emu, int device, snd_pcm_t **rpcm)
    855 {
    856         snd_pcm_t *pcm;
     834static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct snd_pcm **rpcm)
     835{
     836        struct snd_pcm *pcm;
    857837        int err;
    858838        int capture = 0;
     
    867847 
    868848        pcm->private_data = emu;
    869         pcm->private_free = snd_emu10k1x_pcm_free;
    870849       
    871850        switch(device) {
     
    905884}
    906885
    907 static int __devinit snd_emu10k1x_create(snd_card_t *card,
     886static int __devinit snd_emu10k1x_create(struct snd_card *card,
    908887                                         struct pci_dev *pci,
    909                                          emu10k1x_t **rchip)
    910 {
    911         emu10k1x_t *chip;
     888                                         struct emu10k1x **rchip)
     889{
     890        struct emu10k1x *chip;
    912891        int err;
    913892        int ch;
    914         static snd_device_ops_t ops = {
    915                 /*.dev_free = */snd_emu10k1x_dev_free,0,0,0
     893        static struct snd_device_ops ops = {
     894                .dev_free = snd_emu10k1x_dev_free,
    916895        };
    917896 
     
    920899        if ((err = pci_enable_device(pci)) < 0)
    921900                return err;
    922         pci_set_dma_mask(pci, 0x0fffffff);
    923 
    924         chip = kzalloc(sizeof(*chip), GFP_KERNEL);
     901        pci_set_dma_mask(pci, 0x0fffffff);
     902 
     903        chip = (struct emu10k1x *)kzalloc(sizeof(*chip), GFP_KERNEL);
    925904        if (chip == NULL) {
    926905                pci_disable_device(pci);
     
    10211000}
    10221001
    1023 static void snd_emu10k1x_proc_reg_read(snd_info_entry_t *entry,
    1024                                        snd_info_buffer_t * buffer)
    1025 {
    1026         emu10k1x_t *emu = entry->private_data;
     1002static void snd_emu10k1x_proc_reg_read(struct snd_info_entry *entry,
     1003                                       struct snd_info_buffer *buffer)
     1004{
     1005        struct emu10k1x *emu = entry->private_data;
    10271006        unsigned long value,value1,value2;
    10281007        unsigned long flags;
     
    10491028}
    10501029
    1051 static void snd_emu10k1x_proc_reg_write(snd_info_entry_t *entry,
    1052                                         snd_info_buffer_t *buffer)
    1053 {
    1054         emu10k1x_t *emu = entry->private_data;
     1030static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry,
     1031                                        struct snd_info_buffer *buffer)
     1032{
     1033        struct emu10k1x *emu = entry->private_data;
    10551034        char line[64];
    10561035        unsigned int reg, channel_id , val;
    1057 
     1036#if 0
    10581037        while (!snd_info_get_line(buffer, line, sizeof(line))) {
    10591038                if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
     
    10631042                    && (channel_id >=0) && (channel_id <= 2) )
    10641043                        snd_emu10k1x_ptr_write(emu, reg, channel_id, val);
    1065         }
    1066 }
    1067 
    1068 static int __devinit snd_emu10k1x_proc_init(emu10k1x_t * emu)
    1069 {
    1070         snd_info_entry_t *entry;
     1044        }
     1045#endif
     1046}
     1047
     1048static int __devinit snd_emu10k1x_proc_init(struct emu10k1x * emu)
     1049{
     1050        struct snd_info_entry *entry;
    10711051       
    10721052        if(! snd_card_proc_new(emu->card, "emu10k1x_regs", &entry)) {
     
    10741054                entry->c.text.write_size = 64;
    10751055                entry->c.text.write = snd_emu10k1x_proc_reg_write;
     1056                entry->mode |= S_IWUSR;
    10761057                entry->private_data = emu;
    10771058        }
     
    10801061}
    10811062
    1082 static int snd_emu10k1x_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
     1063static int snd_emu10k1x_shared_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    10831064{
    10841065        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
     
    10891070}
    10901071
    1091 static int snd_emu10k1x_shared_spdif_get(snd_kcontrol_t * kcontrol,
    1092                                          snd_ctl_elem_value_t * ucontrol)
    1093 {
    1094         emu10k1x_t *emu = snd_kcontrol_chip(kcontrol);
     1072static int snd_emu10k1x_shared_spdif_get(struct snd_kcontrol *kcontrol,
     1073                                         struct snd_ctl_elem_value *ucontrol)
     1074{
     1075        struct emu10k1x *emu = snd_kcontrol_chip(kcontrol);
    10951076
    10961077        ucontrol->value.integer.value[0] = (snd_emu10k1x_ptr_read(emu, SPDIF_SELECT, 0) == 0x700) ? 0 : 1;
     
    10991080}
    11001081
    1101 static int snd_emu10k1x_shared_spdif_put(snd_kcontrol_t * kcontrol,
    1102                                          snd_ctl_elem_value_t * ucontrol)
    1103 {
    1104         emu10k1x_t *emu = snd_kcontrol_chip(kcontrol);
     1082static int snd_emu10k1x_shared_spdif_put(struct snd_kcontrol *kcontrol,
     1083                                         struct snd_ctl_elem_value *ucontrol)
     1084{
     1085        struct emu10k1x *emu = snd_kcontrol_chip(kcontrol);
    11051086        unsigned int val;
    11061087        int change = 0;
     
    11221103}
    11231104
    1124 static snd_kcontrol_new_t snd_emu10k1x_shared_spdif __devinitdata =
    1125 {
    1126         /*.iface = */     SNDRV_CTL_ELEM_IFACE_MIXER,0,0,
    1127         /*.name =  */           "Analog/Digital Output Jack",0,0,0,
    1128         /*.info =  */           snd_emu10k1x_shared_spdif_info,
    1129         /*.get =   */           snd_emu10k1x_shared_spdif_get,
    1130         /*.put =   */           snd_emu10k1x_shared_spdif_put,0
     1105static struct snd_kcontrol_new snd_emu10k1x_shared_spdif __devinitdata =
     1106{
     1107        .iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
     1108        .name =         "Analog/Digital Output Jack",
     1109        .info =         snd_emu10k1x_shared_spdif_info,
     1110        .get =          snd_emu10k1x_shared_spdif_get,
     1111        .put =          snd_emu10k1x_shared_spdif_put
    11311112};
    11321113
    1133 static int snd_emu10k1x_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
     1114static int snd_emu10k1x_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    11341115{
    11351116        uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
     
    11381119}
    11391120
    1140 static int snd_emu10k1x_spdif_get(snd_kcontrol_t * kcontrol,
    1141                                   snd_ctl_elem_value_t * ucontrol)
    1142 {
    1143         emu10k1x_t *emu = snd_kcontrol_chip(kcontrol);
     1121static int snd_emu10k1x_spdif_get(struct snd_kcontrol *kcontrol,
     1122                                  struct snd_ctl_elem_value *ucontrol)
     1123{
     1124        struct emu10k1x *emu = snd_kcontrol_chip(kcontrol);
    11441125        unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    11451126
     
    11511132}
    11521133
    1153 static int snd_emu10k1x_spdif_get_mask(snd_kcontrol_t * kcontrol,
    1154                                        snd_ctl_elem_value_t * ucontrol)
     1134static int snd_emu10k1x_spdif_get_mask(struct snd_kcontrol *kcontrol,
     1135                                       struct snd_ctl_elem_value *ucontrol)
    11551136{
    11561137        ucontrol->value.iec958.status[0] = 0xff;
     
    11611142}
    11621143
    1163 static int snd_emu10k1x_spdif_put(snd_kcontrol_t * kcontrol,
    1164                                   snd_ctl_elem_value_t * ucontrol)
    1165 {
    1166         emu10k1x_t *emu = snd_kcontrol_chip(kcontrol);
     1144static int snd_emu10k1x_spdif_put(struct snd_kcontrol *kcontrol,
     1145                                  struct snd_ctl_elem_value *ucontrol)
     1146{
     1147        struct emu10k1x *emu = snd_kcontrol_chip(kcontrol);
    11671148        unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    11681149        int change;
     
    11811162}
    11821163
    1183 static snd_kcontrol_new_t snd_emu10k1x_spdif_mask_control =
    1184 {
    1185         /*.iface = */       SNDRV_CTL_ELEM_IFACE_MIXER,0,0,
    1186         /*.name =  */       SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK),0,
    1187         /*.access =*/   SNDRV_CTL_ELEM_ACCESS_READ,
    1188         /*.count = */     3,
    1189         /*.info =  */       snd_emu10k1x_spdif_info,
    1190         /*.get =   */       snd_emu10k1x_spdif_get_mask,0,0
     1164static struct snd_kcontrol_new snd_emu10k1x_spdif_mask_control =
     1165{
     1166        .access =       SNDRV_CTL_ELEM_ACCESS_READ,
     1167        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
     1168        .name =         SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK),
     1169        .count =        3,
     1170        .info =         snd_emu10k1x_spdif_info,
     1171        .get =          snd_emu10k1x_spdif_get_mask
    11911172};
    11921173
    1193 static snd_kcontrol_new_t snd_emu10k1x_spdif_control =
    1194 {
    1195         /*.iface = */     SNDRV_CTL_ELEM_IFACE_MIXER,0,0,
    1196         /*.name =  */       SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),0,0,
    1197         /*.count = */     3,
    1198         /*.info =  */       snd_emu10k1x_spdif_info,
    1199         /*.get =   */       snd_emu10k1x_spdif_get,
    1200         /*.put =   */       snd_emu10k1x_spdif_put,0
     1174static struct snd_kcontrol_new snd_emu10k1x_spdif_control =
     1175{
     1176        .iface =        SNDRV_CTL_ELEM_IFACE_PCM,
     1177        .name =         SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
     1178        .count =        3,
     1179        .info =         snd_emu10k1x_spdif_info,
     1180        .get =          snd_emu10k1x_spdif_get,
     1181        .put =          snd_emu10k1x_spdif_put
    12011182};
    12021183
    1203 static int __devinit snd_emu10k1x_mixer(emu10k1x_t *emu)
     1184static int __devinit snd_emu10k1x_mixer(struct emu10k1x *emu)
    12041185{
    12051186        int err;
    1206         snd_kcontrol_t *kctl;
    1207         snd_card_t *card = emu->card;
     1187        struct snd_kcontrol *kctl;
     1188        struct snd_card *card = emu->card;
    12081189
    12091190        if ((kctl = snd_ctl_new1(&snd_emu10k1x_spdif_mask_control, emu)) == NULL)
     
    12261207#define EMU10K1X_MIDI_MODE_OUTPUT       (1<<1)
    12271208
    1228 static inline unsigned char mpu401_read(emu10k1x_t *emu, emu10k1x_midi_t *mpu, int idx)
     1209static inline unsigned char mpu401_read(struct emu10k1x *emu, struct emu10k1x_midi *mpu, int idx)
    12291210{
    12301211        return (unsigned char)snd_emu10k1x_ptr_read(emu, mpu->port + idx, 0);
    12311212}
    12321213
    1233 static inline void mpu401_write(emu10k1x_t *emu, emu10k1x_midi_t *mpu, int data, int idx)
     1214static inline void mpu401_write(struct emu10k1x *emu, struct emu10k1x_midi *mpu, int data, int idx)
    12341215{
    12351216        snd_emu10k1x_ptr_write(emu, mpu->port + idx, 0, data);
     
    12481229#define MPU401_ACK              0xfe
    12491230
    1250 static void mpu401_clear_rx(emu10k1x_t *emu, emu10k1x_midi_t *mpu)
     1231static void mpu401_clear_rx(struct emu10k1x *emu, struct emu10k1x_midi *mpu)
    12511232{
    12521233        int timeout = 100000;
     
    12631244 */
    12641245
    1265 static void do_emu10k1x_midi_interrupt(emu10k1x_t *emu, emu10k1x_midi_t *midi, unsigned int status)
     1246static void do_emu10k1x_midi_interrupt(struct emu10k1x *emu,
     1247                                       struct emu10k1x_midi *midi, unsigned int status)
    12661248{
    12671249        unsigned char byte;
     
    12961278}
    12971279
    1298 static void snd_emu10k1x_midi_interrupt(emu10k1x_t *emu, unsigned int status)
     1280static void snd_emu10k1x_midi_interrupt(struct emu10k1x *emu, unsigned int status)
    12991281{
    13001282        do_emu10k1x_midi_interrupt(emu, &emu->midi, status);
    13011283}
    13021284
    1303 static void snd_emu10k1x_midi_cmd(emu10k1x_t * emu, emu10k1x_midi_t *midi, unsigned char cmd, int ack)
     1285static void snd_emu10k1x_midi_cmd(struct emu10k1x * emu,
     1286                                  struct emu10k1x_midi *midi, unsigned char cmd, int ack)
    13041287{
    13051288        unsigned long flags;
     
    13331316}
    13341317
    1335 static int snd_emu10k1x_midi_input_open(snd_rawmidi_substream_t * substream)
    1336 {
    1337         emu10k1x_t *emu;
    1338         emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data;
     1318static int snd_emu10k1x_midi_input_open(struct snd_rawmidi_substream *substream)
     1319{
     1320        struct emu10k1x *emu;
     1321        struct emu10k1x_midi *midi = substream->rmidi->private_data;
    13391322        unsigned long flags;
    13401323       
     
    13541337}
    13551338
    1356 static int snd_emu10k1x_midi_output_open(snd_rawmidi_substream_t * substream)
    1357 {
    1358         emu10k1x_t *emu;
    1359         emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data;
     1339static int snd_emu10k1x_midi_output_open(struct snd_rawmidi_substream *substream)
     1340{
     1341        struct emu10k1x *emu;
     1342        struct emu10k1x_midi *midi = substream->rmidi->private_data;
    13601343        unsigned long flags;
    13611344
     
    13751358}
    13761359
    1377 static int snd_emu10k1x_midi_input_close(snd_rawmidi_substream_t * substream)
    1378 {
    1379         emu10k1x_t *emu;
    1380         emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data;
     1360static int snd_emu10k1x_midi_input_close(struct snd_rawmidi_substream *substream)
     1361{
     1362        struct emu10k1x *emu;
     1363        struct emu10k1x_midi *midi = substream->rmidi->private_data;
    13811364        unsigned long flags;
    13821365
     
    13961379}
    13971380
    1398 static int snd_emu10k1x_midi_output_close(snd_rawmidi_substream_t * substream)
    1399 {
    1400         emu10k1x_t *emu;
    1401         emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data;
     1381static int snd_emu10k1x_midi_output_close(struct snd_rawmidi_substream *substream)
     1382{
     1383        struct emu10k1x *emu;
     1384        struct emu10k1x_midi *midi = substream->rmidi->private_data;
    14021385        unsigned long flags;
    14031386
     
    14171400}
    14181401
    1419 static void snd_emu10k1x_midi_input_trigger(snd_rawmidi_substream_t * substream, int up)
    1420 {
    1421         emu10k1x_t *emu;
    1422         emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data;
     1402static void snd_emu10k1x_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
     1403{
     1404        struct emu10k1x *emu;
     1405        struct emu10k1x_midi *midi = substream->rmidi->private_data;
    14231406        emu = midi->emu;
    14241407        snd_assert(emu, return);
     
    14301413}
    14311414
    1432 static void snd_emu10k1x_midi_output_trigger(snd_rawmidi_substream_t * substream, int up)
    1433 {
    1434         emu10k1x_t *emu;
    1435         emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data;
     1415static void snd_emu10k1x_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
     1416{
     1417        struct emu10k1x *emu;
     1418        struct emu10k1x_midi *midi = substream->rmidi->private_data;
    14361419        unsigned long flags;
    14371420
     
    14701453 */
    14711454
    1472 static snd_rawmidi_ops_t snd_emu10k1x_midi_output =
    1473 {
    1474         snd_emu10k1x_midi_output_open,
    1475         snd_emu10k1x_midi_output_close,
    1476         snd_emu10k1x_midi_output_trigger,0
     1455static struct snd_rawmidi_ops snd_emu10k1x_midi_output =
     1456{
     1457        .open =         snd_emu10k1x_midi_output_open,
     1458        .close =        snd_emu10k1x_midi_output_close,
     1459        .trigger =      snd_emu10k1x_midi_output_trigger,
    14771460};
    14781461
    1479 static snd_rawmidi_ops_t snd_emu10k1x_midi_input =
    1480 {
    1481         snd_emu10k1x_midi_input_open,
    1482         snd_emu10k1x_midi_input_close,
    1483         snd_emu10k1x_midi_input_trigger,0
     1462static struct snd_rawmidi_ops snd_emu10k1x_midi_input =
     1463{
     1464        .open =         snd_emu10k1x_midi_input_open,
     1465        .close =        snd_emu10k1x_midi_input_close,
     1466        .trigger =      snd_emu10k1x_midi_input_trigger,
    14841467};
    14851468
    1486 static void snd_emu10k1x_midi_free(snd_rawmidi_t *rmidi)
    1487 {
    1488         emu10k1x_midi_t *midi = (emu10k1x_midi_t *)rmidi->private_data;
     1469static void snd_emu10k1x_midi_free(struct snd_rawmidi *rmidi)
     1470{
     1471        struct emu10k1x_midi *midi = rmidi->private_data;
    14891472        midi->interrupt = NULL;
    14901473        midi->rmidi = NULL;
    14911474}
    14921475
    1493 static int __devinit emu10k1x_midi_init(emu10k1x_t *emu, emu10k1x_midi_t *midi, int device, char *name)
    1494 {
    1495         snd_rawmidi_t *rmidi;
     1476static int __devinit emu10k1x_midi_init(struct emu10k1x *emu,
     1477                                        struct emu10k1x_midi *midi, int device, char *name)
     1478{
     1479        struct snd_rawmidi *rmidi;
    14961480        int err;
    14971481
     
    15141498}
    15151499
    1516 static int __devinit snd_emu10k1x_midi(emu10k1x_t *emu)
    1517 {
    1518         emu10k1x_midi_t *midi = &emu->midi;
     1500static int __devinit snd_emu10k1x_midi(struct emu10k1x *emu)
     1501{
     1502        struct emu10k1x_midi *midi = &emu->midi;
    15191503        int err;
    15201504
     
    15351519{
    15361520        static int dev;
    1537         snd_card_t *card;
    1538         emu10k1x_t *chip;
     1521        struct snd_card *card;
     1522        struct emu10k1x *chip;
    15391523        int err;
    15401524
     
    16151599// pci_driver definition
    16161600static struct pci_driver driver = {
    1617     0,0,0,
    1618         /*.name = */"EMU10K1X",
    1619         /*.id_table = */snd_emu10k1x_ids,
    1620         /*.probe = */snd_emu10k1x_probe,
    1621         /*.remove = */snd_emu10k1x_remove,
    1622         0,0
     1601        .name = "EMU10K1X",
     1602        .id_table = snd_emu10k1x_ids,
     1603        .probe = snd_emu10k1x_probe,
     1604        .remove = snd_emu10k1x_remove,
    16231605};
    16241606
     
    16281610        int err;
    16291611
    1630         if ((err = pci_module_init(&driver)) > 0)
     1612        if ((err = pci_register_driver(&driver)) > 0)
    16311613                return err;
    16321614
Note: See TracChangeset for help on using the changeset viewer.