aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/oss/pcm_oss.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/oss/pcm_oss.c')
-rw-r--r--sound/core/oss/pcm_oss.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index a2e4eb32469..23c34a02894 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -41,6 +41,7 @@
41#include <sound/info.h> 41#include <sound/info.h>
42#include <linux/soundcard.h> 42#include <linux/soundcard.h>
43#include <sound/initval.h> 43#include <sound/initval.h>
44#include <sound/mixer_oss.h>
44 45
45#define OSS_ALSAEMULVER _SIOR ('M', 249, int) 46#define OSS_ALSAEMULVER _SIOR ('M', 249, int)
46 47
@@ -60,7 +61,6 @@ MODULE_PARM_DESC(nonblock_open, "Don't block opening busy PCM devices.");
60MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM); 61MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM);
61MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM1); 62MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM1);
62 63
63extern int snd_mixer_oss_ioctl_card(struct snd_card *card, unsigned int cmd, unsigned long arg);
64static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file); 64static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file);
65static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file); 65static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file);
66static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file); 66static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file);
@@ -656,7 +656,7 @@ snd_pcm_uframes_t get_hw_ptr_period(struct snd_pcm_runtime *runtime)
656#define AFMT_AC3 0x00000400 656#define AFMT_AC3 0x00000400
657#define AFMT_VORBIS 0x00000800 657#define AFMT_VORBIS 0x00000800
658 658
659static int snd_pcm_oss_format_from(int format) 659static snd_pcm_format_t snd_pcm_oss_format_from(int format)
660{ 660{
661 switch (format) { 661 switch (format) {
662 case AFMT_MU_LAW: return SNDRV_PCM_FORMAT_MU_LAW; 662 case AFMT_MU_LAW: return SNDRV_PCM_FORMAT_MU_LAW;
@@ -680,7 +680,7 @@ static int snd_pcm_oss_format_from(int format)
680 } 680 }
681} 681}
682 682
683static int snd_pcm_oss_format_to(int format) 683static int snd_pcm_oss_format_to(snd_pcm_format_t format)
684{ 684{
685 switch (format) { 685 switch (format) {
686 case SNDRV_PCM_FORMAT_MU_LAW: return AFMT_MU_LAW; 686 case SNDRV_PCM_FORMAT_MU_LAW: return AFMT_MU_LAW;
@@ -843,7 +843,8 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
843 size_t oss_frame_size; 843 size_t oss_frame_size;
844 int err; 844 int err;
845 int direct; 845 int direct;
846 int format, sformat, n; 846 snd_pcm_format_t format, sformat;
847 int n;
847 struct snd_mask sformat_mask; 848 struct snd_mask sformat_mask;
848 struct snd_mask mask; 849 struct snd_mask mask;
849 850
@@ -868,11 +869,11 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
868 _snd_pcm_hw_param_min(sparams, SNDRV_PCM_HW_PARAM_PERIODS, 2, 0); 869 _snd_pcm_hw_param_min(sparams, SNDRV_PCM_HW_PARAM_PERIODS, 2, 0);
869 snd_mask_none(&mask); 870 snd_mask_none(&mask);
870 if (atomic_read(&substream->mmap_count)) 871 if (atomic_read(&substream->mmap_count))
871 snd_mask_set(&mask, SNDRV_PCM_ACCESS_MMAP_INTERLEAVED); 872 snd_mask_set(&mask, (__force int)SNDRV_PCM_ACCESS_MMAP_INTERLEAVED);
872 else { 873 else {
873 snd_mask_set(&mask, SNDRV_PCM_ACCESS_RW_INTERLEAVED); 874 snd_mask_set(&mask, (__force int)SNDRV_PCM_ACCESS_RW_INTERLEAVED);
874 if (!direct) 875 if (!direct)
875 snd_mask_set(&mask, SNDRV_PCM_ACCESS_RW_NONINTERLEAVED); 876 snd_mask_set(&mask, (__force int)SNDRV_PCM_ACCESS_RW_NONINTERLEAVED);
876 } 877 }
877 err = snd_pcm_hw_param_mask(substream, sparams, SNDRV_PCM_HW_PARAM_ACCESS, &mask); 878 err = snd_pcm_hw_param_mask(substream, sparams, SNDRV_PCM_HW_PARAM_ACCESS, &mask);
878 if (err < 0) { 879 if (err < 0) {
@@ -891,19 +892,22 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
891 else 892 else
892 sformat = snd_pcm_plug_slave_format(format, &sformat_mask); 893 sformat = snd_pcm_plug_slave_format(format, &sformat_mask);
893 894
894 if (sformat < 0 || !snd_mask_test(&sformat_mask, sformat)) { 895 if ((__force int)sformat < 0 ||
895 for (sformat = 0; sformat <= SNDRV_PCM_FORMAT_LAST; sformat++) { 896 !snd_mask_test(&sformat_mask, (__force int)sformat)) {
896 if (snd_mask_test(&sformat_mask, sformat) && 897 for (sformat = (__force snd_pcm_format_t)0;
898 (__force int)sformat <= (__force int)SNDRV_PCM_FORMAT_LAST;
899 sformat = (__force snd_pcm_format_t)((__force int)sformat + 1)) {
900 if (snd_mask_test(&sformat_mask, (__force int)sformat) &&
897 snd_pcm_oss_format_to(sformat) >= 0) 901 snd_pcm_oss_format_to(sformat) >= 0)
898 break; 902 break;
899 } 903 }
900 if (sformat > SNDRV_PCM_FORMAT_LAST) { 904 if ((__force int)sformat > (__force int)SNDRV_PCM_FORMAT_LAST) {
901 snd_printd("Cannot find a format!!!\n"); 905 snd_printd("Cannot find a format!!!\n");
902 err = -EINVAL; 906 err = -EINVAL;
903 goto failure; 907 goto failure;
904 } 908 }
905 } 909 }
906 err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0); 910 err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, (__force int)sformat, 0);
907 if (err < 0) 911 if (err < 0)
908 goto failure; 912 goto failure;
909 913
@@ -912,9 +916,9 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
912 } else { 916 } else {
913 _snd_pcm_hw_params_any(params); 917 _snd_pcm_hw_params_any(params);
914 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_ACCESS, 918 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_ACCESS,
915 SNDRV_PCM_ACCESS_RW_INTERLEAVED, 0); 919 (__force int)SNDRV_PCM_ACCESS_RW_INTERLEAVED, 0);
916 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_FORMAT, 920 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_FORMAT,
917 snd_pcm_oss_format_from(runtime->oss.format), 0); 921 (__force int)snd_pcm_oss_format_from(runtime->oss.format), 0);
918 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_CHANNELS, 922 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_CHANNELS,
919 runtime->oss.channels, 0); 923 runtime->oss.channels, 0);
920 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_RATE, 924 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_RATE,
@@ -1185,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
1185 if (in_kernel) { 1189 if (in_kernel) {
1186 mm_segment_t fs; 1190 mm_segment_t fs;
1187 fs = snd_enter_user(); 1191 fs = snd_enter_user();
1188 ret = snd_pcm_lib_write(substream, (void __user *)ptr, frames); 1192 ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
1189 snd_leave_user(fs); 1193 snd_leave_user(fs);
1190 } else { 1194 } else {
1191 ret = snd_pcm_lib_write(substream, (void __user *)ptr, frames); 1195 ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
1192 } 1196 }
1193 if (ret != -EPIPE && ret != -ESTRPIPE) 1197 if (ret != -EPIPE && ret != -ESTRPIPE)
1194 break; 1198 break;
@@ -1230,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
1230 if (in_kernel) { 1234 if (in_kernel) {
1231 mm_segment_t fs; 1235 mm_segment_t fs;
1232 fs = snd_enter_user(); 1236 fs = snd_enter_user();
1233 ret = snd_pcm_lib_read(substream, (void __user *)ptr, frames); 1237 ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
1234 snd_leave_user(fs); 1238 snd_leave_user(fs);
1235 } else { 1239 } else {
1236 ret = snd_pcm_lib_read(substream, (void __user *)ptr, frames); 1240 ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
1237 } 1241 }
1238 if (ret == -EPIPE) { 1242 if (ret == -EPIPE) {
1239 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) { 1243 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
@@ -1333,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
1333 struct snd_pcm_plugin_channel *channels; 1337 struct snd_pcm_plugin_channel *channels;
1334 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8; 1338 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
1335 if (!in_kernel) { 1339 if (!in_kernel) {
1336 if (copy_from_user(runtime->oss.buffer, (const char __user *)buf, bytes)) 1340 if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
1337 return -EFAULT; 1341 return -EFAULT;
1338 buf = runtime->oss.buffer; 1342 buf = runtime->oss.buffer;
1339 } 1343 }
@@ -1429,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
1429 struct snd_pcm_runtime *runtime = substream->runtime; 1433 struct snd_pcm_runtime *runtime = substream->runtime;
1430 snd_pcm_sframes_t frames, frames1; 1434 snd_pcm_sframes_t frames, frames1;
1431#ifdef CONFIG_SND_PCM_OSS_PLUGINS 1435#ifdef CONFIG_SND_PCM_OSS_PLUGINS
1432 char __user *final_dst = (char __user *)buf; 1436 char __user *final_dst = (char __force __user *)buf;
1433 if (runtime->oss.plugin_first) { 1437 if (runtime->oss.plugin_first) {
1434 struct snd_pcm_plugin_channel *channels; 1438 struct snd_pcm_plugin_channel *channels;
1435 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8; 1439 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
@@ -1549,6 +1553,7 @@ static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size)
1549{ 1553{
1550 struct snd_pcm_runtime *runtime; 1554 struct snd_pcm_runtime *runtime;
1551 ssize_t result = 0; 1555 ssize_t result = 0;
1556 snd_pcm_state_t state;
1552 long res; 1557 long res;
1553 wait_queue_t wait; 1558 wait_queue_t wait;
1554 1559
@@ -1570,9 +1575,9 @@ static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size)
1570 result = 0; 1575 result = 0;
1571 set_current_state(TASK_INTERRUPTIBLE); 1576 set_current_state(TASK_INTERRUPTIBLE);
1572 snd_pcm_stream_lock_irq(substream); 1577 snd_pcm_stream_lock_irq(substream);
1573 res = runtime->status->state; 1578 state = runtime->status->state;
1574 snd_pcm_stream_unlock_irq(substream); 1579 snd_pcm_stream_unlock_irq(substream);
1575 if (res != SNDRV_PCM_STATE_RUNNING) { 1580 if (state != SNDRV_PCM_STATE_RUNNING) {
1576 set_current_state(TASK_RUNNING); 1581 set_current_state(TASK_RUNNING);
1577 break; 1582 break;
1578 } 1583 }
@@ -1658,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
1658 size1); 1663 size1);
1659 size1 /= runtime->channels; /* frames */ 1664 size1 /= runtime->channels; /* frames */
1660 fs = snd_enter_user(); 1665 fs = snd_enter_user();
1661 snd_pcm_lib_write(substream, (void __user *)runtime->oss.buffer, size1); 1666 snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
1662 snd_leave_user(fs); 1667 snd_leave_user(fs);
1663 } 1668 }
1664 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) { 1669 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {