static void
ad1816_intr(void *arg)
{
    struct ad1816_info *ad1816 = (struct ad1816_info *)arg;
    unsigned char   c, served = 0;

    ad1816_lock(ad1816);
    /* get interrupt status */
    c = io_rd(ad1816, AD1816_INT);

    /* check for stray interrupts */
    if (c & ~(AD1816_INTRCI | AD1816_INTRPI)) {
        printf("pcm: stray int (%x)\n", c);
        c &= AD1816_INTRCI | AD1816_INTRPI;
    }
    /* check for capture interrupt */
    if (sndbuf_runsz(ad1816->rch.buffer) && (c & AD1816_INTRCI)) {
        ad1816_unlock(ad1816);
        chn_intr(ad1816->rch.channel);
        ad1816_lock(ad1816);
        served |= AD1816_INTRCI;		/* cp served */
    }
    /* check for playback interrupt */
    if (sndbuf_runsz(ad1816->pch.buffer) && (c & AD1816_INTRPI)) {
        ad1816_unlock(ad1816);
        chn_intr(ad1816->pch.channel);
        ad1816_lock(ad1816);
        served |= AD1816_INTRPI;		/* pb served */
    }
    if (served == 0) {
        /* this probably means this is not a (working) ad1816 chip, */
        /* or an error in dma handling                              */
        printf("pcm: int without reason (%x)\n", c);
        c = 0;
    } else c &= ~served;
    io_wr(ad1816, AD1816_INT, c);
    c = io_rd(ad1816, AD1816_INT);
    if (c != 0) printf("pcm: int clear failed (%x)\n", c);
    ad1816_unlock(ad1816);
}
Beispiel #2
0
int
sndbuf_dmaptr(struct snd_dbuf *b)
{
	int i;

	KASSERT(b, ("sndbuf_dmaptr called with b == NULL"));
	KASSERT(sndbuf_getflags(b) & SNDBUF_F_DMA, ("sndbuf_dmaptr called on non-ISA buffer"));

	if (!sndbuf_runsz(b))
		return 0;
	i = isa_dmastatus(b->dmachan);
	KASSERT(i >= 0, ("isa_dmastatus returned %d", i));
	return b->bufsize - i;
}