snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner,
				       char *name, int size, int w_16, int align,
				       unsigned int *share_id)
{
	snd_gf1_mem_block_t block, *nblock;

	snd_gf1_mem_lock(alloc, 0);
	if (share_id != NULL) {
		nblock = snd_gf1_mem_share(alloc, share_id);
		if (nblock != NULL) {
			if (size != (int)nblock->size) {
				/* TODO: remove in the future */
				snd_printk("snd_gf1_mem_alloc - share: sizes differ\n");
				goto __std;
			}
			nblock->share++;
			snd_gf1_mem_lock(alloc, 1);
			return NULL;
		}
	}
      __std:
	if (snd_gf1_mem_find(alloc, &block, size, w_16, align) < 0) {
		snd_gf1_mem_lock(alloc, 1);
		return NULL;
	}
	if (share_id != NULL)
		memcpy(&block.share_id, share_id, sizeof(block.share_id));
	block.owner = owner;
	block.name = snd_kmalloc_strdup(name, GFP_KERNEL);
	nblock = snd_gf1_mem_xalloc(alloc, &block);
	snd_gf1_mem_lock(alloc, 1);
	return nblock;
}
int snd_gf1_mem_init(snd_gus_card_t * gus)
{
	snd_gf1_mem_t *alloc;
	snd_gf1_mem_block_t block;
#ifdef CONFIG_SND_DEBUG
	snd_info_entry_t *entry;
#endif

	alloc = &gus->gf1.mem_alloc;
	init_MUTEX(&alloc->memory_mutex);
	alloc->first = alloc->last = NULL;
	if (!gus->gf1.memory)
		return 0;

	memset(&block, 0, sizeof(block));
	block.owner = SNDRV_GF1_MEM_OWNER_DRIVER;
	if (gus->gf1.enh_mode) {
		block.ptr = 0;
		block.size = 1024;
		block.name = snd_kmalloc_strdup("InterWave LFOs", GFP_KERNEL);
		if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
			return -ENOMEM;
	}
	block.ptr = gus->gf1.default_voice_address;
	block.size = 4;
	block.name = snd_kmalloc_strdup("Voice default (NULL's)", GFP_KERNEL);
	if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
		return -ENOMEM;
#ifdef CONFIG_SND_DEBUG
	if (! snd_card_proc_new(gus->card, "gusmem", &entry)) {
		snd_info_set_text_ops(entry, gus, 1024, snd_gf1_mem_info_read);
		entry->c.text.read_size = 256 * 1024;
	}
#endif
	return 0;
}
Пример #3
0
static snd_info_entry_t *snd_info_create_entry(const char *name)
{
	snd_info_entry_t *entry;
	entry = (snd_info_entry_t *) snd_kcalloc(sizeof(snd_info_entry_t), GFP_KERNEL);
	if (entry == NULL)
		return NULL;
	entry->name = snd_kmalloc_strdup(name, GFP_KERNEL);
	if (entry->name == NULL) {
		kfree(entry);
		return NULL;
	}
	entry->mode = S_IFREG | S_IRUGO;
	entry->content = SNDRV_INFO_CONTENT_TEXT;
	init_MUTEX(&entry->access);
	return entry;
}
Пример #4
0
int snd_info_card_register(snd_card_t * card)
{
	char str[8];
	char *s;
	snd_info_entry_t *entry;
	struct proc_dir_entry *p;

	snd_assert(card != NULL, return -ENXIO);

	sprintf(str, "card%i", card->number);
	if ((entry = snd_info_create_module_entry(card->module, str, NULL)) == NULL)
		return -ENOMEM;
	entry->mode = S_IFDIR | S_IRUGO | S_IXUGO;
	if (snd_info_register(entry) < 0) {
		snd_info_free_entry(entry);
		return -ENOMEM;
	}
	card->proc_root = entry;

	if (!strcmp(card->id, str))
		return 0;

	s = snd_kmalloc_strdup(str, GFP_KERNEL);
	if (s == NULL)
		return -ENOMEM;
	p = snd_create_proc_entry(card->id, S_IFLNK | S_IRUGO | S_IWUGO | S_IXUGO, snd_proc_root);
	if (p == NULL)
		return -ENOMEM;
	p->data = s;
#ifndef TARGET_OS2
#ifdef LINUX_2_3
	p->owner = card->module;
	p->proc_iops = &snd_info_card_link_inode_operations;
#else
	p->ops = &snd_info_card_link_inode_operations;
#endif
#endif
	card->proc_root_link = p;
	return 0;
}
Пример #5
0
int snd_oss_info_register(int dev, int num, char *string)
{
	char *x;

	snd_assert(dev >= 0 && dev < SNDRV_OSS_INFO_DEV_COUNT, return -ENXIO);
	snd_assert(num >= 0 && num < SNDRV_CARDS, return -ENXIO);
	down(&strings);
	if (string == NULL) {
		if ((x = snd_sndstat_strings[num][dev]) != NULL) {
			kfree(x);
			x = NULL;
		}
	} else {
		x = snd_kmalloc_strdup(string, GFP_KERNEL);
		if (x == NULL) {
			up(&strings);
			return -ENOMEM;
		}
	}
	snd_sndstat_strings[num][dev] = x;
	up(&strings);
	return 0;
}