~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/isa/gus/gus_reset.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/isa/gus/gus_reset.c (Architecture sparc64) and /sound/isa/gus/gus_reset.c (Architecture m68k)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*                                                  2 /*
  3  *  Copyright (c) by Jaroslav Kysela <perex@pe      3  *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  4  */                                                 4  */
  5                                                     5 
  6 #include <linux/delay.h>                            6 #include <linux/delay.h>
  7 #include <linux/interrupt.h>                        7 #include <linux/interrupt.h>
  8 #include <linux/time.h>                             8 #include <linux/time.h>
  9 #include <sound/core.h>                             9 #include <sound/core.h>
 10 #include <sound/gus.h>                             10 #include <sound/gus.h>
 11                                                    11 
 12 extern int snd_gf1_synth_init(struct snd_gus_c     12 extern int snd_gf1_synth_init(struct snd_gus_card * gus);
 13 extern void snd_gf1_synth_done(struct snd_gus_     13 extern void snd_gf1_synth_done(struct snd_gus_card * gus);
 14                                                    14 
 15 /*                                                 15 /*
 16  *  ok.. default interrupt handlers...             16  *  ok.. default interrupt handlers...
 17  */                                                17  */
 18                                                    18 
 19 static void snd_gf1_default_interrupt_handler_     19 static void snd_gf1_default_interrupt_handler_midi_out(struct snd_gus_card * gus)
 20 {                                                  20 {
 21         snd_gf1_uart_cmd(gus, gus->gf1.uart_cm     21         snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd &= ~0x20);
 22 }                                                  22 }
 23                                                    23 
 24 static void snd_gf1_default_interrupt_handler_     24 static void snd_gf1_default_interrupt_handler_midi_in(struct snd_gus_card * gus)
 25 {                                                  25 {
 26         snd_gf1_uart_cmd(gus, gus->gf1.uart_cm     26         snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd &= ~0x80);
 27 }                                                  27 }
 28                                                    28 
 29 static void snd_gf1_default_interrupt_handler_     29 static void snd_gf1_default_interrupt_handler_timer1(struct snd_gus_card * gus)
 30 {                                                  30 {
 31         snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOU     31         snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, gus->gf1.timer_enabled &= ~4);
 32 }                                                  32 }
 33                                                    33 
 34 static void snd_gf1_default_interrupt_handler_     34 static void snd_gf1_default_interrupt_handler_timer2(struct snd_gus_card * gus)
 35 {                                                  35 {
 36         snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOU     36         snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, gus->gf1.timer_enabled &= ~8);
 37 }                                                  37 }
 38                                                    38 
 39 static void snd_gf1_default_interrupt_handler_     39 static void snd_gf1_default_interrupt_handler_wave_and_volume(struct snd_gus_card * gus, struct snd_gus_voice * voice)
 40 {                                                  40 {
 41         snd_gf1_i_ctrl_stop(gus, 0x00);            41         snd_gf1_i_ctrl_stop(gus, 0x00);
 42         snd_gf1_i_ctrl_stop(gus, 0x0d);            42         snd_gf1_i_ctrl_stop(gus, 0x0d);
 43 }                                                  43 }
 44                                                    44 
 45 static void snd_gf1_default_interrupt_handler_     45 static void snd_gf1_default_interrupt_handler_dma_write(struct snd_gus_card * gus)
 46 {                                                  46 {
 47         snd_gf1_i_write8(gus, 0x41, 0x00);         47         snd_gf1_i_write8(gus, 0x41, 0x00);
 48 }                                                  48 }
 49                                                    49 
 50 static void snd_gf1_default_interrupt_handler_     50 static void snd_gf1_default_interrupt_handler_dma_read(struct snd_gus_card * gus)
 51 {                                                  51 {
 52         snd_gf1_i_write8(gus, 0x49, 0x00);         52         snd_gf1_i_write8(gus, 0x49, 0x00);
 53 }                                                  53 }
 54                                                    54 
 55 void snd_gf1_set_default_handlers(struct snd_g     55 void snd_gf1_set_default_handlers(struct snd_gus_card * gus, unsigned int what)
 56 {                                                  56 {
 57         if (what & SNDRV_GF1_HANDLER_MIDI_OUT)     57         if (what & SNDRV_GF1_HANDLER_MIDI_OUT)
 58                 gus->gf1.interrupt_handler_mid     58                 gus->gf1.interrupt_handler_midi_out = snd_gf1_default_interrupt_handler_midi_out;
 59         if (what & SNDRV_GF1_HANDLER_MIDI_IN)      59         if (what & SNDRV_GF1_HANDLER_MIDI_IN)
 60                 gus->gf1.interrupt_handler_mid     60                 gus->gf1.interrupt_handler_midi_in = snd_gf1_default_interrupt_handler_midi_in;
 61         if (what & SNDRV_GF1_HANDLER_TIMER1)       61         if (what & SNDRV_GF1_HANDLER_TIMER1)
 62                 gus->gf1.interrupt_handler_tim     62                 gus->gf1.interrupt_handler_timer1 = snd_gf1_default_interrupt_handler_timer1;
 63         if (what & SNDRV_GF1_HANDLER_TIMER2)       63         if (what & SNDRV_GF1_HANDLER_TIMER2)
 64                 gus->gf1.interrupt_handler_tim     64                 gus->gf1.interrupt_handler_timer2 = snd_gf1_default_interrupt_handler_timer2;
 65         if (what & SNDRV_GF1_HANDLER_VOICE) {      65         if (what & SNDRV_GF1_HANDLER_VOICE) {
 66                 struct snd_gus_voice *voice;       66                 struct snd_gus_voice *voice;
 67                                                    67                 
 68                 voice = &gus->gf1.voices[what      68                 voice = &gus->gf1.voices[what & 0xffff];
 69                 voice->handler_wave =              69                 voice->handler_wave =
 70                 voice->handler_volume = snd_gf     70                 voice->handler_volume = snd_gf1_default_interrupt_handler_wave_and_volume;
 71                 voice->handler_effect = NULL;      71                 voice->handler_effect = NULL;
 72                 voice->volume_change = NULL;       72                 voice->volume_change = NULL;
 73         }                                          73         }
 74         if (what & SNDRV_GF1_HANDLER_DMA_WRITE     74         if (what & SNDRV_GF1_HANDLER_DMA_WRITE)
 75                 gus->gf1.interrupt_handler_dma     75                 gus->gf1.interrupt_handler_dma_write = snd_gf1_default_interrupt_handler_dma_write;
 76         if (what & SNDRV_GF1_HANDLER_DMA_READ)     76         if (what & SNDRV_GF1_HANDLER_DMA_READ)
 77                 gus->gf1.interrupt_handler_dma     77                 gus->gf1.interrupt_handler_dma_read = snd_gf1_default_interrupt_handler_dma_read;
 78 }                                                  78 }
 79                                                    79 
 80 /*                                                 80 /*
 81                                                    81 
 82  */                                                82  */
 83                                                    83 
 84 static void snd_gf1_clear_regs(struct snd_gus_     84 static void snd_gf1_clear_regs(struct snd_gus_card * gus)
 85 {                                                  85 {
 86         unsigned long flags;                       86         unsigned long flags;
 87                                                    87 
 88         spin_lock_irqsave(&gus->reg_lock, flag     88         spin_lock_irqsave(&gus->reg_lock, flags);
 89         inb(GUSP(gus, IRQSTAT));                   89         inb(GUSP(gus, IRQSTAT));
 90         snd_gf1_write8(gus, 0x41, 0);   /* DRA     90         snd_gf1_write8(gus, 0x41, 0);   /* DRAM DMA Control Register */
 91         snd_gf1_write8(gus, 0x45, 0);   /* Tim     91         snd_gf1_write8(gus, 0x45, 0);   /* Timer Control */
 92         snd_gf1_write8(gus, 0x49, 0);   /* Sam     92         snd_gf1_write8(gus, 0x49, 0);   /* Sampling Control Register */
 93         spin_unlock_irqrestore(&gus->reg_lock,     93         spin_unlock_irqrestore(&gus->reg_lock, flags);
 94 }                                                  94 }
 95                                                    95 
 96 static void snd_gf1_look_regs(struct snd_gus_c     96 static void snd_gf1_look_regs(struct snd_gus_card * gus)
 97 {                                                  97 {
 98         unsigned long flags;                       98         unsigned long flags;
 99                                                    99 
100         spin_lock_irqsave(&gus->reg_lock, flag    100         spin_lock_irqsave(&gus->reg_lock, flags);
101         snd_gf1_look8(gus, 0x41);       /* DRA    101         snd_gf1_look8(gus, 0x41);       /* DRAM DMA Control Register */
102         snd_gf1_look8(gus, 0x49);       /* Sam    102         snd_gf1_look8(gus, 0x49);       /* Sampling Control Register */
103         inb(GUSP(gus, IRQSTAT));                  103         inb(GUSP(gus, IRQSTAT));
104         snd_gf1_read8(gus, 0x0f);       /* IRQ    104         snd_gf1_read8(gus, 0x0f);       /* IRQ Source Register */
105         spin_unlock_irqrestore(&gus->reg_lock,    105         spin_unlock_irqrestore(&gus->reg_lock, flags);
106 }                                                 106 }
107                                                   107 
108 /*                                                108 /*
109  *  put selected GF1 voices to initial stage..    109  *  put selected GF1 voices to initial stage...
110  */                                               110  */
111                                                   111 
112 void snd_gf1_smart_stop_voice(struct snd_gus_c    112 void snd_gf1_smart_stop_voice(struct snd_gus_card * gus, unsigned short voice)
113 {                                                 113 {
114         unsigned long flags;                      114         unsigned long flags;
115                                                   115 
116         spin_lock_irqsave(&gus->reg_lock, flag    116         spin_lock_irqsave(&gus->reg_lock, flags);
117         snd_gf1_select_voice(gus, voice);         117         snd_gf1_select_voice(gus, voice);
118 #if 0                                             118 #if 0
119         dev_dbg(gus->card->dev,                   119         dev_dbg(gus->card->dev,
120                 " -%i- smart stop voice - volu    120                 " -%i- smart stop voice - volume = 0x%x\n",
121                 voice, snd_gf1_i_read16(gus, S    121                 voice, snd_gf1_i_read16(gus, SNDRV_GF1_VW_VOLUME));
122 #endif                                            122 #endif
123         snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_AD    123         snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_ADDRESS_CONTROL);
124         snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VO    124         snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL);
125         spin_unlock_irqrestore(&gus->reg_lock,    125         spin_unlock_irqrestore(&gus->reg_lock, flags);
126 }                                                 126 }
127                                                   127 
128 void snd_gf1_stop_voice(struct snd_gus_card *     128 void snd_gf1_stop_voice(struct snd_gus_card * gus, unsigned short voice)
129 {                                                 129 {
130         unsigned long flags;                      130         unsigned long flags;
131                                                   131 
132         spin_lock_irqsave(&gus->reg_lock, flag    132         spin_lock_irqsave(&gus->reg_lock, flags);
133         snd_gf1_select_voice(gus, voice);         133         snd_gf1_select_voice(gus, voice);
134 #if 0                                             134 #if 0
135         dev_dbg(gus->card->dev,                   135         dev_dbg(gus->card->dev,
136                 " -%i- stop voice - volume = 0    136                 " -%i- stop voice - volume = 0x%x\n",
137                 voice, snd_gf1_i_read16(gus, S    137                 voice, snd_gf1_i_read16(gus, SNDRV_GF1_VW_VOLUME));
138 #endif                                            138 #endif
139         snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_AD    139         snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_ADDRESS_CONTROL);
140         snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VO    140         snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL);
141         if (gus->gf1.enh_mode)                    141         if (gus->gf1.enh_mode)
142                 snd_gf1_write8(gus, SNDRV_GF1_    142                 snd_gf1_write8(gus, SNDRV_GF1_VB_ACCUMULATOR, 0);
143         spin_unlock_irqrestore(&gus->reg_lock,    143         spin_unlock_irqrestore(&gus->reg_lock, flags);
144 #if 0                                             144 #if 0
145         snd_gf1_lfo_shutdown(gus, voice, ULTRA    145         snd_gf1_lfo_shutdown(gus, voice, ULTRA_LFO_VIBRATO);
146         snd_gf1_lfo_shutdown(gus, voice, ULTRA    146         snd_gf1_lfo_shutdown(gus, voice, ULTRA_LFO_TREMOLO);
147 #endif                                            147 #endif
148 }                                                 148 }
149                                                   149 
150 static void snd_gf1_clear_voices(struct snd_gu    150 static void snd_gf1_clear_voices(struct snd_gus_card * gus, unsigned short v_min,
151                                  unsigned shor    151                                  unsigned short v_max)
152 {                                                 152 {
153         unsigned long flags;                      153         unsigned long flags;
154         unsigned int daddr;                       154         unsigned int daddr;
155         unsigned short i, w_16;                   155         unsigned short i, w_16;
156                                                   156 
157         daddr = gus->gf1.default_voice_address    157         daddr = gus->gf1.default_voice_address << 4;
158         for (i = v_min; i <= v_max; i++) {        158         for (i = v_min; i <= v_max; i++) {
159 #if 0                                             159 #if 0
160                 if (gus->gf1.syn_voices)          160                 if (gus->gf1.syn_voices)
161                         gus->gf1.syn_voices[i]    161                         gus->gf1.syn_voices[i].flags = ~VFLG_DYNAMIC;
162 #endif                                            162 #endif
163                 spin_lock_irqsave(&gus->reg_lo    163                 spin_lock_irqsave(&gus->reg_lock, flags);
164                 snd_gf1_select_voice(gus, i);     164                 snd_gf1_select_voice(gus, i);
165                 snd_gf1_ctrl_stop(gus, SNDRV_G    165                 snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_ADDRESS_CONTROL);   /* Voice Control Register = voice stop */
166                 snd_gf1_ctrl_stop(gus, SNDRV_G    166                 snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL);    /* Volume Ramp Control Register = ramp off */
167                 if (gus->gf1.enh_mode)            167                 if (gus->gf1.enh_mode)
168                         snd_gf1_write8(gus, SN    168                         snd_gf1_write8(gus, SNDRV_GF1_VB_MODE, gus->gf1.memory ? 0x02 : 0x82);  /* Deactivate voice */
169                 w_16 = snd_gf1_read8(gus, SNDR    169                 w_16 = snd_gf1_read8(gus, SNDRV_GF1_VB_ADDRESS_CONTROL) & 0x04;
170                 snd_gf1_write16(gus, SNDRV_GF1    170                 snd_gf1_write16(gus, SNDRV_GF1_VW_FREQUENCY, 0x400);
171                 snd_gf1_write_addr(gus, SNDRV_    171                 snd_gf1_write_addr(gus, SNDRV_GF1_VA_START, daddr, w_16);
172                 snd_gf1_write_addr(gus, SNDRV_    172                 snd_gf1_write_addr(gus, SNDRV_GF1_VA_END, daddr, w_16);
173                 snd_gf1_write8(gus, SNDRV_GF1_    173                 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_START, 0);
174                 snd_gf1_write8(gus, SNDRV_GF1_    174                 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_END, 0);
175                 snd_gf1_write8(gus, SNDRV_GF1_    175                 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_RATE, 0);
176                 snd_gf1_write16(gus, SNDRV_GF1    176                 snd_gf1_write16(gus, SNDRV_GF1_VW_VOLUME, 0);
177                 snd_gf1_write_addr(gus, SNDRV_    177                 snd_gf1_write_addr(gus, SNDRV_GF1_VA_CURRENT, daddr, w_16);
178                 snd_gf1_write8(gus, SNDRV_GF1_    178                 snd_gf1_write8(gus, SNDRV_GF1_VB_PAN, 7);
179                 if (gus->gf1.enh_mode) {          179                 if (gus->gf1.enh_mode) {
180                         snd_gf1_write8(gus, SN    180                         snd_gf1_write8(gus, SNDRV_GF1_VB_ACCUMULATOR, 0);
181                         snd_gf1_write16(gus, S    181                         snd_gf1_write16(gus, SNDRV_GF1_VW_EFFECT_VOLUME, 0);
182                         snd_gf1_write16(gus, S    182                         snd_gf1_write16(gus, SNDRV_GF1_VW_EFFECT_VOLUME_FINAL, 0);
183                 }                                 183                 }
184                 spin_unlock_irqrestore(&gus->r    184                 spin_unlock_irqrestore(&gus->reg_lock, flags);
185 #if 0                                             185 #if 0
186                 snd_gf1_lfo_shutdown(gus, i, U    186                 snd_gf1_lfo_shutdown(gus, i, ULTRA_LFO_VIBRATO);
187                 snd_gf1_lfo_shutdown(gus, i, U    187                 snd_gf1_lfo_shutdown(gus, i, ULTRA_LFO_TREMOLO);
188 #endif                                            188 #endif
189         }                                         189         }
190 }                                                 190 }
191                                                   191 
192 void snd_gf1_stop_voices(struct snd_gus_card *    192 void snd_gf1_stop_voices(struct snd_gus_card * gus, unsigned short v_min, unsigned short v_max)
193 {                                                 193 {
194         unsigned long flags;                      194         unsigned long flags;
195         short i, ramp_ok;                         195         short i, ramp_ok;
196         unsigned short ramp_end;                  196         unsigned short ramp_end;
197                                                   197 
198         if (!in_interrupt()) {  /* this can't     198         if (!in_interrupt()) {  /* this can't be done in interrupt */
199                 for (i = v_min, ramp_ok = 0; i    199                 for (i = v_min, ramp_ok = 0; i <= v_max; i++) {
200                         spin_lock_irqsave(&gus    200                         spin_lock_irqsave(&gus->reg_lock, flags);
201                         snd_gf1_select_voice(g    201                         snd_gf1_select_voice(gus, i);
202                         ramp_end = snd_gf1_rea    202                         ramp_end = snd_gf1_read16(gus, 9) >> 8;
203                         if (ramp_end > SNDRV_G    203                         if (ramp_end > SNDRV_GF1_MIN_OFFSET) {
204                                 ramp_ok++;        204                                 ramp_ok++;
205                                 snd_gf1_write8    205                                 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_RATE, 20);      /* ramp rate */
206                                 snd_gf1_write8    206                                 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_START, SNDRV_GF1_MIN_OFFSET);   /* ramp start */
207                                 snd_gf1_write8    207                                 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_END, ramp_end); /* ramp end */
208                                 snd_gf1_write8    208                                 snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_CONTROL, 0x40); /* ramp down */
209                                 if (gus->gf1.e    209                                 if (gus->gf1.enh_mode) {
210                                         snd_gf    210                                         snd_gf1_delay(gus);
211                                         snd_gf    211                                         snd_gf1_write8(gus, SNDRV_GF1_VB_VOLUME_CONTROL, 0x40);
212                                 }                 212                                 }
213                         }                         213                         }
214                         spin_unlock_irqrestore    214                         spin_unlock_irqrestore(&gus->reg_lock, flags);
215                 }                                 215                 }
216                 msleep_interruptible(50);         216                 msleep_interruptible(50);
217         }                                         217         }
218         snd_gf1_clear_voices(gus, v_min, v_max    218         snd_gf1_clear_voices(gus, v_min, v_max);
219 }                                                 219 }
220                                                   220 
221 static void snd_gf1_alloc_voice_use(struct snd    221 static void snd_gf1_alloc_voice_use(struct snd_gus_card * gus, 
222                                     struct snd    222                                     struct snd_gus_voice * pvoice,
223                                     int type,     223                                     int type, int client, int port)
224 {                                                 224 {
225         pvoice->use = 1;                          225         pvoice->use = 1;
226         switch (type) {                           226         switch (type) {
227         case SNDRV_GF1_VOICE_TYPE_PCM:            227         case SNDRV_GF1_VOICE_TYPE_PCM:
228                 gus->gf1.pcm_alloc_voices++;      228                 gus->gf1.pcm_alloc_voices++;
229                 pvoice->pcm = 1;                  229                 pvoice->pcm = 1;
230                 break;                            230                 break;
231         case SNDRV_GF1_VOICE_TYPE_SYNTH:          231         case SNDRV_GF1_VOICE_TYPE_SYNTH:
232                 pvoice->synth = 1;                232                 pvoice->synth = 1;
233                 pvoice->client = client;          233                 pvoice->client = client;
234                 pvoice->port = port;              234                 pvoice->port = port;
235                 break;                            235                 break;
236         case SNDRV_GF1_VOICE_TYPE_MIDI:           236         case SNDRV_GF1_VOICE_TYPE_MIDI:
237                 pvoice->midi = 1;                 237                 pvoice->midi = 1;
238                 pvoice->client = client;          238                 pvoice->client = client;
239                 pvoice->port = port;              239                 pvoice->port = port;
240                 break;                            240                 break;
241         }                                         241         }
242 }                                                 242 }
243                                                   243 
244 struct snd_gus_voice *snd_gf1_alloc_voice(stru    244 struct snd_gus_voice *snd_gf1_alloc_voice(struct snd_gus_card * gus, int type, int client, int port)
245 {                                                 245 {
246         struct snd_gus_voice *pvoice;             246         struct snd_gus_voice *pvoice;
247         unsigned long flags;                      247         unsigned long flags;
248         int idx;                                  248         int idx;
249                                                   249 
250         spin_lock_irqsave(&gus->voice_alloc, f    250         spin_lock_irqsave(&gus->voice_alloc, flags);
251         if (type == SNDRV_GF1_VOICE_TYPE_PCM)     251         if (type == SNDRV_GF1_VOICE_TYPE_PCM) {
252                 if (gus->gf1.pcm_alloc_voices     252                 if (gus->gf1.pcm_alloc_voices >= gus->gf1.pcm_channels) {
253                         spin_unlock_irqrestore    253                         spin_unlock_irqrestore(&gus->voice_alloc, flags);
254                         return NULL;              254                         return NULL;
255                 }                                 255                 }
256         }                                         256         }
257         for (idx = 0; idx < 32; idx++) {          257         for (idx = 0; idx < 32; idx++) {
258                 pvoice = &gus->gf1.voices[idx]    258                 pvoice = &gus->gf1.voices[idx];
259                 if (!pvoice->use) {               259                 if (!pvoice->use) {
260                         snd_gf1_alloc_voice_us    260                         snd_gf1_alloc_voice_use(gus, pvoice, type, client, port);
261                         spin_unlock_irqrestore    261                         spin_unlock_irqrestore(&gus->voice_alloc, flags);
262                         return pvoice;            262                         return pvoice;
263                 }                                 263                 }
264         }                                         264         } 
265         for (idx = 0; idx < 32; idx++) {          265         for (idx = 0; idx < 32; idx++) {
266                 pvoice = &gus->gf1.voices[idx]    266                 pvoice = &gus->gf1.voices[idx];
267                 if (pvoice->midi && !pvoice->c    267                 if (pvoice->midi && !pvoice->client) {
268                         snd_gf1_clear_voices(g    268                         snd_gf1_clear_voices(gus, pvoice->number, pvoice->number);
269                         snd_gf1_alloc_voice_us    269                         snd_gf1_alloc_voice_use(gus, pvoice, type, client, port);
270                         spin_unlock_irqrestore    270                         spin_unlock_irqrestore(&gus->voice_alloc, flags);
271                         return pvoice;            271                         return pvoice;
272                 }                                 272                 }
273         }                                         273         } 
274         spin_unlock_irqrestore(&gus->voice_all    274         spin_unlock_irqrestore(&gus->voice_alloc, flags);
275         return NULL;                              275         return NULL;
276 }                                                 276 }
277                                                   277 
278 void snd_gf1_free_voice(struct snd_gus_card *     278 void snd_gf1_free_voice(struct snd_gus_card * gus, struct snd_gus_voice *voice)
279 {                                                 279 {
280         unsigned long flags;                      280         unsigned long flags;
281         void (*private_free)(struct snd_gus_vo    281         void (*private_free)(struct snd_gus_voice *voice);
282                                                   282 
283         if (voice == NULL || !voice->use)         283         if (voice == NULL || !voice->use)
284                 return;                           284                 return;
285         snd_gf1_set_default_handlers(gus, SNDR    285         snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_VOICE | voice->number);
286         snd_gf1_clear_voices(gus, voice->numbe    286         snd_gf1_clear_voices(gus, voice->number, voice->number);
287         spin_lock_irqsave(&gus->voice_alloc, f    287         spin_lock_irqsave(&gus->voice_alloc, flags);
288         private_free = voice->private_free;       288         private_free = voice->private_free;
289         voice->private_free = NULL;               289         voice->private_free = NULL;
290         voice->private_data = NULL;               290         voice->private_data = NULL;
291         if (voice->pcm)                           291         if (voice->pcm)
292                 gus->gf1.pcm_alloc_voices--;      292                 gus->gf1.pcm_alloc_voices--;
293         voice->use = voice->pcm = 0;              293         voice->use = voice->pcm = 0;
294         voice->sample_ops = NULL;                 294         voice->sample_ops = NULL;
295         spin_unlock_irqrestore(&gus->voice_all    295         spin_unlock_irqrestore(&gus->voice_alloc, flags);
296         if (private_free)                         296         if (private_free)
297                 private_free(voice);              297                 private_free(voice);
298 }                                                 298 }
299                                                   299 
300 /*                                                300 /*
301  *  call this function only by start of driver    301  *  call this function only by start of driver
302  */                                               302  */
303                                                   303 
304 int snd_gf1_start(struct snd_gus_card * gus)      304 int snd_gf1_start(struct snd_gus_card * gus)
305 {                                                 305 {
306         unsigned long flags;                      306         unsigned long flags;
307         unsigned int i;                           307         unsigned int i;
308                                                   308 
309         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RES    309         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0);   /* reset GF1 */
310         udelay(160);                              310         udelay(160);
311         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RES    311         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1);   /* disable IRQ & DAC */
312         udelay(160);                              312         udelay(160);
313         snd_gf1_i_write8(gus, SNDRV_GF1_GB_JOY    313         snd_gf1_i_write8(gus, SNDRV_GF1_GB_JOYSTICK_DAC_LEVEL, gus->joystick_dac);
314                                                   314 
315         snd_gf1_set_default_handlers(gus, SNDR    315         snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_ALL);
316         for (i = 0; i < 32; i++) {                316         for (i = 0; i < 32; i++) {
317                 gus->gf1.voices[i].number = i;    317                 gus->gf1.voices[i].number = i;
318                 snd_gf1_set_default_handlers(g    318                 snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_VOICE | i);
319         }                                         319         }
320                                                   320 
321         snd_gf1_uart_cmd(gus, 0x03);    /* huh    321         snd_gf1_uart_cmd(gus, 0x03);    /* huh.. this cleanup took me some time... */
322                                                   322 
323         if (gus->gf1.enh_mode) {        /* enh    323         if (gus->gf1.enh_mode) {        /* enhanced mode !!!! */
324                 snd_gf1_i_write8(gus, SNDRV_GF    324                 snd_gf1_i_write8(gus, SNDRV_GF1_GB_GLOBAL_MODE, snd_gf1_i_look8(gus, SNDRV_GF1_GB_GLOBAL_MODE) | 0x01);
325                 snd_gf1_i_write8(gus, SNDRV_GF    325                 snd_gf1_i_write8(gus, SNDRV_GF1_GB_MEMORY_CONTROL, 0x01);
326         }                                         326         }
327         snd_gf1_clear_regs(gus);                  327         snd_gf1_clear_regs(gus);
328         snd_gf1_select_active_voices(gus);        328         snd_gf1_select_active_voices(gus);
329         snd_gf1_delay(gus);                       329         snd_gf1_delay(gus);
330         gus->gf1.default_voice_address = gus->    330         gus->gf1.default_voice_address = gus->gf1.memory > 0 ? 0 : 512 - 8;
331         /* initialize LFOs & clear LFOs memory    331         /* initialize LFOs & clear LFOs memory */
332         if (gus->gf1.enh_mode && gus->gf1.memo    332         if (gus->gf1.enh_mode && gus->gf1.memory) {
333                 gus->gf1.hw_lfo = 1;              333                 gus->gf1.hw_lfo = 1;
334                 gus->gf1.default_voice_address    334                 gus->gf1.default_voice_address += 1024;
335         } else {                                  335         } else {
336                 gus->gf1.sw_lfo = 1;              336                 gus->gf1.sw_lfo = 1;
337         }                                         337         }
338 #if 0                                             338 #if 0
339         snd_gf1_lfo_init(gus);                    339         snd_gf1_lfo_init(gus);
340 #endif                                            340 #endif
341         if (gus->gf1.memory > 0)                  341         if (gus->gf1.memory > 0)
342                 for (i = 0; i < 4; i++)           342                 for (i = 0; i < 4; i++)
343                         snd_gf1_poke(gus, gus-    343                         snd_gf1_poke(gus, gus->gf1.default_voice_address + i, 0);
344         snd_gf1_clear_regs(gus);                  344         snd_gf1_clear_regs(gus);
345         snd_gf1_clear_voices(gus, 0, 31);         345         snd_gf1_clear_voices(gus, 0, 31);
346         snd_gf1_look_regs(gus);                   346         snd_gf1_look_regs(gus);
347         udelay(160);                              347         udelay(160);
348         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RES    348         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 7);   /* Reset Register = IRQ enable, DAC enable */
349         udelay(160);                              349         udelay(160);
350         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RES    350         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 7);   /* Reset Register = IRQ enable, DAC enable */
351         if (gus->gf1.enh_mode) {        /* enh    351         if (gus->gf1.enh_mode) {        /* enhanced mode !!!! */
352                 snd_gf1_i_write8(gus, SNDRV_GF    352                 snd_gf1_i_write8(gus, SNDRV_GF1_GB_GLOBAL_MODE, snd_gf1_i_look8(gus, SNDRV_GF1_GB_GLOBAL_MODE) | 0x01);
353                 snd_gf1_i_write8(gus, SNDRV_GF    353                 snd_gf1_i_write8(gus, SNDRV_GF1_GB_MEMORY_CONTROL, 0x01);
354         }                                         354         }
355         while ((snd_gf1_i_read8(gus, SNDRV_GF1    355         while ((snd_gf1_i_read8(gus, SNDRV_GF1_GB_VOICES_IRQ) & 0xc0) != 0xc0);
356                                                   356 
357         spin_lock_irqsave(&gus->reg_lock, flag    357         spin_lock_irqsave(&gus->reg_lock, flags);
358         outb(gus->gf1.active_voice = 0, GUSP(g    358         outb(gus->gf1.active_voice = 0, GUSP(gus, GF1PAGE));
359         outb(gus->mix_cntrl_reg, GUSP(gus, MIX    359         outb(gus->mix_cntrl_reg, GUSP(gus, MIXCNTRLREG));
360         spin_unlock_irqrestore(&gus->reg_lock,    360         spin_unlock_irqrestore(&gus->reg_lock, flags);
361                                                   361 
362         snd_gf1_timers_init(gus);                 362         snd_gf1_timers_init(gus);
363         snd_gf1_look_regs(gus);                   363         snd_gf1_look_regs(gus);
364         snd_gf1_mem_init(gus);                    364         snd_gf1_mem_init(gus);
365         snd_gf1_mem_proc_init(gus);               365         snd_gf1_mem_proc_init(gus);
366 #ifdef CONFIG_SND_DEBUG                           366 #ifdef CONFIG_SND_DEBUG
367         snd_gus_irq_profile_init(gus);            367         snd_gus_irq_profile_init(gus);
368 #endif                                            368 #endif
369                                                   369 
370 #if 0                                             370 #if 0
371         if (gus->pnp_flag) {                      371         if (gus->pnp_flag) {
372                 if (gus->chip.playback_fifo_si    372                 if (gus->chip.playback_fifo_size > 0)
373                         snd_gf1_i_write16(gus,    373                         snd_gf1_i_write16(gus, SNDRV_GF1_GW_FIFO_RECORD_BASE_ADDR, gus->chip.playback_fifo_block->ptr >> 8);
374                 if (gus->chip.record_fifo_size    374                 if (gus->chip.record_fifo_size > 0)
375                         snd_gf1_i_write16(gus,    375                         snd_gf1_i_write16(gus, SNDRV_GF1_GW_FIFO_PLAY_BASE_ADDR, gus->chip.record_fifo_block->ptr >> 8);
376                 snd_gf1_i_write16(gus, SNDRV_G    376                 snd_gf1_i_write16(gus, SNDRV_GF1_GW_FIFO_SIZE, gus->chip.interwave_fifo_reg);
377         }                                         377         }
378 #endif                                            378 #endif
379                                                   379 
380         return 0;                                 380         return 0;
381 }                                                 381 }
382                                                   382 
383 /*                                                383 /*
384  *  call this function only by shutdown of dri    384  *  call this function only by shutdown of driver
385  */                                               385  */
386                                                   386 
387 int snd_gf1_stop(struct snd_gus_card * gus)       387 int snd_gf1_stop(struct snd_gus_card * gus)
388 {                                                 388 {
389         snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOU    389         snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, 0); /* stop all timers */
390         snd_gf1_stop_voices(gus, 0, 31);          390         snd_gf1_stop_voices(gus, 0, 31);                /* stop all voices */
391         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RES    391         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1);   /* disable IRQ & DAC */
392         snd_gf1_timers_done(gus);                 392         snd_gf1_timers_done(gus);
393         snd_gf1_mem_done(gus);                    393         snd_gf1_mem_done(gus);
394 #if 0                                             394 #if 0
395         snd_gf1_lfo_done(gus);                    395         snd_gf1_lfo_done(gus);
396 #endif                                            396 #endif
397         return 0;                                 397         return 0;
398 }                                                 398 }
399                                                   399 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php