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

Modified Files:
        awacs.c pmac.c pmac.h powermac.c 
Log Message:
- removed beep stuff from the alsa-kernel (2.5) tree.
- fixed suspend/resume of AWACS/SCREAMER by Colin Gibbs <[EMAIL PROTECTED]>



Index: awacs.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/ppc/awacs.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- awacs.c     23 Sep 2002 15:20:51 -0000      1.18
+++ awacs.c     3 Apr 2003 10:34:49 -0000       1.19
@@ -52,6 +52,18 @@
 #endif /* PMAC_AMP_AVAIL */
 
 
+static void snd_pmac_screamer_wait(pmac_t *chip)
+{
+       long timeout = 2000;
+       while (!(in_le32(&chip->awacs->codec_stat) & MASK_VALID)) {
+               mdelay(1);
+               if (! --timeout) {
+                       snd_printd("snd_pmac_screamer_wait timeout\n");
+                       break;
+               }
+       }
+}
+
 /*
  * write AWACS register
  */
@@ -60,13 +72,15 @@
 {
        long timeout = 5000000;
 
+       if (chip->model == PMAC_SCREAMER)
+               snd_pmac_screamer_wait(chip);
+       out_le32(&chip->awacs->codec_ctrl, val | (chip->subframe << 22));
        while (in_le32(&chip->awacs->codec_ctrl) & MASK_NEWECMD) {
                if (! --timeout) {
                        snd_printd("snd_pmac_awacs_write timeout\n");
                        break;
                }
        }
-       out_le32(&chip->awacs->codec_ctrl, val | (chip->subframe << 22));
 }
 
 static void
@@ -101,11 +115,14 @@
        /* Sorry for the horrible delays... I hope to get that improved
         * by making the whole PM process asynchronous in a future version
         */
-       do_mdelay(750, can_schedule);
+       snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]);
+       if (chip->manufacturer == 0x1)
+               /* delay for broken crystal part */
+               do_mdelay(750, can_schedule);
        snd_pmac_awacs_write_noreg(chip, 1,
                                   chip->awacs_reg[1] | MASK_RECALIBRATE | MASK_CMUTE 
| MASK_AMUTE);
-       do_mdelay(1000, can_schedule);
        snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]);
+       snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]);
 }
 
 #else
@@ -626,12 +643,8 @@
        snd_pmac_awacs_write_noreg(chip, 4, chip->awacs_reg[4]);
        if (chip->model == PMAC_SCREAMER) {
                snd_pmac_awacs_write_noreg(chip, 5, chip->awacs_reg[5]);
-               do_mdelay(100, can_schedule);
                snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]);
-               mdelay(2);
-               snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]);
                snd_pmac_awacs_write_noreg(chip, 7, chip->awacs_reg[7]);
-               snd_pmac_awacs_write_noreg(chip, 0, chip->awacs_reg[0]);
        }
 }
 
@@ -639,6 +652,11 @@
 static void snd_pmac_awacs_resume(pmac_t *chip)
 {
        awacs_restore_all_regs(chip, 0);
+       if (chip->model == PMAC_SCREAMER) {
+               /* reset power bits in reg 6 */
+               mdelay(5);
+               snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]);
+       }
        screamer_recalibrate(chip, 0);
 #ifdef PMAC_AMP_AVAIL
        if (chip->mixer_data) {
@@ -748,6 +766,7 @@
        }
 
        awacs_restore_all_regs(chip, 1);
+       chip->manufacturer = (in_le32(&chip->awacs->codec_stat) >> 8) & 0xf;
        screamer_recalibrate(chip, 1);
 
        chip->revision = (in_le32(&chip->awacs->codec_stat) >> 12) & 0xf;

Index: pmac.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/ppc/pmac.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- pmac.c      9 Feb 2003 17:25:43 -0000       1.18
+++ pmac.c      3 Apr 2003 10:34:52 -0000       1.19
@@ -269,21 +269,6 @@
 
 
 /*
- * stop beep if running (no spinlock!)
- */
-static void snd_pmac_beep_stop(pmac_t *chip)
-{
-       pmac_beep_t *beep = chip->beep;
-
-       if (beep && beep->running) {
-               beep->running = 0;
-               del_timer(&beep->timer);
-               snd_pmac_dma_stop(&chip->playback);
-               st_le16(&chip->extra_dma.cmds->command, DBDMA_STOP);
-       }
-}
-
-/*
  * PCM trigger/stop
  */
 static int snd_pmac_pcm_trigger(pmac_t *chip, pmac_stream_t *rec,
@@ -696,245 +681,6 @@
 }
 
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-
-/*
- * beep stuff
- */
-
-/*
- * Stuff for outputting a beep.  The values range from -327 to +327
- * so we can multiply by an amplitude in the range 0..100 to get a
- * signed short value to put in the output buffer.
- */
-static short beep_wform[256] = {
-       0,      40,     79,     117,    153,    187,    218,    245,
-       269,    288,    304,    316,    323,    327,    327,    324,
-       318,    310,    299,    288,    275,    262,    249,    236,
-       224,    213,    204,    196,    190,    186,    183,    182,
-       182,    183,    186,    189,    192,    196,    200,    203,
-       206,    208,    209,    209,    209,    207,    204,    201,
-       197,    193,    188,    183,    179,    174,    170,    166,
-       163,    161,    160,    159,    159,    160,    161,    162,
-       164,    166,    168,    169,    171,    171,    171,    170,
-       169,    167,    163,    159,    155,    150,    144,    139,
-       133,    128,    122,    117,    113,    110,    107,    105,
-       103,    103,    103,    103,    104,    104,    105,    105,
-       105,    103,    101,    97,     92,     86,     78,     68,
-       58,     45,     32,     18,     3,      -11,    -26,    -41,
-       -55,    -68,    -79,    -88,    -95,    -100,   -102,   -102,
-       -99,    -93,    -85,    -75,    -62,    -48,    -33,    -16,
-       0,      16,     33,     48,     62,     75,     85,     93,
-       99,     102,    102,    100,    95,     88,     79,     68,
-       55,     41,     26,     11,     -3,     -18,    -32,    -45,
-       -58,    -68,    -78,    -86,    -92,    -97,    -101,   -103,
-       -105,   -105,   -105,   -104,   -104,   -103,   -103,   -103,
-       -103,   -105,   -107,   -110,   -113,   -117,   -122,   -128,
-       -133,   -139,   -144,   -150,   -155,   -159,   -163,   -167,
-       -169,   -170,   -171,   -171,   -171,   -169,   -168,   -166,
-       -164,   -162,   -161,   -160,   -159,   -159,   -160,   -161,
-       -163,   -166,   -170,   -174,   -179,   -183,   -188,   -193,
-       -197,   -201,   -204,   -207,   -209,   -209,   -209,   -208,
-       -206,   -203,   -200,   -196,   -192,   -189,   -186,   -183,
-       -182,   -182,   -183,   -186,   -190,   -196,   -204,   -213,
-       -224,   -236,   -249,   -262,   -275,   -288,   -299,   -310,
-       -318,   -324,   -327,   -327,   -323,   -316,   -304,   -288,
-       -269,   -245,   -218,   -187,   -153,   -117,   -79,    -40,
-};
-
-#define BEEP_SRATE     22050   /* 22050 Hz sample rate */
-#define BEEP_BUFLEN    512
-#define BEEP_VOLUME    15      /* 0 - 100 */
-
-static void snd_pmac_beep_stop_callback(unsigned long data)
-{
-       pmac_t *chip = snd_magic_cast(pmac_t, (void*)data,);
-
-       spin_lock(&chip->reg_lock);
-       snd_pmac_beep_stop(chip);
-       snd_pmac_pcm_set_format(chip);
-       spin_unlock(&chip->reg_lock);
-}
-
-/* because mksound callback takes no private argument, we must keep
-   the chip pointer here as static variable.
-   This means that only one chip can beep.  Well, it's ok -
-   anyway we don't like hearing loud beeps from every chip
-   at the same time :)
-*/
-   
-static pmac_t *beeping_chip = NULL;
-
-static void snd_pmac_mksound(unsigned int hz, unsigned int ticks)
-{
-       pmac_t *chip;
-       pmac_stream_t *rec;
-       pmac_beep_t *beep;
-       unsigned long flags;
-       int beep_speed = 0;
-       int srate;
-       int period, ncycles, nsamples;
-       int i, j, f;
-       short *p;
-
-       if ((chip = beeping_chip) == NULL || (beep = chip->beep) == NULL)
-               return;
-       rec = &chip->playback;
-
-       beep_speed = snd_pmac_rate_index(chip, rec, BEEP_SRATE);
-       srate = chip->freq_table[beep_speed];
-
-       if (hz <= srate / BEEP_BUFLEN || hz > srate / 2) {
-               /* this is a hack for broken X server code */
-               hz = 750;
-               ticks = 12;
-       }
-
-       spin_lock_irqsave(&chip->reg_lock, flags);
-       if (chip->playback.running || chip->capture.running || beep->running) {
-               spin_unlock_irqrestore(&chip->reg_lock, flags);
-               return;
-       }
-       beep->running = 1;
-       spin_unlock_irqrestore(&chip->reg_lock, flags);
-
-       if (hz == beep->hz && beep->volume == beep->volume_play) {
-               nsamples = beep->nsamples;
-       } else {
-               period = srate * 256 / hz;      /* fixed point */
-               ncycles = BEEP_BUFLEN * 256 / period;
-               nsamples = (period * ncycles) >> 8;
-               f = ncycles * 65536 / nsamples;
-               j = 0;
-               p = beep->buf;
-               for (i = 0; i < nsamples; ++i, p += 2) {
-                       p[0] = p[1] = beep_wform[j >> 8] * beep->volume;
-                       j = (j + f) & 0xffff;
-               }
-               beep->hz = hz;
-               beep->volume_play = beep->volume;
-               beep->nsamples = nsamples;
-       }
-
-       spin_lock_irqsave(&chip->reg_lock, flags);
-       if (beep->running) {
-               if (ticks <= 0)
-                       ticks = 1;
-               del_timer(&beep->timer);
-               beep->timer.expires = jiffies + ticks;
-               beep->timer.function = snd_pmac_beep_stop_callback;
-               beep->timer.data = (unsigned long)chip;
-               add_timer(&beep->timer);
-               snd_pmac_dma_stop(rec);
-               st_le16(&chip->extra_dma.cmds->req_count, nsamples * 4);
-               st_le16(&chip->extra_dma.cmds->xfer_status, 0);
-               st_le32(&chip->extra_dma.cmds->cmd_dep, chip->extra_dma.addr);
-               st_le32(&chip->extra_dma.cmds->phy_addr, beep->addr);
-               st_le16(&chip->extra_dma.cmds->command, OUTPUT_MORE + BR_ALWAYS);
-               out_le32(&chip->awacs->control,
-                        (in_le32(&chip->awacs->control) & ~0x1f00)
-                        | (beep_speed << 8));
-               out_le32(&chip->awacs->byteswap, 0);
-               snd_pmac_dma_set_command(rec, &chip->extra_dma);
-               snd_pmac_dma_run(rec, RUN);
-       }
-       spin_unlock_irqrestore(&chip->reg_lock, flags);
-}
-
-/*
- * beep volume mixer
- */
-static int snd_pmac_info_beep(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 100;
-       return 0;
-}
-
-static int snd_pmac_get_beep(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       pmac_t *chip = snd_kcontrol_chip(kcontrol);
-       snd_runtime_check(chip->beep, return -ENXIO);
-       ucontrol->value.integer.value[0] = chip->beep->volume;
-       return 0;
-}
-
-static int snd_pmac_put_beep(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
-       pmac_t *chip = snd_kcontrol_chip(kcontrol);
-       int oval;
-       snd_runtime_check(chip->beep, return -ENXIO);
-       oval = chip->beep->volume;
-       chip->beep->volume = ucontrol->value.integer.value[0];
-       return oval != chip->beep->volume;
-}
-
-static snd_kcontrol_new_t snd_pmac_beep_mixer = {
-       .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-       .name = "Beep Playback Volume",
-       .index = 0,
-       .info = snd_pmac_info_beep,
-       .get = snd_pmac_get_beep,
-       .put = snd_pmac_put_beep,
-};
-
-static void snd_pmac_beep_free(snd_kcontrol_t *control)
-{
-       pmac_t *chip = snd_magic_cast(pmac_t, _snd_kcontrol_chip(control),);
-       if (chip->beep) {
-               /* restore */
-               kd_mksound = chip->beep->orig_mksound;
-               kfree(chip->beep->buf);
-               kfree(chip->beep);
-               chip->beep = NULL;
-       }
-}
-
-/* Initialize beep stuff */
-int __init snd_pmac_attach_beep(pmac_t *chip)
-{
-       pmac_beep_t *beep;
-       int err;
-
-       beep = kmalloc(sizeof(*beep), GFP_KERNEL);
-       if (! beep)
-               return -ENOMEM;
-
-       beep->buf = (short *) kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL);
-       if (! beep->buf) {
-               kfree(beep);
-               return -ENOMEM;
-       }
-       beep->addr = virt_to_bus(beep->buf);
-       init_timer(&beep->timer);
-       beep->timer.function = snd_pmac_beep_stop_callback;
-       beep->timer.data = (unsigned long) chip;
-       beep->orig_mksound = kd_mksound;
-       beep->volume = BEEP_VOLUME;
-       beep->running = 0;
-       beep->control = snd_ctl_new1(&snd_pmac_beep_mixer, chip);
-       if (beep->control == NULL) {
-               kfree(beep);
-               return -ENOMEM;
-       }
-       beep->control->private_free = snd_pmac_beep_free;
-       if ((err = snd_ctl_add(chip->card, beep->control)) < 0) {
-               kfree(beep);
-               return err;
-       }
-
-       /* hook */
-       beeping_chip = chip;
-       chip->beep = beep;
-       kd_mksound = snd_pmac_mksound;
-
-       return 0;
-}
-
-#endif /* beep stuff */
-
 static void snd_pmac_dbdma_reset(pmac_t *chip)
 {
        out_le32(&chip->playback.dma->control, (RUN|PAUSE|FLUSH|WAKE|DEAD) << 16);
@@ -1471,8 +1217,7 @@
                chip->suspend(chip);
        snd_pcm_suspend_all(chip->pcm);
        spin_lock_irqsave(&chip->reg_lock, flags);
-       if (chip->beep && chip->beep->running)
-               snd_pmac_beep_stop(chip);
+       snd_pmac_beep_stop(chip);
        spin_unlock_irqrestore(&chip->reg_lock, flags);
        disable_irq(chip->irq);
        disable_irq(chip->tx_irq);

Index: pmac.h
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/ppc/pmac.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- pmac.h      29 Aug 2002 16:20:05 -0000      1.8
+++ pmac.h      3 Apr 2003 10:34:53 -0000       1.9
@@ -95,24 +95,6 @@
 
 
 /*
- * beep using pcm
- */
-struct snd_pmac_beep {
-       int running;    /* boolean */
-       int volume;     /* mixer volume: 0-100 */
-       int volume_play;        /* currently playing volume */
-       int hz;
-       int nsamples;
-       short *buf;             /* allocated wave buffer */
-       unsigned long addr;     /* physical address of buffer */
-       struct timer_list timer;        /* timer list for stopping beep */
-       void (*orig_mksound)(unsigned int, unsigned int);
-                               /* pointer to restore */
-       snd_kcontrol_t *control;        /* mixer element */
-};
-
-
-/*
  */
 
 enum snd_pmac_model {
@@ -125,6 +107,7 @@
        /* h/w info */
        struct device_node *node;
        unsigned int revision;
+       unsigned int manufacturer;
        unsigned int subframe;
        unsigned int device_id;
        enum snd_pmac_model model;
@@ -222,5 +205,10 @@
 int snd_pmac_boolean_mono_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo);
 
 int snd_pmac_add_automute(pmac_t *chip);
+
+#ifndef PMAC_SUPPORT_PCM_BEEP
+#define snd_pmac_attach_beep(chip) 0
+#define snd_pmac_beep_stop(chip)  /**/
+#endif
 
 #endif /* __PMAC_H */

Index: powermac.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/ppc/powermac.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- powermac.c  9 Feb 2003 17:25:44 -0000       1.13
+++ powermac.c  3 Apr 2003 10:34:53 -0000       1.14
@@ -37,7 +37,9 @@
 static int index = SNDRV_DEFAULT_IDX1;         /* Index 0-MAX */
 static char *id = SNDRV_DEFAULT_STR1;          /* ID for this card */
 static int enable = 1;
+#ifdef PMAC_SUPPORT_PCM_BEEP
 static int enable_beep = 1;
+#endif
 
 MODULE_PARM(index, "i");
 MODULE_PARM_DESC(index, "Index value for " CHIP_NAME " soundchip.");
@@ -48,9 +50,11 @@
 MODULE_PARM(enable, "i");
 MODULE_PARM_DESC(enable, "Enable this soundchip.");
 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
+#ifdef PMAC_SUPPORT_PCM_BEEP
 MODULE_PARM(enable_beep, "i");
 MODULE_PARM_DESC(enable_beep, "Enable beep using PCM.");
 MODULE_PARM_SYNTAX(enable_beep, SNDRV_ENABLED "," SNDRV_BOOLEAN_TRUE_DESC);
+#endif
 
 
 /*
@@ -129,7 +133,7 @@
                goto __error;
 
        chip->initialized = 1;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#ifdef PMAC_SUPPORT_PCM_BEEP
        if (enable_beep)
                snd_pmac_attach_beep(chip);
 #endif
@@ -181,8 +185,10 @@
 {
        (void)(get_option(&str,&enable) == 2 &&
               get_option(&str,&index) == 2 &&
-              get_id(&str,&id) == 2 &&
-              get_option(&str,&enable_beep) == 2
+              get_id(&str,&id) == 2
+#ifdef PMAC_SUPPORT_PCM_BEEP
+              && get_option(&str,&enable_beep) == 2
+#endif
               );
        return 1;
 }



-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to