Hi, This is the 3rd part of my patches. This actually is not Medion specific, it fixes some bugs in the SAA7134 oss streaming code which should help which the sound problems reported in this list. - memory allocation cleanup - fixed off by 1 error in the DMA setup - corrected the SAA7134 audio clock routing for sound streaming. Have Fun Hartmut Hackmann >-------------------- snip -----------------------< diff -uprNw video4linux.orig/saa7134-oss.c video4linux/saa7134-oss.c --- video4linux.orig/saa7134-oss.c 2004-12-10 14:07:00.000000000 +0100 +++ video4linux/saa7134-oss.c 2005-04-22 00:08:47.000000000 +0200 @@ -49,7 +49,6 @@ MODULE_PARM_DESC(oss_rate,"sample rate ( static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks) { - blksize &= ~0xff; if (blksize < 0x100) blksize = 0x100; if (blksize > 0x10000) @@ -57,8 +56,6 @@ static int dsp_buffer_conf(struct saa713 if (blocks < 2) blocks = 2; - while ((blksize * blocks) & ~PAGE_MASK) - blocks++; if ((blksize * blocks) > 1024*1024) blocks = 1024*1024 / blksize; @@ -79,7 +76,7 @@ static int dsp_buffer_init(struct saa713 BUG(); videobuf_dma_init(&dev->oss.dma); err = videobuf_dma_init_kernel(&dev->oss.dma, PCI_DMA_FROMDEVICE, - dev->oss.bufsize >> PAGE_SHIFT); + (dev->oss.bufsize + PAGE_SIZE) >> PAGE_SHIFT); if (0 != err) return err; return 0; @@ -163,10 +160,11 @@ static int dsp_rec_start(struct saa7134_ fmt |= 0x04; fmt |= (TV == dev->oss.input) ? 0xc0 : 0x80; - saa_writeb(SAA7134_NUM_SAMPLES0, (dev->oss.blksize & 0x0000ff)); - saa_writeb(SAA7134_NUM_SAMPLES1, (dev->oss.blksize & 0x00ff00) >> 8); - saa_writeb(SAA7134_NUM_SAMPLES2, (dev->oss.blksize & 0xff0000) >> 16); + saa_writeb(SAA7134_NUM_SAMPLES0, ((dev->oss.blksize - 1) & 0x0000ff)); + saa_writeb(SAA7134_NUM_SAMPLES1, ((dev->oss.blksize - 1) & 0x00ff00) >> 8); + saa_writeb(SAA7134_NUM_SAMPLES2, ((dev->oss.blksize - 1) & 0xff0000) >> 16); saa_writeb(SAA7134_AUDIO_FORMAT_CTRL, fmt); + break; case PCI_DEVICE_ID_PHILIPS_SAA7133: case PCI_DEVICE_ID_PHILIPS_SAA7135: @@ -550,6 +548,7 @@ mixer_recsrc_7134(struct saa7134_dev *de saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, analog_io); saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0x80); saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, rate); + break; } return 0; @@ -817,7 +816,7 @@ void saa7134_irq_oss_done(struct saa7134 reg = SAA7134_RS_BA1(6); } else { /* even */ - if (0 == (dev->oss.dma_blk & 0x00)) + if (1 == (dev->oss.dma_blk & 0x01)) reg = SAA7134_RS_BA2(6); } if (0 == reg) { @@ -836,9 +835,9 @@ void saa7134_irq_oss_done(struct saa7134 next_blk = (dev->oss.dma_blk + 2) % dev->oss.blocks; saa_writel(reg,next_blk * dev->oss.blksize); if (oss_debug > 2) - dprintk("irq: ok, %s, next_blk=%d, addr=%x\n", + dprintk("irq: ok, %s, next_blk=%d, addr=%x, base=%x\n", (status & 0x10000000) ? "even" : "odd ", next_blk, - next_blk * dev->oss.blksize); + next_blk * dev->oss.blksize, reg << 2); /* update status & wake waiting readers */ dev->oss.dma_blk = (dev->oss.dma_blk + 1) % dev->oss.blocks; diff -uprNw video4linux.orig/saa7134-tvaudio.c video4linux/saa7134-tvaudio.c --- video4linux.orig/saa7134-tvaudio.c 2005-01-07 14:27:01.000000000 +0100 +++ video4linux/saa7134-tvaudio.c 2005-04-21 22:45:03.000000000 +0200 @@ -181,7 +181,8 @@ static void tvaudio_init(struct saa7134_ saa_writeb(SAA7134_AUDIO_CLOCK0, clock & 0xff); saa_writeb(SAA7134_AUDIO_CLOCK1, (clock >> 8) & 0xff); saa_writeb(SAA7134_AUDIO_CLOCK2, (clock >> 16) & 0xff); - saa_writeb(SAA7134_AUDIO_PLL_CTRL, 0x01); + // frame locked audio was reported not to be reliable + saa_writeb(SAA7134_AUDIO_PLL_CTRL, 0x02); saa_writeb(SAA7134_NICAM_ERROR_LOW, 0x14); saa_writeb(SAA7134_NICAM_ERROR_HIGH, 0x50); @@ -250,6 +251,11 @@ static void mute_input_7134(struct saa71 saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, ausel); saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, ics); saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, ocs); + // for oss, we need to change the clock configuration + if (in->amux == TV) + saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, 0x00); + else + saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, 0x01); /* switch gpio-connected external audio mux */ if (0 == card(dev).gpiomask)