]> bbs.cooldavid.org Git - net-next-2.6.git/blame - sound/core/seq/instr/ainstr_fm.c
[PATCH] remove many unneeded #includes of sched.h
[net-next-2.6.git] / sound / core / seq / instr / ainstr_fm.c
CommitLineData
1da177e4
LT
1/*
2 * FM (OPL2/3) Instrument routines
3 * Copyright (c) 2000 Uros Bizjak <uros@kss-loka.si>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20
21#include <sound/driver.h>
22#include <linux/init.h>
1da177e4
LT
23#include <sound/core.h>
24#include <sound/ainstr_fm.h>
25#include <sound/initval.h>
26#include <asm/uaccess.h>
27
28MODULE_AUTHOR("Uros Bizjak <uros@kss-loka.si>");
29MODULE_DESCRIPTION("Advanced Linux Sound Architecture FM Instrument support.");
30MODULE_LICENSE("GPL");
31
19ac31e8 32static int snd_seq_fm_put(void *private_data, struct snd_seq_kinstr *instr,
1da177e4
LT
33 char __user *instr_data, long len, int atomic, int cmd)
34{
19ac31e8
TI
35 struct fm_instrument *ip;
36 struct fm_xinstrument ix;
1da177e4
LT
37 int idx;
38
39 if (cmd != SNDRV_SEQ_INSTR_PUT_CMD_CREATE)
40 return -EINVAL;
41 /* copy instrument data */
42 if (len < (long)sizeof(ix))
43 return -EINVAL;
44 if (copy_from_user(&ix, instr_data, sizeof(ix)))
45 return -EFAULT;
46 if (ix.stype != FM_STRU_INSTR)
47 return -EINVAL;
19ac31e8 48 ip = (struct fm_instrument *)KINSTR_DATA(instr);
1da177e4
LT
49 ip->share_id[0] = le32_to_cpu(ix.share_id[0]);
50 ip->share_id[1] = le32_to_cpu(ix.share_id[1]);
51 ip->share_id[2] = le32_to_cpu(ix.share_id[2]);
52 ip->share_id[3] = le32_to_cpu(ix.share_id[3]);
53 ip->type = ix.type;
54 for (idx = 0; idx < 4; idx++) {
55 ip->op[idx].am_vib = ix.op[idx].am_vib;
56 ip->op[idx].ksl_level = ix.op[idx].ksl_level;
57 ip->op[idx].attack_decay = ix.op[idx].attack_decay;
58 ip->op[idx].sustain_release = ix.op[idx].sustain_release;
59 ip->op[idx].wave_select = ix.op[idx].wave_select;
60 }
61 for (idx = 0; idx < 2; idx++) {
62 ip->feedback_connection[idx] = ix.feedback_connection[idx];
63 }
64 ip->echo_delay = ix.echo_delay;
65 ip->echo_atten = ix.echo_atten;
66 ip->chorus_spread = ix.chorus_spread;
67 ip->trnsps = ix.trnsps;
68 ip->fix_dur = ix.fix_dur;
69 ip->modes = ix.modes;
70 ip->fix_key = ix.fix_key;
71 return 0;
72}
73
19ac31e8 74static int snd_seq_fm_get(void *private_data, struct snd_seq_kinstr *instr,
1da177e4
LT
75 char __user *instr_data, long len, int atomic,
76 int cmd)
77{
19ac31e8
TI
78 struct fm_instrument *ip;
79 struct fm_xinstrument ix;
1da177e4
LT
80 int idx;
81
82 if (cmd != SNDRV_SEQ_INSTR_GET_CMD_FULL)
83 return -EINVAL;
84 if (len < (long)sizeof(ix))
85 return -ENOMEM;
86 memset(&ix, 0, sizeof(ix));
19ac31e8 87 ip = (struct fm_instrument *)KINSTR_DATA(instr);
1da177e4
LT
88 ix.stype = FM_STRU_INSTR;
89 ix.share_id[0] = cpu_to_le32(ip->share_id[0]);
90 ix.share_id[1] = cpu_to_le32(ip->share_id[1]);
91 ix.share_id[2] = cpu_to_le32(ip->share_id[2]);
92 ix.share_id[3] = cpu_to_le32(ip->share_id[3]);
93 ix.type = ip->type;
94 for (idx = 0; idx < 4; idx++) {
95 ix.op[idx].am_vib = ip->op[idx].am_vib;
96 ix.op[idx].ksl_level = ip->op[idx].ksl_level;
97 ix.op[idx].attack_decay = ip->op[idx].attack_decay;
98 ix.op[idx].sustain_release = ip->op[idx].sustain_release;
99 ix.op[idx].wave_select = ip->op[idx].wave_select;
100 }
101 for (idx = 0; idx < 2; idx++) {
102 ix.feedback_connection[idx] = ip->feedback_connection[idx];
103 }
104 if (copy_to_user(instr_data, &ix, sizeof(ix)))
105 return -EFAULT;
106 ix.echo_delay = ip->echo_delay;
107 ix.echo_atten = ip->echo_atten;
108 ix.chorus_spread = ip->chorus_spread;
109 ix.trnsps = ip->trnsps;
110 ix.fix_dur = ip->fix_dur;
111 ix.modes = ip->modes;
112 ix.fix_key = ip->fix_key;
113 return 0;
114}
115
19ac31e8 116static int snd_seq_fm_get_size(void *private_data, struct snd_seq_kinstr *instr,
1da177e4
LT
117 long *size)
118{
19ac31e8 119 *size = sizeof(struct fm_xinstrument);
1da177e4
LT
120 return 0;
121}
122
19ac31e8
TI
123int snd_seq_fm_init(struct snd_seq_kinstr_ops *ops,
124 struct snd_seq_kinstr_ops *next)
1da177e4
LT
125{
126 memset(ops, 0, sizeof(*ops));
127 // ops->private_data = private_data;
19ac31e8 128 ops->add_len = sizeof(struct fm_instrument);
1da177e4
LT
129 ops->instr_type = SNDRV_SEQ_INSTR_ID_OPL2_3;
130 ops->put = snd_seq_fm_put;
131 ops->get = snd_seq_fm_get;
132 ops->get_size = snd_seq_fm_get_size;
133 // ops->remove = snd_seq_fm_remove;
134 // ops->notify = snd_seq_fm_notify;
135 ops->next = next;
136 return 0;
137}
138
139/*
140 * Init part
141 */
142
143static int __init alsa_ainstr_fm_init(void)
144{
145 return 0;
146}
147
148static void __exit alsa_ainstr_fm_exit(void)
149{
150}
151
152module_init(alsa_ainstr_fm_init)
153module_exit(alsa_ainstr_fm_exit)
154
155EXPORT_SYMBOL(snd_seq_fm_init);