Update of /cvsroot/alsa/alsa-kernel/pci/ymfpci
In directory sc8-pr-cvs1:/tmp/cvs-serv27996/pci/ymfpci

Modified Files:
        ymfpci.c ymfpci_main.c 
Log Message:
Clemens Ladisch <[EMAIL PROTECTED]>:

- added the support for the timer on ymfpci chips.



Index: ymfpci.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ymfpci/ymfpci.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- ymfpci.c    12 Aug 2003 14:10:16 -0000      1.26
+++ ymfpci.c    7 Oct 2003 10:03:24 -0000       1.27
@@ -206,6 +206,10 @@
                snd_card_free(card);
                return err;
        }
+       if ((err = snd_ymfpci_timer(chip, 0)) < 0) {
+               snd_card_free(card);
+               return err;
+       }
        if (chip->mpu_res) {
                if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_YMFPCI,
                                               mpu_port[dev], 1,

Index: ymfpci_main.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ymfpci/ymfpci_main.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- ymfpci_main.c       14 Aug 2003 11:05:38 -0000      1.41
+++ ymfpci_main.c       7 Oct 2003 10:03:24 -0000       1.42
@@ -779,7 +779,8 @@
 
        status = snd_ymfpci_readw(chip, YDSXGR_INTFLAG);
        if (status & 1) {
-               /* timer handler */
+               if (chip->timer)
+                       snd_timer_interrupt(chip->timer, chip->timer->sticks);
        }
        snd_ymfpci_writew(chip, YDSXGR_INTFLAG, status);
 
@@ -1699,6 +1700,77 @@
        }
 
        return 0;
+}
+
+
+/*
+ * timer
+ */
+
+static int snd_ymfpci_timer_start(snd_timer_t *timer)
+{
+       ymfpci_t *chip;
+       unsigned long flags;
+       unsigned int count;
+
+       chip = snd_timer_chip(timer);
+       count = timer->sticks - 1;
+       if (count == 0) /* minimum time is 20.8 us */
+               count = 1;
+       spin_lock_irqsave(&chip->reg_lock, flags);
+       snd_ymfpci_writew(chip, YDSXGR_TIMERCOUNT, count);
+       snd_ymfpci_writeb(chip, YDSXGR_TIMERCTRL, 0x03);
+       spin_unlock_irqrestore(&chip->reg_lock, flags);
+       return 0;
+}
+
+static int snd_ymfpci_timer_stop(snd_timer_t *timer)
+{
+       ymfpci_t *chip;
+       unsigned long flags;
+
+       chip = snd_timer_chip(timer);
+       spin_lock_irqsave(&chip->reg_lock, flags);
+       snd_ymfpci_writeb(chip, YDSXGR_TIMERCTRL, 0x00);
+       spin_unlock_irqrestore(&chip->reg_lock, flags);
+       return 0;
+}
+
+static int snd_ymfpci_timer_precise_resolution(snd_timer_t *timer,
+                                              unsigned long *num, unsigned long *den)
+{
+       *num = 1;
+       *den = 96000;
+       return 0;
+}
+
+static struct _snd_timer_hardware snd_ymfpci_timer_hw = {
+       .flags = SNDRV_TIMER_HW_AUTO,
+       .resolution = 10417, /* 1/2fs = 10.41666...us */
+       .ticks = 65536,
+       .start = snd_ymfpci_timer_start,
+       .stop = snd_ymfpci_timer_stop,
+       .precise_resolution = snd_ymfpci_timer_precise_resolution,
+};
+
+int __devinit snd_ymfpci_timer(ymfpci_t *chip, int device)
+{
+       snd_timer_t *timer = NULL;
+       snd_timer_id_t tid;
+       int err;
+
+       tid.dev_class = SNDRV_TIMER_CLASS_CARD;
+       tid.dev_sclass = SNDRV_TIMER_SCLASS_NONE;
+       tid.card = chip->card->number;
+       tid.device = device;
+       tid.subdevice = 0;
+       if ((err = snd_timer_new(chip->card, "YMFPCI", &tid, &timer)) >= 0) {
+               strcpy(timer->name, "YMFPCI timer");
+               timer->private_data = chip;
+               timer->hw = snd_ymfpci_timer_hw;
+       }
+       chip->timer = timer;
+       return err;
 }
 
 



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to