At Wed, 14 Apr 2010 12:21:29 +0800,
Wu Zhangjin wrote:
> > > $ mplayer -ao alsa file.mp3
> > >
> > > but without it, the ALSA output is broken.
> > Hm, which driver/device are you using? Also, how is it broken?
> I'm using the cs5535 audio in my Yeeloong laptop with the config
> the above 'broken' means there is audio output with ALSA, but the output
> is not normal for it has lots of noises: sha sha sha...
> > There is already a low-level hack in sound/core/pcm_native.c for MIPS,
> > so I thought the kernel oops should have been avoided, at least.
> > Maybe still pgprot_noncached() is missing, though.
> You mean this part for MIPS:
> static inline struct page *
> snd_pcm_default_page_ops(struct snd_pcm_substream *substream, unsigned
> long ofs)
> void *vaddr = substream->runtime->dma_area + ofs;
> #if defined(CONFIG_MIPS) && defined(CONFIG_DMA_NONCOHERENT)
> if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV)
> return virt_to_page(CAC_ADDR(vaddr));
> Yes, it was already there from one of your patches to linux-2.6.33, but
> the pgprot_noncached() was missing as you mentioned above.
> And I have found you have added the ARM specific dma_mmap_coherent() to
> snd_pcm_default_mmap() to mmap the DMA buffer on RAM:
> * mmap the DMA buffer on RAM
> static int snd_pcm_default_mmap(struct snd_pcm_substream *substream,
> struct vm_area_struct *area)
> area->vm_flags |= VM_RESERVED;
> #ifdef ARCH_HAS_DMA_MMAP_COHERENT
> if (!substream->ops->page &&
> substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV)
> return dma_mmap_coherent(substream->dma_buffer.dev.dev,
> area->vm_end - area->vm_start);
> #endif /* ARCH_HAS_DMA_MMAP_COHERENT */
> /* mmap with fault handler */
> area->vm_ops = &snd_pcm_vm_ops_data_fault;
> return 0;
> Before, we have added the low-level handling with pgprot_noncached() in
> snd_pcm_mmap() to fix it, but now, can we add MIPS specific
> dma_mmap_coherent() as ARM did?
That would be a certainly fix, yes. I have no objection, of course ;)
A quicky, less-intrusive one would be the patch below.
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index c22ebb0..fd6703e 100644
@@ -3188,6 +3188,8 @@ static int snd_pcm_default_mmap(struct snd_pcm_substream
area->vm_end - area->vm_start);
+#elif defined(CONFIG_MIPS) && defined(CONFIG_DMA_NONCOHERENT)
+ area->vm_page_prot = pgprot_noncached(area->vm_page_prot);
#endif /* ARCH_HAS_DMA_MMAP_COHERENT */
/* mmap with fault handler */
area->vm_ops = &snd_pcm_vm_ops_data_fault;