]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/pci/emu10k1/emu10k1_callback.c
ALSA: Kill snd_assert() in sound/pci/*
[linux-2.6-omap-h63xx.git] / sound / pci / emu10k1 / emu10k1_callback.c
index 6589bf24abcda1bbe540db08a0ddd9d30d50c1f4..0e649dcdbf64bef54d800e8ad7b3384124ca0efe 100644 (file)
@@ -27,26 +27,27 @@ 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 *emux, struct snd_emu10k1 *hw,
+                         struct best_voice *best, int active_only);
+static struct snd_emux_voice *get_voice(struct snd_emux *emux,
+                                       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 +60,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,9 +74,9 @@ static snd_emux_operators_t emu10k1_ops = {
 };
 
 void
-snd_emu10k1_ops_setup(snd_emux_t *emu)
+snd_emu10k1_ops_setup(struct snd_emux *emux)
 {
-       emu->ops = emu10k1_ops;
+       emux->ops = emu10k1_ops;
 }
 
 
@@ -85,11 +86,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 +124,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 +141,17 @@ 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);
+       if (snd_BUG_ON(!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,12 +161,16 @@ 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) {
+       /* FIXME: emu10k1_synth is broken. */
+       /* This can get called with hw == 0 */
+       /* Problem apparent on plug, unplug then plug */
+       /* on the Audigy 2 ZS Notebook. */
+       if (hw && (vp->ch >= 0)) {
                snd_emu10k1_ptr_write(hw, IFATN, vp->ch, 0xff00);
                snd_emu10k1_ptr_write(hw, DCYSUSV, vp->ch, 0x807f | DCYSUSV_CHANNELENABLE_MASK);
                // snd_emu10k1_ptr_write(hw, DCYSUSV, vp->ch, 0);
@@ -181,9 +187,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 +216,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++) {
@@ -274,12 +281,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 +297,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 +315,22 @@ 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);
+       if (snd_BUG_ON(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++;
@@ -463,15 +471,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 +503,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 +521,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 +539,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;