Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 23 Jan 2003 11:41:45 -0000 @@ -232,6 +232,7 @@ struct snd_via_sg_table *idx_table; /* for recovery from the unexpected pointer */ unsigned int lastpos; + unsigned int lastidx; unsigned int bufsize; unsigned int bufsize2; }; @@ -485,6 +486,7 @@ outb(0x00, port + VIA_REG_OFFSET_TYPE); /* for via686 */ outl(0, port + VIA_REG_OFFSET_CURR_PTR); viadev->lastpos = 0; + viadev->lastidx = 0; } @@ -512,10 +514,13 @@ /* check status for each stream */ for (i = 0; i < chip->num_devs; i++) { viadev_t *viadev = &chip->devs[i]; - if (inb(chip->port + viadev->reg_offset) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { - outb(VIA_REG_STAT_FLAG | VIA_REG_STAT_EOL, VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset); + unsigned long port = chip->port + viadev->reg_offset; + unsigned char status = inb(port) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG); + if (status) { + outb(status, port); /* ack */ if (viadev->substream && viadev->running) { spin_unlock(&chip->reg_lock); + printk("via: period_elapsed [%d]\n", i); snd_pcm_period_elapsed(viadev->substream); spin_lock(&chip->reg_lock); } @@ -582,24 +587,25 @@ size = viadev->idx_table[idx].size; res = viadev->idx_table[idx].offset + size - count; - /* check the validity of the calculated position */ - if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) { #ifdef POINTER_DEBUG - printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); + printk("via: idx = %i/%i, lastpos = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); #endif + /* check the validity of the calculated position */ + if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) { /* count register returns full size when end of buffer is reached */ if (size != count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); - res = viadev->lastpos; + printk("invalid via82xx_cur_ptr, using last valid pointer\n"); + return viadev->lastpos; } else { res = viadev->idx_table[idx].offset + size; if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); - res = viadev->lastpos; + printk("invalid via82xx_cur_ptr (2), using last valid pointer\n"); + return viadev->lastpos; } } } viadev->lastpos = res; /* remember the last positiion */ + viadev->lastidx = idx; if (res >= viadev->bufsize) res -= viadev->bufsize; return res; @@ -648,7 +654,7 @@ return 0; spin_lock(&chip->reg_lock); count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); - idx = count >> 24; + idx = (count >> 24) & viadev->tbl_entries; count &= 0xffffff; res = calc_linear_pos(viadev, idx, count); spin_unlock(&chip->reg_lock);