Lines Matching refs:substream

39 #define trace_hwptr(substream, pos, in_interrupt)  argument
40 #define trace_xrun(substream) argument
41 #define trace_hw_ptr_error(substream, reason) argument
53 void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_uframes_t new_hw_ptr) in snd_pcm_playback_silence() argument
55 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_silence()
111 if (substream->ops->silence) { in snd_pcm_playback_silence()
113 err = substream->ops->silence(substream, -1, ofs, transfer); in snd_pcm_playback_silence()
122 if (substream->ops->silence) { in snd_pcm_playback_silence()
125 err = substream->ops->silence(substream, c, ofs, transfer); in snd_pcm_playback_silence()
143 void snd_pcm_debug_name(struct snd_pcm_substream *substream, in snd_pcm_debug_name() argument
147 substream->pcm->card->number, in snd_pcm_debug_name()
148 substream->pcm->device, in snd_pcm_debug_name()
149 substream->stream ? 'c' : 'p', in snd_pcm_debug_name()
150 substream->number); in snd_pcm_debug_name()
161 #define xrun_debug(substream, mask) \ argument
162 ((substream)->pstr->xrun_debug & (mask))
164 #define xrun_debug(substream, mask) 0 argument
167 #define dump_stack_on_xrun(substream) do { \ argument
168 if (xrun_debug(substream, XRUN_DEBUG_STACK)) \
172 static void xrun(struct snd_pcm_substream *substream) in xrun() argument
174 struct snd_pcm_runtime *runtime = substream->runtime; in xrun()
176 trace_xrun(substream); in xrun()
179 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); in xrun()
180 if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { in xrun()
182 snd_pcm_debug_name(substream, name, sizeof(name)); in xrun()
183 pcm_warn(substream->pcm, "XRUN: %s\n", name); in xrun()
184 dump_stack_on_xrun(substream); in xrun()
189 #define hw_ptr_error(substream, in_interrupt, reason, fmt, args...) \ argument
191 trace_hw_ptr_error(substream, reason); \
192 if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { \
195 dump_stack_on_xrun(substream); \
201 #define hw_ptr_error(substream, fmt, args...) do { } while (0) argument
205 int snd_pcm_update_state(struct snd_pcm_substream *substream, in snd_pcm_update_state() argument
210 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_update_state()
218 snd_pcm_drain_done(substream); in snd_pcm_update_state()
223 xrun(substream); in snd_pcm_update_state()
235 static void update_audio_tstamp(struct snd_pcm_substream *substream, in update_audio_tstamp() argument
239 struct snd_pcm_runtime *runtime = substream->runtime; in update_audio_tstamp()
246 if (!(substream->ops->get_time_info) || in update_audio_tstamp()
258 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in update_audio_tstamp()
274 snd_pcm_gettime(substream->runtime, (struct timespec *)&driver_tstamp); in update_audio_tstamp()
278 static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, in snd_pcm_update_hw_ptr0() argument
281 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_update_hw_ptr0()
299 pos = substream->ops->pointer(substream); in snd_pcm_update_hw_ptr0()
302 if ((substream->ops->get_time_info) && in snd_pcm_update_hw_ptr0()
304 substream->ops->get_time_info(substream, &curr_tstamp, in snd_pcm_update_hw_ptr0()
317 xrun(substream); in snd_pcm_update_hw_ptr0()
323 snd_pcm_debug_name(substream, name, sizeof(name)); in snd_pcm_update_hw_ptr0()
324 pcm_err(substream->pcm, in snd_pcm_update_hw_ptr0()
332 trace_hwptr(substream, pos, in_interrupt); in snd_pcm_update_hw_ptr0()
394 hw_ptr_error(substream, in_interrupt, "Unexpected hw_ptr", in snd_pcm_update_hw_ptr0()
396 substream->stream, (long)pos, in snd_pcm_update_hw_ptr0()
402 if (!xrun_debug(substream, XRUN_DEBUG_JIFFIESCHECK)) in snd_pcm_update_hw_ptr0()
434 hw_ptr_error(substream, in_interrupt, "hw_ptr skipping", in snd_pcm_update_hw_ptr0()
447 hw_ptr_error(substream, in_interrupt, in snd_pcm_update_hw_ptr0()
450 substream->stream, (long)delta, in snd_pcm_update_hw_ptr0()
457 update_audio_tstamp(substream, &curr_tstamp, &audio_tstamp); in snd_pcm_update_hw_ptr0()
461 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_update_hw_ptr0()
463 snd_pcm_playback_silence(substream, new_hw_ptr); in snd_pcm_update_hw_ptr0()
482 update_audio_tstamp(substream, &curr_tstamp, &audio_tstamp); in snd_pcm_update_hw_ptr0()
484 return snd_pcm_update_state(substream, runtime); in snd_pcm_update_hw_ptr0()
488 int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) in snd_pcm_update_hw_ptr() argument
490 return snd_pcm_update_hw_ptr0(substream, 0); in snd_pcm_update_hw_ptr()
505 struct snd_pcm_substream *substream; in snd_pcm_set_ops() local
507 for (substream = stream->substream; substream != NULL; substream = substream->next) in snd_pcm_set_ops()
508 substream->ops = ops; in snd_pcm_set_ops()
519 void snd_pcm_set_sync(struct snd_pcm_substream *substream) in snd_pcm_set_sync() argument
521 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_set_sync()
523 runtime->sync.id32[0] = substream->pcm->card->number; in snd_pcm_set_sync()
1759 static int snd_pcm_lib_ioctl_reset(struct snd_pcm_substream *substream, in snd_pcm_lib_ioctl_reset() argument
1762 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_ioctl_reset()
1764 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_lib_ioctl_reset()
1765 if (snd_pcm_running(substream) && in snd_pcm_lib_ioctl_reset()
1766 snd_pcm_update_hw_ptr(substream) >= 0) in snd_pcm_lib_ioctl_reset()
1772 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_lib_ioctl_reset()
1776 static int snd_pcm_lib_ioctl_channel_info(struct snd_pcm_substream *substream, in snd_pcm_lib_ioctl_channel_info() argument
1780 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_ioctl_channel_info()
1811 static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream, in snd_pcm_lib_ioctl_fifo_size() argument
1819 params->fifo_size = substream->runtime->hw.fifo_size; in snd_pcm_lib_ioctl_fifo_size()
1820 if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) { in snd_pcm_lib_ioctl_fifo_size()
1841 int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream, in snd_pcm_lib_ioctl() argument
1848 return snd_pcm_lib_ioctl_reset(substream, arg); in snd_pcm_lib_ioctl()
1850 return snd_pcm_lib_ioctl_channel_info(substream, arg); in snd_pcm_lib_ioctl()
1852 return snd_pcm_lib_ioctl_fifo_size(substream, arg); in snd_pcm_lib_ioctl()
1870 void snd_pcm_period_elapsed(struct snd_pcm_substream *substream) in snd_pcm_period_elapsed() argument
1875 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_period_elapsed()
1877 runtime = substream->runtime; in snd_pcm_period_elapsed()
1879 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_period_elapsed()
1880 if (!snd_pcm_running(substream) || in snd_pcm_period_elapsed()
1881 snd_pcm_update_hw_ptr0(substream, 1) < 0) in snd_pcm_period_elapsed()
1885 if (substream->timer_running) in snd_pcm_period_elapsed()
1886 snd_timer_interrupt(substream->timer, 1); in snd_pcm_period_elapsed()
1889 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_period_elapsed()
1901 static int wait_for_avail(struct snd_pcm_substream *substream, in wait_for_avail() argument
1904 struct snd_pcm_runtime *runtime = substream->runtime; in wait_for_avail()
1905 int is_playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; in wait_for_avail()
1945 snd_pcm_stream_unlock_irq(substream); in wait_for_avail()
1949 snd_pcm_stream_lock_irq(substream); in wait_for_avail()
1973 pcm_dbg(substream->pcm, in wait_for_avail()
1987 static int snd_pcm_lib_write_transfer(struct snd_pcm_substream *substream, in snd_pcm_lib_write_transfer() argument
1992 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_write_transfer()
1995 if (substream->ops->copy) { in snd_pcm_lib_write_transfer()
1996 if ((err = substream->ops->copy(substream, -1, hwoff, buf, frames)) < 0) in snd_pcm_lib_write_transfer()
2006 typedef int (*transfer_f)(struct snd_pcm_substream *substream, unsigned int hwoff,
2010 static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream, in snd_pcm_lib_write1() argument
2016 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_write1()
2025 snd_pcm_stream_lock_irq(substream); in snd_pcm_lib_write1()
2044 snd_pcm_update_hw_ptr(substream); in snd_pcm_lib_write1()
2056 err = wait_for_avail(substream, &avail); in snd_pcm_lib_write1()
2066 snd_pcm_stream_unlock_irq(substream); in snd_pcm_lib_write1()
2071 snd_pcm_stream_unlock_irq(substream); in snd_pcm_lib_write1()
2072 err = transfer(substream, appl_ofs, data, offset, frames); in snd_pcm_lib_write1()
2073 snd_pcm_stream_lock_irq(substream); in snd_pcm_lib_write1()
2090 if (substream->ops->ack) in snd_pcm_lib_write1()
2091 substream->ops->ack(substream); in snd_pcm_lib_write1()
2099 err = snd_pcm_start(substream); in snd_pcm_lib_write1()
2107 snd_pcm_update_state(substream, runtime); in snd_pcm_lib_write1()
2108 snd_pcm_stream_unlock_irq(substream); in snd_pcm_lib_write1()
2113 static int pcm_sanity_check(struct snd_pcm_substream *substream) in pcm_sanity_check() argument
2116 if (PCM_RUNTIME_CHECK(substream)) in pcm_sanity_check()
2118 runtime = substream->runtime; in pcm_sanity_check()
2119 if (snd_BUG_ON(!substream->ops->copy && !runtime->dma_area)) in pcm_sanity_check()
2126 snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream, const void __user *buf, sn… in snd_pcm_lib_write() argument
2132 err = pcm_sanity_check(substream); in snd_pcm_lib_write()
2135 runtime = substream->runtime; in snd_pcm_lib_write()
2136 nonblock = !!(substream->f_flags & O_NONBLOCK); in snd_pcm_lib_write()
2141 return snd_pcm_lib_write1(substream, (unsigned long)buf, size, nonblock, in snd_pcm_lib_write()
2147 static int snd_pcm_lib_writev_transfer(struct snd_pcm_substream *substream, in snd_pcm_lib_writev_transfer() argument
2152 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_writev_transfer()
2157 if (substream->ops->copy) { in snd_pcm_lib_writev_transfer()
2158 if (snd_BUG_ON(!substream->ops->silence)) in snd_pcm_lib_writev_transfer()
2162 if ((err = substream->ops->silence(substream, c, hwoff, frames)) < 0) in snd_pcm_lib_writev_transfer()
2166 if ((err = substream->ops->copy(substream, c, hwoff, buf, frames)) < 0) in snd_pcm_lib_writev_transfer()
2187 snd_pcm_sframes_t snd_pcm_lib_writev(struct snd_pcm_substream *substream, in snd_pcm_lib_writev() argument
2195 err = pcm_sanity_check(substream); in snd_pcm_lib_writev()
2198 runtime = substream->runtime; in snd_pcm_lib_writev()
2199 nonblock = !!(substream->f_flags & O_NONBLOCK); in snd_pcm_lib_writev()
2203 return snd_pcm_lib_write1(substream, (unsigned long)bufs, frames, in snd_pcm_lib_writev()
2209 static int snd_pcm_lib_read_transfer(struct snd_pcm_substream *substream, in snd_pcm_lib_read_transfer() argument
2214 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_read_transfer()
2217 if (substream->ops->copy) { in snd_pcm_lib_read_transfer()
2218 if ((err = substream->ops->copy(substream, -1, hwoff, buf, frames)) < 0) in snd_pcm_lib_read_transfer()
2228 static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream, in snd_pcm_lib_read1() argument
2234 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_read1()
2243 snd_pcm_stream_lock_irq(substream); in snd_pcm_lib_read1()
2247 err = snd_pcm_start(substream); in snd_pcm_lib_read1()
2269 snd_pcm_update_hw_ptr(substream); in snd_pcm_lib_read1()
2277 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_lib_read1()
2286 err = wait_for_avail(substream, &avail); in snd_pcm_lib_read1()
2298 snd_pcm_stream_unlock_irq(substream); in snd_pcm_lib_read1()
2303 snd_pcm_stream_unlock_irq(substream); in snd_pcm_lib_read1()
2304 err = transfer(substream, appl_ofs, data, offset, frames); in snd_pcm_lib_read1()
2305 snd_pcm_stream_lock_irq(substream); in snd_pcm_lib_read1()
2322 if (substream->ops->ack) in snd_pcm_lib_read1()
2323 substream->ops->ack(substream); in snd_pcm_lib_read1()
2333 snd_pcm_update_state(substream, runtime); in snd_pcm_lib_read1()
2334 snd_pcm_stream_unlock_irq(substream); in snd_pcm_lib_read1()
2338 snd_pcm_sframes_t snd_pcm_lib_read(struct snd_pcm_substream *substream, void __user *buf, snd_pcm_u… in snd_pcm_lib_read() argument
2344 err = pcm_sanity_check(substream); in snd_pcm_lib_read()
2347 runtime = substream->runtime; in snd_pcm_lib_read()
2348 nonblock = !!(substream->f_flags & O_NONBLOCK); in snd_pcm_lib_read()
2351 return snd_pcm_lib_read1(substream, (unsigned long)buf, size, nonblock, snd_pcm_lib_read_transfer); in snd_pcm_lib_read()
2356 static int snd_pcm_lib_readv_transfer(struct snd_pcm_substream *substream, in snd_pcm_lib_readv_transfer() argument
2361 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_readv_transfer()
2366 if (substream->ops->copy) { in snd_pcm_lib_readv_transfer()
2372 if ((err = substream->ops->copy(substream, c, hwoff, buf, frames)) < 0) in snd_pcm_lib_readv_transfer()
2392 snd_pcm_sframes_t snd_pcm_lib_readv(struct snd_pcm_substream *substream, in snd_pcm_lib_readv() argument
2400 err = pcm_sanity_check(substream); in snd_pcm_lib_readv()
2403 runtime = substream->runtime; in snd_pcm_lib_readv()
2407 nonblock = !!(substream->f_flags & O_NONBLOCK); in snd_pcm_lib_readv()
2410 …return snd_pcm_lib_read1(substream, (unsigned long)bufs, frames, nonblock, snd_pcm_lib_readv_trans… in snd_pcm_lib_readv()
2491 struct snd_pcm_substream *substream; in pcm_chmap_ctl_get() local
2496 substream = snd_pcm_chmap_substream(info, idx); in pcm_chmap_ctl_get()
2497 if (!substream) in pcm_chmap_ctl_get()
2501 if (!substream->runtime) in pcm_chmap_ctl_get()
2505 if (map->channels == substream->runtime->channels && in pcm_chmap_ctl_get()