vserver 1.9.5.x5
[linux-2.6.git] / sound / pci / emu10k1 / emupcm.c
index 9fbbf6c..de78ffe 100644 (file)
@@ -267,6 +267,7 @@ static void snd_emu10k1_pcm_init_voice(emu10k1_t *emu,
                send_routing[3] = 3;
                memset(send_amount, 0, sizeof(send_amount));
        } else {
+               /* mono, left, right (master voice = left) */
                tmp = stereo ? (master ? 1 : 2) : 0;
                memcpy(send_routing, &mix->send_routing[tmp][0], 8);
                memcpy(send_amount, &mix->send_volume[tmp][0], 8);
@@ -292,15 +293,9 @@ static void snd_emu10k1_pcm_init_voice(emu10k1_t *emu,
        // setup routing
        if (emu->audigy) {
                snd_emu10k1_ptr_write(emu, A_FXRT1, voice,
-                                     ((unsigned int)send_routing[3] << 24) |
-                                     ((unsigned int)send_routing[2] << 16) |
-                                     ((unsigned int)send_routing[1] << 8) |
-                                     (unsigned int)send_routing[0]);
+                                     snd_emu10k1_compose_audigy_fxrt1(send_routing));
                snd_emu10k1_ptr_write(emu, A_FXRT2, voice,
-                                     ((unsigned int)send_routing[7] << 24) |
-                                     ((unsigned int)send_routing[6] << 16) |
-                                     ((unsigned int)send_routing[5] << 8) |
-                                     (unsigned int)send_routing[4]);
+                                     snd_emu10k1_compose_audigy_fxrt2(send_routing));
                snd_emu10k1_ptr_write(emu, A_SENDAMOUNTS, voice,
                                      ((unsigned int)send_amount[4] << 24) |
                                      ((unsigned int)send_amount[5] << 16) |
@@ -777,8 +772,7 @@ static void snd_emu10k1_pcm_free_substream(snd_pcm_runtime_t *runtime)
 {
        emu10k1_pcm_t *epcm = runtime->private_data;
 
-       if (epcm)
-               kfree(epcm);
+       kfree(epcm);
 }
 
 static int snd_emu10k1_playback_open(snd_pcm_substream_t * substream)
@@ -1092,6 +1086,7 @@ static int snd_emu10k1_pcm_efx_voices_mask_put(snd_kcontrol_t * kcontrol, snd_ct
        emu10k1_t *emu = snd_kcontrol_chip(kcontrol);
        unsigned int nval[2], bits;
        int nefx = emu->audigy ? 64 : 32;
+       int nefxb = emu->audigy ? 7 : 6;
        int change, idx;
        
        nval[0] = nval[1] = 0;
@@ -1100,8 +1095,14 @@ static int snd_emu10k1_pcm_efx_voices_mask_put(snd_kcontrol_t * kcontrol, snd_ct
                        nval[idx / 32] |= 1 << (idx % 32);
                        bits++;
                }
-       if (bits != 1 && bits != 2 && bits != 4 && bits != 8)
+               
+       for (idx = 0; idx < nefxb; idx++)
+               if (1 << idx == bits)
+                       break;
+       
+       if (idx >= nefxb)
                return -EINVAL;
+
        spin_lock_irq(&emu->reg_lock);
        change = (nval[0] != emu->efx_voices_mask[0]) ||
                (nval[1] != emu->efx_voices_mask[1]);
@@ -1185,7 +1186,7 @@ static void fx8010_pb_trans_copy(snd_pcm_substream_t *substream,
        }
        snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu->fx8010.etram_pages.area + tram_pos,
                                               (unsigned short *)emu->fx8010.etram_pages.area + tram_pos + tram_size / 2,
-                                              src, frames, tram_shift++);
+                                              src, frames, tram_shift);
        tram_pos -= frames;
        pcm->tram_pos = tram_pos;
        pcm->tram_shift = tram_shift;