saa_writel(SAA7134_RS_BA2(6),dev->oss.blksize); 
saa_writel(SAA7134_RS_BA2(6),dev->dmasound.blksize); 
static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream){	snd_pcm_runtime_t *runtime = substream->runtime;	int err, bswap, sign;	u32 fmt, control;	unsigned long flags;	snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);	struct saa7134_dev *dev;	snd_card_saa7134_pcm_t *saapcm = runtime->private_data;	unsigned int bps;	unsigned long size;	unsigned count;	size = snd_pcm_lib_buffer_bytes(substream);	count = snd_pcm_lib_period_bytes(substream);	saapcm->saadev->oss.substream = substream;	bps = runtime->rate * runtime->channels;	bps *= snd_pcm_format_width(runtime->format);	bps /= 8;	if (bps <= 0)		return -EINVAL;	saapcm->pcm_bps = bps;	saapcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);	saapcm->pcm_count = snd_pcm_lib_period_bytes(substream);	dev=saa7134->saadev;	dsp_buffer_conf(dev,saapcm->pcm_count,(saapcm->pcm_size/saapcm->pcm_count));	err = dsp_buffer_init(dev);	if (0 != err)		goto fail2;	/* prepare buffer */	if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->oss.dma)))		return err;	if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->oss.pt)))		goto fail1;	if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->oss.pt,					      dev->oss.dma.sglist,					      dev->oss.dma.sglen,					      0)))		goto fail2;	switch (runtime->format) {	  case SNDRV_PCM_FORMAT_U8:	  case SNDRV_PCM_FORMAT_S8:		fmt = 0x00;		break;	  case SNDRV_PCM_FORMAT_U16_LE:	  case SNDRV_PCM_FORMAT_U16_BE:	  case SNDRV_PCM_FORMAT_S16_LE:	  case SNDRV_PCM_FORMAT_S16_BE:		fmt = 0x01;		break;	  default:		err = -EINVAL;		return 1;	}	switch (runtime->format) {	  case SNDRV_PCM_FORMAT_S8:	  case SNDRV_PCM_FORMAT_S16_LE:	  case SNDRV_PCM_FORMAT_S16_BE:		sign = 1;		break;	  default:		sign = 0;		break;	}	switch (runtime->format) {	  case SNDRV_PCM_FORMAT_U16_BE:	  case SNDRV_PCM_FORMAT_S16_BE:		bswap = 1; break;	  default:		bswap = 0; break;	}	switch (dev->pci->device) {	  case PCI_DEVICE_ID_PHILIPS_SAA7134:		if (1 == runtime->channels)			fmt |= (1 << 3);		if (2 == runtime->channels)			fmt |= (3 << 3);		if (sign)			fmt |= 0x04;		fmt |= (MIXER_ADDR_TVTUNER == dev->oss.input) ? 0xc0 : 0x80;		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:		if (1 == runtime->channels)			fmt |= (1 << 4);		if (2 == runtime->channels)			fmt |= (2 << 4);		if (!sign)			fmt |= 0x04;		saa_writel(SAA7133_NUM_SAMPLES, dev->oss.blksize -1);		saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24));		//saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210);		break;	}	dprintk("rec_start: afmt=%d ch=%d  =>  fmt=0x%x swap=%c\n",		runtime->format, runtime->channels, fmt,		bswap ? 'b' : '-');	/* dma: setup channel 6 (= AUDIO) */	control = SAA7134_RS_CONTROL_BURST_16 |		SAA7134_RS_CONTROL_ME |		(dev->oss.pt.dma >> 12);	if (bswap)		control |= SAA7134_RS_CONTROL_BSWAP;	/* I should be able to use runtime->dma_addr in the control	   byte, but it doesn't work. So I allocate the DMA using the	   V4L functions, and force ALSA to use that as the DMA area */	runtime->dma_area = dev->oss.dma.vmalloc;	saa_writel(SAA7134_RS_BA1(6),0);	saa_writel(SAA7134_RS_BA2(6),dev->oss.blksize);	saa_writel(SAA7134_RS_PITCH(6),0);	saa_writel(SAA7134_RS_CONTROL(6),control);	dev->oss.rate = runtime->rate;	/* start dma */	spin_lock_irqsave(&dev->slock,flags);	saa7134_dma_start(dev);	spin_unlock_irqrestore(&dev->slock,flags);	return 0; fail2:	saa7134_pgtable_free(dev->pci,&dev->oss.pt); fail1:	videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma);	return err;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/b54134be53be720da423692665ec215eb14a678b/saa7134-alsa.c/clean/drivers/media/video/saa7134/saa7134-alsa.c