Exemplo n.º 1
0
/*
 * registration of the synth device
 */
int
snd_seq_oss_synth_probe(struct device *_dev)
{
    struct snd_seq_device *dev = to_seq_dev(_dev);
    int i;
    struct seq_oss_synth *rec;
    struct snd_seq_oss_reg *reg = SNDRV_SEQ_DEVICE_ARGPTR(dev);
    unsigned long flags;

    rec = kzalloc(sizeof(*rec), GFP_KERNEL);
    if (!rec)
        return -ENOMEM;
    rec->seq_device = -1;
    rec->synth_type = reg->type;
    rec->synth_subtype = reg->subtype;
    rec->nr_voices = reg->nvoices;
    rec->oper = reg->oper;
    rec->private_data = reg->private_data;
    rec->opened = 0;
    snd_use_lock_init(&rec->use_lock);

    /* copy and truncate the name of synth device */
    strlcpy(rec->name, dev->name, sizeof(rec->name));

    /* registration */
    spin_lock_irqsave(&register_lock, flags);
    for (i = 0; i < max_synth_devs; i++) {
        if (synth_devs[i] == NULL)
            break;
    }
    if (i >= max_synth_devs) {
        if (max_synth_devs >= SNDRV_SEQ_OSS_MAX_SYNTH_DEVS) {
            spin_unlock_irqrestore(&register_lock, flags);
            pr_err("ALSA: seq_oss: no more synth slot\n");
            kfree(rec);
            return -ENOMEM;
        }
        max_synth_devs++;
    }
    rec->seq_device = i;
    synth_devs[i] = rec;
    spin_unlock_irqrestore(&register_lock, flags);
    dev->driver_data = rec;
#ifdef SNDRV_OSS_INFO_DEV_SYNTH
    if (i < SNDRV_CARDS)
        snd_oss_info_register(SNDRV_OSS_INFO_DEV_SYNTH, i, rec->name);
#endif
    return 0;
}
Exemplo n.º 2
0
static int snd_opl3_seq_remove(struct device *_dev)
{
	struct snd_seq_device *dev = to_seq_dev(_dev);
	struct snd_opl3 *opl3;

	opl3 = *(struct snd_opl3 **)SNDRV_SEQ_DEVICE_ARGPTR(dev);
	if (opl3 == NULL)
		return -EINVAL;

#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
	snd_opl3_free_seq_oss(opl3);
#endif
	if (opl3->seq_client >= 0) {
		snd_seq_delete_kernel_client(opl3->seq_client);
		opl3->seq_client = -1;
	}
	return 0;
}
Exemplo n.º 3
0
static int snd_opl3_seq_probe(struct device *_dev)
{
	struct snd_seq_device *dev = to_seq_dev(_dev);
	struct snd_opl3 *opl3;
	int client, err;
	char name[32];
	int opl_ver;

	opl3 = *(struct snd_opl3 **)SNDRV_SEQ_DEVICE_ARGPTR(dev);
	if (opl3 == NULL)
		return -EINVAL;

	spin_lock_init(&opl3->voice_lock);

	opl3->seq_client = -1;

	/* allocate new client */
	opl_ver = (opl3->hardware & OPL3_HW_MASK) >> 8;
	sprintf(name, "OPL%i FM synth", opl_ver);
	client = opl3->seq_client =
		snd_seq_create_kernel_client(opl3->card, opl3->seq_dev_num,
					     name);
	if (client < 0)
		return client;

	if ((err = snd_opl3_synth_create_port(opl3)) < 0) {
		snd_seq_delete_kernel_client(client);
		opl3->seq_client = -1;
		return err;
	}

	/* setup system timer */
	setup_timer(&opl3->tlist, snd_opl3_timer_func, (unsigned long) opl3);
	spin_lock_init(&opl3->sys_timer_lock);
	opl3->sys_timer_status = 0;

#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
	snd_opl3_init_seq_oss(opl3, name);
#endif
	return 0;
}
Exemplo n.º 4
0
int
snd_seq_oss_synth_remove(struct device *_dev)
{
    struct snd_seq_device *dev = to_seq_dev(_dev);
    int index;
    struct seq_oss_synth *rec = dev->driver_data;
    unsigned long flags;

    spin_lock_irqsave(&register_lock, flags);
    for (index = 0; index < max_synth_devs; index++) {
        if (synth_devs[index] == rec)
            break;
    }
    if (index >= max_synth_devs) {
        spin_unlock_irqrestore(&register_lock, flags);
        pr_err("ALSA: seq_oss: can't unregister synth\n");
        return -EINVAL;
    }
    synth_devs[index] = NULL;
    if (index == max_synth_devs - 1) {
        for (index--; index >= 0; index--) {
            if (synth_devs[index])
                break;
        }
        max_synth_devs = index + 1;
    }
    spin_unlock_irqrestore(&register_lock, flags);
#ifdef SNDRV_OSS_INFO_DEV_SYNTH
    if (rec->seq_device < SNDRV_CARDS)
        snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_SYNTH, rec->seq_device);
#endif

    snd_use_lock_sync(&rec->use_lock);
    kfree(rec);

    return 0;
}