Lines Matching defs:substream

531 static int snd_pcm_oss_plugin_clear(struct snd_pcm_substream *substream)
533 struct snd_pcm_runtime *runtime = substream->runtime;
577 static long snd_pcm_oss_bytes(struct snd_pcm_substream *substream, long frames)
579 struct snd_pcm_runtime *runtime = substream->runtime;
580 long buffer_size = snd_pcm_lib_buffer_bytes(substream);
594 static long snd_pcm_alsa_frames(struct snd_pcm_substream *substream, long bytes)
596 struct snd_pcm_runtime *runtime = substream->runtime;
597 long buffer_size = snd_pcm_lib_buffer_bytes(substream);
673 static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,
681 struct snd_pcm_runtime *runtime = substream->runtime;
692 oss_buffer_size = snd_pcm_plug_client_size(substream,
697 if (atomic_read(&substream->mmap_count)) {
702 if (substream->oss.setup.period_size > 16)
703 oss_period_size = substream->oss.setup.period_size;
729 min_period_size = snd_pcm_plug_client_size(substream,
738 max_period_size = snd_pcm_plug_client_size(substream,
749 if (substream->oss.setup.periods > 1)
750 oss_periods = substream->oss.setup.periods;
780 static int choose_rate(struct snd_pcm_substream *substream,
800 ret = snd_pcm_hw_param_set(substream, params,
814 return snd_pcm_hw_param_near(substream, params, SNDRV_PCM_HW_PARAM_RATE, best_rate, NULL);
834 static void snd_pcm_oss_release_buffers(struct snd_pcm_substream *substream)
836 struct snd_pcm_runtime *runtime = substream->runtime;
841 snd_pcm_oss_plugin_clear(substream);
846 static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
848 struct snd_pcm_runtime *runtime = substream->runtime;
870 if (atomic_read(&substream->mmap_count))
873 direct = substream->oss.setup.direct;
879 if (atomic_read(&substream->mmap_count))
886 err = snd_pcm_hw_param_mask(substream, sparams, SNDRV_PCM_HW_PARAM_ACCESS, &mask);
888 pcm_dbg(substream->pcm, "No usable accesses\n");
893 err = choose_rate(substream, sparams, runtime->oss.rate);
896 err = snd_pcm_hw_param_near(substream, sparams,
917 pcm_dbg(substream->pcm, "Cannot find a format!!!\n");
949 err = snd_pcm_oss_period_size(substream, params, sparams);
953 n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size);
954 err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL);
958 err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS,
963 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
965 err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_HW_PARAMS, sparams);
967 pcm_dbg(substream->pcm, "HW_PARAMS failed: %i\n", err);
972 snd_pcm_oss_plugin_clear(substream);
975 err = snd_pcm_plug_format_plugins(substream, params, sparams);
977 pcm_dbg(substream->pcm,
983 err = snd_pcm_plugin_build_io(substream, sparams, &plugin);
985 pcm_dbg(substream->pcm,
989 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1005 if (atomic_read(&substream->mmap_count) ||
1006 substream->stream == SNDRV_PCM_STREAM_CAPTURE)
1012 sw_params->avail_min = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
1014 if (atomic_read(&substream->mmap_count) ||
1015 substream->oss.setup.nosilence) {
1027 err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_SW_PARAMS, sw_params);
1029 pcm_dbg(substream->pcm, "SW_PARAMS failed: %i\n", err);
1034 oss_period_size = snd_pcm_plug_client_size(substream, params_period_size(sparams));
1041 err = snd_pcm_plug_alloc(substream, oss_period_size);
1080 runtime->oss.period_frames = snd_pcm_alsa_frames(substream, oss_period_size);
1085 snd_pcm_oss_release_buffers(substream);
1093 static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream,
1096 struct snd_pcm_runtime *runtime = substream->runtime;
1105 err = snd_pcm_oss_change_params_locked(substream);
1113 struct snd_pcm_substream *asubstream = NULL, *substream;
1116 substream = pcm_oss_file->streams[idx];
1117 if (substream == NULL)
1120 asubstream = substream;
1121 if (substream->runtime->oss.params) {
1122 err = snd_pcm_oss_change_params(substream, false);
1138 static int snd_pcm_oss_prepare(struct snd_pcm_substream *substream)
1141 struct snd_pcm_runtime *runtime = substream->runtime;
1143 err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_PREPARE, NULL);
1145 pcm_dbg(substream->pcm,
1157 static int snd_pcm_oss_make_ready(struct snd_pcm_substream *substream)
1162 runtime = substream->runtime;
1164 err = snd_pcm_oss_change_params(substream, false);
1171 err = snd_pcm_oss_prepare(substream);
1180 static int snd_pcm_oss_make_ready_locked(struct snd_pcm_substream *substream)
1185 runtime = substream->runtime;
1187 err = snd_pcm_oss_change_params_locked(substream);
1192 err = snd_pcm_oss_prepare(substream);
1199 static int snd_pcm_oss_capture_position_fixup(struct snd_pcm_substream *substream, snd_pcm_sframes_t *delay)
1206 err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DELAY, delay);
1209 runtime = substream->runtime;
1217 err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_FORWARD, &frames);
1224 snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const char *ptr, snd_pcm_uframes_t frames, int in_kernel)
1226 struct snd_pcm_runtime *runtime = substream->runtime;
1232 pcm_dbg(substream->pcm,
1237 ret = snd_pcm_oss_prepare(substream);
1242 ret = __snd_pcm_lib_xfer(substream, (void *)ptr, true,
1255 snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *ptr, snd_pcm_uframes_t frames, int in_kernel)
1257 struct snd_pcm_runtime *runtime = substream->runtime;
1264 pcm_dbg(substream->pcm,
1269 ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL);
1273 ret = snd_pcm_oss_prepare(substream);
1277 ret = snd_pcm_oss_capture_position_fixup(substream, &delay);
1281 ret = __snd_pcm_lib_xfer(substream, (void *)ptr, true,
1286 ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
1299 snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream, void **bufs, snd_pcm_uframes_t frames)
1301 struct snd_pcm_runtime *runtime = substream->runtime;
1307 pcm_dbg(substream->pcm,
1312 ret = snd_pcm_oss_prepare(substream);
1316 ret = snd_pcm_kernel_writev(substream, bufs, frames);
1328 snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream, void **bufs, snd_pcm_uframes_t frames)
1330 struct snd_pcm_runtime *runtime = substream->runtime;
1336 pcm_dbg(substream->pcm,
1341 ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL);
1345 ret = snd_pcm_oss_prepare(substream);
1349 ret = snd_pcm_kernel_readv(substream, bufs, frames);
1357 static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const char *buf, size_t bytes, int in_kernel)
1359 struct snd_pcm_runtime *runtime = substream->runtime;
1371 frames1 = snd_pcm_plug_client_channels_buf(substream, (char *)buf, frames, &channels);
1374 frames1 = snd_pcm_plug_write_transfer(substream, channels, frames1);
1382 frames1 = snd_pcm_oss_write3(substream, buf, frames, in_kernel);
1390 static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const char __user *buf, size_t bytes)
1394 struct snd_pcm_runtime *runtime = substream->runtime;
1396 if (atomic_read(&substream->mmap_count))
1405 tmp = snd_pcm_oss_make_ready_locked(substream);
1422 if (substream->oss.setup.partialfrag ||
1424 tmp = snd_pcm_oss_write2(substream, runtime->oss.buffer + runtime->oss.period_ptr,
1434 else if ((substream->f_flags & O_NONBLOCK) != 0) {
1440 tmp = snd_pcm_oss_write2(substream,
1449 if ((substream->f_flags & O_NONBLOCK) != 0 &&
1467 static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf, size_t bytes, int in_kernel)
1469 struct snd_pcm_runtime *runtime = substream->runtime;
1479 frames1 = snd_pcm_plug_client_channels_buf(substream, buf, frames, &channels);
1482 frames1 = snd_pcm_plug_read_transfer(substream, channels, frames1);
1492 frames1 = snd_pcm_oss_read3(substream, buf, frames, in_kernel);
1500 static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __user *buf, size_t bytes)
1504 struct snd_pcm_runtime *runtime = substream->runtime;
1506 if (atomic_read(&substream->mmap_count))
1515 tmp = snd_pcm_oss_make_ready_locked(substream);
1520 tmp = snd_pcm_oss_read2(substream, runtime->oss.buffer, runtime->oss.period_bytes, 1);
1539 tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
1564 struct snd_pcm_substream *substream;
1569 substream = pcm_oss_file->streams[i];
1570 if (!substream)
1572 runtime = substream->runtime;
1573 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
1586 struct snd_pcm_substream *substream;
1589 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
1590 if (substream != NULL) {
1591 err = snd_pcm_oss_make_ready(substream);
1594 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_START, NULL);
1601 static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size)
1609 runtime = substream->runtime;
1613 pcm_dbg(substream->pcm, "sync1: size = %li\n", size);
1616 result = snd_pcm_oss_write2(substream, runtime->oss.buffer, size, 1);
1626 scoped_guard(pcm_stream_lock_irq, substream)
1638 pcm_err(substream->pcm,
1652 struct snd_pcm_substream *substream;
1658 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
1659 if (substream != NULL) {
1660 runtime = substream->runtime;
1661 if (atomic_read(&substream->mmap_count))
1668 err = snd_pcm_oss_make_ready_locked(substream);
1675 pcm_dbg(substream->pcm, "sync: buffer_used\n");
1681 err = snd_pcm_oss_sync1(substream, runtime->oss.period_bytes);
1686 pcm_dbg(substream->pcm, "sync: period_ptr\n");
1692 err = snd_pcm_oss_sync1(substream, size);
1704 snd_pcm_lib_write(substream, NULL, size);
1706 snd_pcm_lib_writev(substream, NULL, size);
1717 saved_f_flags = substream->f_flags;
1718 substream->f_flags &= ~O_NONBLOCK;
1719 err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL);
1720 substream->f_flags = saved_f_flags;
1728 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
1729 if (substream != NULL) {
1730 err = snd_pcm_oss_make_ready(substream);
1733 runtime = substream->runtime;
1734 err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
1750 struct snd_pcm_substream *substream = pcm_oss_file->streams[idx];
1754 if (substream == NULL)
1756 runtime = substream->runtime;
1775 struct snd_pcm_substream *substream;
1778 err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);
1781 return substream->runtime->oss.rate;
1792 struct snd_pcm_substream *substream = pcm_oss_file->streams[idx];
1796 if (substream == NULL)
1798 runtime = substream->runtime;
1813 struct snd_pcm_substream *substream;
1816 err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);
1819 return substream->runtime->oss.channels;
1824 struct snd_pcm_substream *substream;
1827 err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);
1830 return substream->runtime->oss.period_bytes;
1835 struct snd_pcm_substream *substream;
1843 err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);
1846 if (atomic_read(&substream->mmap_count))
1849 direct = substream->oss.setup.direct;
1862 err = snd_pcm_hw_refine(substream, params);
1889 struct snd_pcm_substream *substream = pcm_oss_file->streams[idx];
1891 if (substream == NULL)
1893 runtime = substream->runtime;
1909 struct snd_pcm_substream *substream;
1912 err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);
1915 return substream->runtime->oss.format;
1918 static int snd_pcm_oss_set_subdivide1(struct snd_pcm_substream *substream, int subdivide)
1922 runtime = substream->runtime;
1944 struct snd_pcm_substream *substream = pcm_oss_file->streams[idx];
1947 if (substream == NULL)
1949 runtime = substream->runtime;
1953 err = snd_pcm_oss_set_subdivide1(substream, subdivide);
1961 static int snd_pcm_oss_set_fragment1(struct snd_pcm_substream *substream, unsigned int val)
1966 runtime = substream->runtime;
1987 struct snd_pcm_substream *substream = pcm_oss_file->streams[idx];
1990 if (substream == NULL)
1992 runtime = substream->runtime;
1996 err = snd_pcm_oss_set_fragment1(substream, val);
2012 static int snd_pcm_oss_get_caps1(struct snd_pcm_substream *substream, int res)
2015 if (substream == NULL) {
2020 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
2021 if (substream->pstr->substream_count > 1)
2028 struct snd_pcm_runtime *runtime = substream->runtime;
2042 struct snd_pcm_substream *substream = pcm_oss_file->streams[idx];
2043 result = snd_pcm_oss_get_caps1(substream, result);
2049 static void snd_pcm_oss_simulate_fill(struct snd_pcm_substream *substream,
2052 struct snd_pcm_runtime *runtime = substream->runtime;
2158 struct snd_pcm_substream *substream;
2163 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
2164 if (substream == NULL)
2166 err = snd_pcm_oss_make_ready(substream);
2169 runtime = substream->runtime;
2172 err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DELAY, &delay);
2177 return snd_pcm_oss_bytes(substream, delay);
2182 struct snd_pcm_substream *substream;
2191 substream = pcm_oss_file->streams[stream];
2192 if (substream == NULL)
2194 err = snd_pcm_oss_make_ready(substream);
2197 runtime = substream->runtime;
2205 err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DELAY, &delay);
2214 err = snd_pcm_oss_capture_position_fixup(substream, &delay);
2219 info.ptr = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr % runtime->buffer_size);
2220 if (atomic_read(&substream->mmap_count)) {
2228 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
2229 snd_pcm_oss_simulate_fill(substream, delay);
2230 info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX;
2232 delay = snd_pcm_oss_bytes(substream, delay);
2234 if (substream->oss.setup.buggyptr)
2252 struct snd_pcm_substream *substream;
2261 substream = pcm_oss_file->streams[stream];
2262 if (substream == NULL)
2264 runtime = substream->runtime;
2267 err = snd_pcm_oss_change_params(substream, false);
2284 err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DELAY, &avail);
2294 err = snd_pcm_oss_capture_position_fixup(substream, &avail);
2299 info.bytes = snd_pcm_oss_bytes(substream, avail) + fixup;
2304 pcm_dbg(substream->pcm,
2349 static void snd_pcm_oss_release_substream(struct snd_pcm_substream *substream)
2351 snd_pcm_oss_release_buffers(substream);
2352 substream->oss.oss = 0;
2355 static void snd_pcm_oss_init_substream(struct snd_pcm_substream *substream,
2361 substream->oss.oss = 1;
2362 substream->oss.setup = *setup;
2364 substream->f_flags |= O_NONBLOCK;
2366 substream->f_flags &= ~O_NONBLOCK;
2367 runtime = substream->runtime;
2386 substream->pcm_release = snd_pcm_oss_release_substream;
2396 struct snd_pcm_substream *substream = pcm_oss_file->streams[cidx];
2397 if (substream)
2398 snd_pcm_release_substream(substream);
2412 struct snd_pcm_substream *substream;
2431 continue; /* no matching substream */
2439 err = snd_pcm_open_substream(pcm, idx, file, &substream);
2445 pcm_oss_file->streams[idx] = substream;
2446 snd_pcm_oss_init_substream(substream, &setup[idx], minor);
2564 struct snd_pcm_substream *substream;
2568 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
2569 if (substream == NULL)
2570 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
2571 if (snd_BUG_ON(!substream))
2573 pcm = substream->pcm;
2598 struct snd_pcm_substream *substream;
2601 substream = pcm_oss_file->streams[idx];
2602 if (substream != NULL)
2607 return snd_mixer_oss_ioctl_card(substream->pcm->card, cmd, arg);
2765 struct snd_pcm_substream *substream;
2768 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
2769 if (substream == NULL)
2771 substream->f_flags = file->f_flags & O_NONBLOCK;
2773 return snd_pcm_oss_read1(substream, buf, count);
2776 ssize_t res = snd_pcm_oss_read1(substream, buf, count);
2777 pcm_dbg(substream->pcm,
2788 struct snd_pcm_substream *substream;
2792 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
2793 if (substream == NULL)
2795 substream->f_flags = file->f_flags & O_NONBLOCK;
2796 result = snd_pcm_oss_write1(substream, buf, count);
2798 pcm_dbg(substream->pcm, "pcm_oss: write %li bytes (wrote %li bytes)\n",
2804 static int snd_pcm_oss_playback_ready(struct snd_pcm_substream *substream)
2806 struct snd_pcm_runtime *runtime = substream->runtime;
2807 if (atomic_read(&substream->mmap_count))
2815 static int snd_pcm_oss_capture_ready(struct snd_pcm_substream *substream)
2817 struct snd_pcm_runtime *runtime = substream->runtime;
2818 if (atomic_read(&substream->mmap_count))
2873 struct snd_pcm_substream *substream = NULL;
2883 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
2884 if (substream)
2888 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
2891 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
2899 if (substream == NULL)
2901 runtime = substream->runtime;
2914 err = snd_pcm_oss_change_params(substream, true);
2926 err = snd_pcm_mmap_data(substream, file, area);