Update of /cvsroot/alsa/alsa-kernel/ppc
In directory sc8-pr-cvs1:/tmp/cvs-serv882

Modified Files:
        pmac.c tumbler.c 
Log Message:
- fixed the hang-up at the resume on tumbler/snapper.



Index: pmac.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/ppc/pmac.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- pmac.c      31 May 2003 11:44:56 -0000      1.21
+++ pmac.c      5 Jun 2003 11:10:52 -0000       1.22
@@ -1211,9 +1211,12 @@
        spin_lock_irqsave(&chip->reg_lock, flags);
        snd_pmac_beep_stop(chip);
        spin_unlock_irqrestore(&chip->reg_lock, flags);
-       disable_irq(chip->irq);
-       disable_irq(chip->tx_irq);
-       disable_irq(chip->rx_irq);
+       if (chip->irq >= 0)
+               disable_irq(chip->irq);
+       if (chip->tx_irq >= 0)
+               disable_irq(chip->tx_irq);
+       if (chip->rx_irq >= 0)
+               disable_irq(chip->rx_irq);
        snd_pmac_sound_feature(chip, 0);
        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 }
@@ -1237,9 +1240,12 @@
 
        snd_pmac_pcm_set_format(chip);
 
-       enable_irq(chip->irq);
-       enable_irq(chip->tx_irq);
-       enable_irq(chip->rx_irq);
+       if (chip->irq >= 0)
+               enable_irq(chip->irq);
+       if (chip->tx_irq >= 0)
+               enable_irq(chip->tx_irq);
+       if (chip->rx_irq >= 0)
+               enable_irq(chip->rx_irq);
 
        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 }

Index: tumbler.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/ppc/tumbler.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- tumbler.c   14 May 2003 13:30:12 -0000      1.20
+++ tumbler.c   5 Jun 2003 11:10:53 -0000       1.21
@@ -27,6 +27,7 @@
 #include <linux/kmod.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
+#include <linux/workqueue.h>
 #include <sound/core.h>
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -79,7 +80,7 @@
        int active_state;
 } pmac_gpio_t;
 
-typedef struct pmac_tumber_t {
+typedef struct pmac_tumbler_t {
        pmac_keywest_t i2c;
        pmac_gpio_t audio_reset;
        pmac_gpio_t amp_mute;
@@ -92,11 +93,12 @@
        unsigned int mix_vol[VOL_IDX_LAST_MIX][2]; /* stereo volumes for tas3004 */
        int drc_range;
        int drc_enable;
+#ifdef CONFIG_PMAC_PBOOK
+       struct work_struct resume_workq;
+#endif
 } pmac_tumbler_t;
 
 
-#define number_of(ary) (sizeof(ary) / sizeof(ary[0]))
-
 /*
  */
 
@@ -168,16 +170,16 @@
                left_vol = 0;
        else {
                left_vol = mix->master_vol[0];
-               if (left_vol >= number_of(master_volume_table))
-                       left_vol = number_of(master_volume_table) - 1;
+               if (left_vol >= ARRAY_SIZE(master_volume_table))
+                       left_vol = ARRAY_SIZE(master_volume_table) - 1;
                left_vol = master_volume_table[left_vol];
        }
        if (! mix->master_switch[1])
                right_vol = 0;
        else {
                right_vol = mix->master_vol[1];
-               if (right_vol >= number_of(master_volume_table))
-                       right_vol = number_of(master_volume_table) - 1;
+               if (right_vol >= ARRAY_SIZE(master_volume_table))
+                       right_vol = ARRAY_SIZE(master_volume_table) - 1;
                right_vol = master_volume_table[right_vol];
        }
 
@@ -203,7 +205,7 @@
        uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
        uinfo->count = 2;
        uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = number_of(master_volume_table) - 1;
+       uinfo->value.integer.max = ARRAY_SIZE(master_volume_table) - 1;
        return 0;
 }
 
@@ -479,7 +481,7 @@
        .index = VOL_IDX_PCM_MONO,
        .reg = TAS_REG_PCM,
        .bytes = 3,
-       .max = number_of(mixer_volume_table),
+       .max = ARRAY_SIZE(mixer_volume_table),
        .table = mixer_volume_table,
 };
 
@@ -487,7 +489,7 @@
        .index = VOL_IDX_BASS,
        .reg = TAS_REG_BASS,
        .bytes = 1,
-       .max = number_of(bass_volume_table),
+       .max = ARRAY_SIZE(bass_volume_table),
        .table = bass_volume_table,
 };
 
@@ -495,7 +497,7 @@
        .index = VOL_IDX_TREBLE,
        .reg = TAS_REG_TREBLE,
        .bytes = 1,
-       .max = number_of(treble_volume_table),
+       .max = ARRAY_SIZE(treble_volume_table),
        .table = treble_volume_table,
 };
 
@@ -504,7 +506,7 @@
        .index = VOL_IDX_BASS,
        .reg = TAS_REG_BASS,
        .bytes = 1,
-       .max = number_of(snapper_bass_volume_table),
+       .max = ARRAY_SIZE(snapper_bass_volume_table),
        .table = snapper_bass_volume_table,
 };
 
@@ -512,7 +514,7 @@
        .index = VOL_IDX_TREBLE,
        .reg = TAS_REG_TREBLE,
        .bytes = 1,
-       .max = number_of(snapper_treble_volume_table),
+       .max = ARRAY_SIZE(snapper_treble_volume_table),
        .table = snapper_treble_volume_table,
 };
 
@@ -546,8 +548,8 @@
        unsigned char block[9];
 
        vol = mix->mix_vol[idx][ch];
-       if (vol >= number_of(mixer_volume_table)) {
-               vol = number_of(mixer_volume_table) - 1;
+       if (vol >= ARRAY_SIZE(mixer_volume_table)) {
+               vol = ARRAY_SIZE(mixer_volume_table) - 1;
                mix->mix_vol[idx][ch] = vol;
        }
 
@@ -579,7 +581,7 @@
        uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
        uinfo->count = 2;
        uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = number_of(mixer_volume_table) - 1;
+       uinfo->value.integer.max = ARRAY_SIZE(mixer_volume_table) - 1;
        return 0;
 }
 
@@ -877,29 +879,47 @@
 
 #ifdef CONFIG_PMAC_PBOOK
 /* resume mixer */
-static void tumbler_resume(pmac_t *chip)
+/* we call the i2c transfer in a workqueue because it may need either schedule()
+ * or completion from timer interrupts.
+ */
+static void tumbler_resume_work(void *arg)
 {
+       pmac_t *chip = (pmac_t *)arg;
        pmac_tumbler_t *mix = chip->mixer_data;
-       snd_assert(mix, return);
+
        tumbler_reset_audio(chip);
-       if (mix->i2c.client)
-               tumbler_init_client(&mix->i2c);
+       if (mix->i2c.client) {
+               if (tumbler_init_client(&mix->i2c) < 0)
+                       printk(KERN_ERR "tumbler_init_client error\n");
+       } else
+               printk(KERN_ERR "tumbler: i2c is not initialized\n");
        if (chip->model == PMAC_TUMBLER) {
                tumbler_set_mono_volume(mix, &tumbler_pcm_vol_info);
                tumbler_set_mono_volume(mix, &tumbler_bass_vol_info);
                tumbler_set_mono_volume(mix, &tumbler_treble_vol_info);
+               tumbler_set_drc(mix);
        } else {
                snapper_set_mix_vol(mix, VOL_IDX_PCM);
                snapper_set_mix_vol(mix, VOL_IDX_PCM2);
                snapper_set_mix_vol(mix, VOL_IDX_ADC);
                tumbler_set_mono_volume(mix, &tumbler_bass_vol_info);
                tumbler_set_mono_volume(mix, &tumbler_treble_vol_info);
+               snapper_set_drc(mix);
        }
-       tumbler_set_drc(mix);
        tumbler_set_master_volume(mix);
        if (chip->update_automute)
                chip->update_automute(chip, 0);
 }
+
+static void tumbler_resume(pmac_t *chip)
+{
+       pmac_tumbler_t *mix = chip->mixer_data;
+       snd_assert(mix, return);
+       INIT_WORK(&mix->resume_workq, tumbler_resume_work, chip);
+       if (schedule_work(&mix->resume_workq))
+               return;
+       printk(KERN_ERR "ALSA tumbler: cannot schedule resume-workqueue.\n");
+}
 #endif
 
 /* initialize tumbler */
@@ -1001,12 +1021,12 @@
        sprintf(chip->card->mixername, "PowerMac %s", chipname);
 
        if (chip->model == PMAC_TUMBLER) {
-               for (i = 0; i < number_of(tumbler_mixers); i++) {
+               for (i = 0; i < ARRAY_SIZE(tumbler_mixers); i++) {
                        if ((err = snd_ctl_add(chip->card, 
snd_ctl_new1(&tumbler_mixers[i], chip))) < 0)
                                return err;
                }
        } else {
-               for (i = 0; i < number_of(snapper_mixers); i++) {
+               for (i = 0; i < ARRAY_SIZE(snapper_mixers); i++) {
                        if ((err = snd_ctl_add(chip->card, 
snd_ctl_new1(&snapper_mixers[i], chip))) < 0)
                                return err;
                }



-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to