Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / sound / pci / emu10k1 / emu10k1_callback.c
index 7cf2f90..01965bd 100644 (file)
@@ -27,26 +27,28 @@ enum {
 };
 
 /* Keeps track of what we are finding */
-typedef struct best_voice {
+struct best_voice {
        unsigned int time;
        int voice;
-} best_voice_t;
+};
 
 /*
  * prototypes
  */
-static void lookup_voices(snd_emux_t *emu, emu10k1_t *hw, best_voice_t *best, int active_only);
-static snd_emux_voice_t *get_voice(snd_emux_t *emu, snd_emux_port_t *port);
-static int start_voice(snd_emux_voice_t *vp);
-static void trigger_voice(snd_emux_voice_t *vp);
-static void release_voice(snd_emux_voice_t *vp);
-static void update_voice(snd_emux_voice_t *vp, int update);
-static void terminate_voice(snd_emux_voice_t *vp);
-static void free_voice(snd_emux_voice_t *vp);
-
-static void set_fmmod(emu10k1_t *hw, snd_emux_voice_t *vp);
-static void set_fm2frq2(emu10k1_t *hw, snd_emux_voice_t *vp);
-static void set_filterQ(emu10k1_t *hw, snd_emux_voice_t *vp);
+static void lookup_voices(struct snd_emux *emu, struct snd_emu10k1 *hw,
+                         struct best_voice *best, int active_only);
+static struct snd_emux_voice *get_voice(struct snd_emux *emu,
+                                       struct snd_emux_port *port);
+static int start_voice(struct snd_emux_voice *vp);
+static void trigger_voice(struct snd_emux_voice *vp);
+static void release_voice(struct snd_emux_voice *vp);
+static void update_voice(struct snd_emux_voice *vp, int update);
+static void terminate_voice(struct snd_emux_voice *vp);
+static void free_voice(struct snd_emux_voice *vp);
+
+static void set_fmmod(struct snd_emu10k1 *hw, struct snd_emux_voice *vp);
+static void set_fm2frq2(struct snd_emu10k1 *hw, struct snd_emux_voice *vp);
+static void set_filterQ(struct snd_emu10k1 *hw, struct snd_emux_voice *vp);
 
 /*
  * Ensure a value is between two points
@@ -59,7 +61,7 @@ static void set_filterQ(emu10k1_t *hw, snd_emux_voice_t *vp);
 /*
  * set up operators
  */
-static snd_emux_operators_t emu10k1_ops = {
+static struct snd_emux_operators emu10k1_ops = {
        .owner =        THIS_MODULE,
        .get_voice =    get_voice,
        .prepare =      start_voice,
@@ -73,7 +75,7 @@ static snd_emux_operators_t emu10k1_ops = {
 };
 
 void
-snd_emu10k1_ops_setup(snd_emux_t *emu)
+snd_emu10k1_ops_setup(struct snd_emux *emu)
 {
        emu->ops = emu10k1_ops;
 }
@@ -85,11 +87,11 @@ snd_emu10k1_ops_setup(snd_emux_t *emu)
  * terminate most inactive voice and give it as a pcm voice.
  */
 int
-snd_emu10k1_synth_get_voice(emu10k1_t *hw)
+snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw)
 {
-       snd_emux_t *emu;
-       snd_emux_voice_t *vp;
-       best_voice_t best[V_END];
+       struct snd_emux *emu;
+       struct snd_emux_voice *vp;
+       struct best_voice best[V_END];
        unsigned long flags;
        int i;
 
@@ -123,10 +125,10 @@ snd_emu10k1_synth_get_voice(emu10k1_t *hw)
  * turn off the voice (not terminated)
  */
 static void
-release_voice(snd_emux_voice_t *vp)
+release_voice(struct snd_emux_voice *vp)
 {
        int dcysusv;
-       emu10k1_t *hw;
+       struct snd_emu10k1 *hw;
        
        hw = vp->hw;
        dcysusv = 0x8000 | (unsigned char)vp->reg.parm.modrelease;
@@ -140,16 +142,16 @@ release_voice(snd_emux_voice_t *vp)
  * terminate the voice
  */
 static void
-terminate_voice(snd_emux_voice_t *vp)
+terminate_voice(struct snd_emux_voice *vp)
 {
-       emu10k1_t *hw;
+       struct snd_emu10k1 *hw;
        
        snd_assert(vp, return);
        hw = vp->hw;
        snd_emu10k1_ptr_write(hw, DCYSUSV, vp->ch, 0x807f | DCYSUSV_CHANNELENABLE_MASK);
        if (vp->block) {
-               emu10k1_memblk_t *emem;
-               emem = (emu10k1_memblk_t *)vp->block;
+               struct snd_emu10k1_memblk *emem;
+               emem = (struct snd_emu10k1_memblk *)vp->block;
                if (emem->map_locked > 0)
                        emem->map_locked--;
        }
@@ -159,9 +161,9 @@ terminate_voice(snd_emux_voice_t *vp)
  * release the voice to system
  */
 static void
-free_voice(snd_emux_voice_t *vp)
+free_voice(struct snd_emux_voice *vp)
 {
-       emu10k1_t *hw;
+       struct snd_emu10k1 *hw;
        
        hw = vp->hw;
        if (vp->ch >= 0) {
@@ -181,9 +183,9 @@ free_voice(snd_emux_voice_t *vp)
  * update registers
  */
 static void
-update_voice(snd_emux_voice_t *vp, int update)
+update_voice(struct snd_emux_voice *vp, int update)
 {
-       emu10k1_t *hw;
+       struct snd_emu10k1 *hw;
        
        hw = vp->hw;
        if (update & SNDRV_EMUX_UPDATE_VOLUME)
@@ -210,10 +212,11 @@ update_voice(snd_emux_voice_t *vp, int update)
  */
 /* spinlock held! */
 static void
-lookup_voices(snd_emux_t *emu, emu10k1_t *hw, best_voice_t *best, int active_only)
+lookup_voices(struct snd_emux *emu, struct snd_emu10k1 *hw,
+             struct best_voice *best, int active_only)
 {
-       snd_emux_voice_t *vp;
-       best_voice_t *bp;
+       struct snd_emux_voice *vp;
+       struct best_voice *bp;
        int  i;
 
        for (i = 0; i < V_END; i++) {
@@ -241,7 +244,7 @@ lookup_voices(snd_emux_t *emu, emu10k1_t *hw, best_voice_t *best, int active_onl
                else if (state == SNDRV_EMUX_ST_RELEASED ||
                         state == SNDRV_EMUX_ST_PENDING) {
                        bp = best + V_RELEASED;
-#if 0
+#if 1
                        val = snd_emu10k1_ptr_read(hw, CVCF_CURRENTVOL, vp->ch);
                        if (! val)
                                bp = best + V_OFF;
@@ -274,12 +277,12 @@ lookup_voices(snd_emux_t *emu, emu10k1_t *hw, best_voice_t *best, int active_onl
  *
  * emu->voice_lock is already held.
  */
-static snd_emux_voice_t *
-get_voice(snd_emux_t *emu, snd_emux_port_t *port)
+static struct snd_emux_voice *
+get_voice(struct snd_emux *emu, struct snd_emux_port *port)
 {
-       emu10k1_t *hw;
-       snd_emux_voice_t *vp;
-       best_voice_t best[V_END];
+       struct snd_emu10k1 *hw;
+       struct snd_emux_voice *vp;
+       struct best_voice best[V_END];
        int i;
 
        hw = emu->hw;
@@ -290,7 +293,7 @@ get_voice(snd_emux_t *emu, snd_emux_port_t *port)
                        vp = &emu->voices[best[i].voice];
                        if (vp->ch < 0) {
                                /* allocate a voice */
-                               emu10k1_voice_t *hwvoice;
+                               struct snd_emu10k1_voice *hwvoice;
                                if (snd_emu10k1_voice_alloc(hw, EMU10K1_SYNTH, 1, &hwvoice) < 0 || hwvoice == NULL)
                                        continue;
                                vp->ch = hwvoice->number;
@@ -308,21 +311,21 @@ get_voice(snd_emux_t *emu, snd_emux_port_t *port)
  * prepare envelopes and LFOs
  */
 static int
-start_voice(snd_emux_voice_t *vp)
+start_voice(struct snd_emux_voice *vp)
 {
        unsigned int temp;
        int ch;
        unsigned int addr, mapped_offset;
-       snd_midi_channel_t *chan;
-       emu10k1_t *hw;
-       emu10k1_memblk_t *emem;
+       struct snd_midi_channel *chan;
+       struct snd_emu10k1 *hw;
+       struct snd_emu10k1_memblk *emem;
        
        hw = vp->hw;
        ch = vp->ch;
        snd_assert(ch >= 0, return -EINVAL);
        chan = vp->chan;
 
-       emem = (emu10k1_memblk_t *)vp->block;
+       emem = (struct snd_emu10k1_memblk *)vp->block;
        if (emem == NULL)
                return -EINVAL;
        emem->map_locked++;
@@ -349,7 +352,7 @@ start_voice(snd_emux_voice_t *vp)
        }
 
        /* channel to be silent and idle */
-       snd_emu10k1_ptr_write(hw, DCYSUSV, ch, 0x0080);
+       snd_emu10k1_ptr_write(hw, DCYSUSV, ch, 0x0000);
        snd_emu10k1_ptr_write(hw, VTFT, ch, 0x0000FFFF);
        snd_emu10k1_ptr_write(hw, CVCF, ch, 0x0000FFFF);
        snd_emu10k1_ptr_write(hw, PTRX, ch, 0);
@@ -463,15 +466,15 @@ start_voice(snd_emux_voice_t *vp)
  * Start envelope
  */
 static void
-trigger_voice(snd_emux_voice_t *vp)
+trigger_voice(struct snd_emux_voice *vp)
 {
        unsigned int temp, ptarget;
-       emu10k1_t *hw;
-       emu10k1_memblk_t *emem;
+       struct snd_emu10k1 *hw;
+       struct snd_emu10k1_memblk *emem;
        
        hw = vp->hw;
 
-       emem = (emu10k1_memblk_t *)vp->block;
+       emem = (struct snd_emu10k1_memblk *)vp->block;
        if (! emem || emem->mapped_page < 0)
                return; /* not mapped */
 
@@ -495,7 +498,7 @@ trigger_voice(snd_emux_voice_t *vp)
 
 /* set lfo1 modulation height and cutoff */
 static void
-set_fmmod(emu10k1_t *hw, snd_emux_voice_t *vp)
+set_fmmod(struct snd_emu10k1 *hw, struct snd_emux_voice *vp)
 {
        unsigned short fmmod;
        short pitch;
@@ -513,7 +516,7 @@ set_fmmod(emu10k1_t *hw, snd_emux_voice_t *vp)
 
 /* set lfo2 pitch & frequency */
 static void
-set_fm2frq2(emu10k1_t *hw, snd_emux_voice_t *vp)
+set_fm2frq2(struct snd_emu10k1 *hw, struct snd_emux_voice *vp)
 {
        unsigned short fm2frq2;
        short pitch;
@@ -531,7 +534,7 @@ set_fm2frq2(emu10k1_t *hw, snd_emux_voice_t *vp)
 
 /* set filterQ */
 static void
-set_filterQ(emu10k1_t *hw, snd_emux_voice_t *vp)
+set_filterQ(struct snd_emu10k1 *hw, struct snd_emux_voice *vp)
 {
        unsigned int val;
        val = snd_emu10k1_ptr_read(hw, CCCA, vp->ch) & ~CCCA_RESONANCE;