Lines Matching refs:blk

77 static int synth_alloc_pages(struct snd_emu10k1 *hw, struct snd_emu10k1_memblk *blk);
78 static int synth_free_pages(struct snd_emu10k1 *hw, struct snd_emu10k1_memblk *blk);
84 static void emu10k1_memblk_init(struct snd_emu10k1_memblk *blk) in emu10k1_memblk_init() argument
86 blk->mapped_page = -1; in emu10k1_memblk_init()
87 INIT_LIST_HEAD(&blk->mapped_link); in emu10k1_memblk_init()
88 INIT_LIST_HEAD(&blk->mapped_order_link); in emu10k1_memblk_init()
89 blk->map_locked = 0; in emu10k1_memblk_init()
91 blk->first_page = get_aligned_page(blk->mem.offset); in emu10k1_memblk_init()
92 blk->last_page = get_aligned_page(blk->mem.offset + blk->mem.size - 1); in emu10k1_memblk_init()
93 blk->pages = blk->last_page - blk->first_page + 1; in emu10k1_memblk_init()
112 struct snd_emu10k1_memblk *blk = get_emu10k1_memblk(pos, mapped_link); in search_empty_map_area() local
113 if (blk->mapped_page < 0) in search_empty_map_area()
115 size = blk->mapped_page - page; in search_empty_map_area()
126 page = blk->mapped_page + blk->pages; in search_empty_map_area()
142 static int map_memblk(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) in map_memblk() argument
147 page = search_empty_map_area(emu, blk->pages, &next); in map_memblk()
151 list_add_tail(&blk->mapped_link, next); in map_memblk()
153 list_add_tail(&blk->mapped_order_link, &emu->mapped_order_link_head); in map_memblk()
154 blk->mapped_page = page; in map_memblk()
156 for (pg = blk->first_page; pg <= blk->last_page; pg++) { in map_memblk()
169 static int unmap_memblk(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) in unmap_memblk() argument
176 if ((p = blk->mapped_link.prev) != &emu->mapped_link_head) { in unmap_memblk()
181 if ((p = blk->mapped_link.next) != &emu->mapped_link_head) { in unmap_memblk()
188 list_del(&blk->mapped_link); in unmap_memblk()
189 list_del(&blk->mapped_order_link); in unmap_memblk()
191 mpage = blk->mapped_page; in unmap_memblk()
192 for (pg = blk->first_page; pg <= blk->last_page; pg++) { in unmap_memblk()
196 blk->mapped_page = -1; in unmap_memblk()
209 struct snd_emu10k1_memblk *blk; in search_empty() local
215 blk = get_emu10k1_memblk(p, mem.list); in search_empty()
216 if (page + psize <= blk->first_page) in search_empty()
218 page = blk->last_page + 1; in search_empty()
225blk = (struct snd_emu10k1_memblk *)__snd_util_memblk_new(emu->memhdr, psize << PAGE_SHIFT, p->prev… in search_empty()
226 if (blk == NULL) in search_empty()
228 blk->mem.offset = aligned_page_offset(page); /* set aligned offset */ in search_empty()
229 emu10k1_memblk_init(blk); in search_empty()
230 return blk; in search_empty()
258 int snd_emu10k1_memblk_map(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) in snd_emu10k1_memblk_map() argument
267 if (blk->mapped_page >= 0) { in snd_emu10k1_memblk_map()
269 list_move_tail(&blk->mapped_order_link, in snd_emu10k1_memblk_map()
274 if ((err = map_memblk(emu, blk)) < 0) { in snd_emu10k1_memblk_map()
284 if (size >= blk->pages) { in snd_emu10k1_memblk_map()
286 err = map_memblk(emu, blk); in snd_emu10k1_memblk_map()
305 struct snd_emu10k1_memblk *blk; in snd_emu10k1_alloc_pages() local
320 blk = search_empty(emu, runtime->dma_bytes + idx); in snd_emu10k1_alloc_pages()
321 if (blk == NULL) { in snd_emu10k1_alloc_pages()
329 for (page = blk->first_page; page <= blk->last_page; page++, idx++) { in snd_emu10k1_alloc_pages()
347 blk->map_locked = 1; /* do not unmap this block! */ in snd_emu10k1_alloc_pages()
348 err = snd_emu10k1_memblk_map(emu, blk); in snd_emu10k1_alloc_pages()
350 __snd_util_mem_free(hdr, (struct snd_util_memblk *)blk); in snd_emu10k1_alloc_pages()
355 return (struct snd_util_memblk *)blk; in snd_emu10k1_alloc_pages()
362 int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk) in snd_emu10k1_free_pages() argument
364 if (snd_BUG_ON(!emu || !blk)) in snd_emu10k1_free_pages()
366 return snd_emu10k1_synth_free(emu, blk); in snd_emu10k1_free_pages()
381 struct snd_emu10k1_memblk *blk; in snd_emu10k1_synth_alloc() local
385 blk = (struct snd_emu10k1_memblk *)__snd_util_mem_alloc(hdr, size); in snd_emu10k1_synth_alloc()
386 if (blk == NULL) { in snd_emu10k1_synth_alloc()
390 if (synth_alloc_pages(hw, blk)) { in snd_emu10k1_synth_alloc()
391 __snd_util_mem_free(hdr, (struct snd_util_memblk *)blk); in snd_emu10k1_synth_alloc()
395 snd_emu10k1_memblk_map(hw, blk); in snd_emu10k1_synth_alloc()
397 return (struct snd_util_memblk *)blk; in snd_emu10k1_synth_alloc()
409 struct snd_emu10k1_memblk *blk = (struct snd_emu10k1_memblk *)memblk; in snd_emu10k1_synth_free() local
414 if (blk->mapped_page >= 0) in snd_emu10k1_synth_free()
415 unmap_memblk(emu, blk); in snd_emu10k1_synth_free()
417 synth_free_pages(emu, blk); in snd_emu10k1_synth_free()
427 struct snd_emu10k1_memblk *blk, in get_single_page_range() argument
433 first_page = blk->first_page; in get_single_page_range()
434 if ((p = blk->mem.list.prev) != &hdr->block) { in get_single_page_range()
439 last_page = blk->last_page; in get_single_page_range()
440 if ((p = blk->mem.list.next) != &hdr->block) { in get_single_page_range()
465 static int synth_alloc_pages(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) in synth_alloc_pages() argument
469 emu10k1_memblk_init(blk); in synth_alloc_pages()
470 get_single_page_range(emu->memhdr, blk, &first_page, &last_page); in synth_alloc_pages()
497 static int synth_free_pages(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) in synth_free_pages() argument
501 get_single_page_range(emu->memhdr, blk, &first_page, &last_page); in synth_free_pages()
525 int snd_emu10k1_synth_bzero(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, in snd_emu10k1_synth_bzero() argument
530 struct snd_emu10k1_memblk *p = (struct snd_emu10k1_memblk *)blk; in snd_emu10k1_synth_bzero()
532 offset += blk->offset & (PAGE_SIZE - 1); in snd_emu10k1_synth_bzero()
555 int snd_emu10k1_synth_copy_from_user(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, in snd_emu10k1_synth_copy_from_user() argument
560 struct snd_emu10k1_memblk *p = (struct snd_emu10k1_memblk *)blk; in snd_emu10k1_synth_copy_from_user()
562 offset += blk->offset & (PAGE_SIZE - 1); in snd_emu10k1_synth_copy_from_user()