1 --- btsco.old/kernel/btsco.c 2006-10-28 16:39:27.000000000 +0200
2 +++ btsco-0.5/kernel/btsco.c 2007-07-12 22:13:13.000000000 +0200
4 #include <linux/file.h>
5 #include <linux/completion.h>
6 #include <linux/smp_lock.h>
7 +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19)
8 +#include <linux/freezer.h>
11 #include <net/bluetooth/bluetooth.h>
13 +// this was ostensibly for newer kernels but fails on 2.6.19.2
15 +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
16 +#include <sound/typedefs.h>
19 #include <sound/core.h>
20 #include <sound/control.h>
21 #include <sound/pcm.h>
23 MODULE_LICENSE("GPL");
24 MODULE_SUPPORTED_DEVICE("{{ALSA,Bluetooth SCO Soundcard}}");
26 -static char *mod_revision = "$Revision$";
27 +static char *mod_revision = "$Revision$";
29 static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the first card */
32 } snd_card_bt_sco_info_t;
34 typedef struct snd_card_bt_sco {
36 + struct snd_card *card;
37 spinlock_t mixer_lock;
38 int mixer_volume[MIXER_ADDR_LAST + 1];
39 #ifdef DYNAMIC_COMPRESSION
40 - snd_kcontrol_t *mixer_controls[MIXER_ADDR_LAST + 2 + 1]; /* also loopback and agc */
41 + struct snd_kcontrol *mixer_controls[MIXER_ADDR_LAST + 2 + 1]; /* also loopback and agc */
43 - snd_kcontrol_t *mixer_controls[MIXER_ADDR_LAST + 2 ]; /* also loopback */
44 + struct snd_kcontrol *mixer_controls[MIXER_ADDR_LAST + 2 ]; /* also loopback */
46 volatile int loopback;
47 #ifdef DYNAMIC_COMPRESSION
49 unsigned int pcm_bps; /* bytes per second */
50 unsigned int pcm_irq_pos; /* IRQ position */
51 unsigned int pcm_buf_pos; /* position in buffer */
52 - snd_pcm_substream_t *substream;
53 + struct snd_pcm_substream *substream;
54 } snd_card_bt_sco_pcm_t;
56 -static snd_card_t *snd_bt_sco_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
57 +static struct snd_card *snd_bt_sco_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
59 -static int snd_card_bt_sco_playback_trigger(snd_pcm_substream_t *
60 +static int snd_card_bt_sco_playback_trigger(struct snd_pcm_substream *
63 - snd_pcm_runtime_t *runtime = substream->runtime;
64 + struct snd_pcm_runtime *runtime = substream->runtime;
65 snd_card_bt_sco_pcm_t *bspcm = runtime->private_data;
66 snd_card_bt_sco_t *bt_sco = snd_pcm_substream_chip(substream);
72 -static int snd_card_bt_sco_capture_trigger(snd_pcm_substream_t *
73 +static int snd_card_bt_sco_capture_trigger(struct snd_pcm_substream *
76 - snd_pcm_runtime_t *runtime = substream->runtime;
77 + struct snd_pcm_runtime *runtime = substream->runtime;
78 snd_card_bt_sco_pcm_t *bspcm = runtime->private_data;
79 snd_card_bt_sco_t *bt_sco = snd_pcm_substream_chip(substream);
85 -static int snd_card_bt_sco_pcm_prepare(snd_pcm_substream_t * substream)
86 +static int snd_card_bt_sco_pcm_prepare(struct snd_pcm_substream * substream)
88 - snd_pcm_runtime_t *runtime = substream->runtime;
89 + struct snd_pcm_runtime *runtime = substream->runtime;
90 snd_card_bt_sco_pcm_t *bspcm = runtime->private_data;
97 -static int snd_card_bt_sco_playback_prepare(snd_pcm_substream_t * substream)
98 +static int snd_card_bt_sco_playback_prepare(struct snd_pcm_substream * substream)
100 return snd_card_bt_sco_pcm_prepare(substream);
103 -static int snd_card_bt_sco_capture_prepare(snd_pcm_substream_t * substream)
104 +static int snd_card_bt_sco_capture_prepare(struct snd_pcm_substream * substream)
106 dprintk("capture_prepare\n");
107 return snd_card_bt_sco_pcm_prepare(substream);
108 @@ -311,24 +320,24 @@
111 static snd_pcm_uframes_t
112 -snd_card_bt_sco_playback_pointer(snd_pcm_substream_t * substream)
113 +snd_card_bt_sco_playback_pointer(struct snd_pcm_substream * substream)
115 - snd_pcm_runtime_t *runtime = substream->runtime;
116 + struct snd_pcm_runtime *runtime = substream->runtime;
117 snd_card_bt_sco_pcm_t *bspcm = runtime->private_data;
119 return bytes_to_frames(runtime, bspcm->pcm_buf_pos);
122 static snd_pcm_uframes_t
123 -snd_card_bt_sco_capture_pointer(snd_pcm_substream_t * substream)
124 +snd_card_bt_sco_capture_pointer(struct snd_pcm_substream * substream)
126 - snd_pcm_runtime_t *runtime = substream->runtime;
127 + struct snd_pcm_runtime *runtime = substream->runtime;
128 snd_card_bt_sco_pcm_t *bspcm = runtime->private_data;
130 return bytes_to_frames(runtime, bspcm->pcm_buf_pos);
133 -static snd_pcm_hardware_t snd_card_bt_sco_playback = {
134 +static struct snd_pcm_hardware snd_card_bt_sco_playback = {
135 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
136 SNDRV_PCM_INFO_MMAP_VALID),
137 .formats = SNDRV_PCM_FMTBIT_S16_LE,
142 -static snd_pcm_hardware_t snd_card_bt_sco_capture = {
143 +static struct snd_pcm_hardware snd_card_bt_sco_capture = {
144 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
145 SNDRV_PCM_INFO_MMAP_VALID),
146 .formats = SNDRV_PCM_FMTBIT_S16_LE,
147 @@ -362,15 +371,15 @@
151 -static void snd_card_bt_sco_runtime_free(snd_pcm_runtime_t * runtime)
152 +static void snd_card_bt_sco_runtime_free(struct snd_pcm_runtime * runtime)
154 snd_card_bt_sco_pcm_t *bspcm = runtime->private_data;
158 -static int snd_card_bt_sco_playback_open(snd_pcm_substream_t * substream)
159 +static int snd_card_bt_sco_playback_open(struct snd_pcm_substream * substream)
161 - snd_pcm_runtime_t *runtime = substream->runtime;
162 + struct snd_pcm_runtime *runtime = substream->runtime;
163 snd_card_bt_sco_pcm_t *bspcm;
164 snd_card_bt_sco_t *bt_sco = snd_pcm_substream_chip(substream);
170 -static int snd_card_bt_sco_capture_open(snd_pcm_substream_t * substream)
171 +static int snd_card_bt_sco_capture_open(struct snd_pcm_substream * substream)
173 - snd_pcm_runtime_t *runtime = substream->runtime;
174 + struct snd_pcm_runtime *runtime = substream->runtime;
175 snd_card_bt_sco_pcm_t *bspcm;
176 snd_card_bt_sco_t *bt_sco = snd_pcm_substream_chip(substream);
182 -static int snd_card_bt_sco_playback_close(snd_pcm_substream_t * substream)
183 +static int snd_card_bt_sco_playback_close(struct snd_pcm_substream * substream)
185 - snd_pcm_runtime_t *runtime = substream->runtime;
186 + struct snd_pcm_runtime *runtime = substream->runtime;
187 snd_card_bt_sco_t *bt_sco = snd_pcm_substream_chip(substream);
189 snd_assert(bt_sco->playback == NULL,;
194 -static int snd_card_bt_sco_capture_close(snd_pcm_substream_t * substream)
195 +static int snd_card_bt_sco_capture_close(struct snd_pcm_substream * substream)
197 - snd_pcm_runtime_t *runtime = substream->runtime;
198 + struct snd_pcm_runtime *runtime = substream->runtime;
199 struct snd_card_bt_sco *bt_sco =
200 (struct snd_card_bt_sco *)substream->private_data;
206 -static snd_pcm_ops_t snd_card_bt_sco_playback_ops = {
207 +static struct snd_pcm_ops snd_card_bt_sco_playback_ops = {
208 .open = snd_card_bt_sco_playback_open,
209 .close = snd_card_bt_sco_playback_close,
210 .ioctl = snd_pcm_lib_ioctl,
212 .pointer = snd_card_bt_sco_playback_pointer,
215 -static snd_pcm_ops_t snd_card_bt_sco_capture_ops = {
216 +static struct snd_pcm_ops snd_card_bt_sco_capture_ops = {
217 .open = snd_card_bt_sco_capture_open,
218 .close = snd_card_bt_sco_capture_close,
219 .ioctl = snd_pcm_lib_ioctl,
222 static int __init snd_card_bt_sco_pcm(snd_card_bt_sco_t * bt_sco)
225 + struct snd_pcm *pcm;
230 .get = snd_bt_sco_volume_get, .put = snd_bt_sco_volume_put, \
231 .private_value = addr }
233 -static int snd_bt_sco_volume_info(snd_kcontrol_t * kcontrol,
234 - snd_ctl_elem_info_t * uinfo)
235 +static int snd_bt_sco_volume_info(struct snd_kcontrol * kcontrol,
236 + struct snd_ctl_elem_info * uinfo)
238 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
244 -static int snd_bt_sco_volume_get(snd_kcontrol_t * kcontrol,
245 - snd_ctl_elem_value_t * ucontrol)
246 +static int snd_bt_sco_volume_get(struct snd_kcontrol * kcontrol,
247 + struct snd_ctl_elem_value * ucontrol)
249 snd_card_bt_sco_t *bt_sco = snd_kcontrol_chip(kcontrol);
255 -static int snd_bt_sco_volume_put(snd_kcontrol_t * kcontrol,
256 - snd_ctl_elem_value_t * ucontrol)
257 +static int snd_bt_sco_volume_put(struct snd_kcontrol * kcontrol,
258 + struct snd_ctl_elem_value * ucontrol)
260 snd_card_bt_sco_t *bt_sco = snd_kcontrol_chip(kcontrol);
266 -static int snd_bt_sco_boolean_info(snd_kcontrol_t * kcontrol,
267 - snd_ctl_elem_info_t * uinfo)
268 +static int snd_bt_sco_boolean_info(struct snd_kcontrol * kcontrol,
269 + struct snd_ctl_elem_info * uinfo)
271 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
277 -static int snd_bt_sco_loopback_get(snd_kcontrol_t * kcontrol,
278 - snd_ctl_elem_value_t * ucontrol)
279 +static int snd_bt_sco_loopback_get(struct snd_kcontrol * kcontrol,
280 + struct snd_ctl_elem_value * ucontrol)
282 snd_card_bt_sco_t *bt_sco = snd_kcontrol_chip(kcontrol);
288 -static int snd_bt_sco_loopback_put(snd_kcontrol_t * kcontrol,
289 - snd_ctl_elem_value_t * ucontrol)
290 +static int snd_bt_sco_loopback_put(struct snd_kcontrol * kcontrol,
291 + struct snd_ctl_elem_value * ucontrol)
293 snd_card_bt_sco_t *bt_sco = snd_kcontrol_chip(kcontrol);
298 #ifdef DYNAMIC_COMPRESSION
299 -static int snd_bt_sco_agc_get(snd_kcontrol_t * kcontrol,
300 - snd_ctl_elem_value_t * ucontrol)
301 +static int snd_bt_sco_agc_get(struct snd_kcontrol * kcontrol,
302 + struct snd_ctl_elem_value * ucontrol)
304 snd_card_bt_sco_t *bt_sco = snd_kcontrol_chip(kcontrol);
310 -static int snd_bt_sco_agc_put(snd_kcontrol_t * kcontrol,
311 - snd_ctl_elem_value_t * ucontrol)
312 +static int snd_bt_sco_agc_put(struct snd_kcontrol * kcontrol,
313 + struct snd_ctl_elem_value * ucontrol)
315 snd_card_bt_sco_t *bt_sco = snd_kcontrol_chip(kcontrol);
321 -#define BT_SCO_CONTROLS (sizeof(snd_bt_sco_controls)/sizeof(snd_kcontrol_new_t))
322 +#define BT_SCO_CONTROLS (sizeof(snd_bt_sco_controls)/sizeof(struct snd_kcontrol_new))
324 -static snd_kcontrol_new_t snd_bt_sco_controls[] = {
325 +static struct snd_kcontrol_new snd_bt_sco_controls[] = {
326 BT_SCO_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
327 BT_SCO_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
328 {.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
331 int __init snd_card_bt_sco_new_mixer(snd_card_bt_sco_t * bt_sco)
333 - snd_card_t *card = bt_sco->card;
334 + struct snd_card *card = bt_sco->card;
338 @@ -686,17 +695,17 @@
342 -static int snd_card_bt_open(snd_hwdep_t * hw, struct file *file)
343 +static int snd_card_bt_open(struct snd_hwdep * hw, struct file *file)
348 -static int snd_card_bt_release(snd_hwdep_t * hw, struct file *file)
349 +static int snd_card_bt_release(struct snd_hwdep * hw, struct file *file)
354 -static int snd_card_bt_ioctl(snd_hwdep_t * hw, struct file *file,
355 +static int snd_card_bt_ioctl(struct snd_hwdep * hw, struct file *file,
356 unsigned int cmd, unsigned long arg)
358 snd_card_bt_sco_t *bt_sco = hw->card->private_data;
363 -static long snd_card_bt_write(snd_hwdep_t * hw, const char *buf, long count,
364 +static long snd_card_bt_write(struct snd_hwdep * hw, const char *buf, long count,
367 snd_card_bt_sco_t *bt_sco = hw->card->private_data;
372 -static long snd_card_bt_read(snd_hwdep_t * hw, char *buf, long count,
373 +static long snd_card_bt_read(struct snd_hwdep * hw, char *buf, long count,
376 snd_card_bt_sco_t *bt_sco = hw->card->private_data;
381 -static unsigned int snd_card_bt_poll(snd_hwdep_t * hw,
382 +static unsigned int snd_card_bt_poll(struct snd_hwdep * hw,
383 struct file *file, poll_table * wait)
385 snd_card_bt_sco_t *bt_sco = hw->card->private_data;
388 static int snd_card_bt_sco_thread(void *data)
390 - snd_card_t *card = (snd_card_t *) data;
391 + struct snd_card *card = (struct snd_card *) data;
392 snd_card_bt_sco_t *bt_sco = card->private_data;
395 @@ -1117,7 +1126,7 @@
396 complete_and_exit(&bt_sco->thread_done, 0);
399 -static void snd_card_bt_private_free(snd_card_t * card)
400 +static void snd_card_bt_private_free(struct snd_card * card)
402 snd_card_bt_sco_t *bt_sco = card->private_data;
404 @@ -1139,10 +1148,10 @@
406 static int __init snd_card_bt_sco_probe(int dev)
409 + struct snd_card *card;
410 snd_card_bt_sco_t *bt_sco;
413 + struct snd_hwdep *hw;
416 snd_card_new(index[dev], SNDRV_DEFAULT_STR1,