diff options
author | Jaroslav Kysela <perex@perex.cz> | 2008-08-01 07:36:04 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-08-01 07:36:04 -0400 |
commit | 896e6cc20e67038af12e1a7711eef32647e62f23 (patch) | |
tree | 54fc5c48570c75aa2f0a5bbecf0d159006c69638 | |
parent | 687fbc3fece34e7e1c2ac529348ad897095a0bde (diff) |
sound: Revert "ALSA: Fix limit of 8 PCM devices in SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE"
This reverts commit fb3d6f2b77bdec75d45aa9d4464287ed87927866.
New, updated patch with same subject replaces this commit.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r-- | include/sound/minors.h | 2 | ||||
-rw-r--r-- | include/sound/pcm.h | 4 | ||||
-rw-r--r-- | sound/core/oss/pcm_oss.c | 10 | ||||
-rw-r--r-- | sound/core/pcm.c | 50 | ||||
-rw-r--r-- | sound/core/sound.c | 2 |
5 files changed, 23 insertions, 45 deletions
diff --git a/include/sound/minors.h b/include/sound/minors.h index a81798ab73ed..46bcd2023ed8 100644 --- a/include/sound/minors.h +++ b/include/sound/minors.h | |||
@@ -21,8 +21,6 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #define SNDRV_OS_MINORS 256 | ||
25 | |||
26 | #define SNDRV_MINOR_DEVICES 32 | 24 | #define SNDRV_MINOR_DEVICES 32 |
27 | #define SNDRV_MINOR_CARD(minor) ((minor) >> 5) | 25 | #define SNDRV_MINOR_CARD(minor) ((minor) >> 5) |
28 | #define SNDRV_MINOR_DEVICE(minor) ((minor) & 0x001f) | 26 | #define SNDRV_MINOR_DEVICE(minor) ((minor) & 0x001f) |
diff --git a/include/sound/pcm.h b/include/sound/pcm.h index bfc096ac82e5..51d58ccda2d8 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h | |||
@@ -84,6 +84,8 @@ struct snd_pcm_ops { | |||
84 | * | 84 | * |
85 | */ | 85 | */ |
86 | 86 | ||
87 | #define SNDRV_PCM_DEVICES 8 | ||
88 | |||
87 | #define SNDRV_PCM_IOCTL1_FALSE ((void *)0) | 89 | #define SNDRV_PCM_IOCTL1_FALSE ((void *)0) |
88 | #define SNDRV_PCM_IOCTL1_TRUE ((void *)1) | 90 | #define SNDRV_PCM_IOCTL1_TRUE ((void *)1) |
89 | 91 | ||
@@ -414,7 +416,7 @@ struct snd_pcm_str { | |||
414 | struct snd_pcm { | 416 | struct snd_pcm { |
415 | struct snd_card *card; | 417 | struct snd_card *card; |
416 | struct list_head list; | 418 | struct list_head list; |
417 | int device; /* device number */ | 419 | unsigned int device; /* device number */ |
418 | unsigned int info_flags; | 420 | unsigned int info_flags; |
419 | unsigned short dev_class; | 421 | unsigned short dev_class; |
420 | unsigned short dev_subclass; | 422 | unsigned short dev_subclass; |
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 4ccd761a5f41..4c601b192ddf 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c | |||
@@ -2947,7 +2947,7 @@ static void register_oss_dsp(struct snd_pcm *pcm, int index) | |||
2947 | static int snd_pcm_oss_register_minor(struct snd_pcm *pcm) | 2947 | static int snd_pcm_oss_register_minor(struct snd_pcm *pcm) |
2948 | { | 2948 | { |
2949 | pcm->oss.reg = 0; | 2949 | pcm->oss.reg = 0; |
2950 | if (dsp_map[pcm->card->number] == pcm->device) { | 2950 | if (dsp_map[pcm->card->number] == (int)pcm->device) { |
2951 | char name[128]; | 2951 | char name[128]; |
2952 | int duplex; | 2952 | int duplex; |
2953 | register_oss_dsp(pcm, 0); | 2953 | register_oss_dsp(pcm, 0); |
@@ -2963,7 +2963,7 @@ static int snd_pcm_oss_register_minor(struct snd_pcm *pcm) | |||
2963 | pcm->oss.reg++; | 2963 | pcm->oss.reg++; |
2964 | pcm->oss.reg_mask |= 1; | 2964 | pcm->oss.reg_mask |= 1; |
2965 | } | 2965 | } |
2966 | if (adsp_map[pcm->card->number] == pcm->device) { | 2966 | if (adsp_map[pcm->card->number] == (int)pcm->device) { |
2967 | register_oss_dsp(pcm, 1); | 2967 | register_oss_dsp(pcm, 1); |
2968 | pcm->oss.reg++; | 2968 | pcm->oss.reg++; |
2969 | pcm->oss.reg_mask |= 2; | 2969 | pcm->oss.reg_mask |= 2; |
@@ -2988,7 +2988,7 @@ static int snd_pcm_oss_disconnect_minor(struct snd_pcm *pcm) | |||
2988 | snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM, | 2988 | snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM, |
2989 | pcm->card, 1); | 2989 | pcm->card, 1); |
2990 | } | 2990 | } |
2991 | if (dsp_map[pcm->card->number] == pcm->device) { | 2991 | if (dsp_map[pcm->card->number] == (int)pcm->device) { |
2992 | #ifdef SNDRV_OSS_INFO_DEV_AUDIO | 2992 | #ifdef SNDRV_OSS_INFO_DEV_AUDIO |
2993 | snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_AUDIO, pcm->card->number); | 2993 | snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_AUDIO, pcm->card->number); |
2994 | #endif | 2994 | #endif |
@@ -3019,12 +3019,12 @@ static int __init alsa_pcm_oss_init(void) | |||
3019 | 3019 | ||
3020 | /* check device map table */ | 3020 | /* check device map table */ |
3021 | for (i = 0; i < SNDRV_CARDS; i++) { | 3021 | for (i = 0; i < SNDRV_CARDS; i++) { |
3022 | if (dsp_map[i] < 0 || dsp_map[i] >= SNDRV_OS_MINORS) { | 3022 | if (dsp_map[i] < 0 || dsp_map[i] >= SNDRV_PCM_DEVICES) { |
3023 | snd_printk(KERN_ERR "invalid dsp_map[%d] = %d\n", | 3023 | snd_printk(KERN_ERR "invalid dsp_map[%d] = %d\n", |
3024 | i, dsp_map[i]); | 3024 | i, dsp_map[i]); |
3025 | dsp_map[i] = 0; | 3025 | dsp_map[i] = 0; |
3026 | } | 3026 | } |
3027 | if (adsp_map[i] < 0 || adsp_map[i] >= SNDRV_OS_MINORS) { | 3027 | if (adsp_map[i] < 0 || adsp_map[i] >= SNDRV_PCM_DEVICES) { |
3028 | snd_printk(KERN_ERR "invalid adsp_map[%d] = %d\n", | 3028 | snd_printk(KERN_ERR "invalid adsp_map[%d] = %d\n", |
3029 | i, adsp_map[i]); | 3029 | i, adsp_map[i]); |
3030 | adsp_map[i] = 1; | 3030 | adsp_map[i] = 1; |
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 24271a3bd901..ece25c718e95 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c | |||
@@ -42,7 +42,7 @@ static int snd_pcm_dev_free(struct snd_device *device); | |||
42 | static int snd_pcm_dev_register(struct snd_device *device); | 42 | static int snd_pcm_dev_register(struct snd_device *device); |
43 | static int snd_pcm_dev_disconnect(struct snd_device *device); | 43 | static int snd_pcm_dev_disconnect(struct snd_device *device); |
44 | 44 | ||
45 | static inline struct snd_pcm *snd_pcm_get(struct snd_card *card, int device) | 45 | static struct snd_pcm *snd_pcm_search(struct snd_card *card, int device) |
46 | { | 46 | { |
47 | struct snd_pcm *pcm; | 47 | struct snd_pcm *pcm; |
48 | 48 | ||
@@ -53,37 +53,6 @@ static inline struct snd_pcm *snd_pcm_get(struct snd_card *card, int device) | |||
53 | return NULL; | 53 | return NULL; |
54 | } | 54 | } |
55 | 55 | ||
56 | static inline int snd_pcm_next(struct snd_card *card, int device) | ||
57 | { | ||
58 | struct snd_pcm *pcm; | ||
59 | |||
60 | list_for_each_entry(pcm, &snd_pcm_devices, list) { | ||
61 | if (pcm->card == card && pcm->device > device) | ||
62 | return pcm->device; | ||
63 | else if (pcm->card->number > card->number) | ||
64 | return -1; | ||
65 | } | ||
66 | return -1; | ||
67 | } | ||
68 | |||
69 | static inline int snd_pcm_add(struct snd_pcm *newpcm) | ||
70 | { | ||
71 | struct snd_pcm *pcm; | ||
72 | |||
73 | list_for_each_entry(pcm, &snd_pcm_devices, list) { | ||
74 | if (pcm->card == newpcm->card && pcm->device == newpcm->device) | ||
75 | return -EBUSY; | ||
76 | if (pcm->card->number > newpcm->card->number || | ||
77 | (pcm->card == newpcm->card && | ||
78 | pcm->device > newpcm->device)) { | ||
79 | list_add(&newpcm->list, pcm->list.prev); | ||
80 | return 0; | ||
81 | } | ||
82 | } | ||
83 | list_add_tail(&newpcm->list, &snd_pcm_devices); | ||
84 | return 0; | ||
85 | } | ||
86 | |||
87 | static int snd_pcm_control_ioctl(struct snd_card *card, | 56 | static int snd_pcm_control_ioctl(struct snd_card *card, |
88 | struct snd_ctl_file *control, | 57 | struct snd_ctl_file *control, |
89 | unsigned int cmd, unsigned long arg) | 58 | unsigned int cmd, unsigned long arg) |
@@ -96,7 +65,14 @@ static int snd_pcm_control_ioctl(struct snd_card *card, | |||
96 | if (get_user(device, (int __user *)arg)) | 65 | if (get_user(device, (int __user *)arg)) |
97 | return -EFAULT; | 66 | return -EFAULT; |
98 | mutex_lock(®ister_mutex); | 67 | mutex_lock(®ister_mutex); |
99 | device = snd_pcm_next(card, device); | 68 | device = device < 0 ? 0 : device + 1; |
69 | while (device < SNDRV_PCM_DEVICES) { | ||
70 | if (snd_pcm_search(card, device)) | ||
71 | break; | ||
72 | device++; | ||
73 | } | ||
74 | if (device == SNDRV_PCM_DEVICES) | ||
75 | device = -1; | ||
100 | mutex_unlock(®ister_mutex); | 76 | mutex_unlock(®ister_mutex); |
101 | if (put_user(device, (int __user *)arg)) | 77 | if (put_user(device, (int __user *)arg)) |
102 | return -EFAULT; | 78 | return -EFAULT; |
@@ -122,7 +98,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, | |||
122 | if (get_user(subdevice, &info->subdevice)) | 98 | if (get_user(subdevice, &info->subdevice)) |
123 | return -EFAULT; | 99 | return -EFAULT; |
124 | mutex_lock(®ister_mutex); | 100 | mutex_lock(®ister_mutex); |
125 | pcm = snd_pcm_get(card, device); | 101 | pcm = snd_pcm_search(card, device); |
126 | if (pcm == NULL) { | 102 | if (pcm == NULL) { |
127 | err = -ENXIO; | 103 | err = -ENXIO; |
128 | goto _error; | 104 | goto _error; |
@@ -955,11 +931,11 @@ static int snd_pcm_dev_register(struct snd_device *device) | |||
955 | 931 | ||
956 | snd_assert(pcm != NULL && device != NULL, return -ENXIO); | 932 | snd_assert(pcm != NULL && device != NULL, return -ENXIO); |
957 | mutex_lock(®ister_mutex); | 933 | mutex_lock(®ister_mutex); |
958 | err = snd_pcm_add(pcm); | 934 | if (snd_pcm_search(pcm->card, pcm->device)) { |
959 | if (err) { | ||
960 | mutex_unlock(®ister_mutex); | 935 | mutex_unlock(®ister_mutex); |
961 | return err; | 936 | return -EBUSY; |
962 | } | 937 | } |
938 | list_add_tail(&pcm->list, &snd_pcm_devices); | ||
963 | for (cidx = 0; cidx < 2; cidx++) { | 939 | for (cidx = 0; cidx < 2; cidx++) { |
964 | int devtype = -1; | 940 | int devtype = -1; |
965 | if (pcm->streams[cidx].substream == NULL) | 941 | if (pcm->streams[cidx].substream == NULL) |
diff --git a/sound/core/sound.c b/sound/core/sound.c index 838dd9ee957c..1003ae375d47 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c | |||
@@ -34,6 +34,8 @@ | |||
34 | #include <linux/kmod.h> | 34 | #include <linux/kmod.h> |
35 | #include <linux/mutex.h> | 35 | #include <linux/mutex.h> |
36 | 36 | ||
37 | #define SNDRV_OS_MINORS 256 | ||
38 | |||
37 | static int major = CONFIG_SND_MAJOR; | 39 | static int major = CONFIG_SND_MAJOR; |
38 | int snd_major; | 40 | int snd_major; |
39 | EXPORT_SYMBOL(snd_major); | 41 | EXPORT_SYMBOL(snd_major); |