diff options
Diffstat (limited to 'sound/pci/trident/trident_memory.c')
-rw-r--r-- | sound/pci/trident/trident_memory.c | 92 |
1 files changed, 51 insertions, 41 deletions
diff --git a/sound/pci/trident/trident_memory.c b/sound/pci/trident/trident_memory.c index f3e6c546af74..cf09ea99755c 100644 --- a/sound/pci/trident/trident_memory.c +++ b/sound/pci/trident/trident_memory.c | |||
@@ -68,13 +68,14 @@ | |||
68 | #define page_to_addr(trident,page) __tlb_to_addr(trident, (page) << 1) | 68 | #define page_to_addr(trident,page) __tlb_to_addr(trident, (page) << 1) |
69 | 69 | ||
70 | /* fill TLB entries -- we need to fill two entries */ | 70 | /* fill TLB entries -- we need to fill two entries */ |
71 | static inline void set_tlb_bus(trident_t *trident, int page, unsigned long ptr, dma_addr_t addr) | 71 | static inline void set_tlb_bus(struct snd_trident *trident, int page, |
72 | unsigned long ptr, dma_addr_t addr) | ||
72 | { | 73 | { |
73 | page <<= 1; | 74 | page <<= 1; |
74 | __set_tlb_bus(trident, page, ptr, addr); | 75 | __set_tlb_bus(trident, page, ptr, addr); |
75 | __set_tlb_bus(trident, page+1, ptr + SNDRV_TRIDENT_PAGE_SIZE, addr + SNDRV_TRIDENT_PAGE_SIZE); | 76 | __set_tlb_bus(trident, page+1, ptr + SNDRV_TRIDENT_PAGE_SIZE, addr + SNDRV_TRIDENT_PAGE_SIZE); |
76 | } | 77 | } |
77 | static inline void set_silent_tlb(trident_t *trident, int page) | 78 | static inline void set_silent_tlb(struct snd_trident *trident, int page) |
78 | { | 79 | { |
79 | page <<= 1; | 80 | page <<= 1; |
80 | __set_tlb_bus(trident, page, (unsigned long)trident->tlb.silent_page.area, trident->tlb.silent_page.addr); | 81 | __set_tlb_bus(trident, page, (unsigned long)trident->tlb.silent_page.area, trident->tlb.silent_page.addr); |
@@ -97,7 +98,8 @@ static inline void set_silent_tlb(trident_t *trident, int page) | |||
97 | #define page_to_addr(trident,page) __tlb_to_addr(trident, (page) * UNIT_PAGES) | 98 | #define page_to_addr(trident,page) __tlb_to_addr(trident, (page) * UNIT_PAGES) |
98 | 99 | ||
99 | /* fill TLB entries -- UNIT_PAGES entries must be filled */ | 100 | /* fill TLB entries -- UNIT_PAGES entries must be filled */ |
100 | static inline void set_tlb_bus(trident_t *trident, int page, unsigned long ptr, dma_addr_t addr) | 101 | static inline void set_tlb_bus(struct snd_trident *trident, int page, |
102 | unsigned long ptr, dma_addr_t addr) | ||
101 | { | 103 | { |
102 | int i; | 104 | int i; |
103 | page *= UNIT_PAGES; | 105 | page *= UNIT_PAGES; |
@@ -107,7 +109,7 @@ static inline void set_tlb_bus(trident_t *trident, int page, unsigned long ptr, | |||
107 | addr += SNDRV_TRIDENT_PAGE_SIZE; | 109 | addr += SNDRV_TRIDENT_PAGE_SIZE; |
108 | } | 110 | } |
109 | } | 111 | } |
110 | static inline void set_silent_tlb(trident_t *trident, int page) | 112 | static inline void set_silent_tlb(struct snd_trident *trident, int page) |
111 | { | 113 | { |
112 | int i; | 114 | int i; |
113 | page *= UNIT_PAGES; | 115 | page *= UNIT_PAGES; |
@@ -118,7 +120,7 @@ static inline void set_silent_tlb(trident_t *trident, int page) | |||
118 | #endif /* PAGE_SIZE */ | 120 | #endif /* PAGE_SIZE */ |
119 | 121 | ||
120 | /* calculate buffer pointer from offset address */ | 122 | /* calculate buffer pointer from offset address */ |
121 | static inline void *offset_ptr(trident_t *trident, int offset) | 123 | static inline void *offset_ptr(struct snd_trident *trident, int offset) |
122 | { | 124 | { |
123 | char *ptr; | 125 | char *ptr; |
124 | ptr = page_to_ptr(trident, get_aligned_page(offset)); | 126 | ptr = page_to_ptr(trident, get_aligned_page(offset)); |
@@ -127,16 +129,16 @@ static inline void *offset_ptr(trident_t *trident, int offset) | |||
127 | } | 129 | } |
128 | 130 | ||
129 | /* first and last (aligned) pages of memory block */ | 131 | /* first and last (aligned) pages of memory block */ |
130 | #define firstpg(blk) (((snd_trident_memblk_arg_t*)snd_util_memblk_argptr(blk))->first_page) | 132 | #define firstpg(blk) (((struct snd_trident_memblk_arg *)snd_util_memblk_argptr(blk))->first_page) |
131 | #define lastpg(blk) (((snd_trident_memblk_arg_t*)snd_util_memblk_argptr(blk))->last_page) | 133 | #define lastpg(blk) (((struct snd_trident_memblk_arg *)snd_util_memblk_argptr(blk))->last_page) |
132 | 134 | ||
133 | /* | 135 | /* |
134 | * search empty pages which may contain given size | 136 | * search empty pages which may contain given size |
135 | */ | 137 | */ |
136 | static snd_util_memblk_t * | 138 | static struct snd_util_memblk * |
137 | search_empty(snd_util_memhdr_t *hdr, int size) | 139 | search_empty(struct snd_util_memhdr *hdr, int size) |
138 | { | 140 | { |
139 | snd_util_memblk_t *blk, *prev; | 141 | struct snd_util_memblk *blk, *prev; |
140 | int page, psize; | 142 | int page, psize; |
141 | struct list_head *p; | 143 | struct list_head *p; |
142 | 144 | ||
@@ -144,7 +146,7 @@ search_empty(snd_util_memhdr_t *hdr, int size) | |||
144 | prev = NULL; | 146 | prev = NULL; |
145 | page = 0; | 147 | page = 0; |
146 | list_for_each(p, &hdr->block) { | 148 | list_for_each(p, &hdr->block) { |
147 | blk = list_entry(p, snd_util_memblk_t, list); | 149 | blk = list_entry(p, struct snd_util_memblk, list); |
148 | if (page + psize <= firstpg(blk)) | 150 | if (page + psize <= firstpg(blk)) |
149 | goto __found_pages; | 151 | goto __found_pages; |
150 | page = lastpg(blk) + 1; | 152 | page = lastpg(blk) + 1; |
@@ -183,12 +185,13 @@ static int is_valid_page(unsigned long ptr) | |||
183 | /* | 185 | /* |
184 | * page allocation for DMA (Scatter-Gather version) | 186 | * page allocation for DMA (Scatter-Gather version) |
185 | */ | 187 | */ |
186 | static snd_util_memblk_t * | 188 | static struct snd_util_memblk * |
187 | snd_trident_alloc_sg_pages(trident_t *trident, snd_pcm_substream_t *substream) | 189 | snd_trident_alloc_sg_pages(struct snd_trident *trident, |
190 | struct snd_pcm_substream *substream) | ||
188 | { | 191 | { |
189 | snd_util_memhdr_t *hdr; | 192 | struct snd_util_memhdr *hdr; |
190 | snd_util_memblk_t *blk; | 193 | struct snd_util_memblk *blk; |
191 | snd_pcm_runtime_t *runtime = substream->runtime; | 194 | struct snd_pcm_runtime *runtime = substream->runtime; |
192 | int idx, page; | 195 | int idx, page; |
193 | struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); | 196 | struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); |
194 | 197 | ||
@@ -230,13 +233,14 @@ snd_trident_alloc_sg_pages(trident_t *trident, snd_pcm_substream_t *substream) | |||
230 | /* | 233 | /* |
231 | * page allocation for DMA (contiguous version) | 234 | * page allocation for DMA (contiguous version) |
232 | */ | 235 | */ |
233 | static snd_util_memblk_t * | 236 | static struct snd_util_memblk * |
234 | snd_trident_alloc_cont_pages(trident_t *trident, snd_pcm_substream_t *substream) | 237 | snd_trident_alloc_cont_pages(struct snd_trident *trident, |
238 | struct snd_pcm_substream *substream) | ||
235 | { | 239 | { |
236 | snd_util_memhdr_t *hdr; | 240 | struct snd_util_memhdr *hdr; |
237 | snd_util_memblk_t *blk; | 241 | struct snd_util_memblk *blk; |
238 | int page; | 242 | int page; |
239 | snd_pcm_runtime_t *runtime = substream->runtime; | 243 | struct snd_pcm_runtime *runtime = substream->runtime; |
240 | dma_addr_t addr; | 244 | dma_addr_t addr; |
241 | unsigned long ptr; | 245 | unsigned long ptr; |
242 | 246 | ||
@@ -270,8 +274,9 @@ snd_trident_alloc_cont_pages(trident_t *trident, snd_pcm_substream_t *substream) | |||
270 | /* | 274 | /* |
271 | * page allocation for DMA | 275 | * page allocation for DMA |
272 | */ | 276 | */ |
273 | snd_util_memblk_t * | 277 | struct snd_util_memblk * |
274 | snd_trident_alloc_pages(trident_t *trident, snd_pcm_substream_t *substream) | 278 | snd_trident_alloc_pages(struct snd_trident *trident, |
279 | struct snd_pcm_substream *substream) | ||
275 | { | 280 | { |
276 | snd_assert(trident != NULL, return NULL); | 281 | snd_assert(trident != NULL, return NULL); |
277 | snd_assert(substream != NULL, return NULL); | 282 | snd_assert(substream != NULL, return NULL); |
@@ -285,9 +290,10 @@ snd_trident_alloc_pages(trident_t *trident, snd_pcm_substream_t *substream) | |||
285 | /* | 290 | /* |
286 | * release DMA buffer from page table | 291 | * release DMA buffer from page table |
287 | */ | 292 | */ |
288 | int snd_trident_free_pages(trident_t *trident, snd_util_memblk_t *blk) | 293 | int snd_trident_free_pages(struct snd_trident *trident, |
294 | struct snd_util_memblk *blk) | ||
289 | { | 295 | { |
290 | snd_util_memhdr_t *hdr; | 296 | struct snd_util_memhdr *hdr; |
291 | int page; | 297 | int page; |
292 | 298 | ||
293 | snd_assert(trident != NULL, return -EINVAL); | 299 | snd_assert(trident != NULL, return -EINVAL); |
@@ -314,17 +320,17 @@ int snd_trident_free_pages(trident_t *trident, snd_util_memblk_t *blk) | |||
314 | 320 | ||
315 | /* | 321 | /* |
316 | */ | 322 | */ |
317 | static int synth_alloc_pages(trident_t *hw, snd_util_memblk_t *blk); | 323 | static int synth_alloc_pages(struct snd_trident *hw, struct snd_util_memblk *blk); |
318 | static int synth_free_pages(trident_t *hw, snd_util_memblk_t *blk); | 324 | static int synth_free_pages(struct snd_trident *hw, struct snd_util_memblk *blk); |
319 | 325 | ||
320 | /* | 326 | /* |
321 | * allocate a synth sample area | 327 | * allocate a synth sample area |
322 | */ | 328 | */ |
323 | snd_util_memblk_t * | 329 | struct snd_util_memblk * |
324 | snd_trident_synth_alloc(trident_t *hw, unsigned int size) | 330 | snd_trident_synth_alloc(struct snd_trident *hw, unsigned int size) |
325 | { | 331 | { |
326 | snd_util_memblk_t *blk; | 332 | struct snd_util_memblk *blk; |
327 | snd_util_memhdr_t *hdr = hw->tlb.memhdr; | 333 | struct snd_util_memhdr *hdr = hw->tlb.memhdr; |
328 | 334 | ||
329 | down(&hdr->block_mutex); | 335 | down(&hdr->block_mutex); |
330 | blk = __snd_util_mem_alloc(hdr, size); | 336 | blk = __snd_util_mem_alloc(hdr, size); |
@@ -346,9 +352,9 @@ snd_trident_synth_alloc(trident_t *hw, unsigned int size) | |||
346 | * free a synth sample area | 352 | * free a synth sample area |
347 | */ | 353 | */ |
348 | int | 354 | int |
349 | snd_trident_synth_free(trident_t *hw, snd_util_memblk_t *blk) | 355 | snd_trident_synth_free(struct snd_trident *hw, struct snd_util_memblk *blk) |
350 | { | 356 | { |
351 | snd_util_memhdr_t *hdr = hw->tlb.memhdr; | 357 | struct snd_util_memhdr *hdr = hw->tlb.memhdr; |
352 | 358 | ||
353 | down(&hdr->block_mutex); | 359 | down(&hdr->block_mutex); |
354 | synth_free_pages(hw, blk); | 360 | synth_free_pages(hw, blk); |
@@ -361,7 +367,7 @@ snd_trident_synth_free(trident_t *hw, snd_util_memblk_t *blk) | |||
361 | /* | 367 | /* |
362 | * reset TLB entry and free kernel page | 368 | * reset TLB entry and free kernel page |
363 | */ | 369 | */ |
364 | static void clear_tlb(trident_t *trident, int page) | 370 | static void clear_tlb(struct snd_trident *trident, int page) |
365 | { | 371 | { |
366 | void *ptr = page_to_ptr(trident, page); | 372 | void *ptr = page_to_ptr(trident, page); |
367 | dma_addr_t addr = page_to_addr(trident, page); | 373 | dma_addr_t addr = page_to_addr(trident, page); |
@@ -378,20 +384,22 @@ static void clear_tlb(trident_t *trident, int page) | |||
378 | } | 384 | } |
379 | 385 | ||
380 | /* check new allocation range */ | 386 | /* check new allocation range */ |
381 | static void get_single_page_range(snd_util_memhdr_t *hdr, snd_util_memblk_t *blk, int *first_page_ret, int *last_page_ret) | 387 | static void get_single_page_range(struct snd_util_memhdr *hdr, |
388 | struct snd_util_memblk *blk, | ||
389 | int *first_page_ret, int *last_page_ret) | ||
382 | { | 390 | { |
383 | struct list_head *p; | 391 | struct list_head *p; |
384 | snd_util_memblk_t *q; | 392 | struct snd_util_memblk *q; |
385 | int first_page, last_page; | 393 | int first_page, last_page; |
386 | first_page = firstpg(blk); | 394 | first_page = firstpg(blk); |
387 | if ((p = blk->list.prev) != &hdr->block) { | 395 | if ((p = blk->list.prev) != &hdr->block) { |
388 | q = list_entry(p, snd_util_memblk_t, list); | 396 | q = list_entry(p, struct snd_util_memblk, list); |
389 | if (lastpg(q) == first_page) | 397 | if (lastpg(q) == first_page) |
390 | first_page++; /* first page was already allocated */ | 398 | first_page++; /* first page was already allocated */ |
391 | } | 399 | } |
392 | last_page = lastpg(blk); | 400 | last_page = lastpg(blk); |
393 | if ((p = blk->list.next) != &hdr->block) { | 401 | if ((p = blk->list.next) != &hdr->block) { |
394 | q = list_entry(p, snd_util_memblk_t, list); | 402 | q = list_entry(p, struct snd_util_memblk, list); |
395 | if (firstpg(q) == last_page) | 403 | if (firstpg(q) == last_page) |
396 | last_page--; /* last page was already allocated */ | 404 | last_page--; /* last page was already allocated */ |
397 | } | 405 | } |
@@ -402,7 +410,7 @@ static void get_single_page_range(snd_util_memhdr_t *hdr, snd_util_memblk_t *blk | |||
402 | /* | 410 | /* |
403 | * allocate kernel pages and assign them to TLB | 411 | * allocate kernel pages and assign them to TLB |
404 | */ | 412 | */ |
405 | static int synth_alloc_pages(trident_t *hw, snd_util_memblk_t *blk) | 413 | static int synth_alloc_pages(struct snd_trident *hw, struct snd_util_memblk *blk) |
406 | { | 414 | { |
407 | int page, first_page, last_page; | 415 | int page, first_page, last_page; |
408 | struct snd_dma_buffer dmab; | 416 | struct snd_dma_buffer dmab; |
@@ -438,7 +446,7 @@ __fail: | |||
438 | /* | 446 | /* |
439 | * free pages | 447 | * free pages |
440 | */ | 448 | */ |
441 | static int synth_free_pages(trident_t *trident, snd_util_memblk_t *blk) | 449 | static int synth_free_pages(struct snd_trident *trident, struct snd_util_memblk *blk) |
442 | { | 450 | { |
443 | int page, first_page, last_page; | 451 | int page, first_page, last_page; |
444 | 452 | ||
@@ -452,7 +460,9 @@ static int synth_free_pages(trident_t *trident, snd_util_memblk_t *blk) | |||
452 | /* | 460 | /* |
453 | * copy_from_user(blk + offset, data, size) | 461 | * copy_from_user(blk + offset, data, size) |
454 | */ | 462 | */ |
455 | int snd_trident_synth_copy_from_user(trident_t *trident, snd_util_memblk_t *blk, int offset, const char __user *data, int size) | 463 | int snd_trident_synth_copy_from_user(struct snd_trident *trident, |
464 | struct snd_util_memblk *blk, | ||
465 | int offset, const char __user *data, int size) | ||
456 | { | 466 | { |
457 | int page, nextofs, end_offset, temp, temp1; | 467 | int page, nextofs, end_offset, temp, temp1; |
458 | 468 | ||