22 #include <linux/slab.h>
23 #include <linux/string.h>
28 #ifdef CONFIG_SND_DEBUG
51 pblock = alloc->
first;
53 if (pblock->
ptr > nblock->
ptr) {
55 nblock->
next = pblock;
56 pblock->
prev = nblock;
57 if (pblock == alloc->
first)
58 alloc->
first = nblock;
60 nblock->
prev->next = nblock;
64 pblock = pblock->
next;
72 alloc->
last->next = nblock;
85 if (alloc->
first == block) {
94 if (alloc->
last == block) {
113 for (block = alloc->
first; block; block = block->
next) {
114 if (block->
ptr == address) {
126 if (!share_id[0] && !share_id[1] &&
127 !share_id[2] && !share_id[3])
129 for (block = alloc->
first; block; block = block->
next)
136 static int snd_gf1_mem_find(
struct snd_gf1_mem * alloc,
141 unsigned int idx, boundary;
144 unsigned int ptr1, ptr2;
146 if (w_16 && align < 2)
155 for (pblock = alloc->
first, idx = 0; pblock; pblock = pblock->
next) {
156 while (pblock->
ptr >= (boundary = info[idx].
address + info[idx].
size))
162 if (pblock->
ptr + pblock->
size == pblock->
next->ptr)
164 if (pblock->
next->ptr < boundary)
165 ptr2 = pblock->
next->ptr;
171 if ((
int)size <= size1) {
178 if (size <= info[idx].size) {
189 char *
name,
int size,
int w_16,
int align,
190 unsigned int *share_id)
195 if (share_id !=
NULL) {
196 nblock = snd_gf1_mem_share(alloc, share_id);
197 if (nblock !=
NULL) {
198 if (size != (
int)nblock->
size) {
209 if (snd_gf1_mem_find(alloc, &block, size, w_16, align) < 0) {
213 if (share_id !=
NULL)
217 nblock = snd_gf1_mem_xalloc(alloc, &block);
228 if ((block = snd_gf1_mem_look(alloc, address)) !=
NULL) {
241 #ifdef CONFIG_SND_DEBUG
245 alloc = &gus->
gf1.mem_alloc;
248 if (!gus->
gf1.memory)
251 memset(&block, 0,
sizeof(block));
253 if (gus->
gf1.enh_mode) {
257 if (snd_gf1_mem_xalloc(alloc, &block) ==
NULL)
260 block.
ptr = gus->
gf1.default_voice_address;
263 if (snd_gf1_mem_xalloc(alloc, &block) ==
NULL)
265 #ifdef CONFIG_SND_DEBUG
266 if (! snd_card_proc_new(gus->
card,
"gusmem", &entry))
267 snd_info_set_text_ops(entry, gus, snd_gf1_mem_info_read);
277 alloc = &gus->
gf1.mem_alloc;
278 block = alloc->
first;
280 nblock = block->
next;
287 #ifdef CONFIG_SND_DEBUG
294 unsigned int total,
used;
298 alloc = &gus->
gf1.mem_alloc;
300 snd_iprintf(buffer,
"8-bit banks : \n ");
301 for (i = 0; i < 4; i++)
302 snd_iprintf(buffer,
"0x%06x (%04ik)%s", alloc->
banks_8[i].address, alloc->
banks_8[i].size >> 10, i + 1 < 4 ?
"," :
"");
303 snd_iprintf(buffer,
"\n"
304 "16-bit banks : \n ");
305 for (i = total = 0; i < 4; i++) {
306 snd_iprintf(buffer,
"0x%06x (%04ik)%s", alloc->
banks_16[i].address, alloc->
banks_16[i].size >> 10, i + 1 < 4 ?
"," :
"");
309 snd_iprintf(buffer,
"\n");
311 for (block = alloc->
first, i = 0; block; block = block->
next, i++) {
313 snd_iprintf(buffer,
"Block %i at 0x%lx onboard 0x%x size %i (0x%x):\n", i, (
long) block, block->
ptr, block->size, block->size);
317 snd_iprintf(buffer,
" Share : %i [id0 0x%x] [id1 0x%x] [id2 0x%x] [id3 0x%x]\n",
321 snd_iprintf(buffer,
" Flags :%s\n",
323 snd_iprintf(buffer,
" Owner : ");
324 switch (block->
owner) {
326 snd_iprintf(buffer,
"driver - %s\n", block->
name);
329 snd_iprintf(buffer,
"SIMPLE wave\n");
332 snd_iprintf(buffer,
"GF1 wave\n");
335 snd_iprintf(buffer,
"IWFFFF wave\n");
338 snd_iprintf(buffer,
"unknown\n");
341 snd_iprintf(buffer,
" Total: memory = %i, used = %i, free = %i\n",
342 total, used, total - used);
345 ultra_iprintf(buffer,
" Verify: free = %i, max 8-bit block = %i, max 16-bit block = %i\n",
346 ultra_memory_free_size(
card, &
card->gf1.mem_alloc),
347 ultra_memory_free_block(
card, &
card->gf1.mem_alloc, 0),
348 ultra_memory_free_block(
card, &
card->gf1.mem_alloc, 1));