diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /sound/isa/gus/gus_instr.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'sound/isa/gus/gus_instr.c')
-rw-r--r-- | sound/isa/gus/gus_instr.c | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/sound/isa/gus/gus_instr.c b/sound/isa/gus/gus_instr.c new file mode 100644 index 000000000000..591a9a17feb5 --- /dev/null +++ b/sound/isa/gus/gus_instr.c | |||
@@ -0,0 +1,173 @@ | |||
1 | /* | ||
2 | * Routines for Gravis UltraSound soundcards - Synthesizer | ||
3 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz> | ||
4 | * | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include <sound/driver.h> | ||
23 | #include <linux/time.h> | ||
24 | #include <sound/core.h> | ||
25 | #include <sound/gus.h> | ||
26 | |||
27 | /* | ||
28 | * | ||
29 | */ | ||
30 | |||
31 | int snd_gus_iwffff_put_sample(void *private_data, iwffff_wave_t *wave, | ||
32 | char __user *data, long len, int atomic) | ||
33 | { | ||
34 | snd_gus_card_t *gus = private_data; | ||
35 | snd_gf1_mem_block_t *block; | ||
36 | int err; | ||
37 | |||
38 | if (wave->format & IWFFFF_WAVE_ROM) | ||
39 | return 0; /* it's probably ok - verify the address? */ | ||
40 | if (wave->format & IWFFFF_WAVE_STEREO) | ||
41 | return -EINVAL; /* not supported */ | ||
42 | block = snd_gf1_mem_alloc(&gus->gf1.mem_alloc, | ||
43 | SNDRV_GF1_MEM_OWNER_WAVE_IWFFFF, | ||
44 | NULL, wave->size, | ||
45 | wave->format & IWFFFF_WAVE_16BIT, 1, | ||
46 | wave->share_id); | ||
47 | if (block == NULL) | ||
48 | return -ENOMEM; | ||
49 | err = snd_gus_dram_write(gus, data, | ||
50 | block->ptr, wave->size); | ||
51 | if (err < 0) { | ||
52 | snd_gf1_mem_lock(&gus->gf1.mem_alloc, 0); | ||
53 | snd_gf1_mem_xfree(&gus->gf1.mem_alloc, block); | ||
54 | snd_gf1_mem_lock(&gus->gf1.mem_alloc, 1); | ||
55 | return err; | ||
56 | } | ||
57 | wave->address.memory = block->ptr; | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | int snd_gus_iwffff_get_sample(void *private_data, iwffff_wave_t *wave, | ||
62 | char __user *data, long len, int atomic) | ||
63 | { | ||
64 | snd_gus_card_t *gus = private_data; | ||
65 | |||
66 | return snd_gus_dram_read(gus, data, wave->address.memory, wave->size, | ||
67 | wave->format & IWFFFF_WAVE_ROM ? 1 : 0); | ||
68 | } | ||
69 | |||
70 | int snd_gus_iwffff_remove_sample(void *private_data, iwffff_wave_t *wave, | ||
71 | int atomic) | ||
72 | { | ||
73 | snd_gus_card_t *gus = private_data; | ||
74 | |||
75 | if (wave->format & IWFFFF_WAVE_ROM) | ||
76 | return 0; /* it's probably ok - verify the address? */ | ||
77 | return snd_gf1_mem_free(&gus->gf1.mem_alloc, wave->address.memory); | ||
78 | } | ||
79 | |||
80 | /* | ||
81 | * | ||
82 | */ | ||
83 | |||
84 | int snd_gus_gf1_put_sample(void *private_data, gf1_wave_t *wave, | ||
85 | char __user *data, long len, int atomic) | ||
86 | { | ||
87 | snd_gus_card_t *gus = private_data; | ||
88 | snd_gf1_mem_block_t *block; | ||
89 | int err; | ||
90 | |||
91 | if (wave->format & GF1_WAVE_STEREO) | ||
92 | return -EINVAL; /* not supported */ | ||
93 | block = snd_gf1_mem_alloc(&gus->gf1.mem_alloc, | ||
94 | SNDRV_GF1_MEM_OWNER_WAVE_GF1, | ||
95 | NULL, wave->size, | ||
96 | wave->format & GF1_WAVE_16BIT, 1, | ||
97 | wave->share_id); | ||
98 | if (block == NULL) | ||
99 | return -ENOMEM; | ||
100 | err = snd_gus_dram_write(gus, data, | ||
101 | block->ptr, wave->size); | ||
102 | if (err < 0) { | ||
103 | snd_gf1_mem_lock(&gus->gf1.mem_alloc, 0); | ||
104 | snd_gf1_mem_xfree(&gus->gf1.mem_alloc, block); | ||
105 | snd_gf1_mem_lock(&gus->gf1.mem_alloc, 1); | ||
106 | return err; | ||
107 | } | ||
108 | wave->address.memory = block->ptr; | ||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | int snd_gus_gf1_get_sample(void *private_data, gf1_wave_t *wave, | ||
113 | char __user *data, long len, int atomic) | ||
114 | { | ||
115 | snd_gus_card_t *gus = private_data; | ||
116 | |||
117 | return snd_gus_dram_read(gus, data, wave->address.memory, wave->size, 0); | ||
118 | } | ||
119 | |||
120 | int snd_gus_gf1_remove_sample(void *private_data, gf1_wave_t *wave, | ||
121 | int atomic) | ||
122 | { | ||
123 | snd_gus_card_t *gus = private_data; | ||
124 | |||
125 | return snd_gf1_mem_free(&gus->gf1.mem_alloc, wave->address.memory); | ||
126 | } | ||
127 | |||
128 | /* | ||
129 | * | ||
130 | */ | ||
131 | |||
132 | int snd_gus_simple_put_sample(void *private_data, simple_instrument_t *instr, | ||
133 | char __user *data, long len, int atomic) | ||
134 | { | ||
135 | snd_gus_card_t *gus = private_data; | ||
136 | snd_gf1_mem_block_t *block; | ||
137 | int err; | ||
138 | |||
139 | if (instr->format & SIMPLE_WAVE_STEREO) | ||
140 | return -EINVAL; /* not supported */ | ||
141 | block = snd_gf1_mem_alloc(&gus->gf1.mem_alloc, | ||
142 | SNDRV_GF1_MEM_OWNER_WAVE_SIMPLE, | ||
143 | NULL, instr->size, | ||
144 | instr->format & SIMPLE_WAVE_16BIT, 1, | ||
145 | instr->share_id); | ||
146 | if (block == NULL) | ||
147 | return -ENOMEM; | ||
148 | err = snd_gus_dram_write(gus, data, block->ptr, instr->size); | ||
149 | if (err < 0) { | ||
150 | snd_gf1_mem_lock(&gus->gf1.mem_alloc, 0); | ||
151 | snd_gf1_mem_xfree(&gus->gf1.mem_alloc, block); | ||
152 | snd_gf1_mem_lock(&gus->gf1.mem_alloc, 1); | ||
153 | return err; | ||
154 | } | ||
155 | instr->address.memory = block->ptr; | ||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | int snd_gus_simple_get_sample(void *private_data, simple_instrument_t *instr, | ||
160 | char __user *data, long len, int atomic) | ||
161 | { | ||
162 | snd_gus_card_t *gus = private_data; | ||
163 | |||
164 | return snd_gus_dram_read(gus, data, instr->address.memory, instr->size, 0); | ||
165 | } | ||
166 | |||
167 | int snd_gus_simple_remove_sample(void *private_data, simple_instrument_t *instr, | ||
168 | int atomic) | ||
169 | { | ||
170 | snd_gus_card_t *gus = private_data; | ||
171 | |||
172 | return snd_gf1_mem_free(&gus->gf1.mem_alloc, instr->address.memory); | ||
173 | } | ||