2 * Routines for Gravis UltraSound soundcards - Synthesizer
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
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.
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.
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
22 #include <sound/driver.h>
23 #include <linux/time.h>
24 #include <sound/core.h>
25 #include <sound/gus.h>
31 int snd_gus_iwffff_put_sample(void *private_data, struct iwffff_wave *wave,
32 char __user *data, long len, int atomic)
34 struct snd_gus_card *gus = private_data;
35 struct snd_gf1_mem_block *block;
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,
45 wave->format & IWFFFF_WAVE_16BIT, 1,
49 err = snd_gus_dram_write(gus, data,
50 block->ptr, wave->size);
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);
57 wave->address.memory = block->ptr;
61 int snd_gus_iwffff_get_sample(void *private_data, struct iwffff_wave *wave,
62 char __user *data, long len, int atomic)
64 struct snd_gus_card *gus = private_data;
66 return snd_gus_dram_read(gus, data, wave->address.memory, wave->size,
67 wave->format & IWFFFF_WAVE_ROM ? 1 : 0);
70 int snd_gus_iwffff_remove_sample(void *private_data, struct iwffff_wave *wave,
73 struct snd_gus_card *gus = private_data;
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);
84 int snd_gus_gf1_put_sample(void *private_data, struct gf1_wave *wave,
85 char __user *data, long len, int atomic)
87 struct snd_gus_card *gus = private_data;
88 struct snd_gf1_mem_block *block;
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,
96 wave->format & GF1_WAVE_16BIT, 1,
100 err = snd_gus_dram_write(gus, data,
101 block->ptr, wave->size);
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);
108 wave->address.memory = block->ptr;
112 int snd_gus_gf1_get_sample(void *private_data, struct gf1_wave *wave,
113 char __user *data, long len, int atomic)
115 struct snd_gus_card *gus = private_data;
117 return snd_gus_dram_read(gus, data, wave->address.memory, wave->size, 0);
120 int snd_gus_gf1_remove_sample(void *private_data, struct gf1_wave *wave,
123 struct snd_gus_card *gus = private_data;
125 return snd_gf1_mem_free(&gus->gf1.mem_alloc, wave->address.memory);
132 int snd_gus_simple_put_sample(void *private_data, struct simple_instrument *instr,
133 char __user *data, long len, int atomic)
135 struct snd_gus_card *gus = private_data;
136 struct snd_gf1_mem_block *block;
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,
144 instr->format & SIMPLE_WAVE_16BIT, 1,
148 err = snd_gus_dram_write(gus, data, block->ptr, instr->size);
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);
155 instr->address.memory = block->ptr;
159 int snd_gus_simple_get_sample(void *private_data, struct simple_instrument *instr,
160 char __user *data, long len, int atomic)
162 struct snd_gus_card *gus = private_data;
164 return snd_gus_dram_read(gus, data, instr->address.memory, instr->size, 0);
167 int snd_gus_simple_remove_sample(void *private_data, struct simple_instrument *instr,
170 struct snd_gus_card *gus = private_data;
172 return snd_gf1_mem_free(&gus->gf1.mem_alloc, instr->address.memory);