diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-11-26 06:43:39 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-11-26 09:07:21 -0500 |
commit | 9eb4a06788a598573c751af1a7e46639afc89513 (patch) | |
tree | d82ea448a63dc6972995a85d4037f8318c76f869 /sound/core | |
parent | 657b1989dacf58e83e7a76bca6d4a91a9f294cf6 (diff) |
ALSA: pcm - define snd_pcm_default_page_ops()
Add a helper (inline) function as the default page ops. Any hacks wrt
the page address conversion will be applied in this function.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/pcm_native.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index f067c5b906e4..c906be26c312 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -3062,6 +3062,13 @@ static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file | |||
3062 | } | 3062 | } |
3063 | #endif /* coherent mmap */ | 3063 | #endif /* coherent mmap */ |
3064 | 3064 | ||
3065 | static inline struct page * | ||
3066 | snd_pcm_default_page_ops(struct snd_pcm_substream *substream, unsigned long ofs) | ||
3067 | { | ||
3068 | void *vaddr = substream->runtime->dma_area + ofs; | ||
3069 | return virt_to_page(vaddr); | ||
3070 | } | ||
3071 | |||
3065 | /* | 3072 | /* |
3066 | * fault callback for mmapping a RAM page | 3073 | * fault callback for mmapping a RAM page |
3067 | */ | 3074 | */ |
@@ -3072,7 +3079,6 @@ static int snd_pcm_mmap_data_fault(struct vm_area_struct *area, | |||
3072 | struct snd_pcm_runtime *runtime; | 3079 | struct snd_pcm_runtime *runtime; |
3073 | unsigned long offset; | 3080 | unsigned long offset; |
3074 | struct page * page; | 3081 | struct page * page; |
3075 | void *vaddr; | ||
3076 | size_t dma_bytes; | 3082 | size_t dma_bytes; |
3077 | 3083 | ||
3078 | if (substream == NULL) | 3084 | if (substream == NULL) |
@@ -3082,14 +3088,12 @@ static int snd_pcm_mmap_data_fault(struct vm_area_struct *area, | |||
3082 | dma_bytes = PAGE_ALIGN(runtime->dma_bytes); | 3088 | dma_bytes = PAGE_ALIGN(runtime->dma_bytes); |
3083 | if (offset > dma_bytes - PAGE_SIZE) | 3089 | if (offset > dma_bytes - PAGE_SIZE) |
3084 | return VM_FAULT_SIGBUS; | 3090 | return VM_FAULT_SIGBUS; |
3085 | if (substream->ops->page) { | 3091 | if (substream->ops->page) |
3086 | page = substream->ops->page(substream, offset); | 3092 | page = substream->ops->page(substream, offset); |
3087 | if (!page) | 3093 | else |
3088 | return VM_FAULT_SIGBUS; | 3094 | page = snd_pcm_default_page_ops(substream, offset); |
3089 | } else { | 3095 | if (!page) |
3090 | vaddr = runtime->dma_area + offset; | 3096 | return VM_FAULT_SIGBUS; |
3091 | page = virt_to_page(vaddr); | ||
3092 | } | ||
3093 | get_page(page); | 3097 | get_page(page); |
3094 | vmf->page = page; | 3098 | vmf->page = page; |
3095 | return 0; | 3099 | return 0; |