diff options
Diffstat (limited to 'sound/core/oss/pcm_oss.c')
-rw-r--r-- | sound/core/oss/pcm_oss.c | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 7fd072392c7e..f8302b703a30 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c | |||
@@ -78,6 +78,7 @@ static inline void snd_leave_user(mm_segment_t fs) | |||
78 | set_fs(fs); | 78 | set_fs(fs); |
79 | } | 79 | } |
80 | 80 | ||
81 | #ifdef CONFIG_SND_PCM_OSS_PLUGINS | ||
81 | static int snd_pcm_oss_plugin_clear(struct snd_pcm_substream *substream) | 82 | static int snd_pcm_oss_plugin_clear(struct snd_pcm_substream *substream) |
82 | { | 83 | { |
83 | struct snd_pcm_runtime *runtime = substream->runtime; | 84 | struct snd_pcm_runtime *runtime = substream->runtime; |
@@ -122,6 +123,7 @@ int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin) | |||
122 | } | 123 | } |
123 | return 0; | 124 | return 0; |
124 | } | 125 | } |
126 | #endif /* CONFIG_SND_PCM_OSS_PLUGINS */ | ||
125 | 127 | ||
126 | static long snd_pcm_oss_bytes(struct snd_pcm_substream *substream, long frames) | 128 | static long snd_pcm_oss_bytes(struct snd_pcm_substream *substream, long frames) |
127 | { | 129 | { |
@@ -412,6 +414,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) | |||
412 | oss_frame_size = snd_pcm_format_physical_width(params_format(params)) * | 414 | oss_frame_size = snd_pcm_format_physical_width(params_format(params)) * |
413 | params_channels(params) / 8; | 415 | params_channels(params) / 8; |
414 | 416 | ||
417 | #ifdef CONFIG_SND_PCM_OSS_PLUGINS | ||
415 | snd_pcm_oss_plugin_clear(substream); | 418 | snd_pcm_oss_plugin_clear(substream); |
416 | if (!direct) { | 419 | if (!direct) { |
417 | /* add necessary plugins */ | 420 | /* add necessary plugins */ |
@@ -441,6 +444,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) | |||
441 | } | 444 | } |
442 | } | 445 | } |
443 | } | 446 | } |
447 | #endif | ||
444 | 448 | ||
445 | err = snd_pcm_oss_period_size(substream, params, sparams); | 449 | err = snd_pcm_oss_period_size(substream, params, sparams); |
446 | if (err < 0) | 450 | if (err < 0) |
@@ -498,11 +502,13 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) | |||
498 | runtime->oss.periods = params_periods(sparams); | 502 | runtime->oss.periods = params_periods(sparams); |
499 | oss_period_size = snd_pcm_plug_client_size(substream, params_period_size(sparams)); | 503 | oss_period_size = snd_pcm_plug_client_size(substream, params_period_size(sparams)); |
500 | snd_assert(oss_period_size >= 0, err = -EINVAL; goto failure); | 504 | snd_assert(oss_period_size >= 0, err = -EINVAL; goto failure); |
505 | #ifdef CONFIG_SND_PCM_OSS_PLUGINS | ||
501 | if (runtime->oss.plugin_first) { | 506 | if (runtime->oss.plugin_first) { |
502 | err = snd_pcm_plug_alloc(substream, oss_period_size); | 507 | err = snd_pcm_plug_alloc(substream, oss_period_size); |
503 | if (err < 0) | 508 | if (err < 0) |
504 | goto failure; | 509 | goto failure; |
505 | } | 510 | } |
511 | #endif | ||
506 | oss_period_size *= oss_frame_size; | 512 | oss_period_size *= oss_frame_size; |
507 | 513 | ||
508 | oss_buffer_size = oss_period_size * runtime->oss.periods; | 514 | oss_buffer_size = oss_period_size * runtime->oss.periods; |
@@ -784,6 +790,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha | |||
784 | { | 790 | { |
785 | struct snd_pcm_runtime *runtime = substream->runtime; | 791 | struct snd_pcm_runtime *runtime = substream->runtime; |
786 | snd_pcm_sframes_t frames, frames1; | 792 | snd_pcm_sframes_t frames, frames1; |
793 | #ifdef CONFIG_SND_PCM_OSS_PLUGINS | ||
787 | if (runtime->oss.plugin_first) { | 794 | if (runtime->oss.plugin_first) { |
788 | struct snd_pcm_plugin_channel *channels; | 795 | struct snd_pcm_plugin_channel *channels; |
789 | size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8; | 796 | size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8; |
@@ -800,7 +807,9 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha | |||
800 | if (frames1 <= 0) | 807 | if (frames1 <= 0) |
801 | return frames1; | 808 | return frames1; |
802 | bytes = frames1 * oss_frame_bytes; | 809 | bytes = frames1 * oss_frame_bytes; |
803 | } else { | 810 | } else |
811 | #endif | ||
812 | { | ||
804 | frames = bytes_to_frames(runtime, bytes); | 813 | frames = bytes_to_frames(runtime, bytes); |
805 | frames1 = snd_pcm_oss_write3(substream, buf, frames, in_kernel); | 814 | frames1 = snd_pcm_oss_write3(substream, buf, frames, in_kernel); |
806 | if (frames1 <= 0) | 815 | if (frames1 <= 0) |
@@ -871,6 +880,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf, | |||
871 | { | 880 | { |
872 | struct snd_pcm_runtime *runtime = substream->runtime; | 881 | struct snd_pcm_runtime *runtime = substream->runtime; |
873 | snd_pcm_sframes_t frames, frames1; | 882 | snd_pcm_sframes_t frames, frames1; |
883 | #ifdef CONFIG_SND_PCM_OSS_PLUGINS | ||
874 | char __user *final_dst = (char __user *)buf; | 884 | char __user *final_dst = (char __user *)buf; |
875 | if (runtime->oss.plugin_first) { | 885 | if (runtime->oss.plugin_first) { |
876 | struct snd_pcm_plugin_channel *channels; | 886 | struct snd_pcm_plugin_channel *channels; |
@@ -887,7 +897,9 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf, | |||
887 | bytes = frames1 * oss_frame_bytes; | 897 | bytes = frames1 * oss_frame_bytes; |
888 | if (!in_kernel && copy_to_user(final_dst, buf, bytes)) | 898 | if (!in_kernel && copy_to_user(final_dst, buf, bytes)) |
889 | return -EFAULT; | 899 | return -EFAULT; |
890 | } else { | 900 | } else |
901 | #endif | ||
902 | { | ||
891 | frames = bytes_to_frames(runtime, bytes); | 903 | frames = bytes_to_frames(runtime, bytes); |
892 | frames1 = snd_pcm_oss_read3(substream, buf, frames, in_kernel); | 904 | frames1 = snd_pcm_oss_read3(substream, buf, frames, in_kernel); |
893 | if (frames1 <= 0) | 905 | if (frames1 <= 0) |
@@ -1631,10 +1643,10 @@ static struct snd_pcm_oss_setup *snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, | |||
1631 | const char *ptr, *ptrl; | 1643 | const char *ptr, *ptrl; |
1632 | struct snd_pcm_oss_setup *setup; | 1644 | struct snd_pcm_oss_setup *setup; |
1633 | 1645 | ||
1634 | down(&pcm->streams[stream].oss.setup_mutex); | 1646 | mutex_lock(&pcm->streams[stream].oss.setup_mutex); |
1635 | for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) { | 1647 | for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) { |
1636 | if (!strcmp(setup->task_name, task_name)) { | 1648 | if (!strcmp(setup->task_name, task_name)) { |
1637 | up(&pcm->streams[stream].oss.setup_mutex); | 1649 | mutex_unlock(&pcm->streams[stream].oss.setup_mutex); |
1638 | return setup; | 1650 | return setup; |
1639 | } | 1651 | } |
1640 | } | 1652 | } |
@@ -1650,12 +1662,12 @@ static struct snd_pcm_oss_setup *snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, | |||
1650 | } | 1662 | } |
1651 | for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) { | 1663 | for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) { |
1652 | if (!strcmp(setup->task_name, ptrl)) { | 1664 | if (!strcmp(setup->task_name, ptrl)) { |
1653 | up(&pcm->streams[stream].oss.setup_mutex); | 1665 | mutex_unlock(&pcm->streams[stream].oss.setup_mutex); |
1654 | return setup; | 1666 | return setup; |
1655 | } | 1667 | } |
1656 | } | 1668 | } |
1657 | __not_found: | 1669 | __not_found: |
1658 | up(&pcm->streams[stream].oss.setup_mutex); | 1670 | mutex_unlock(&pcm->streams[stream].oss.setup_mutex); |
1659 | return NULL; | 1671 | return NULL; |
1660 | } | 1672 | } |
1661 | 1673 | ||
@@ -1692,7 +1704,9 @@ static void snd_pcm_oss_release_substream(struct snd_pcm_substream *substream) | |||
1692 | struct snd_pcm_runtime *runtime; | 1704 | struct snd_pcm_runtime *runtime; |
1693 | runtime = substream->runtime; | 1705 | runtime = substream->runtime; |
1694 | vfree(runtime->oss.buffer); | 1706 | vfree(runtime->oss.buffer); |
1707 | #ifdef CONFIG_SND_PCM_OSS_PLUGINS | ||
1695 | snd_pcm_oss_plugin_clear(substream); | 1708 | snd_pcm_oss_plugin_clear(substream); |
1709 | #endif | ||
1696 | substream->oss.file = NULL; | 1710 | substream->oss.file = NULL; |
1697 | substream->oss.oss = 0; | 1711 | substream->oss.oss = 0; |
1698 | } | 1712 | } |
@@ -1881,7 +1895,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) | |||
1881 | 1895 | ||
1882 | init_waitqueue_entry(&wait, current); | 1896 | init_waitqueue_entry(&wait, current); |
1883 | add_wait_queue(&pcm->open_wait, &wait); | 1897 | add_wait_queue(&pcm->open_wait, &wait); |
1884 | down(&pcm->open_mutex); | 1898 | mutex_lock(&pcm->open_mutex); |
1885 | while (1) { | 1899 | while (1) { |
1886 | err = snd_pcm_oss_open_file(file, pcm, &pcm_oss_file, | 1900 | err = snd_pcm_oss_open_file(file, pcm, &pcm_oss_file, |
1887 | iminor(inode), psetup, csetup); | 1901 | iminor(inode), psetup, csetup); |
@@ -1895,16 +1909,16 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) | |||
1895 | } else | 1909 | } else |
1896 | break; | 1910 | break; |
1897 | set_current_state(TASK_INTERRUPTIBLE); | 1911 | set_current_state(TASK_INTERRUPTIBLE); |
1898 | up(&pcm->open_mutex); | 1912 | mutex_unlock(&pcm->open_mutex); |
1899 | schedule(); | 1913 | schedule(); |
1900 | down(&pcm->open_mutex); | 1914 | mutex_lock(&pcm->open_mutex); |
1901 | if (signal_pending(current)) { | 1915 | if (signal_pending(current)) { |
1902 | err = -ERESTARTSYS; | 1916 | err = -ERESTARTSYS; |
1903 | break; | 1917 | break; |
1904 | } | 1918 | } |
1905 | } | 1919 | } |
1906 | remove_wait_queue(&pcm->open_wait, &wait); | 1920 | remove_wait_queue(&pcm->open_wait, &wait); |
1907 | up(&pcm->open_mutex); | 1921 | mutex_unlock(&pcm->open_mutex); |
1908 | if (err < 0) | 1922 | if (err < 0) |
1909 | goto __error; | 1923 | goto __error; |
1910 | return err; | 1924 | return err; |
@@ -1930,9 +1944,9 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file) | |||
1930 | snd_assert(substream != NULL, return -ENXIO); | 1944 | snd_assert(substream != NULL, return -ENXIO); |
1931 | pcm = substream->pcm; | 1945 | pcm = substream->pcm; |
1932 | snd_pcm_oss_sync(pcm_oss_file); | 1946 | snd_pcm_oss_sync(pcm_oss_file); |
1933 | down(&pcm->open_mutex); | 1947 | mutex_lock(&pcm->open_mutex); |
1934 | snd_pcm_oss_release_file(pcm_oss_file); | 1948 | snd_pcm_oss_release_file(pcm_oss_file); |
1935 | up(&pcm->open_mutex); | 1949 | mutex_unlock(&pcm->open_mutex); |
1936 | wake_up(&pcm->open_wait); | 1950 | wake_up(&pcm->open_wait); |
1937 | module_put(pcm->card->module); | 1951 | module_put(pcm->card->module); |
1938 | snd_card_file_remove(pcm->card, file); | 1952 | snd_card_file_remove(pcm->card, file); |
@@ -2246,8 +2260,10 @@ static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area) | |||
2246 | if ((err = snd_pcm_oss_change_params(substream)) < 0) | 2260 | if ((err = snd_pcm_oss_change_params(substream)) < 0) |
2247 | return err; | 2261 | return err; |
2248 | } | 2262 | } |
2263 | #ifdef CONFIG_SND_PCM_OSS_PLUGINS | ||
2249 | if (runtime->oss.plugin_first != NULL) | 2264 | if (runtime->oss.plugin_first != NULL) |
2250 | return -EIO; | 2265 | return -EIO; |
2266 | #endif | ||
2251 | 2267 | ||
2252 | if (area->vm_pgoff != 0) | 2268 | if (area->vm_pgoff != 0) |
2253 | return -EINVAL; | 2269 | return -EINVAL; |
@@ -2277,7 +2293,7 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry, | |||
2277 | { | 2293 | { |
2278 | struct snd_pcm_str *pstr = entry->private_data; | 2294 | struct snd_pcm_str *pstr = entry->private_data; |
2279 | struct snd_pcm_oss_setup *setup = pstr->oss.setup_list; | 2295 | struct snd_pcm_oss_setup *setup = pstr->oss.setup_list; |
2280 | down(&pstr->oss.setup_mutex); | 2296 | mutex_lock(&pstr->oss.setup_mutex); |
2281 | while (setup) { | 2297 | while (setup) { |
2282 | snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n", | 2298 | snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n", |
2283 | setup->task_name, | 2299 | setup->task_name, |
@@ -2291,7 +2307,7 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry, | |||
2291 | setup->nosilence ? " no-silence" : ""); | 2307 | setup->nosilence ? " no-silence" : ""); |
2292 | setup = setup->next; | 2308 | setup = setup->next; |
2293 | } | 2309 | } |
2294 | up(&pstr->oss.setup_mutex); | 2310 | mutex_unlock(&pstr->oss.setup_mutex); |
2295 | } | 2311 | } |
2296 | 2312 | ||
2297 | static void snd_pcm_oss_proc_free_setup_list(struct snd_pcm_str * pstr) | 2313 | static void snd_pcm_oss_proc_free_setup_list(struct snd_pcm_str * pstr) |
@@ -2321,12 +2337,12 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry, | |||
2321 | struct snd_pcm_oss_setup *setup, *setup1, template; | 2337 | struct snd_pcm_oss_setup *setup, *setup1, template; |
2322 | 2338 | ||
2323 | while (!snd_info_get_line(buffer, line, sizeof(line))) { | 2339 | while (!snd_info_get_line(buffer, line, sizeof(line))) { |
2324 | down(&pstr->oss.setup_mutex); | 2340 | mutex_lock(&pstr->oss.setup_mutex); |
2325 | memset(&template, 0, sizeof(template)); | 2341 | memset(&template, 0, sizeof(template)); |
2326 | ptr = snd_info_get_str(task_name, line, sizeof(task_name)); | 2342 | ptr = snd_info_get_str(task_name, line, sizeof(task_name)); |
2327 | if (!strcmp(task_name, "clear") || !strcmp(task_name, "erase")) { | 2343 | if (!strcmp(task_name, "clear") || !strcmp(task_name, "erase")) { |
2328 | snd_pcm_oss_proc_free_setup_list(pstr); | 2344 | snd_pcm_oss_proc_free_setup_list(pstr); |
2329 | up(&pstr->oss.setup_mutex); | 2345 | mutex_unlock(&pstr->oss.setup_mutex); |
2330 | continue; | 2346 | continue; |
2331 | } | 2347 | } |
2332 | for (setup = pstr->oss.setup_list; setup; setup = setup->next) { | 2348 | for (setup = pstr->oss.setup_list; setup; setup = setup->next) { |
@@ -2378,7 +2394,7 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry, | |||
2378 | } | 2394 | } |
2379 | if (setup) | 2395 | if (setup) |
2380 | *setup = template; | 2396 | *setup = template; |
2381 | up(&pstr->oss.setup_mutex); | 2397 | mutex_unlock(&pstr->oss.setup_mutex); |
2382 | } | 2398 | } |
2383 | } | 2399 | } |
2384 | 2400 | ||