static int snd_opl3_seq_new_device(struct snd_seq_device *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; } /* initialize instrument list */ opl3->ilist = snd_seq_instr_list_new(); if (opl3->ilist == NULL) { snd_seq_delete_kernel_client(client); opl3->seq_client = -1; return -ENOMEM; } opl3->ilist->flags = SNDRV_SEQ_INSTR_FLG_DIRECT; snd_seq_fm_init(&opl3->fm_ops, NULL); /* setup system timer */ init_timer(&opl3->tlist); opl3->tlist.function = snd_opl3_timer_func; opl3->tlist.data = (unsigned long) opl3; spin_lock_init(&opl3->sys_timer_lock); opl3->sys_timer_status = 0; #ifdef CONFIG_SND_SEQUENCER_OSS snd_opl3_init_seq_oss(opl3, name); #endif return 0; }
static int snd_gus_synth_new_device(snd_seq_device_t *dev) { snd_gus_card_t *gus; int client, i; snd_seq_client_callback_t callbacks; snd_seq_client_info_t *cinfo; snd_seq_port_subscribe_t sub; snd_iwffff_ops_t *iwops; snd_gf1_ops_t *gf1ops; snd_simple_ops_t *simpleops; gus = *(snd_gus_card_t**)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (gus == NULL) return -EINVAL; init_MUTEX(&gus->register_mutex); gus->gf1.seq_client = -1; cinfo = kmalloc(sizeof(*cinfo), GFP_KERNEL); if (! cinfo) return -ENOMEM; /* allocate new client */ memset(&callbacks, 0, sizeof(callbacks)); callbacks.private_data = gus; callbacks.allow_output = callbacks.allow_input = 1; client = gus->gf1.seq_client = snd_seq_create_kernel_client(gus->card, 1, &callbacks); if (client < 0) { kfree(cinfo); return client; } /* change name of client */ memset(cinfo, 0, sizeof(*cinfo)); cinfo->client = client; cinfo->type = KERNEL_CLIENT; sprintf(cinfo->name, gus->interwave ? "AMD InterWave" : "GF1"); snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, cinfo); kfree(cinfo); for (i = 0; i < 4; i++) snd_gus_synth_create_port(gus, i); gus->gf1.ilist = snd_seq_instr_list_new(); if (gus->gf1.ilist == NULL) { snd_seq_delete_kernel_client(client); gus->gf1.seq_client = -1; return -ENOMEM; } gus->gf1.ilist->flags = SNDRV_SEQ_INSTR_FLG_DIRECT; simpleops = &gus->gf1.simple_ops; snd_seq_simple_init(simpleops, gus, NULL); simpleops->put_sample = snd_gus_simple_put_sample; simpleops->get_sample = snd_gus_simple_get_sample; simpleops->remove_sample = snd_gus_simple_remove_sample; simpleops->notify = snd_gus_synth_instr_notify; gf1ops = &gus->gf1.gf1_ops; snd_seq_gf1_init(gf1ops, gus, &simpleops->kops); gf1ops->put_sample = snd_gus_gf1_put_sample; gf1ops->get_sample = snd_gus_gf1_get_sample; gf1ops->remove_sample = snd_gus_gf1_remove_sample; gf1ops->notify = snd_gus_synth_instr_notify; iwops = &gus->gf1.iwffff_ops; snd_seq_iwffff_init(iwops, gus, &gf1ops->kops); iwops->put_sample = snd_gus_iwffff_put_sample; iwops->get_sample = snd_gus_iwffff_get_sample; iwops->remove_sample = snd_gus_iwffff_remove_sample; iwops->notify = snd_gus_synth_instr_notify; memset(&sub, 0, sizeof(sub)); sub.sender.client = SNDRV_SEQ_CLIENT_SYSTEM; sub.sender.port = SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE; sub.dest.client = client; sub.dest.port = 0; snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT, &sub); return 0; }