aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 13:13:38 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 13:13:38 -0400
commitfc8a327db6c46de783b1a4276d846841b9abc24c (patch)
treebee512c142cccea93511debd98ef954581693727 /sound/core
parent92d15c2ccbb3e31a3fc71ad28fdb55e1319383c0 (diff)
parent24837e6f249a2c83667552e6871c1543b4a6b934 (diff)
Merge branch 'linus' of master.kernel.org:/pub/scm/linux/kernel/git/perex/alsa
* 'linus' of master.kernel.org:/pub/scm/linux/kernel/git/perex/alsa: (264 commits) [ALSA] version 1.0.15 [ALSA] Fix thinko in cs4231 mce down check [ALSA] sun-cs4231: improved waiting after MCE down [ALSA] sun-cs4231: use cs4231-regs.h [ALSA] This simplifies and fixes waiting loops of the mce_down() [ALSA] This patch adds support for a wavetable chip on [ALSA] This patch removes open_mutex from the ad1848-lib as [ALSA] fix bootup crash in snd_gus_interrupt() [ALSA] hda-codec - Fix SKU ID function for realtek codecs [ALSA] Support ASUS P701 eeepc [0x1043 0x82a1] support [ALSA] hda-codec - Add array terminator for dmic in STAC codec [ALSA] hdsp - Fix zero division [ALSA] usb-audio - Fix double comment [ALSA] hda-codec - Fix STAC922x volume knob control [ALSA] Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz [ALSA] hda-codec - Fix for Fujitsu Lifebook C1410 [ALSA] mpu-401: remove MPU401_INFO_UART_ONLY flag [ALSA] mpu-401: do not require an ACK byte for the ENTER_UART command [ALSA] via82xx - Add DXS quirk for Shuttle AK31v2 [ALSA] hda-codec - Fix input_mux numbers for vaio stac92xx ...
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/Makefile15
-rw-r--r--sound/core/control.c33
-rw-r--r--sound/core/device.c2
-rw-r--r--sound/core/hwdep.c4
-rw-r--r--sound/core/info.c2
-rw-r--r--sound/core/info_oss.c2
-rw-r--r--sound/core/init.c2
-rw-r--r--sound/core/isadma.c2
-rw-r--r--sound/core/memalloc.c10
-rw-r--r--sound/core/memory.c2
-rw-r--r--sound/core/misc.c2
-rw-r--r--sound/core/oss/Makefile7
-rw-r--r--sound/core/oss/copy.c5
-rw-r--r--sound/core/oss/io.c7
-rw-r--r--sound/core/oss/linear.c91
-rw-r--r--sound/core/oss/mixer_oss.c4
-rw-r--r--sound/core/oss/mulaw.c90
-rw-r--r--sound/core/oss/pcm_oss.c39
-rw-r--r--sound/core/oss/pcm_plugin.c63
-rw-r--r--sound/core/oss/pcm_plugin.h2
-rw-r--r--sound/core/oss/plugin_ops.h370
-rw-r--r--sound/core/oss/rate.c7
-rw-r--r--sound/core/oss/route.c5
-rw-r--r--sound/core/pcm.c4
-rw-r--r--sound/core/pcm_lib.c2
-rw-r--r--sound/core/pcm_memory.c2
-rw-r--r--sound/core/pcm_misc.c65
-rw-r--r--sound/core/pcm_native.c10
-rw-r--r--sound/core/pcm_timer.c2
-rw-r--r--sound/core/rawmidi.c5
-rw-r--r--sound/core/seq/Makefile2
-rw-r--r--sound/core/seq/instr/Makefile2
-rw-r--r--sound/core/seq/instr/ainstr_gf1.c4
-rw-r--r--sound/core/seq/instr/ainstr_iw.c4
-rw-r--r--sound/core/seq/instr/ainstr_simple.c4
-rw-r--r--sound/core/seq/oss/Makefile2
-rw-r--r--sound/core/seq/oss/seq_oss_init.c40
-rw-r--r--sound/core/seq/oss/seq_oss_writeq.c6
-rw-r--r--sound/core/seq/seq.c2
-rw-r--r--sound/core/seq/seq_clientmgr.c2
-rw-r--r--sound/core/seq/seq_instr.c14
-rw-r--r--sound/core/seq/seq_memory.c2
-rw-r--r--sound/core/seq/seq_midi.c4
-rw-r--r--sound/core/seq/seq_midi_event.c101
-rw-r--r--sound/core/seq/seq_ports.c2
-rw-r--r--sound/core/seq/seq_timer.c2
-rw-r--r--sound/core/sound.c12
-rw-r--r--sound/core/sound_oss.c2
-rw-r--r--sound/core/timer.c4
49 files changed, 382 insertions, 685 deletions
diff --git a/sound/core/Makefile b/sound/core/Makefile
index 5a01c76d02e8..267039a97bd5 100644
--- a/sound/core/Makefile
+++ b/sound/core/Makefile
@@ -1,20 +1,17 @@
1# 1#
2# Makefile for ALSA 2# Makefile for ALSA
3# Copyright (c) 1999,2001 by Jaroslav Kysela <perex@suse.cz> 3# Copyright (c) 1999,2001 by Jaroslav Kysela <perex@perex.cz>
4# 4#
5 5
6snd-objs := sound.o init.o memory.o info.o control.o misc.o device.o 6snd-y := sound.o init.o memory.o info.o control.o misc.o device.o
7ifeq ($(CONFIG_ISA_DMA_API),y) 7snd-$(CONFIG_ISA_DMA_API) += isadma.o
8snd-objs += isadma.o 8snd-$(CONFIG_SND_OSSEMUL) += sound_oss.o info_oss.o
9endif
10ifeq ($(CONFIG_SND_OSSEMUL),y)
11snd-objs += sound_oss.o info_oss.o
12endif
13 9
14snd-pcm-objs := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \ 10snd-pcm-objs := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \
15 pcm_memory.o 11 pcm_memory.o
16 12
17snd-page-alloc-objs := memalloc.o sgbuf.o 13snd-page-alloc-y := memalloc.o
14snd-page-alloc-$(CONFIG_HAS_DMA) += sgbuf.o
18 15
19snd-rawmidi-objs := rawmidi.o 16snd-rawmidi-objs := rawmidi.o
20snd-timer-objs := timer.o 17snd-timer-objs := timer.o
diff --git a/sound/core/control.c b/sound/core/control.c
index 1f1ab9c1b668..4c3aa8e10378 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Routines for driver control interface 2 * Routines for driver control interface
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
@@ -716,8 +716,6 @@ int snd_ctl_elem_read(struct snd_card *card, struct snd_ctl_elem_value *control)
716 return result; 716 return result;
717} 717}
718 718
719EXPORT_SYMBOL(snd_ctl_elem_read);
720
721static int snd_ctl_elem_read_user(struct snd_card *card, 719static int snd_ctl_elem_read_user(struct snd_card *card,
722 struct snd_ctl_elem_value __user *_control) 720 struct snd_ctl_elem_value __user *_control)
723{ 721{
@@ -781,8 +779,6 @@ int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file,
781 return result; 779 return result;
782} 780}
783 781
784EXPORT_SYMBOL(snd_ctl_elem_write);
785
786static int snd_ctl_elem_write_user(struct snd_ctl_file *file, 782static int snd_ctl_elem_write_user(struct snd_ctl_file *file,
787 struct snd_ctl_elem_value __user *_control) 783 struct snd_ctl_elem_value __user *_control)
788{ 784{
@@ -1486,3 +1482,30 @@ int snd_ctl_create(struct snd_card *card)
1486 snd_assert(card != NULL, return -ENXIO); 1482 snd_assert(card != NULL, return -ENXIO);
1487 return snd_device_new(card, SNDRV_DEV_CONTROL, card, &ops); 1483 return snd_device_new(card, SNDRV_DEV_CONTROL, card, &ops);
1488} 1484}
1485
1486/*
1487 * Frequently used control callbacks
1488 */
1489int snd_ctl_boolean_mono_info(struct snd_kcontrol *kcontrol,
1490 struct snd_ctl_elem_info *uinfo)
1491{
1492 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1493 uinfo->count = 1;
1494 uinfo->value.integer.min = 0;
1495 uinfo->value.integer.max = 1;
1496 return 0;
1497}
1498
1499EXPORT_SYMBOL(snd_ctl_boolean_mono_info);
1500
1501int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol,
1502 struct snd_ctl_elem_info *uinfo)
1503{
1504 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1505 uinfo->count = 2;
1506 uinfo->value.integer.min = 0;
1507 uinfo->value.integer.max = 1;
1508 return 0;
1509}
1510
1511EXPORT_SYMBOL(snd_ctl_boolean_stereo_info);
diff --git a/sound/core/device.c b/sound/core/device.c
index 5858b02b0b1d..ea1a0621eefb 100644
--- a/sound/core/device.c
+++ b/sound/core/device.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Device management routines 2 * Device management routines
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index 51ad95b7c894..bfd9d182b8a3 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Hardware dependent layer 2 * Hardware dependent layer
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
@@ -31,7 +31,7 @@
31#include <sound/hwdep.h> 31#include <sound/hwdep.h>
32#include <sound/info.h> 32#include <sound/info.h>
33 33
34MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 34MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
35MODULE_DESCRIPTION("Hardware dependent layer"); 35MODULE_DESCRIPTION("Hardware dependent layer");
36MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
37 37
diff --git a/sound/core/info.c b/sound/core/info.c
index bf6dbf99528b..1ffd29bb4cd0 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Information interface for ALSA driver 2 * Information interface for ALSA driver
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
diff --git a/sound/core/info_oss.c b/sound/core/info_oss.c
index a444bfe2cf74..435c9399f7a9 100644
--- a/sound/core/info_oss.c
+++ b/sound/core/info_oss.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Information interface for ALSA driver 2 * Information interface for ALSA driver
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
diff --git a/sound/core/init.c b/sound/core/init.c
index f2fe35737186..2cb7099eb1e1 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Initialization routines 2 * Initialization routines
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
diff --git a/sound/core/isadma.c b/sound/core/isadma.c
index d52398727f0a..eb173cef4f05 100644
--- a/sound/core/isadma.c
+++ b/sound/core/isadma.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * ISA DMA support functions 2 * ISA DMA support functions
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c
index 9b5656d8bcca..9b4992eab479 100644
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 2 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
3 * Takashi Iwai <tiwai@suse.de> 3 * Takashi Iwai <tiwai@suse.de>
4 * 4 *
5 * Generic memory allocators 5 * Generic memory allocators
@@ -38,7 +38,7 @@
38#endif 38#endif
39 39
40 40
41MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@suse.cz>"); 41MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@perex.cz>");
42MODULE_DESCRIPTION("Memory allocator for ALSA system."); 42MODULE_DESCRIPTION("Memory allocator for ALSA system.");
43MODULE_LICENSE("GPL"); 43MODULE_LICENSE("GPL");
44 44
@@ -206,6 +206,7 @@ void snd_free_pages(void *ptr, size_t size)
206 * 206 *
207 */ 207 */
208 208
209#ifdef CONFIG_HAS_DMA
209/* allocate the coherent DMA pages */ 210/* allocate the coherent DMA pages */
210static void *snd_malloc_dev_pages(struct device *dev, size_t size, dma_addr_t *dma) 211static void *snd_malloc_dev_pages(struct device *dev, size_t size, dma_addr_t *dma)
211{ 212{
@@ -239,6 +240,7 @@ static void snd_free_dev_pages(struct device *dev, size_t size, void *ptr,
239 dec_snd_pages(pg); 240 dec_snd_pages(pg);
240 dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma); 241 dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma);
241} 242}
243#endif /* CONFIG_HAS_DMA */
242 244
243#ifdef CONFIG_SBUS 245#ifdef CONFIG_SBUS
244 246
@@ -312,12 +314,14 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size,
312 dmab->area = snd_malloc_sbus_pages(device, size, &dmab->addr); 314 dmab->area = snd_malloc_sbus_pages(device, size, &dmab->addr);
313 break; 315 break;
314#endif 316#endif
317#ifdef CONFIG_HAS_DMA
315 case SNDRV_DMA_TYPE_DEV: 318 case SNDRV_DMA_TYPE_DEV:
316 dmab->area = snd_malloc_dev_pages(device, size, &dmab->addr); 319 dmab->area = snd_malloc_dev_pages(device, size, &dmab->addr);
317 break; 320 break;
318 case SNDRV_DMA_TYPE_DEV_SG: 321 case SNDRV_DMA_TYPE_DEV_SG:
319 snd_malloc_sgbuf_pages(device, size, dmab, NULL); 322 snd_malloc_sgbuf_pages(device, size, dmab, NULL);
320 break; 323 break;
324#endif
321 default: 325 default:
322 printk(KERN_ERR "snd-malloc: invalid device type %d\n", type); 326 printk(KERN_ERR "snd-malloc: invalid device type %d\n", type);
323 dmab->area = NULL; 327 dmab->area = NULL;
@@ -383,12 +387,14 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab)
383 snd_free_sbus_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr); 387 snd_free_sbus_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr);
384 break; 388 break;
385#endif 389#endif
390#ifdef CONFIG_HAS_DMA
386 case SNDRV_DMA_TYPE_DEV: 391 case SNDRV_DMA_TYPE_DEV:
387 snd_free_dev_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr); 392 snd_free_dev_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr);
388 break; 393 break;
389 case SNDRV_DMA_TYPE_DEV_SG: 394 case SNDRV_DMA_TYPE_DEV_SG:
390 snd_free_sgbuf_pages(dmab); 395 snd_free_sgbuf_pages(dmab);
391 break; 396 break;
397#endif
392 default: 398 default:
393 printk(KERN_ERR "snd-malloc: invalid device type %d\n", dmab->dev.type); 399 printk(KERN_ERR "snd-malloc: invalid device type %d\n", dmab->dev.type);
394 } 400 }
diff --git a/sound/core/memory.c b/sound/core/memory.c
index 93537ab7c2ac..25b0f056563e 100644
--- a/sound/core/memory.c
+++ b/sound/core/memory.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 2 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
3 * 3 *
4 * Misc memory accessors 4 * Misc memory accessors
5 * 5 *
diff --git a/sound/core/misc.c b/sound/core/misc.c
index f78cd000e88d..6cabab8cc537 100644
--- a/sound/core/misc.c
+++ b/sound/core/misc.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Misc and compatibility things 2 * Misc and compatibility things
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
diff --git a/sound/core/oss/Makefile b/sound/core/oss/Makefile
index e6d5a045ba27..10a79453245f 100644
--- a/sound/core/oss/Makefile
+++ b/sound/core/oss/Makefile
@@ -1,12 +1,13 @@
1# 1#
2# Makefile for ALSA 2# Makefile for ALSA
3# Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz> 3# Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>
4# 4#
5 5
6snd-mixer-oss-objs := mixer_oss.o 6snd-mixer-oss-objs := mixer_oss.o
7 7
8snd-pcm-oss-objs := pcm_oss.o pcm_plugin.o \ 8snd-pcm-oss-y := pcm_oss.o
9 io.o copy.o linear.o mulaw.o route.o rate.o 9snd-pcm-oss-$(CONFIG_SND_PCM_OSS_PLUGINS) += pcm_plugin.o \
10 io.o copy.o linear.o mulaw.o route.o rate.o
10 11
11obj-$(CONFIG_SND_MIXER_OSS) += snd-mixer-oss.o 12obj-$(CONFIG_SND_MIXER_OSS) += snd-mixer-oss.o
12obj-$(CONFIG_SND_PCM_OSS) += snd-pcm-oss.o 13obj-$(CONFIG_SND_PCM_OSS) += snd-pcm-oss.o
diff --git a/sound/core/oss/copy.c b/sound/core/oss/copy.c
index 6658facc5cda..d6a04c2d5a75 100644
--- a/sound/core/oss/copy.c
+++ b/sound/core/oss/copy.c
@@ -20,9 +20,6 @@
20 */ 20 */
21 21
22#include <sound/driver.h> 22#include <sound/driver.h>
23
24#ifdef CONFIG_SND_PCM_OSS_PLUGINS
25
26#include <linux/time.h> 23#include <linux/time.h>
27#include <sound/core.h> 24#include <sound/core.h>
28#include <sound/pcm.h> 25#include <sound/pcm.h>
@@ -88,5 +85,3 @@ int snd_pcm_plugin_build_copy(struct snd_pcm_substream *plug,
88 *r_plugin = plugin; 85 *r_plugin = plugin;
89 return 0; 86 return 0;
90} 87}
91
92#endif
diff --git a/sound/core/oss/io.c b/sound/core/oss/io.c
index b6e7ce30e5a3..3ece39fc48db 100644
--- a/sound/core/oss/io.c
+++ b/sound/core/oss/io.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * PCM I/O Plug-In Interface 2 * PCM I/O Plug-In Interface
3 * Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This library is free software; you can redistribute it and/or modify 6 * This library is free software; you can redistribute it and/or modify
@@ -20,9 +20,6 @@
20 */ 20 */
21 21
22#include <sound/driver.h> 22#include <sound/driver.h>
23
24#ifdef CONFIG_SND_PCM_OSS_PLUGINS
25
26#include <linux/time.h> 23#include <linux/time.h>
27#include <sound/core.h> 24#include <sound/core.h>
28#include <sound/pcm.h> 25#include <sound/pcm.h>
@@ -135,5 +132,3 @@ int snd_pcm_plugin_build_io(struct snd_pcm_substream *plug,
135 *r_plugin = plugin; 132 *r_plugin = plugin;
136 return 0; 133 return 0;
137} 134}
138
139#endif
diff --git a/sound/core/oss/linear.c b/sound/core/oss/linear.c
index 5b1bcdc64779..06f96a3e86f6 100644
--- a/sound/core/oss/linear.c
+++ b/sound/core/oss/linear.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Linear conversion Plug-In 2 * Linear conversion Plug-In
3 * Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>, 3 * Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>,
4 * Abramo Bagnara <abramo@alsa-project.org> 4 * Abramo Bagnara <abramo@alsa-project.org>
5 * 5 *
6 * 6 *
@@ -21,9 +21,6 @@
21 */ 21 */
22 22
23#include <sound/driver.h> 23#include <sound/driver.h>
24
25#ifdef CONFIG_SND_PCM_OSS_PLUGINS
26
27#include <linux/time.h> 24#include <linux/time.h>
28#include <sound/core.h> 25#include <sound/core.h>
29#include <sound/pcm.h> 26#include <sound/pcm.h>
@@ -34,19 +31,34 @@
34 */ 31 */
35 32
36struct linear_priv { 33struct linear_priv {
37 int conv; 34 int cvt_endian; /* need endian conversion? */
35 unsigned int src_ofs; /* byte offset in source format */
36 unsigned int dst_ofs; /* byte soffset in destination format */
37 unsigned int copy_ofs; /* byte offset in temporary u32 data */
38 unsigned int dst_bytes; /* byte size of destination format */
39 unsigned int copy_bytes; /* bytes to copy per conversion */
40 unsigned int flip; /* MSB flip for signeness, done after endian conv */
38}; 41};
39 42
43static inline void do_convert(struct linear_priv *data,
44 unsigned char *dst, unsigned char *src)
45{
46 unsigned int tmp = 0;
47 unsigned char *p = (unsigned char *)&tmp;
48
49 memcpy(p + data->copy_ofs, src + data->src_ofs, data->copy_bytes);
50 if (data->cvt_endian)
51 tmp = swab32(tmp);
52 tmp ^= data->flip;
53 memcpy(dst, p + data->dst_ofs, data->dst_bytes);
54}
55
40static void convert(struct snd_pcm_plugin *plugin, 56static void convert(struct snd_pcm_plugin *plugin,
41 const struct snd_pcm_plugin_channel *src_channels, 57 const struct snd_pcm_plugin_channel *src_channels,
42 struct snd_pcm_plugin_channel *dst_channels, 58 struct snd_pcm_plugin_channel *dst_channels,
43 snd_pcm_uframes_t frames) 59 snd_pcm_uframes_t frames)
44{ 60{
45#define CONV_LABELS
46#include "plugin_ops.h"
47#undef CONV_LABELS
48 struct linear_priv *data = (struct linear_priv *)plugin->extra_data; 61 struct linear_priv *data = (struct linear_priv *)plugin->extra_data;
49 void *conv = conv_labels[data->conv];
50 int channel; 62 int channel;
51 int nchannels = plugin->src_format.channels; 63 int nchannels = plugin->src_format.channels;
52 for (channel = 0; channel < nchannels; ++channel) { 64 for (channel = 0; channel < nchannels; ++channel) {
@@ -67,11 +79,7 @@ static void convert(struct snd_pcm_plugin *plugin,
67 dst_step = dst_channels[channel].area.step / 8; 79 dst_step = dst_channels[channel].area.step / 8;
68 frames1 = frames; 80 frames1 = frames;
69 while (frames1-- > 0) { 81 while (frames1-- > 0) {
70 goto *conv; 82 do_convert(data, dst, src);
71#define CONV_END after
72#include "plugin_ops.h"
73#undef CONV_END
74 after:
75 src += src_step; 83 src += src_step;
76 dst += dst_step; 84 dst += dst_step;
77 } 85 }
@@ -106,29 +114,36 @@ static snd_pcm_sframes_t linear_transfer(struct snd_pcm_plugin *plugin,
106 return frames; 114 return frames;
107} 115}
108 116
109static int conv_index(int src_format, int dst_format) 117static void init_data(struct linear_priv *data, int src_format, int dst_format)
110{ 118{
111 int src_endian, dst_endian, sign, src_width, dst_width; 119 int src_le, dst_le, src_bytes, dst_bytes;
112 120
113 sign = (snd_pcm_format_signed(src_format) != 121 src_bytes = snd_pcm_format_width(src_format) / 8;
114 snd_pcm_format_signed(dst_format)); 122 dst_bytes = snd_pcm_format_width(dst_format) / 8;
115#ifdef SNDRV_LITTLE_ENDIAN 123 src_le = snd_pcm_format_little_endian(src_format) > 0;
116 src_endian = snd_pcm_format_big_endian(src_format); 124 dst_le = snd_pcm_format_little_endian(dst_format) > 0;
117 dst_endian = snd_pcm_format_big_endian(dst_format); 125
118#else 126 data->dst_bytes = dst_bytes;
119 src_endian = snd_pcm_format_little_endian(src_format); 127 data->cvt_endian = src_le != dst_le;
120 dst_endian = snd_pcm_format_little_endian(dst_format); 128 data->copy_bytes = src_bytes < dst_bytes ? src_bytes : dst_bytes;
121#endif 129 if (src_le) {
122 130 data->copy_ofs = 4 - data->copy_bytes;
123 if (src_endian < 0) 131 data->src_ofs = src_bytes - data->copy_bytes;
124 src_endian = 0; 132 } else
125 if (dst_endian < 0) 133 data->src_ofs = snd_pcm_format_physical_width(src_format) / 8 -
126 dst_endian = 0; 134 src_bytes;
127 135 if (dst_le)
128 src_width = snd_pcm_format_width(src_format) / 8 - 1; 136 data->dst_ofs = 4 - data->dst_bytes;
129 dst_width = snd_pcm_format_width(dst_format) / 8 - 1; 137 else
130 138 data->dst_ofs = snd_pcm_format_physical_width(dst_format) / 8 -
131 return src_width * 32 + src_endian * 16 + sign * 8 + dst_width * 2 + dst_endian; 139 dst_bytes;
140 if (snd_pcm_format_signed(src_format) !=
141 snd_pcm_format_signed(dst_format)) {
142 if (dst_le)
143 data->flip = cpu_to_le32(0x80000000);
144 else
145 data->flip = cpu_to_be32(0x80000000);
146 }
132} 147}
133 148
134int snd_pcm_plugin_build_linear(struct snd_pcm_substream *plug, 149int snd_pcm_plugin_build_linear(struct snd_pcm_substream *plug,
@@ -154,10 +169,8 @@ int snd_pcm_plugin_build_linear(struct snd_pcm_substream *plug,
154 if (err < 0) 169 if (err < 0)
155 return err; 170 return err;
156 data = (struct linear_priv *)plugin->extra_data; 171 data = (struct linear_priv *)plugin->extra_data;
157 data->conv = conv_index(src_format->format, dst_format->format); 172 init_data(data, src_format->format, dst_format->format);
158 plugin->transfer = linear_transfer; 173 plugin->transfer = linear_transfer;
159 *r_plugin = plugin; 174 *r_plugin = plugin;
160 return 0; 175 return 0;
161} 176}
162
163#endif
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index fccad8f0a6bb..3ace4a5680ba 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * OSS emulation layer for the mixer interface 2 * OSS emulation layer for the mixer interface
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
@@ -33,7 +33,7 @@
33 33
34#define OSS_ALSAEMULVER _SIOR ('M', 249, int) 34#define OSS_ALSAEMULVER _SIOR ('M', 249, int)
35 35
36MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 36MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
37MODULE_DESCRIPTION("Mixer OSS emulation for ALSA."); 37MODULE_DESCRIPTION("Mixer OSS emulation for ALSA.");
38MODULE_LICENSE("GPL"); 38MODULE_LICENSE("GPL");
39MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_MIXER); 39MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_MIXER);
diff --git a/sound/core/oss/mulaw.c b/sound/core/oss/mulaw.c
index 2eb18807e6d0..848db82529ed 100644
--- a/sound/core/oss/mulaw.c
+++ b/sound/core/oss/mulaw.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Mu-Law conversion Plug-In Interface 2 * Mu-Law conversion Plug-In Interface
3 * Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>
4 * Uros Bizjak <uros@kss-loka.si> 4 * Uros Bizjak <uros@kss-loka.si>
5 * 5 *
6 * Based on reference implementation by Sun Microsystems, Inc. 6 * Based on reference implementation by Sun Microsystems, Inc.
@@ -22,9 +22,6 @@
22 */ 22 */
23 23
24#include <sound/driver.h> 24#include <sound/driver.h>
25
26#ifdef CONFIG_SND_PCM_OSS_PLUGINS
27
28#include <linux/time.h> 25#include <linux/time.h>
29#include <sound/core.h> 26#include <sound/core.h>
30#include <sound/pcm.h> 27#include <sound/pcm.h>
@@ -149,19 +146,32 @@ typedef void (*mulaw_f)(struct snd_pcm_plugin *plugin,
149 146
150struct mulaw_priv { 147struct mulaw_priv {
151 mulaw_f func; 148 mulaw_f func;
152 int conv; 149 int cvt_endian; /* need endian conversion? */
150 unsigned int native_ofs; /* byte offset in native format */
151 unsigned int copy_ofs; /* byte offset in s16 format */
152 unsigned int native_bytes; /* byte size of the native format */
153 unsigned int copy_bytes; /* bytes to copy per conversion */
154 u16 flip; /* MSB flip for signedness, done after endian conversion */
153}; 155};
154 156
157static inline void cvt_s16_to_native(struct mulaw_priv *data,
158 unsigned char *dst, u16 sample)
159{
160 sample ^= data->flip;
161 if (data->cvt_endian)
162 sample = swab16(sample);
163 if (data->native_bytes > data->copy_bytes)
164 memset(dst, 0, data->native_bytes);
165 memcpy(dst + data->native_ofs, (char *)&sample + data->copy_ofs,
166 data->copy_bytes);
167}
168
155static void mulaw_decode(struct snd_pcm_plugin *plugin, 169static void mulaw_decode(struct snd_pcm_plugin *plugin,
156 const struct snd_pcm_plugin_channel *src_channels, 170 const struct snd_pcm_plugin_channel *src_channels,
157 struct snd_pcm_plugin_channel *dst_channels, 171 struct snd_pcm_plugin_channel *dst_channels,
158 snd_pcm_uframes_t frames) 172 snd_pcm_uframes_t frames)
159{ 173{
160#define PUT_S16_LABELS
161#include "plugin_ops.h"
162#undef PUT_S16_LABELS
163 struct mulaw_priv *data = (struct mulaw_priv *)plugin->extra_data; 174 struct mulaw_priv *data = (struct mulaw_priv *)plugin->extra_data;
164 void *put = put_s16_labels[data->conv];
165 int channel; 175 int channel;
166 int nchannels = plugin->src_format.channels; 176 int nchannels = plugin->src_format.channels;
167 for (channel = 0; channel < nchannels; ++channel) { 177 for (channel = 0; channel < nchannels; ++channel) {
@@ -183,30 +193,33 @@ static void mulaw_decode(struct snd_pcm_plugin *plugin,
183 frames1 = frames; 193 frames1 = frames;
184 while (frames1-- > 0) { 194 while (frames1-- > 0) {
185 signed short sample = ulaw2linear(*src); 195 signed short sample = ulaw2linear(*src);
186 goto *put; 196 cvt_s16_to_native(data, dst, sample);
187#define PUT_S16_END after
188#include "plugin_ops.h"
189#undef PUT_S16_END
190 after:
191 src += src_step; 197 src += src_step;
192 dst += dst_step; 198 dst += dst_step;
193 } 199 }
194 } 200 }
195} 201}
196 202
203static inline signed short cvt_native_to_s16(struct mulaw_priv *data,
204 unsigned char *src)
205{
206 u16 sample = 0;
207 memcpy((char *)&sample + data->copy_ofs, src + data->native_ofs,
208 data->copy_bytes);
209 if (data->cvt_endian)
210 sample = swab16(sample);
211 sample ^= data->flip;
212 return (signed short)sample;
213}
214
197static void mulaw_encode(struct snd_pcm_plugin *plugin, 215static void mulaw_encode(struct snd_pcm_plugin *plugin,
198 const struct snd_pcm_plugin_channel *src_channels, 216 const struct snd_pcm_plugin_channel *src_channels,
199 struct snd_pcm_plugin_channel *dst_channels, 217 struct snd_pcm_plugin_channel *dst_channels,
200 snd_pcm_uframes_t frames) 218 snd_pcm_uframes_t frames)
201{ 219{
202#define GET_S16_LABELS
203#include "plugin_ops.h"
204#undef GET_S16_LABELS
205 struct mulaw_priv *data = (struct mulaw_priv *)plugin->extra_data; 220 struct mulaw_priv *data = (struct mulaw_priv *)plugin->extra_data;
206 void *get = get_s16_labels[data->conv];
207 int channel; 221 int channel;
208 int nchannels = plugin->src_format.channels; 222 int nchannels = plugin->src_format.channels;
209 signed short sample = 0;
210 for (channel = 0; channel < nchannels; ++channel) { 223 for (channel = 0; channel < nchannels; ++channel) {
211 char *src; 224 char *src;
212 char *dst; 225 char *dst;
@@ -225,11 +238,7 @@ static void mulaw_encode(struct snd_pcm_plugin *plugin,
225 dst_step = dst_channels[channel].area.step / 8; 238 dst_step = dst_channels[channel].area.step / 8;
226 frames1 = frames; 239 frames1 = frames;
227 while (frames1-- > 0) { 240 while (frames1-- > 0) {
228 goto *get; 241 signed short sample = cvt_native_to_s16(data, src);
229#define GET_S16_END after
230#include "plugin_ops.h"
231#undef GET_S16_END
232 after:
233 *dst = linear2ulaw(sample); 242 *dst = linear2ulaw(sample);
234 src += src_step; 243 src += src_step;
235 dst += dst_step; 244 dst += dst_step;
@@ -265,23 +274,25 @@ static snd_pcm_sframes_t mulaw_transfer(struct snd_pcm_plugin *plugin,
265 return frames; 274 return frames;
266} 275}
267 276
268static int getput_index(int format) 277static void init_data(struct mulaw_priv *data, int format)
269{ 278{
270 int sign, width, endian;
271 sign = !snd_pcm_format_signed(format);
272 width = snd_pcm_format_width(format) / 8 - 1;
273 if (width < 0 || width > 3) {
274 snd_printk(KERN_ERR "snd-pcm-oss: invalid format %d\n", format);
275 width = 0;
276 }
277#ifdef SNDRV_LITTLE_ENDIAN 279#ifdef SNDRV_LITTLE_ENDIAN
278 endian = snd_pcm_format_big_endian(format); 280 data->cvt_endian = snd_pcm_format_big_endian(format) > 0;
279#else 281#else
280 endian = snd_pcm_format_little_endian(format); 282 data->cvt_endian = snd_pcm_format_little_endian(format) > 0;
281#endif 283#endif
282 if (endian < 0) 284 if (!snd_pcm_format_signed(format))
283 endian = 0; 285 data->flip = 0x8000;
284 return width * 4 + endian * 2 + sign; 286 data->native_bytes = snd_pcm_format_physical_width(format) / 8;
287 data->copy_bytes = data->native_bytes < 2 ? 1 : 2;
288 if (snd_pcm_format_little_endian(format)) {
289 data->native_ofs = data->native_bytes - data->copy_bytes;
290 data->copy_ofs = 2 - data->copy_bytes;
291 } else {
292 /* S24 in 4bytes need an 1 byte offset */
293 data->native_ofs = data->native_bytes -
294 snd_pcm_format_width(format) / 8;
295 }
285} 296}
286 297
287int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *plug, 298int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *plug,
@@ -322,11 +333,8 @@ int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *plug,
322 return err; 333 return err;
323 data = (struct mulaw_priv *)plugin->extra_data; 334 data = (struct mulaw_priv *)plugin->extra_data;
324 data->func = func; 335 data->func = func;
325 data->conv = getput_index(format->format); 336 init_data(data, format->format);
326 snd_assert(data->conv >= 0 && data->conv < 4*2*2, return -EINVAL);
327 plugin->transfer = mulaw_transfer; 337 plugin->transfer = mulaw_transfer;
328 *r_plugin = plugin; 338 *r_plugin = plugin;
329 return 0; 339 return 0;
330} 340}
331
332#endif
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index fc11572c48cf..d0c4ceb9f0b4 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Digital Audio (PCM) abstract layer / OSS compatible 2 * Digital Audio (PCM) abstract layer / OSS compatible
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
@@ -48,7 +48,7 @@ static int dsp_map[SNDRV_CARDS];
48static int adsp_map[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1}; 48static int adsp_map[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1};
49static int nonblock_open = 1; 49static int nonblock_open = 1;
50 50
51MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Abramo Bagnara <abramo@alsa-project.org>"); 51MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Abramo Bagnara <abramo@alsa-project.org>");
52MODULE_DESCRIPTION("PCM OSS emulation for ALSA."); 52MODULE_DESCRIPTION("PCM OSS emulation for ALSA.");
53MODULE_LICENSE("GPL"); 53MODULE_LICENSE("GPL");
54module_param_array(dsp_map, int, NULL, 0444); 54module_param_array(dsp_map, int, NULL, 0444);
@@ -633,6 +633,22 @@ static long snd_pcm_alsa_frames(struct snd_pcm_substream *substream, long bytes)
633 return bytes_to_frames(runtime, (buffer_size * bytes) / runtime->oss.buffer_bytes); 633 return bytes_to_frames(runtime, (buffer_size * bytes) / runtime->oss.buffer_bytes);
634} 634}
635 635
636/* define extended formats in the recent OSS versions (if any) */
637/* linear formats */
638#define AFMT_S32_LE 0x00001000
639#define AFMT_S32_BE 0x00002000
640#define AFMT_S24_LE 0x00008000
641#define AFMT_S24_BE 0x00010000
642#define AFMT_S24_PACKED 0x00040000
643
644/* other supported formats */
645#define AFMT_FLOAT 0x00004000
646#define AFMT_SPDIF_RAW 0x00020000
647
648/* unsupported formats */
649#define AFMT_AC3 0x00000400
650#define AFMT_VORBIS 0x00000800
651
636static int snd_pcm_oss_format_from(int format) 652static int snd_pcm_oss_format_from(int format)
637{ 653{
638 switch (format) { 654 switch (format) {
@@ -646,6 +662,13 @@ static int snd_pcm_oss_format_from(int format)
646 case AFMT_U16_LE: return SNDRV_PCM_FORMAT_U16_LE; 662 case AFMT_U16_LE: return SNDRV_PCM_FORMAT_U16_LE;
647 case AFMT_U16_BE: return SNDRV_PCM_FORMAT_U16_BE; 663 case AFMT_U16_BE: return SNDRV_PCM_FORMAT_U16_BE;
648 case AFMT_MPEG: return SNDRV_PCM_FORMAT_MPEG; 664 case AFMT_MPEG: return SNDRV_PCM_FORMAT_MPEG;
665 case AFMT_S32_LE: return SNDRV_PCM_FORMAT_S32_LE;
666 case AFMT_S32_BE: return SNDRV_PCM_FORMAT_S32_BE;
667 case AFMT_S24_LE: return SNDRV_PCM_FORMAT_S24_LE;
668 case AFMT_S24_BE: return SNDRV_PCM_FORMAT_S24_BE;
669 case AFMT_S24_PACKED: return SNDRV_PCM_FORMAT_S24_3LE;
670 case AFMT_FLOAT: return SNDRV_PCM_FORMAT_FLOAT;
671 case AFMT_SPDIF_RAW: return SNDRV_PCM_FORMAT_IEC958_SUBFRAME;
649 default: return SNDRV_PCM_FORMAT_U8; 672 default: return SNDRV_PCM_FORMAT_U8;
650 } 673 }
651} 674}
@@ -663,6 +686,13 @@ static int snd_pcm_oss_format_to(int format)
663 case SNDRV_PCM_FORMAT_U16_LE: return AFMT_U16_LE; 686 case SNDRV_PCM_FORMAT_U16_LE: return AFMT_U16_LE;
664 case SNDRV_PCM_FORMAT_U16_BE: return AFMT_U16_BE; 687 case SNDRV_PCM_FORMAT_U16_BE: return AFMT_U16_BE;
665 case SNDRV_PCM_FORMAT_MPEG: return AFMT_MPEG; 688 case SNDRV_PCM_FORMAT_MPEG: return AFMT_MPEG;
689 case SNDRV_PCM_FORMAT_S32_LE: return AFMT_S32_LE;
690 case SNDRV_PCM_FORMAT_S32_BE: return AFMT_S32_BE;
691 case SNDRV_PCM_FORMAT_S24_LE: return AFMT_S24_LE;
692 case SNDRV_PCM_FORMAT_S24_BE: return AFMT_S24_BE;
693 case SNDRV_PCM_FORMAT_S24_3LE: return AFMT_S24_PACKED;
694 case SNDRV_PCM_FORMAT_FLOAT: return AFMT_FLOAT;
695 case SNDRV_PCM_FORMAT_IEC958_SUBFRAME: return AFMT_SPDIF_RAW;
666 default: return -EINVAL; 696 default: return -EINVAL;
667 } 697 }
668} 698}
@@ -1725,7 +1755,10 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
1725 return AFMT_MU_LAW | AFMT_U8 | 1755 return AFMT_MU_LAW | AFMT_U8 |
1726 AFMT_S16_LE | AFMT_S16_BE | 1756 AFMT_S16_LE | AFMT_S16_BE |
1727 AFMT_S8 | AFMT_U16_LE | 1757 AFMT_S8 | AFMT_U16_LE |
1728 AFMT_U16_BE; 1758 AFMT_U16_BE |
1759 AFMT_S32_LE | AFMT_S32_BE |
1760 AFMT_S24_LE | AFMT_S24_LE |
1761 AFMT_S24_PACKED;
1729 params = kmalloc(sizeof(*params), GFP_KERNEL); 1762 params = kmalloc(sizeof(*params), GFP_KERNEL);
1730 if (!params) 1763 if (!params)
1731 return -ENOMEM; 1764 return -ENOMEM;
diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
index 0e67dd280a5d..14095a927a1b 100644
--- a/sound/core/oss/pcm_plugin.c
+++ b/sound/core/oss/pcm_plugin.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * PCM Plug-In shared (kernel/library) code 2 * PCM Plug-In shared (kernel/library) code
3 * Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>
4 * Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org> 4 * Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org>
5 * 5 *
6 * 6 *
@@ -25,9 +25,6 @@
25#endif 25#endif
26 26
27#include <sound/driver.h> 27#include <sound/driver.h>
28
29#ifdef CONFIG_SND_PCM_OSS_PLUGINS
30
31#include <linux/slab.h> 28#include <linux/slab.h>
32#include <linux/time.h> 29#include <linux/time.h>
33#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
@@ -267,6 +264,8 @@ static int snd_pcm_plug_formats(struct snd_mask *mask, int format)
267 SNDRV_PCM_FMTBIT_U16_BE | SNDRV_PCM_FMTBIT_S16_BE | 264 SNDRV_PCM_FMTBIT_U16_BE | SNDRV_PCM_FMTBIT_S16_BE |
268 SNDRV_PCM_FMTBIT_U24_LE | SNDRV_PCM_FMTBIT_S24_LE | 265 SNDRV_PCM_FMTBIT_U24_LE | SNDRV_PCM_FMTBIT_S24_LE |
269 SNDRV_PCM_FMTBIT_U24_BE | SNDRV_PCM_FMTBIT_S24_BE | 266 SNDRV_PCM_FMTBIT_U24_BE | SNDRV_PCM_FMTBIT_S24_BE |
267 SNDRV_PCM_FMTBIT_U24_3LE | SNDRV_PCM_FMTBIT_S24_3LE |
268 SNDRV_PCM_FMTBIT_U24_3BE | SNDRV_PCM_FMTBIT_S24_3BE |
270 SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_S32_LE | 269 SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_S32_LE |
271 SNDRV_PCM_FMTBIT_U32_BE | SNDRV_PCM_FMTBIT_S32_BE); 270 SNDRV_PCM_FMTBIT_U32_BE | SNDRV_PCM_FMTBIT_S32_BE);
272 snd_mask_set(&formats, SNDRV_PCM_FORMAT_MU_LAW); 271 snd_mask_set(&formats, SNDRV_PCM_FORMAT_MU_LAW);
@@ -283,6 +282,10 @@ static int preferred_formats[] = {
283 SNDRV_PCM_FORMAT_S16_BE, 282 SNDRV_PCM_FORMAT_S16_BE,
284 SNDRV_PCM_FORMAT_U16_LE, 283 SNDRV_PCM_FORMAT_U16_LE,
285 SNDRV_PCM_FORMAT_U16_BE, 284 SNDRV_PCM_FORMAT_U16_BE,
285 SNDRV_PCM_FORMAT_S24_3LE,
286 SNDRV_PCM_FORMAT_S24_3BE,
287 SNDRV_PCM_FORMAT_U24_3LE,
288 SNDRV_PCM_FORMAT_U24_3BE,
286 SNDRV_PCM_FORMAT_S24_LE, 289 SNDRV_PCM_FORMAT_S24_LE,
287 SNDRV_PCM_FORMAT_S24_BE, 290 SNDRV_PCM_FORMAT_S24_BE,
288 SNDRV_PCM_FORMAT_U24_LE, 291 SNDRV_PCM_FORMAT_U24_LE,
@@ -297,41 +300,37 @@ static int preferred_formats[] = {
297 300
298int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask) 301int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask)
299{ 302{
303 int i;
304
300 if (snd_mask_test(format_mask, format)) 305 if (snd_mask_test(format_mask, format))
301 return format; 306 return format;
302 if (! snd_pcm_plug_formats(format_mask, format)) 307 if (! snd_pcm_plug_formats(format_mask, format))
303 return -EINVAL; 308 return -EINVAL;
304 if (snd_pcm_format_linear(format)) { 309 if (snd_pcm_format_linear(format)) {
305 int width = snd_pcm_format_width(format); 310 unsigned int width = snd_pcm_format_width(format);
306 int unsignd = snd_pcm_format_unsigned(format); 311 int unsignd = snd_pcm_format_unsigned(format) > 0;
307 int big = snd_pcm_format_big_endian(format); 312 int big = snd_pcm_format_big_endian(format) > 0;
308 int format1; 313 unsigned int badness, best = -1;
309 int wid, width1=width; 314 int best_format = -1;
310 int dwidth1 = 8; 315 for (i = 0; i < ARRAY_SIZE(preferred_formats); i++) {
311 for (wid = 0; wid < 4; ++wid) { 316 int f = preferred_formats[i];
312 int end, big1 = big; 317 unsigned int w;
313 for (end = 0; end < 2; ++end) { 318 if (!snd_mask_test(format_mask, f))
314 int sgn, unsignd1 = unsignd; 319 continue;
315 for (sgn = 0; sgn < 2; ++sgn) { 320 w = snd_pcm_format_width(f);
316 format1 = snd_pcm_build_linear_format(width1, unsignd1, big1); 321 if (w >= width)
317 if (format1 >= 0 && 322 badness = w - width;
318 snd_mask_test(format_mask, format1)) 323 else
319 goto _found; 324 badness = width - w + 32;
320 unsignd1 = !unsignd1; 325 badness += snd_pcm_format_unsigned(f) != unsignd;
321 } 326 badness += snd_pcm_format_big_endian(f) != big;
322 big1 = !big1; 327 if (badness < best) {
323 } 328 best_format = f;
324 if (width1 == 32) { 329 best = badness;
325 dwidth1 = -dwidth1;
326 width1 = width;
327 } 330 }
328 width1 += dwidth1;
329 } 331 }
330 return -EINVAL; 332 return best_format >= 0 ? best_format : -EINVAL;
331 _found:
332 return format1;
333 } else { 333 } else {
334 unsigned int i;
335 switch (format) { 334 switch (format) {
336 case SNDRV_PCM_FORMAT_MU_LAW: 335 case SNDRV_PCM_FORMAT_MU_LAW:
337 for (i = 0; i < ARRAY_SIZE(preferred_formats); ++i) { 336 for (i = 0; i < ARRAY_SIZE(preferred_formats); ++i) {
@@ -740,5 +739,3 @@ int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_area, size_t src_of
740 } 739 }
741 return 0; 740 return 0;
742} 741}
743
744#endif
diff --git a/sound/core/oss/pcm_plugin.h b/sound/core/oss/pcm_plugin.h
index 3be91b3d5377..ca2f4c39be46 100644
--- a/sound/core/oss/pcm_plugin.h
+++ b/sound/core/oss/pcm_plugin.h
@@ -3,7 +3,7 @@
3 3
4/* 4/*
5 * Digital Audio (Plugin interface) abstract layer 5 * Digital Audio (Plugin interface) abstract layer
6 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 6 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
7 * 7 *
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
diff --git a/sound/core/oss/plugin_ops.h b/sound/core/oss/plugin_ops.h
deleted file mode 100644
index 1f5bde4631f1..000000000000
--- a/sound/core/oss/plugin_ops.h
+++ /dev/null
@@ -1,370 +0,0 @@
1/*
2 * Plugin sample operators with fast switch
3 * Copyright (c) 2000 by Jaroslav Kysela <perex@suse.cz>
4 *
5 *
6 * This library is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Library General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (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 Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22
23#define as_u8(ptr) (*(u_int8_t*)(ptr))
24#define as_u16(ptr) (*(u_int16_t*)(ptr))
25#define as_u32(ptr) (*(u_int32_t*)(ptr))
26#define as_u64(ptr) (*(u_int64_t*)(ptr))
27#define as_s8(ptr) (*(int8_t*)(ptr))
28#define as_s16(ptr) (*(int16_t*)(ptr))
29#define as_s32(ptr) (*(int32_t*)(ptr))
30#define as_s64(ptr) (*(int64_t*)(ptr))
31
32#ifdef COPY_LABELS
33static void *copy_labels[4] = {
34 &&copy_8,
35 &&copy_16,
36 &&copy_32,
37 &&copy_64
38};
39#endif
40
41#ifdef COPY_END
42while(0) {
43copy_8: as_s8(dst) = as_s8(src); goto COPY_END;
44copy_16: as_s16(dst) = as_s16(src); goto COPY_END;
45copy_32: as_s32(dst) = as_s32(src); goto COPY_END;
46copy_64: as_s64(dst) = as_s64(src); goto COPY_END;
47}
48#endif
49
50#ifdef CONV_LABELS
51/* src_wid src_endswap sign_toggle dst_wid dst_endswap */
52static void *conv_labels[4 * 2 * 2 * 4 * 2] = {
53 &&conv_xxx1_xxx1, /* 8h -> 8h */
54 &&conv_xxx1_xxx1, /* 8h -> 8s */
55 &&conv_xxx1_xx10, /* 8h -> 16h */
56 &&conv_xxx1_xx01, /* 8h -> 16s */
57 &&conv_xxx1_x100, /* 8h -> 24h */
58 &&conv_xxx1_001x, /* 8h -> 24s */
59 &&conv_xxx1_1000, /* 8h -> 32h */
60 &&conv_xxx1_0001, /* 8h -> 32s */
61 &&conv_xxx1_xxx9, /* 8h ^> 8h */
62 &&conv_xxx1_xxx9, /* 8h ^> 8s */
63 &&conv_xxx1_xx90, /* 8h ^> 16h */
64 &&conv_xxx1_xx09, /* 8h ^> 16s */
65 &&conv_xxx1_x900, /* 8h ^> 24h */
66 &&conv_xxx1_009x, /* 8h ^> 24s */
67 &&conv_xxx1_9000, /* 8h ^> 32h */
68 &&conv_xxx1_0009, /* 8h ^> 32s */
69 &&conv_xxx1_xxx1, /* 8s -> 8h */
70 &&conv_xxx1_xxx1, /* 8s -> 8s */
71 &&conv_xxx1_xx10, /* 8s -> 16h */
72 &&conv_xxx1_xx01, /* 8s -> 16s */
73 &&conv_xxx1_x100, /* 8s -> 24h */
74 &&conv_xxx1_001x, /* 8s -> 24s */
75 &&conv_xxx1_1000, /* 8s -> 32h */
76 &&conv_xxx1_0001, /* 8s -> 32s */
77 &&conv_xxx1_xxx9, /* 8s ^> 8h */
78 &&conv_xxx1_xxx9, /* 8s ^> 8s */
79 &&conv_xxx1_xx90, /* 8s ^> 16h */
80 &&conv_xxx1_xx09, /* 8s ^> 16s */
81 &&conv_xxx1_x900, /* 8s ^> 24h */
82 &&conv_xxx1_009x, /* 8s ^> 24s */
83 &&conv_xxx1_9000, /* 8s ^> 32h */
84 &&conv_xxx1_0009, /* 8s ^> 32s */
85 &&conv_xx12_xxx1, /* 16h -> 8h */
86 &&conv_xx12_xxx1, /* 16h -> 8s */
87 &&conv_xx12_xx12, /* 16h -> 16h */
88 &&conv_xx12_xx21, /* 16h -> 16s */
89 &&conv_xx12_x120, /* 16h -> 24h */
90 &&conv_xx12_021x, /* 16h -> 24s */
91 &&conv_xx12_1200, /* 16h -> 32h */
92 &&conv_xx12_0021, /* 16h -> 32s */
93 &&conv_xx12_xxx9, /* 16h ^> 8h */
94 &&conv_xx12_xxx9, /* 16h ^> 8s */
95 &&conv_xx12_xx92, /* 16h ^> 16h */
96 &&conv_xx12_xx29, /* 16h ^> 16s */
97 &&conv_xx12_x920, /* 16h ^> 24h */
98 &&conv_xx12_029x, /* 16h ^> 24s */
99 &&conv_xx12_9200, /* 16h ^> 32h */
100 &&conv_xx12_0029, /* 16h ^> 32s */
101 &&conv_xx12_xxx2, /* 16s -> 8h */
102 &&conv_xx12_xxx2, /* 16s -> 8s */
103 &&conv_xx12_xx21, /* 16s -> 16h */
104 &&conv_xx12_xx12, /* 16s -> 16s */
105 &&conv_xx12_x210, /* 16s -> 24h */
106 &&conv_xx12_012x, /* 16s -> 24s */
107 &&conv_xx12_2100, /* 16s -> 32h */
108 &&conv_xx12_0012, /* 16s -> 32s */
109 &&conv_xx12_xxxA, /* 16s ^> 8h */
110 &&conv_xx12_xxxA, /* 16s ^> 8s */
111 &&conv_xx12_xxA1, /* 16s ^> 16h */
112 &&conv_xx12_xx1A, /* 16s ^> 16s */
113 &&conv_xx12_xA10, /* 16s ^> 24h */
114 &&conv_xx12_01Ax, /* 16s ^> 24s */
115 &&conv_xx12_A100, /* 16s ^> 32h */
116 &&conv_xx12_001A, /* 16s ^> 32s */
117 &&conv_x123_xxx1, /* 24h -> 8h */
118 &&conv_x123_xxx1, /* 24h -> 8s */
119 &&conv_x123_xx12, /* 24h -> 16h */
120 &&conv_x123_xx21, /* 24h -> 16s */
121 &&conv_x123_x123, /* 24h -> 24h */
122 &&conv_x123_321x, /* 24h -> 24s */
123 &&conv_x123_1230, /* 24h -> 32h */
124 &&conv_x123_0321, /* 24h -> 32s */
125 &&conv_x123_xxx9, /* 24h ^> 8h */
126 &&conv_x123_xxx9, /* 24h ^> 8s */
127 &&conv_x123_xx92, /* 24h ^> 16h */
128 &&conv_x123_xx29, /* 24h ^> 16s */
129 &&conv_x123_x923, /* 24h ^> 24h */
130 &&conv_x123_329x, /* 24h ^> 24s */
131 &&conv_x123_9230, /* 24h ^> 32h */
132 &&conv_x123_0329, /* 24h ^> 32s */
133 &&conv_123x_xxx3, /* 24s -> 8h */
134 &&conv_123x_xxx3, /* 24s -> 8s */
135 &&conv_123x_xx32, /* 24s -> 16h */
136 &&conv_123x_xx23, /* 24s -> 16s */
137 &&conv_123x_x321, /* 24s -> 24h */
138 &&conv_123x_123x, /* 24s -> 24s */
139 &&conv_123x_3210, /* 24s -> 32h */
140 &&conv_123x_0123, /* 24s -> 32s */
141 &&conv_123x_xxxB, /* 24s ^> 8h */
142 &&conv_123x_xxxB, /* 24s ^> 8s */
143 &&conv_123x_xxB2, /* 24s ^> 16h */
144 &&conv_123x_xx2B, /* 24s ^> 16s */
145 &&conv_123x_xB21, /* 24s ^> 24h */
146 &&conv_123x_12Bx, /* 24s ^> 24s */
147 &&conv_123x_B210, /* 24s ^> 32h */
148 &&conv_123x_012B, /* 24s ^> 32s */
149 &&conv_1234_xxx1, /* 32h -> 8h */
150 &&conv_1234_xxx1, /* 32h -> 8s */
151 &&conv_1234_xx12, /* 32h -> 16h */
152 &&conv_1234_xx21, /* 32h -> 16s */
153 &&conv_1234_x123, /* 32h -> 24h */
154 &&conv_1234_321x, /* 32h -> 24s */
155 &&conv_1234_1234, /* 32h -> 32h */
156 &&conv_1234_4321, /* 32h -> 32s */
157 &&conv_1234_xxx9, /* 32h ^> 8h */
158 &&conv_1234_xxx9, /* 32h ^> 8s */
159 &&conv_1234_xx92, /* 32h ^> 16h */
160 &&conv_1234_xx29, /* 32h ^> 16s */
161 &&conv_1234_x923, /* 32h ^> 24h */
162 &&conv_1234_329x, /* 32h ^> 24s */
163 &&conv_1234_9234, /* 32h ^> 32h */
164 &&conv_1234_4329, /* 32h ^> 32s */
165 &&conv_1234_xxx4, /* 32s -> 8h */
166 &&conv_1234_xxx4, /* 32s -> 8s */
167 &&conv_1234_xx43, /* 32s -> 16h */
168 &&conv_1234_xx34, /* 32s -> 16s */
169 &&conv_1234_x432, /* 32s -> 24h */
170 &&conv_1234_234x, /* 32s -> 24s */
171 &&conv_1234_4321, /* 32s -> 32h */
172 &&conv_1234_1234, /* 32s -> 32s */
173 &&conv_1234_xxxC, /* 32s ^> 8h */
174 &&conv_1234_xxxC, /* 32s ^> 8s */
175 &&conv_1234_xxC3, /* 32s ^> 16h */
176 &&conv_1234_xx3C, /* 32s ^> 16s */
177 &&conv_1234_xC32, /* 32s ^> 24h */
178 &&conv_1234_23Cx, /* 32s ^> 24s */
179 &&conv_1234_C321, /* 32s ^> 32h */
180 &&conv_1234_123C, /* 32s ^> 32s */
181};
182#endif
183
184#ifdef CONV_END
185while(0) {
186conv_xxx1_xxx1: as_u8(dst) = as_u8(src); goto CONV_END;
187conv_xxx1_xx10: as_u16(dst) = (u_int16_t)as_u8(src) << 8; goto CONV_END;
188conv_xxx1_xx01: as_u16(dst) = (u_int16_t)as_u8(src); goto CONV_END;
189conv_xxx1_x100: as_u32(dst) = (u_int32_t)as_u8(src) << 16; goto CONV_END;
190conv_xxx1_001x: as_u32(dst) = (u_int32_t)as_u8(src) << 8; goto CONV_END;
191conv_xxx1_1000: as_u32(dst) = (u_int32_t)as_u8(src) << 24; goto CONV_END;
192conv_xxx1_0001: as_u32(dst) = (u_int32_t)as_u8(src); goto CONV_END;
193conv_xxx1_xxx9: as_u8(dst) = as_u8(src) ^ 0x80; goto CONV_END;
194conv_xxx1_xx90: as_u16(dst) = (u_int16_t)(as_u8(src) ^ 0x80) << 8; goto CONV_END;
195conv_xxx1_xx09: as_u16(dst) = (u_int16_t)(as_u8(src) ^ 0x80); goto CONV_END;
196conv_xxx1_x900: as_u32(dst) = (u_int32_t)(as_u8(src) ^ 0x80) << 16; goto CONV_END;
197conv_xxx1_009x: as_u32(dst) = (u_int32_t)(as_u8(src) ^ 0x80) << 8; goto CONV_END;
198conv_xxx1_9000: as_u32(dst) = (u_int32_t)(as_u8(src) ^ 0x80) << 24; goto CONV_END;
199conv_xxx1_0009: as_u32(dst) = (u_int32_t)(as_u8(src) ^ 0x80); goto CONV_END;
200conv_xx12_xxx1: as_u8(dst) = as_u16(src) >> 8; goto CONV_END;
201conv_xx12_xx12: as_u16(dst) = as_u16(src); goto CONV_END;
202conv_xx12_xx21: as_u16(dst) = swab16(as_u16(src)); goto CONV_END;
203conv_xx12_x120: as_u32(dst) = (u_int32_t)as_u16(src) << 8; goto CONV_END;
204conv_xx12_021x: as_u32(dst) = (u_int32_t)swab16(as_u16(src)) << 8; goto CONV_END;
205conv_xx12_1200: as_u32(dst) = (u_int32_t)as_u16(src) << 16; goto CONV_END;
206conv_xx12_0021: as_u32(dst) = (u_int32_t)swab16(as_u16(src)); goto CONV_END;
207conv_xx12_xxx9: as_u8(dst) = (as_u16(src) >> 8) ^ 0x80; goto CONV_END;
208conv_xx12_xx92: as_u16(dst) = as_u16(src) ^ 0x8000; goto CONV_END;
209conv_xx12_xx29: as_u16(dst) = swab16(as_u16(src)) ^ 0x80; goto CONV_END;
210conv_xx12_x920: as_u32(dst) = (u_int32_t)(as_u16(src) ^ 0x8000) << 8; goto CONV_END;
211conv_xx12_029x: as_u32(dst) = (u_int32_t)(swab16(as_u16(src)) ^ 0x80) << 8; goto CONV_END;
212conv_xx12_9200: as_u32(dst) = (u_int32_t)(as_u16(src) ^ 0x8000) << 16; goto CONV_END;
213conv_xx12_0029: as_u32(dst) = (u_int32_t)(swab16(as_u16(src)) ^ 0x80); goto CONV_END;
214conv_xx12_xxx2: as_u8(dst) = as_u16(src) & 0xff; goto CONV_END;
215conv_xx12_x210: as_u32(dst) = (u_int32_t)swab16(as_u16(src)) << 8; goto CONV_END;
216conv_xx12_012x: as_u32(dst) = (u_int32_t)as_u16(src) << 8; goto CONV_END;
217conv_xx12_2100: as_u32(dst) = (u_int32_t)swab16(as_u16(src)) << 16; goto CONV_END;
218conv_xx12_0012: as_u32(dst) = (u_int32_t)as_u16(src); goto CONV_END;
219conv_xx12_xxxA: as_u8(dst) = (as_u16(src) ^ 0x80) & 0xff; goto CONV_END;
220conv_xx12_xxA1: as_u16(dst) = swab16(as_u16(src) ^ 0x80); goto CONV_END;
221conv_xx12_xx1A: as_u16(dst) = as_u16(src) ^ 0x80; goto CONV_END;
222conv_xx12_xA10: as_u32(dst) = (u_int32_t)swab16(as_u16(src) ^ 0x80) << 8; goto CONV_END;
223conv_xx12_01Ax: as_u32(dst) = (u_int32_t)(as_u16(src) ^ 0x80) << 8; goto CONV_END;
224conv_xx12_A100: as_u32(dst) = (u_int32_t)swab16(as_u16(src) ^ 0x80) << 16; goto CONV_END;
225conv_xx12_001A: as_u32(dst) = (u_int32_t)(as_u16(src) ^ 0x80); goto CONV_END;
226conv_x123_xxx1: as_u8(dst) = as_u32(src) >> 16; goto CONV_END;
227conv_x123_xx12: as_u16(dst) = as_u32(src) >> 8; goto CONV_END;
228conv_x123_xx21: as_u16(dst) = swab16(as_u32(src) >> 8); goto CONV_END;
229conv_x123_x123: as_u32(dst) = as_u32(src); goto CONV_END;
230conv_x123_321x: as_u32(dst) = swab32(as_u32(src)); goto CONV_END;
231conv_x123_1230: as_u32(dst) = as_u32(src) << 8; goto CONV_END;
232conv_x123_0321: as_u32(dst) = swab32(as_u32(src)) >> 8; goto CONV_END;
233conv_x123_xxx9: as_u8(dst) = (as_u32(src) >> 16) ^ 0x80; goto CONV_END;
234conv_x123_xx92: as_u16(dst) = (as_u32(src) >> 8) ^ 0x8000; goto CONV_END;
235conv_x123_xx29: as_u16(dst) = swab16(as_u32(src) >> 8) ^ 0x80; goto CONV_END;
236conv_x123_x923: as_u32(dst) = as_u32(src) ^ 0x800000; goto CONV_END;
237conv_x123_329x: as_u32(dst) = swab32(as_u32(src)) ^ 0x8000; goto CONV_END;
238conv_x123_9230: as_u32(dst) = (as_u32(src) ^ 0x800000) << 8; goto CONV_END;
239conv_x123_0329: as_u32(dst) = (swab32(as_u32(src)) >> 8) ^ 0x80; goto CONV_END;
240conv_123x_xxx3: as_u8(dst) = (as_u32(src) >> 8) & 0xff; goto CONV_END;
241conv_123x_xx32: as_u16(dst) = swab16(as_u32(src) >> 8); goto CONV_END;
242conv_123x_xx23: as_u16(dst) = (as_u32(src) >> 8) & 0xffff; goto CONV_END;
243conv_123x_x321: as_u32(dst) = swab32(as_u32(src)); goto CONV_END;
244conv_123x_123x: as_u32(dst) = as_u32(src); goto CONV_END;
245conv_123x_3210: as_u32(dst) = swab32(as_u32(src)) << 8; goto CONV_END;
246conv_123x_0123: as_u32(dst) = as_u32(src) >> 8; goto CONV_END;
247conv_123x_xxxB: as_u8(dst) = ((as_u32(src) >> 8) & 0xff) ^ 0x80; goto CONV_END;
248conv_123x_xxB2: as_u16(dst) = swab16((as_u32(src) >> 8) ^ 0x80); goto CONV_END;
249conv_123x_xx2B: as_u16(dst) = ((as_u32(src) >> 8) & 0xffff) ^ 0x80; goto CONV_END;
250conv_123x_xB21: as_u32(dst) = swab32(as_u32(src)) ^ 0x800000; goto CONV_END;
251conv_123x_12Bx: as_u32(dst) = as_u32(src) ^ 0x8000; goto CONV_END;
252conv_123x_B210: as_u32(dst) = swab32(as_u32(src) ^ 0x8000) << 8; goto CONV_END;
253conv_123x_012B: as_u32(dst) = (as_u32(src) >> 8) ^ 0x80; goto CONV_END;
254conv_1234_xxx1: as_u8(dst) = as_u32(src) >> 24; goto CONV_END;
255conv_1234_xx12: as_u16(dst) = as_u32(src) >> 16; goto CONV_END;
256conv_1234_xx21: as_u16(dst) = swab16(as_u32(src) >> 16); goto CONV_END;
257conv_1234_x123: as_u32(dst) = as_u32(src) >> 8; goto CONV_END;
258conv_1234_321x: as_u32(dst) = swab32(as_u32(src)) << 8; goto CONV_END;
259conv_1234_1234: as_u32(dst) = as_u32(src); goto CONV_END;
260conv_1234_4321: as_u32(dst) = swab32(as_u32(src)); goto CONV_END;
261conv_1234_xxx9: as_u8(dst) = (as_u32(src) >> 24) ^ 0x80; goto CONV_END;
262conv_1234_xx92: as_u16(dst) = (as_u32(src) >> 16) ^ 0x8000; goto CONV_END;
263conv_1234_xx29: as_u16(dst) = swab16(as_u32(src) >> 16) ^ 0x80; goto CONV_END;
264conv_1234_x923: as_u32(dst) = (as_u32(src) >> 8) ^ 0x800000; goto CONV_END;
265conv_1234_329x: as_u32(dst) = (swab32(as_u32(src)) ^ 0x80) << 8; goto CONV_END;
266conv_1234_9234: as_u32(dst) = as_u32(src) ^ 0x80000000; goto CONV_END;
267conv_1234_4329: as_u32(dst) = swab32(as_u32(src)) ^ 0x80; goto CONV_END;
268conv_1234_xxx4: as_u8(dst) = as_u32(src) & 0xff; goto CONV_END;
269conv_1234_xx43: as_u16(dst) = swab16(as_u32(src)); goto CONV_END;
270conv_1234_xx34: as_u16(dst) = as_u32(src) & 0xffff; goto CONV_END;
271conv_1234_x432: as_u32(dst) = swab32(as_u32(src)) >> 8; goto CONV_END;
272conv_1234_234x: as_u32(dst) = as_u32(src) << 8; goto CONV_END;
273conv_1234_xxxC: as_u8(dst) = (as_u32(src) & 0xff) ^ 0x80; goto CONV_END;
274conv_1234_xxC3: as_u16(dst) = swab16(as_u32(src) ^ 0x80); goto CONV_END;
275conv_1234_xx3C: as_u16(dst) = (as_u32(src) & 0xffff) ^ 0x80; goto CONV_END;
276conv_1234_xC32: as_u32(dst) = (swab32(as_u32(src)) >> 8) ^ 0x800000; goto CONV_END;
277conv_1234_23Cx: as_u32(dst) = (as_u32(src) ^ 0x80) << 8; goto CONV_END;
278conv_1234_C321: as_u32(dst) = swab32(as_u32(src) ^ 0x80); goto CONV_END;
279conv_1234_123C: as_u32(dst) = as_u32(src) ^ 0x80; goto CONV_END;
280}
281#endif
282
283#ifdef GET_S16_LABELS
284/* src_wid src_endswap unsigned */
285static void *get_s16_labels[4 * 2 * 2] = {
286 &&get_s16_xxx1_xx10, /* 8h -> 16h */
287 &&get_s16_xxx1_xx90, /* 8h ^> 16h */
288 &&get_s16_xxx1_xx10, /* 8s -> 16h */
289 &&get_s16_xxx1_xx90, /* 8s ^> 16h */
290 &&get_s16_xx12_xx12, /* 16h -> 16h */
291 &&get_s16_xx12_xx92, /* 16h ^> 16h */
292 &&get_s16_xx12_xx21, /* 16s -> 16h */
293 &&get_s16_xx12_xxA1, /* 16s ^> 16h */
294 &&get_s16_x123_xx12, /* 24h -> 16h */
295 &&get_s16_x123_xx92, /* 24h ^> 16h */
296 &&get_s16_123x_xx32, /* 24s -> 16h */
297 &&get_s16_123x_xxB2, /* 24s ^> 16h */
298 &&get_s16_1234_xx12, /* 32h -> 16h */
299 &&get_s16_1234_xx92, /* 32h ^> 16h */
300 &&get_s16_1234_xx43, /* 32s -> 16h */
301 &&get_s16_1234_xxC3, /* 32s ^> 16h */
302};
303#endif
304
305#ifdef GET_S16_END
306while(0) {
307get_s16_xxx1_xx10: sample = (u_int16_t)as_u8(src) << 8; goto GET_S16_END;
308get_s16_xxx1_xx90: sample = (u_int16_t)(as_u8(src) ^ 0x80) << 8; goto GET_S16_END;
309get_s16_xx12_xx12: sample = as_u16(src); goto GET_S16_END;
310get_s16_xx12_xx92: sample = as_u16(src) ^ 0x8000; goto GET_S16_END;
311get_s16_xx12_xx21: sample = swab16(as_u16(src)); goto GET_S16_END;
312get_s16_xx12_xxA1: sample = swab16(as_u16(src) ^ 0x80); goto GET_S16_END;
313get_s16_x123_xx12: sample = as_u32(src) >> 8; goto GET_S16_END;
314get_s16_x123_xx92: sample = (as_u32(src) >> 8) ^ 0x8000; goto GET_S16_END;
315get_s16_123x_xx32: sample = swab16(as_u32(src) >> 8); goto GET_S16_END;
316get_s16_123x_xxB2: sample = swab16((as_u32(src) >> 8) ^ 0x8000); goto GET_S16_END;
317get_s16_1234_xx12: sample = as_u32(src) >> 16; goto GET_S16_END;
318get_s16_1234_xx92: sample = (as_u32(src) >> 16) ^ 0x8000; goto GET_S16_END;
319get_s16_1234_xx43: sample = swab16(as_u32(src)); goto GET_S16_END;
320get_s16_1234_xxC3: sample = swab16(as_u32(src) ^ 0x80); goto GET_S16_END;
321}
322#endif
323
324#ifdef PUT_S16_LABELS
325/* dst_wid dst_endswap unsigned */
326static void *put_s16_labels[4 * 2 * 2] = {
327 &&put_s16_xx12_xxx1, /* 16h -> 8h */
328 &&put_s16_xx12_xxx9, /* 16h ^> 8h */
329 &&put_s16_xx12_xxx1, /* 16h -> 8s */
330 &&put_s16_xx12_xxx9, /* 16h ^> 8s */
331 &&put_s16_xx12_xx12, /* 16h -> 16h */
332 &&put_s16_xx12_xx92, /* 16h ^> 16h */
333 &&put_s16_xx12_xx21, /* 16h -> 16s */
334 &&put_s16_xx12_xx29, /* 16h ^> 16s */
335 &&put_s16_xx12_x120, /* 16h -> 24h */
336 &&put_s16_xx12_x920, /* 16h ^> 24h */
337 &&put_s16_xx12_021x, /* 16h -> 24s */
338 &&put_s16_xx12_029x, /* 16h ^> 24s */
339 &&put_s16_xx12_1200, /* 16h -> 32h */
340 &&put_s16_xx12_9200, /* 16h ^> 32h */
341 &&put_s16_xx12_0021, /* 16h -> 32s */
342 &&put_s16_xx12_0029, /* 16h ^> 32s */
343};
344#endif
345
346#ifdef PUT_S16_END
347while (0) {
348put_s16_xx12_xxx1: as_u8(dst) = sample >> 8; goto PUT_S16_END;
349put_s16_xx12_xxx9: as_u8(dst) = (sample >> 8) ^ 0x80; goto PUT_S16_END;
350put_s16_xx12_xx12: as_u16(dst) = sample; goto PUT_S16_END;
351put_s16_xx12_xx92: as_u16(dst) = sample ^ 0x8000; goto PUT_S16_END;
352put_s16_xx12_xx21: as_u16(dst) = swab16(sample); goto PUT_S16_END;
353put_s16_xx12_xx29: as_u16(dst) = swab16(sample) ^ 0x80; goto PUT_S16_END;
354put_s16_xx12_x120: as_u32(dst) = (u_int32_t)sample << 8; goto PUT_S16_END;
355put_s16_xx12_x920: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 8; goto PUT_S16_END;
356put_s16_xx12_021x: as_u32(dst) = (u_int32_t)swab16(sample) << 8; goto PUT_S16_END;
357put_s16_xx12_029x: as_u32(dst) = (u_int32_t)(swab16(sample) ^ 0x80) << 8; goto PUT_S16_END;
358put_s16_xx12_1200: as_u32(dst) = (u_int32_t)sample << 16; goto PUT_S16_END;
359put_s16_xx12_9200: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 16; goto PUT_S16_END;
360put_s16_xx12_0021: as_u32(dst) = (u_int32_t)swab16(sample); goto PUT_S16_END;
361put_s16_xx12_0029: as_u32(dst) = (u_int32_t)swab16(sample) ^ 0x80; goto PUT_S16_END;
362}
363#endif
364
365#undef as_u8
366#undef as_u16
367#undef as_u32
368#undef as_s8
369#undef as_s16
370#undef as_s32
diff --git a/sound/core/oss/rate.c b/sound/core/oss/rate.c
index 18d8a0f4e816..9eb267913c38 100644
--- a/sound/core/oss/rate.c
+++ b/sound/core/oss/rate.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Rate conversion Plug-In 2 * Rate conversion Plug-In
3 * Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This library is free software; you can redistribute it and/or modify 6 * This library is free software; you can redistribute it and/or modify
@@ -20,9 +20,6 @@
20 */ 20 */
21 21
22#include <sound/driver.h> 22#include <sound/driver.h>
23
24#ifdef CONFIG_SND_PCM_OSS_PLUGINS
25
26#include <linux/time.h> 23#include <linux/time.h>
27#include <sound/core.h> 24#include <sound/core.h>
28#include <sound/pcm.h> 25#include <sound/pcm.h>
@@ -340,5 +337,3 @@ int snd_pcm_plugin_build_rate(struct snd_pcm_substream *plug,
340 *r_plugin = plugin; 337 *r_plugin = plugin;
341 return 0; 338 return 0;
342} 339}
343
344#endif
diff --git a/sound/core/oss/route.c b/sound/core/oss/route.c
index 46917dc0196b..de3ffdeaf7e3 100644
--- a/sound/core/oss/route.c
+++ b/sound/core/oss/route.c
@@ -20,9 +20,6 @@
20 */ 20 */
21 21
22#include <sound/driver.h> 22#include <sound/driver.h>
23
24#ifdef CONFIG_SND_PCM_OSS_PLUGINS
25
26#include <linux/slab.h> 23#include <linux/slab.h>
27#include <linux/time.h> 24#include <linux/time.h>
28#include <sound/core.h> 25#include <sound/core.h>
@@ -108,5 +105,3 @@ int snd_pcm_plugin_build_route(struct snd_pcm_substream *plug,
108 *r_plugin = plugin; 105 *r_plugin = plugin;
109 return 0; 106 return 0;
110} 107}
111
112#endif
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 2743414fc8fa..cf9b9493d41d 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Digital Audio (PCM) abstract layer 2 * Digital Audio (PCM) abstract layer
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
@@ -30,7 +30,7 @@
30#include <sound/control.h> 30#include <sound/control.h>
31#include <sound/info.h> 31#include <sound/info.h>
32 32
33MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Abramo Bagnara <abramo@alsa-project.org>"); 33MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Abramo Bagnara <abramo@alsa-project.org>");
34MODULE_DESCRIPTION("Midlevel PCM code for ALSA."); 34MODULE_DESCRIPTION("Midlevel PCM code for ALSA.");
35MODULE_LICENSE("GPL"); 35MODULE_LICENSE("GPL");
36 36
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 9fefcaa2c324..806f1fba5446 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Digital Audio (PCM) abstract layer 2 * Digital Audio (PCM) abstract layer
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * Abramo Bagnara <abramo@alsa-project.org> 4 * Abramo Bagnara <abramo@alsa-project.org>
5 * 5 *
6 * 6 *
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c
index 95b1b2f0b1e2..a13e38cfd2c6 100644
--- a/sound/core/pcm_memory.c
+++ b/sound/core/pcm_memory.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Digital Audio (PCM) abstract layer 2 * Digital Audio (PCM) abstract layer
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c
index 0019c59a779d..dd9aa51d8c82 100644
--- a/sound/core/pcm_misc.c
+++ b/sound/core/pcm_misc.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * PCM Interface - misc routines 2 * PCM Interface - misc routines
3 * Copyright (c) 1998 by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) 1998 by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This library is free software; you can redistribute it and/or modify 6 * This library is free software; you can redistribute it and/or modify
@@ -422,38 +422,6 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int
422 422
423EXPORT_SYMBOL(snd_pcm_format_set_silence); 423EXPORT_SYMBOL(snd_pcm_format_set_silence);
424 424
425/* [width][unsigned][bigendian] */
426static int linear_formats[4][2][2] = {
427 {{ SNDRV_PCM_FORMAT_S8, SNDRV_PCM_FORMAT_S8},
428 { SNDRV_PCM_FORMAT_U8, SNDRV_PCM_FORMAT_U8}},
429 {{SNDRV_PCM_FORMAT_S16_LE, SNDRV_PCM_FORMAT_S16_BE},
430 {SNDRV_PCM_FORMAT_U16_LE, SNDRV_PCM_FORMAT_U16_BE}},
431 {{SNDRV_PCM_FORMAT_S24_LE, SNDRV_PCM_FORMAT_S24_BE},
432 {SNDRV_PCM_FORMAT_U24_LE, SNDRV_PCM_FORMAT_U24_BE}},
433 {{SNDRV_PCM_FORMAT_S32_LE, SNDRV_PCM_FORMAT_S32_BE},
434 {SNDRV_PCM_FORMAT_U32_LE, SNDRV_PCM_FORMAT_U32_BE}}
435};
436
437/**
438 * snd_pcm_build_linear_format - return the suitable linear format for the given condition
439 * @width: the bit-width
440 * @unsignd: 1 if unsigned, 0 if signed.
441 * @big_endian: 1 if big-endian, 0 if little-endian
442 *
443 * Returns the suitable linear format for the given condition.
444 */
445snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_endian)
446{
447 if (width & 7)
448 return SND_PCM_FORMAT_UNKNOWN;
449 width = (width / 8) - 1;
450 if (width < 0 || width >= 4)
451 return SND_PCM_FORMAT_UNKNOWN;
452 return linear_formats[width][!!unsignd][!!big_endian];
453}
454
455EXPORT_SYMBOL(snd_pcm_build_linear_format);
456
457/** 425/**
458 * snd_pcm_limit_hw_rates - determine rate_min/rate_max fields 426 * snd_pcm_limit_hw_rates - determine rate_min/rate_max fields
459 * @runtime: the runtime instance 427 * @runtime: the runtime instance
@@ -465,21 +433,16 @@ EXPORT_SYMBOL(snd_pcm_build_linear_format);
465 */ 433 */
466int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime) 434int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime)
467{ 435{
468 static unsigned rates[] = {
469 /* ATTENTION: these values depend on the definition in pcm.h! */
470 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000,
471 64000, 88200, 96000, 176400, 192000
472 };
473 int i; 436 int i;
474 for (i = 0; i < (int)ARRAY_SIZE(rates); i++) { 437 for (i = 0; i < (int)snd_pcm_known_rates.count; i++) {
475 if (runtime->hw.rates & (1 << i)) { 438 if (runtime->hw.rates & (1 << i)) {
476 runtime->hw.rate_min = rates[i]; 439 runtime->hw.rate_min = snd_pcm_known_rates.list[i];
477 break; 440 break;
478 } 441 }
479 } 442 }
480 for (i = (int)ARRAY_SIZE(rates) - 1; i >= 0; i--) { 443 for (i = (int)snd_pcm_known_rates.count - 1; i >= 0; i--) {
481 if (runtime->hw.rates & (1 << i)) { 444 if (runtime->hw.rates & (1 << i)) {
482 runtime->hw.rate_max = rates[i]; 445 runtime->hw.rate_max = snd_pcm_known_rates.list[i];
483 break; 446 break;
484 } 447 }
485 } 448 }
@@ -487,3 +450,21 @@ int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime)
487} 450}
488 451
489EXPORT_SYMBOL(snd_pcm_limit_hw_rates); 452EXPORT_SYMBOL(snd_pcm_limit_hw_rates);
453
454/**
455 * snd_pcm_rate_to_rate_bit - converts sample rate to SNDRV_PCM_RATE_xxx bit
456 * @rate: the sample rate to convert
457 *
458 * Returns the SNDRV_PCM_RATE_xxx flag that corresponds to the given rate, or
459 * SNDRV_PCM_RATE_KNOT for an unknown rate.
460 */
461unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate)
462{
463 unsigned int i;
464
465 for (i = 0; i < snd_pcm_known_rates.count; i++)
466 if (snd_pcm_known_rates.list[i] == rate)
467 return 1u << i;
468 return SNDRV_PCM_RATE_KNOT;
469}
470EXPORT_SYMBOL(snd_pcm_rate_to_rate_bit);
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 59b29cd482ae..fb3dde4db045 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Digital Audio (PCM) abstract layer 2 * Digital Audio (PCM) abstract layer
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
@@ -1787,12 +1787,18 @@ static int snd_pcm_hw_rule_sample_bits(struct snd_pcm_hw_params *params,
1787static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, 1787static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100,
1788 48000, 64000, 88200, 96000, 176400, 192000 }; 1788 48000, 64000, 88200, 96000, 176400, 192000 };
1789 1789
1790const struct snd_pcm_hw_constraint_list snd_pcm_known_rates = {
1791 .count = ARRAY_SIZE(rates),
1792 .list = rates,
1793};
1794
1790static int snd_pcm_hw_rule_rate(struct snd_pcm_hw_params *params, 1795static int snd_pcm_hw_rule_rate(struct snd_pcm_hw_params *params,
1791 struct snd_pcm_hw_rule *rule) 1796 struct snd_pcm_hw_rule *rule)
1792{ 1797{
1793 struct snd_pcm_hardware *hw = rule->private; 1798 struct snd_pcm_hardware *hw = rule->private;
1794 return snd_interval_list(hw_param_interval(params, rule->var), 1799 return snd_interval_list(hw_param_interval(params, rule->var),
1795 ARRAY_SIZE(rates), rates, hw->rates); 1800 snd_pcm_known_rates.count,
1801 snd_pcm_known_rates.list, hw->rates);
1796} 1802}
1797 1803
1798static int snd_pcm_hw_rule_buffer_bytes_max(struct snd_pcm_hw_params *params, 1804static int snd_pcm_hw_rule_buffer_bytes_max(struct snd_pcm_hw_params *params,
diff --git a/sound/core/pcm_timer.c b/sound/core/pcm_timer.c
index d94ed16d21ea..23aa9a27e215 100644
--- a/sound/core/pcm_timer.c
+++ b/sound/core/pcm_timer.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Digital Audio (PCM) abstract layer 2 * Digital Audio (PCM) abstract layer
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index e470c3c7d611..b8e700b94e59 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Abstract layer for MIDI v1.0 stream 2 * Abstract layer for MIDI v1.0 stream
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
@@ -30,14 +30,13 @@
30#include <linux/mutex.h> 30#include <linux/mutex.h>
31#include <linux/moduleparam.h> 31#include <linux/moduleparam.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/wait.h>
34#include <sound/rawmidi.h> 33#include <sound/rawmidi.h>
35#include <sound/info.h> 34#include <sound/info.h>
36#include <sound/control.h> 35#include <sound/control.h>
37#include <sound/minors.h> 36#include <sound/minors.h>
38#include <sound/initval.h> 37#include <sound/initval.h>
39 38
40MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 39MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
41MODULE_DESCRIPTION("Midlevel RawMidi code for ALSA."); 40MODULE_DESCRIPTION("Midlevel RawMidi code for ALSA.");
42MODULE_LICENSE("GPL"); 41MODULE_LICENSE("GPL");
43 42
diff --git a/sound/core/seq/Makefile b/sound/core/seq/Makefile
index 402e2b4a34c6..ceef14afee30 100644
--- a/sound/core/seq/Makefile
+++ b/sound/core/seq/Makefile
@@ -1,6 +1,6 @@
1# 1#
2# Makefile for ALSA 2# Makefile for ALSA
3# Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz> 3# Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>
4# 4#
5 5
6obj-$(CONFIG_SND) += instr/ 6obj-$(CONFIG_SND) += instr/
diff --git a/sound/core/seq/instr/Makefile b/sound/core/seq/instr/Makefile
index 69138f30a293..608960364813 100644
--- a/sound/core/seq/instr/Makefile
+++ b/sound/core/seq/instr/Makefile
@@ -1,6 +1,6 @@
1# 1#
2# Makefile for ALSA 2# Makefile for ALSA
3# Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz> 3# Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>
4# 4#
5 5
6snd-ainstr-fm-objs := ainstr_fm.o 6snd-ainstr-fm-objs := ainstr_fm.o
diff --git a/sound/core/seq/instr/ainstr_gf1.c b/sound/core/seq/instr/ainstr_gf1.c
index c640e1cf854d..49400262b1eb 100644
--- a/sound/core/seq/instr/ainstr_gf1.c
+++ b/sound/core/seq/instr/ainstr_gf1.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * GF1 (GUS) Patch - Instrument routines 2 * GF1 (GUS) Patch - Instrument routines
3 * Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 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 6 * it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
26#include <sound/initval.h> 26#include <sound/initval.h>
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28 28
29MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 29MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
30MODULE_DESCRIPTION("Advanced Linux Sound Architecture GF1 (GUS) Patch support."); 30MODULE_DESCRIPTION("Advanced Linux Sound Architecture GF1 (GUS) Patch support.");
31MODULE_LICENSE("GPL"); 31MODULE_LICENSE("GPL");
32 32
diff --git a/sound/core/seq/instr/ainstr_iw.c b/sound/core/seq/instr/ainstr_iw.c
index 5367baee2d08..6c40eb73fa9f 100644
--- a/sound/core/seq/instr/ainstr_iw.c
+++ b/sound/core/seq/instr/ainstr_iw.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * IWFFFF - AMD InterWave (tm) - Instrument routines 2 * IWFFFF - AMD InterWave (tm) - Instrument routines
3 * Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 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 6 * it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
26#include <sound/initval.h> 26#include <sound/initval.h>
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28 28
29MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 29MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
30MODULE_DESCRIPTION("Advanced Linux Sound Architecture IWFFFF support."); 30MODULE_DESCRIPTION("Advanced Linux Sound Architecture IWFFFF support.");
31MODULE_LICENSE("GPL"); 31MODULE_LICENSE("GPL");
32 32
diff --git a/sound/core/seq/instr/ainstr_simple.c b/sound/core/seq/instr/ainstr_simple.c
index ac717bef9d77..78f68bee24fe 100644
--- a/sound/core/seq/instr/ainstr_simple.c
+++ b/sound/core/seq/instr/ainstr_simple.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Simple (MOD player) - Instrument routines 2 * Simple (MOD player) - Instrument routines
3 * Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 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 6 * it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
26#include <sound/initval.h> 26#include <sound/initval.h>
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28 28
29MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 29MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
30MODULE_DESCRIPTION("Advanced Linux Sound Architecture Simple Instrument support."); 30MODULE_DESCRIPTION("Advanced Linux Sound Architecture Simple Instrument support.");
31MODULE_LICENSE("GPL"); 31MODULE_LICENSE("GPL");
32 32
diff --git a/sound/core/seq/oss/Makefile b/sound/core/seq/oss/Makefile
index a37ddedf7107..b38406b8463c 100644
--- a/sound/core/seq/oss/Makefile
+++ b/sound/core/seq/oss/Makefile
@@ -1,6 +1,6 @@
1# 1#
2# Makefile for ALSA 2# Makefile for ALSA
3# Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz> 3# Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>
4# 4#
5 5
6snd-seq-oss-objs := seq_oss.o seq_oss_init.o seq_oss_timer.o seq_oss_ioctl.o \ 6snd-seq-oss-objs := seq_oss.o seq_oss_init.o seq_oss_timer.o seq_oss_ioctl.o \
diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
index ca5a2ed4d7c3..d0d721c22eac 100644
--- a/sound/core/seq/oss/seq_oss_init.c
+++ b/sound/core/seq/oss/seq_oss_init.c
@@ -176,29 +176,29 @@ snd_seq_oss_open(struct file *file, int level)
176 int i, rc; 176 int i, rc;
177 struct seq_oss_devinfo *dp; 177 struct seq_oss_devinfo *dp;
178 178
179 if ((dp = kzalloc(sizeof(*dp), GFP_KERNEL)) == NULL) { 179 dp = kzalloc(sizeof(*dp), GFP_KERNEL);
180 if (!dp) {
180 snd_printk(KERN_ERR "can't malloc device info\n"); 181 snd_printk(KERN_ERR "can't malloc device info\n");
181 return -ENOMEM; 182 return -ENOMEM;
182 } 183 }
183 debug_printk(("oss_open: dp = %p\n", dp)); 184 debug_printk(("oss_open: dp = %p\n", dp));
184 185
186 dp->cseq = system_client;
187 dp->port = -1;
188 dp->queue = -1;
189
185 for (i = 0; i < SNDRV_SEQ_OSS_MAX_CLIENTS; i++) { 190 for (i = 0; i < SNDRV_SEQ_OSS_MAX_CLIENTS; i++) {
186 if (client_table[i] == NULL) 191 if (client_table[i] == NULL)
187 break; 192 break;
188 } 193 }
194
195 dp->index = i;
189 if (i >= SNDRV_SEQ_OSS_MAX_CLIENTS) { 196 if (i >= SNDRV_SEQ_OSS_MAX_CLIENTS) {
190 snd_printk(KERN_ERR "too many applications\n"); 197 snd_printk(KERN_ERR "too many applications\n");
191 kfree(dp); 198 rc = -ENOMEM;
192 return -ENOMEM; 199 goto _error;
193 } 200 }
194 201
195 dp->index = i;
196 dp->cseq = system_client;
197 dp->port = -1;
198 dp->queue = -1;
199 dp->readq = NULL;
200 dp->writeq = NULL;
201
202 /* look up synth and midi devices */ 202 /* look up synth and midi devices */
203 snd_seq_oss_synth_setup(dp); 203 snd_seq_oss_synth_setup(dp);
204 snd_seq_oss_midi_setup(dp); 204 snd_seq_oss_midi_setup(dp);
@@ -211,14 +211,16 @@ snd_seq_oss_open(struct file *file, int level)
211 211
212 /* create port */ 212 /* create port */
213 debug_printk(("create new port\n")); 213 debug_printk(("create new port\n"));
214 if ((rc = create_port(dp)) < 0) { 214 rc = create_port(dp);
215 if (rc < 0) {
215 snd_printk(KERN_ERR "can't create port\n"); 216 snd_printk(KERN_ERR "can't create port\n");
216 goto _error; 217 goto _error;
217 } 218 }
218 219
219 /* allocate queue */ 220 /* allocate queue */
220 debug_printk(("allocate queue\n")); 221 debug_printk(("allocate queue\n"));
221 if ((rc = alloc_seq_queue(dp)) < 0) 222 rc = alloc_seq_queue(dp);
223 if (rc < 0)
222 goto _error; 224 goto _error;
223 225
224 /* set address */ 226 /* set address */
@@ -235,7 +237,8 @@ snd_seq_oss_open(struct file *file, int level)
235 /* initialize read queue */ 237 /* initialize read queue */
236 debug_printk(("initialize read queue\n")); 238 debug_printk(("initialize read queue\n"));
237 if (is_read_mode(dp->file_mode)) { 239 if (is_read_mode(dp->file_mode)) {
238 if ((dp->readq = snd_seq_oss_readq_new(dp, maxqlen)) == NULL) { 240 dp->readq = snd_seq_oss_readq_new(dp, maxqlen);
241 if (!dp->readq) {
239 rc = -ENOMEM; 242 rc = -ENOMEM;
240 goto _error; 243 goto _error;
241 } 244 }
@@ -245,7 +248,7 @@ snd_seq_oss_open(struct file *file, int level)
245 debug_printk(("initialize write queue\n")); 248 debug_printk(("initialize write queue\n"));
246 if (is_write_mode(dp->file_mode)) { 249 if (is_write_mode(dp->file_mode)) {
247 dp->writeq = snd_seq_oss_writeq_new(dp, maxqlen); 250 dp->writeq = snd_seq_oss_writeq_new(dp, maxqlen);
248 if (dp->writeq == NULL) { 251 if (!dp->writeq) {
249 rc = -ENOMEM; 252 rc = -ENOMEM;
250 goto _error; 253 goto _error;
251 } 254 }
@@ -253,7 +256,8 @@ snd_seq_oss_open(struct file *file, int level)
253 256
254 /* initialize timer */ 257 /* initialize timer */
255 debug_printk(("initialize timer\n")); 258 debug_printk(("initialize timer\n"));
256 if ((dp->timer = snd_seq_oss_timer_new(dp)) == NULL) { 259 dp->timer = snd_seq_oss_timer_new(dp);
260 if (!dp->timer) {
257 snd_printk(KERN_ERR "can't alloc timer\n"); 261 snd_printk(KERN_ERR "can't alloc timer\n");
258 rc = -ENOMEM; 262 rc = -ENOMEM;
259 goto _error; 263 goto _error;
@@ -276,11 +280,13 @@ snd_seq_oss_open(struct file *file, int level)
276 return 0; 280 return 0;
277 281
278 _error: 282 _error:
283 snd_seq_oss_writeq_delete(dp->writeq);
284 snd_seq_oss_readq_delete(dp->readq);
279 snd_seq_oss_synth_cleanup(dp); 285 snd_seq_oss_synth_cleanup(dp);
280 snd_seq_oss_midi_cleanup(dp); 286 snd_seq_oss_midi_cleanup(dp);
281 i = dp->queue;
282 delete_port(dp); 287 delete_port(dp);
283 delete_seq_queue(i); 288 delete_seq_queue(dp->queue);
289 kfree(dp);
284 290
285 return rc; 291 return rc;
286} 292}
diff --git a/sound/core/seq/oss/seq_oss_writeq.c b/sound/core/seq/oss/seq_oss_writeq.c
index 5c8495601a38..217424858191 100644
--- a/sound/core/seq/oss/seq_oss_writeq.c
+++ b/sound/core/seq/oss/seq_oss_writeq.c
@@ -63,8 +63,10 @@ snd_seq_oss_writeq_new(struct seq_oss_devinfo *dp, int maxlen)
63void 63void
64snd_seq_oss_writeq_delete(struct seq_oss_writeq *q) 64snd_seq_oss_writeq_delete(struct seq_oss_writeq *q)
65{ 65{
66 snd_seq_oss_writeq_clear(q); /* to be sure */ 66 if (q) {
67 kfree(q); 67 snd_seq_oss_writeq_clear(q); /* to be sure */
68 kfree(q);
69 }
68} 70}
69 71
70 72
diff --git a/sound/core/seq/seq.c b/sound/core/seq/seq.c
index 2f0d8773ac6b..1878208a8026 100644
--- a/sound/core/seq/seq.c
+++ b/sound/core/seq/seq.c
@@ -53,7 +53,7 @@ int seq_default_timer_device =
53int seq_default_timer_subdevice = 0; 53int seq_default_timer_subdevice = 0;
54int seq_default_timer_resolution = 0; /* Hz */ 54int seq_default_timer_resolution = 0; /* Hz */
55 55
56MODULE_AUTHOR("Frank van de Pol <fvdpol@coil.demon.nl>, Jaroslav Kysela <perex@suse.cz>"); 56MODULE_AUTHOR("Frank van de Pol <fvdpol@coil.demon.nl>, Jaroslav Kysela <perex@perex.cz>");
57MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer."); 57MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer.");
58MODULE_LICENSE("GPL"); 58MODULE_LICENSE("GPL");
59 59
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index b31b5282a2c8..2e3fa25ab19f 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * ALSA sequencer Client Manager 2 * ALSA sequencer Client Manager
3 * Copyright (c) 1998-2001 by Frank van de Pol <fvdpol@coil.demon.nl> 3 * Copyright (c) 1998-2001 by Frank van de Pol <fvdpol@coil.demon.nl>
4 * Jaroslav Kysela <perex@suse.cz> 4 * Jaroslav Kysela <perex@perex.cz>
5 * Takashi Iwai <tiwai@suse.de> 5 * Takashi Iwai <tiwai@suse.de>
6 * 6 *
7 * 7 *
diff --git a/sound/core/seq/seq_instr.c b/sound/core/seq/seq_instr.c
index 5efe6523a589..9a6fd56c9109 100644
--- a/sound/core/seq/seq_instr.c
+++ b/sound/core/seq/seq_instr.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Generic Instrument routines for ALSA sequencer 2 * Generic Instrument routines for ALSA sequencer
3 * Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 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 6 * it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
26#include <sound/seq_instr.h> 26#include <sound/seq_instr.h>
27#include <sound/initval.h> 27#include <sound/initval.h>
28 28
29MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 29MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
30MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer instrument library."); 30MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer instrument library.");
31MODULE_LICENSE("GPL"); 31MODULE_LICENSE("GPL");
32 32
@@ -109,7 +109,7 @@ void snd_seq_instr_list_free(struct snd_seq_kinstr_list **list_ptr)
109 spin_lock_irqsave(&list->lock, flags); 109 spin_lock_irqsave(&list->lock, flags);
110 while (instr->use) { 110 while (instr->use) {
111 spin_unlock_irqrestore(&list->lock, flags); 111 spin_unlock_irqrestore(&list->lock, flags);
112 schedule_timeout(1); 112 schedule_timeout_uninterruptible(1);
113 spin_lock_irqsave(&list->lock, flags); 113 spin_lock_irqsave(&list->lock, flags);
114 } 114 }
115 spin_unlock_irqrestore(&list->lock, flags); 115 spin_unlock_irqrestore(&list->lock, flags);
@@ -198,8 +198,10 @@ int snd_seq_instr_list_free_cond(struct snd_seq_kinstr_list *list,
198 while (flist) { 198 while (flist) {
199 instr = flist; 199 instr = flist;
200 flist = instr->next; 200 flist = instr->next;
201 while (instr->use) 201 while (instr->use) {
202 schedule_timeout(1); 202 schedule_timeout_uninterruptible(1);
203 barrier();
204 }
203 if (snd_seq_instr_free(instr, atomic)<0) 205 if (snd_seq_instr_free(instr, atomic)<0)
204 snd_printk(KERN_WARNING "instrument free problem\n"); 206 snd_printk(KERN_WARNING "instrument free problem\n");
205 instr = next; 207 instr = next;
@@ -555,7 +557,7 @@ static int instr_free(struct snd_seq_kinstr_ops *ops,
555 SNDRV_SEQ_INSTR_NOTIFY_REMOVE); 557 SNDRV_SEQ_INSTR_NOTIFY_REMOVE);
556 while (instr->use) { 558 while (instr->use) {
557 spin_unlock_irqrestore(&list->lock, flags); 559 spin_unlock_irqrestore(&list->lock, flags);
558 schedule_timeout(1); 560 schedule_timeout_uninterruptible(1);
559 spin_lock_irqsave(&list->lock, flags); 561 spin_lock_irqsave(&list->lock, flags);
560 } 562 }
561 spin_unlock_irqrestore(&list->lock, flags); 563 spin_unlock_irqrestore(&list->lock, flags);
diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c
index a3dc5e01e9f2..a72a1945bf8a 100644
--- a/sound/core/seq/seq_memory.c
+++ b/sound/core/seq/seq_memory.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * ALSA sequencer Memory Manager 2 * ALSA sequencer Memory Manager
3 * Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl> 3 * Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
4 * Jaroslav Kysela <perex@suse.cz> 4 * Jaroslav Kysela <perex@perex.cz>
5 * 2000 by Takashi Iwai <tiwai@suse.de> 5 * 2000 by Takashi Iwai <tiwai@suse.de>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c
index 1daa5b069c79..5929aaf1df9d 100644
--- a/sound/core/seq/seq_midi.c
+++ b/sound/core/seq/seq_midi.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Generic MIDI synth driver for ALSA sequencer 2 * Generic MIDI synth driver for ALSA sequencer
3 * Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl> 3 * Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
4 * Jaroslav Kysela <perex@suse.cz> 4 * Jaroslav Kysela <perex@perex.cz>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
@@ -40,7 +40,7 @@ Possible options for midisynth module:
40#include <sound/seq_midi_event.h> 40#include <sound/seq_midi_event.h>
41#include <sound/initval.h> 41#include <sound/initval.h>
42 42
43MODULE_AUTHOR("Frank van de Pol <fvdpol@coil.demon.nl>, Jaroslav Kysela <perex@suse.cz>"); 43MODULE_AUTHOR("Frank van de Pol <fvdpol@coil.demon.nl>, Jaroslav Kysela <perex@perex.cz>");
44MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer MIDI synth."); 44MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer MIDI synth.");
45MODULE_LICENSE("GPL"); 45MODULE_LICENSE("GPL");
46static int output_buffer_size = PAGE_SIZE; 46static int output_buffer_size = PAGE_SIZE;
diff --git a/sound/core/seq/seq_midi_event.c b/sound/core/seq/seq_midi_event.c
index 5ff80b776906..b6820a5a73fc 100644
--- a/sound/core/seq/seq_midi_event.c
+++ b/sound/core/seq/seq_midi_event.c
@@ -2,7 +2,7 @@
2 * MIDI byte <-> sequencer event coder 2 * MIDI byte <-> sequencer event coder
3 * 3 *
4 * Copyright (C) 1998,99 Takashi Iwai <tiwai@suse.de>, 4 * Copyright (C) 1998,99 Takashi Iwai <tiwai@suse.de>,
5 * Jaroslav Kysela <perex@suse.cz> 5 * Jaroslav Kysela <perex@perex.cz>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -28,14 +28,13 @@
28#include <sound/seq_midi_event.h> 28#include <sound/seq_midi_event.h>
29#include <sound/asoundef.h> 29#include <sound/asoundef.h>
30 30
31MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@suse.cz>"); 31MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@perex.cz>");
32MODULE_DESCRIPTION("MIDI byte <-> sequencer event coder"); 32MODULE_DESCRIPTION("MIDI byte <-> sequencer event coder");
33MODULE_LICENSE("GPL"); 33MODULE_LICENSE("GPL");
34 34
35/* queue type */ 35/* event type, index into status_event[] */
36/* from 0 to 7 are normal commands (note off, on, etc.) */ 36/* from 0 to 6 are normal commands (note off, on, etc.) for 0x9?-0xe? */
37#define ST_NOTEOFF 0 37#define ST_INVALID 7
38#define ST_NOTEON 1
39#define ST_SPECIAL 8 38#define ST_SPECIAL 8
40#define ST_SYSEX ST_SPECIAL 39#define ST_SYSEX ST_SPECIAL
41/* from 8 to 15 are events for 0xf0-0xf7 */ 40/* from 8 to 15 are events for 0xf0-0xf7 */
@@ -65,32 +64,33 @@ static struct status_event_list {
65 void (*encode)(struct snd_midi_event *dev, struct snd_seq_event *ev); 64 void (*encode)(struct snd_midi_event *dev, struct snd_seq_event *ev);
66 void (*decode)(struct snd_seq_event *ev, unsigned char *buf); 65 void (*decode)(struct snd_seq_event *ev, unsigned char *buf);
67} status_event[] = { 66} status_event[] = {
68 /* 0x80 - 0xf0 */ 67 /* 0x80 - 0xef */
69 {SNDRV_SEQ_EVENT_NOTEOFF, 2, note_event, note_decode}, 68 {SNDRV_SEQ_EVENT_NOTEOFF, 2, note_event, note_decode},
70 {SNDRV_SEQ_EVENT_NOTEON, 2, note_event, note_decode}, 69 {SNDRV_SEQ_EVENT_NOTEON, 2, note_event, note_decode},
71 {SNDRV_SEQ_EVENT_KEYPRESS, 2, note_event, note_decode}, 70 {SNDRV_SEQ_EVENT_KEYPRESS, 2, note_event, note_decode},
72 {SNDRV_SEQ_EVENT_CONTROLLER, 2, two_param_ctrl_event, two_param_decode}, 71 {SNDRV_SEQ_EVENT_CONTROLLER, 2, two_param_ctrl_event, two_param_decode},
73 {SNDRV_SEQ_EVENT_PGMCHANGE, 1, one_param_ctrl_event, one_param_decode}, 72 {SNDRV_SEQ_EVENT_PGMCHANGE, 1, one_param_ctrl_event, one_param_decode},
74 {SNDRV_SEQ_EVENT_CHANPRESS, 1, one_param_ctrl_event, one_param_decode}, 73 {SNDRV_SEQ_EVENT_CHANPRESS, 1, one_param_ctrl_event, one_param_decode},
75 {SNDRV_SEQ_EVENT_PITCHBEND, 2, pitchbend_ctrl_event, pitchbend_decode}, 74 {SNDRV_SEQ_EVENT_PITCHBEND, 2, pitchbend_ctrl_event, pitchbend_decode},
76 {SNDRV_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf0 */ 75 /* invalid */
76 {SNDRV_SEQ_EVENT_NONE, -1, NULL, NULL},
77 /* 0xf0 - 0xff */ 77 /* 0xf0 - 0xff */
78 {SNDRV_SEQ_EVENT_SYSEX, 1, NULL, NULL}, /* sysex: 0xf0 */ 78 {SNDRV_SEQ_EVENT_SYSEX, 1, NULL, NULL}, /* sysex: 0xf0 */
79 {SNDRV_SEQ_EVENT_QFRAME, 1, one_param_event, one_param_decode}, /* 0xf1 */ 79 {SNDRV_SEQ_EVENT_QFRAME, 1, one_param_event, one_param_decode}, /* 0xf1 */
80 {SNDRV_SEQ_EVENT_SONGPOS, 2, songpos_event, songpos_decode}, /* 0xf2 */ 80 {SNDRV_SEQ_EVENT_SONGPOS, 2, songpos_event, songpos_decode}, /* 0xf2 */
81 {SNDRV_SEQ_EVENT_SONGSEL, 1, one_param_event, one_param_decode}, /* 0xf3 */ 81 {SNDRV_SEQ_EVENT_SONGSEL, 1, one_param_event, one_param_decode}, /* 0xf3 */
82 {SNDRV_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf4 */ 82 {SNDRV_SEQ_EVENT_NONE, -1, NULL, NULL}, /* 0xf4 */
83 {SNDRV_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf5 */ 83 {SNDRV_SEQ_EVENT_NONE, -1, NULL, NULL}, /* 0xf5 */
84 {SNDRV_SEQ_EVENT_TUNE_REQUEST, 0, NULL, NULL}, /* 0xf6 */ 84 {SNDRV_SEQ_EVENT_TUNE_REQUEST, 0, NULL, NULL}, /* 0xf6 */
85 {SNDRV_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf7 */ 85 {SNDRV_SEQ_EVENT_NONE, -1, NULL, NULL}, /* 0xf7 */
86 {SNDRV_SEQ_EVENT_CLOCK, 0, NULL, NULL}, /* 0xf8 */ 86 {SNDRV_SEQ_EVENT_CLOCK, 0, NULL, NULL}, /* 0xf8 */
87 {SNDRV_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xf9 */ 87 {SNDRV_SEQ_EVENT_NONE, -1, NULL, NULL}, /* 0xf9 */
88 {SNDRV_SEQ_EVENT_START, 0, NULL, NULL}, /* 0xfa */ 88 {SNDRV_SEQ_EVENT_START, 0, NULL, NULL}, /* 0xfa */
89 {SNDRV_SEQ_EVENT_CONTINUE, 0, NULL, NULL}, /* 0xfb */ 89 {SNDRV_SEQ_EVENT_CONTINUE, 0, NULL, NULL}, /* 0xfb */
90 {SNDRV_SEQ_EVENT_STOP, 0, NULL, NULL}, /* 0xfc */ 90 {SNDRV_SEQ_EVENT_STOP, 0, NULL, NULL}, /* 0xfc */
91 {SNDRV_SEQ_EVENT_NONE, 0, NULL, NULL}, /* 0xfd */ 91 {SNDRV_SEQ_EVENT_NONE, -1, NULL, NULL}, /* 0xfd */
92 {SNDRV_SEQ_EVENT_SENSING, 0, NULL, NULL}, /* 0xfe */ 92 {SNDRV_SEQ_EVENT_SENSING, 0, NULL, NULL}, /* 0xfe */
93 {SNDRV_SEQ_EVENT_RESET, 0, NULL, NULL}, /* 0xff */ 93 {SNDRV_SEQ_EVENT_RESET, 0, NULL, NULL}, /* 0xff */
94}; 94};
95 95
96static int extra_decode_ctrl14(struct snd_midi_event *dev, unsigned char *buf, int len, 96static int extra_decode_ctrl14(struct snd_midi_event *dev, unsigned char *buf, int len,
@@ -129,6 +129,7 @@ int snd_midi_event_new(int bufsize, struct snd_midi_event **rdev)
129 } 129 }
130 dev->bufsize = bufsize; 130 dev->bufsize = bufsize;
131 dev->lastcmd = 0xff; 131 dev->lastcmd = 0xff;
132 dev->type = ST_INVALID;
132 spin_lock_init(&dev->lock); 133 spin_lock_init(&dev->lock);
133 *rdev = dev; 134 *rdev = dev;
134 return 0; 135 return 0;
@@ -149,7 +150,7 @@ static inline void reset_encode(struct snd_midi_event *dev)
149{ 150{
150 dev->read = 0; 151 dev->read = 0;
151 dev->qlen = 0; 152 dev->qlen = 0;
152 dev->type = 0; 153 dev->type = ST_INVALID;
153} 154}
154 155
155void snd_midi_event_reset_encode(struct snd_midi_event *dev) 156void snd_midi_event_reset_encode(struct snd_midi_event *dev)
@@ -251,29 +252,31 @@ int snd_midi_event_encode_byte(struct snd_midi_event *dev, int c,
251 ev->type = status_event[ST_SPECIAL + c - 0xf0].event; 252 ev->type = status_event[ST_SPECIAL + c - 0xf0].event;
252 ev->flags &= ~SNDRV_SEQ_EVENT_LENGTH_MASK; 253 ev->flags &= ~SNDRV_SEQ_EVENT_LENGTH_MASK;
253 ev->flags |= SNDRV_SEQ_EVENT_LENGTH_FIXED; 254 ev->flags |= SNDRV_SEQ_EVENT_LENGTH_FIXED;
254 return 1; 255 return ev->type != SNDRV_SEQ_EVENT_NONE;
255 } 256 }
256 257
257 spin_lock_irqsave(&dev->lock, flags); 258 spin_lock_irqsave(&dev->lock, flags);
258 if (dev->qlen > 0) { 259 if ((c & 0x80) &&
259 /* rest of command */ 260 (c != MIDI_CMD_COMMON_SYSEX_END || dev->type != ST_SYSEX)) {
260 dev->buf[dev->read++] = c;
261 if (dev->type != ST_SYSEX)
262 dev->qlen--;
263 } else {
264 /* new command */ 261 /* new command */
262 dev->buf[0] = c;
263 if ((c & 0xf0) == 0xf0) /* system messages */
264 dev->type = (c & 0x0f) + ST_SPECIAL;
265 else
266 dev->type = (c >> 4) & 0x07;
265 dev->read = 1; 267 dev->read = 1;
266 if (c & 0x80) { 268 dev->qlen = status_event[dev->type].qlen;
267 dev->buf[0] = c; 269 } else {
268 if ((c & 0xf0) == 0xf0) /* special events */ 270 if (dev->qlen > 0) {
269 dev->type = (c & 0x0f) + ST_SPECIAL; 271 /* rest of command */
270 else
271 dev->type = (c >> 4) & 0x07;
272 dev->qlen = status_event[dev->type].qlen;
273 } else {
274 /* process this byte as argument */
275 dev->buf[dev->read++] = c; 272 dev->buf[dev->read++] = c;
273 if (dev->type != ST_SYSEX)
274 dev->qlen--;
275 } else {
276 /* running status */
277 dev->buf[1] = c;
276 dev->qlen = status_event[dev->type].qlen - 1; 278 dev->qlen = status_event[dev->type].qlen - 1;
279 dev->read = 2;
277 } 280 }
278 } 281 }
279 if (dev->qlen == 0) { 282 if (dev->qlen == 0) {
@@ -282,6 +285,8 @@ int snd_midi_event_encode_byte(struct snd_midi_event *dev, int c,
282 ev->flags |= SNDRV_SEQ_EVENT_LENGTH_FIXED; 285 ev->flags |= SNDRV_SEQ_EVENT_LENGTH_FIXED;
283 if (status_event[dev->type].encode) /* set data values */ 286 if (status_event[dev->type].encode) /* set data values */
284 status_event[dev->type].encode(dev, ev); 287 status_event[dev->type].encode(dev, ev);
288 if (dev->type >= ST_SPECIAL)
289 dev->type = ST_INVALID;
285 rc = 1; 290 rc = 1;
286 } else if (dev->type == ST_SYSEX) { 291 } else if (dev->type == ST_SYSEX) {
287 if (c == MIDI_CMD_COMMON_SYSEX_END || 292 if (c == MIDI_CMD_COMMON_SYSEX_END ||
diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c
index eefd1cf872b4..b6e23ad12ab9 100644
--- a/sound/core/seq/seq_ports.c
+++ b/sound/core/seq/seq_ports.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * ALSA sequencer Ports 2 * ALSA sequencer Ports
3 * Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl> 3 * Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
4 * Jaroslav Kysela <perex@suse.cz> 4 * Jaroslav Kysela <perex@perex.cz>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c
index b4b9a132cb16..8716352afc81 100644
--- a/sound/core/seq/seq_timer.c
+++ b/sound/core/seq/seq_timer.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * ALSA sequencer Timer 2 * ALSA sequencer Timer
3 * Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl> 3 * Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
4 * Jaroslav Kysela <perex@suse.cz> 4 * Jaroslav Kysela <perex@perex.cz>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 8dc7a3b32b98..7b486c4d70db 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Advanced Linux Sound Architecture 2 * Advanced Linux Sound Architecture
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
@@ -42,7 +42,7 @@ EXPORT_SYMBOL(snd_major);
42 42
43static int cards_limit = 1; 43static int cards_limit = 1;
44 44
45MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 45MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
46MODULE_DESCRIPTION("Advanced Linux Sound Architecture driver for soundcards."); 46MODULE_DESCRIPTION("Advanced Linux Sound Architecture driver for soundcards.");
47MODULE_LICENSE("GPL"); 47MODULE_LICENSE("GPL");
48module_param(major, int, 0444); 48module_param(major, int, 0444);
@@ -266,6 +266,14 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
266 snd_minors[minor] = preg; 266 snd_minors[minor] = preg;
267 preg->dev = device_create(sound_class, device, MKDEV(major, minor), 267 preg->dev = device_create(sound_class, device, MKDEV(major, minor),
268 "%s", name); 268 "%s", name);
269 if (IS_ERR(preg->dev)) {
270 snd_minors[minor] = NULL;
271 mutex_unlock(&sound_mutex);
272 minor = PTR_ERR(preg->dev);
273 kfree(preg);
274 return minor;
275 }
276
269 if (preg->dev) 277 if (preg->dev)
270 dev_set_drvdata(preg->dev, private_data); 278 dev_set_drvdata(preg->dev, private_data);
271 279
diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c
index 4566df41912a..dc73313b733a 100644
--- a/sound/core/sound_oss.c
+++ b/sound/core/sound_oss.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Advanced Linux Sound Architecture 2 * Advanced Linux Sound Architecture
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
diff --git a/sound/core/timer.c b/sound/core/timer.c
index f2bbacedd567..e7dc56ca4b97 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Timers abstract layer 2 * Timers abstract layer
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
@@ -44,7 +44,7 @@
44#endif 44#endif
45 45
46static int timer_limit = DEFAULT_TIMER_LIMIT; 46static int timer_limit = DEFAULT_TIMER_LIMIT;
47MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Takashi Iwai <tiwai@suse.de>"); 47MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>");
48MODULE_DESCRIPTION("ALSA timer interface"); 48MODULE_DESCRIPTION("ALSA timer interface");
49MODULE_LICENSE("GPL"); 49MODULE_LICENSE("GPL");
50module_param(timer_limit, int, 0444); 50module_param(timer_limit, int, 0444);