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()
1758 static int snd_pcm_lib_ioctl_reset(struct snd_pcm_substream *substream, in snd_pcm_lib_ioctl_reset() argument
1761 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_ioctl_reset()
1763 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_lib_ioctl_reset()
1764 if (snd_pcm_running(substream) && in snd_pcm_lib_ioctl_reset()
1765 snd_pcm_update_hw_ptr(substream) >= 0) in snd_pcm_lib_ioctl_reset()
1771 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_lib_ioctl_reset()
1775 static int snd_pcm_lib_ioctl_channel_info(struct snd_pcm_substream *substream, in snd_pcm_lib_ioctl_channel_info() argument
1779 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_ioctl_channel_info()
1810 static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream, in snd_pcm_lib_ioctl_fifo_size() argument
1818 params->fifo_size = substream->runtime->hw.fifo_size; in snd_pcm_lib_ioctl_fifo_size()
1819 if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) { in snd_pcm_lib_ioctl_fifo_size()
1840 int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream, in snd_pcm_lib_ioctl() argument
1847 return snd_pcm_lib_ioctl_reset(substream, arg); in snd_pcm_lib_ioctl()
1849 return snd_pcm_lib_ioctl_channel_info(substream, arg); in snd_pcm_lib_ioctl()
1851 return snd_pcm_lib_ioctl_fifo_size(substream, arg); in snd_pcm_lib_ioctl()
1869 void snd_pcm_period_elapsed(struct snd_pcm_substream *substream) in snd_pcm_period_elapsed() argument
1874 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_period_elapsed()
1876 runtime = substream->runtime; in snd_pcm_period_elapsed()
1879 runtime->transfer_ack_begin(substream); in snd_pcm_period_elapsed()
1881 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_period_elapsed()
1882 if (!snd_pcm_running(substream) || in snd_pcm_period_elapsed()
1883 snd_pcm_update_hw_ptr0(substream, 1) < 0) in snd_pcm_period_elapsed()
1886 if (substream->timer_running) in snd_pcm_period_elapsed()
1887 snd_timer_interrupt(substream->timer, 1); in snd_pcm_period_elapsed()
1889 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_period_elapsed()
1891 runtime->transfer_ack_end(substream); in snd_pcm_period_elapsed()
1903 static int wait_for_avail(struct snd_pcm_substream *substream, in wait_for_avail() argument
1906 struct snd_pcm_runtime *runtime = substream->runtime; in wait_for_avail()
1907 int is_playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; in wait_for_avail()
1947 snd_pcm_stream_unlock_irq(substream); in wait_for_avail()
1951 snd_pcm_stream_lock_irq(substream); in wait_for_avail()
1975 pcm_dbg(substream->pcm, in wait_for_avail()
1989 static int snd_pcm_lib_write_transfer(struct snd_pcm_substream *substream, in snd_pcm_lib_write_transfer() argument
1994 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_write_transfer()
1997 if (substream->ops->copy) { in snd_pcm_lib_write_transfer()
1998 if ((err = substream->ops->copy(substream, -1, hwoff, buf, frames)) < 0) in snd_pcm_lib_write_transfer()
2008 typedef int (*transfer_f)(struct snd_pcm_substream *substream, unsigned int hwoff,
2012 static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream, in snd_pcm_lib_write1() argument
2018 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_write1()
2027 snd_pcm_stream_lock_irq(substream); in snd_pcm_lib_write1()
2046 snd_pcm_update_hw_ptr(substream); in snd_pcm_lib_write1()
2058 err = wait_for_avail(substream, &avail); in snd_pcm_lib_write1()
2068 snd_pcm_stream_unlock_irq(substream); in snd_pcm_lib_write1()
2073 snd_pcm_stream_unlock_irq(substream); in snd_pcm_lib_write1()
2074 err = transfer(substream, appl_ofs, data, offset, frames); in snd_pcm_lib_write1()
2075 snd_pcm_stream_lock_irq(substream); in snd_pcm_lib_write1()
2092 if (substream->ops->ack) in snd_pcm_lib_write1()
2093 substream->ops->ack(substream); in snd_pcm_lib_write1()
2101 err = snd_pcm_start(substream); in snd_pcm_lib_write1()
2109 snd_pcm_update_state(substream, runtime); in snd_pcm_lib_write1()
2110 snd_pcm_stream_unlock_irq(substream); in snd_pcm_lib_write1()
2115 static int pcm_sanity_check(struct snd_pcm_substream *substream) in pcm_sanity_check() argument
2118 if (PCM_RUNTIME_CHECK(substream)) in pcm_sanity_check()
2120 runtime = substream->runtime; in pcm_sanity_check()
2121 if (snd_BUG_ON(!substream->ops->copy && !runtime->dma_area)) in pcm_sanity_check()
2128 snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream, const void __user *buf, sn… in snd_pcm_lib_write() argument
2134 err = pcm_sanity_check(substream); in snd_pcm_lib_write()
2137 runtime = substream->runtime; in snd_pcm_lib_write()
2138 nonblock = !!(substream->f_flags & O_NONBLOCK); in snd_pcm_lib_write()
2143 return snd_pcm_lib_write1(substream, (unsigned long)buf, size, nonblock, in snd_pcm_lib_write()
2149 static int snd_pcm_lib_writev_transfer(struct snd_pcm_substream *substream, in snd_pcm_lib_writev_transfer() argument
2154 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_writev_transfer()
2159 if (substream->ops->copy) { in snd_pcm_lib_writev_transfer()
2160 if (snd_BUG_ON(!substream->ops->silence)) in snd_pcm_lib_writev_transfer()
2164 if ((err = substream->ops->silence(substream, c, hwoff, frames)) < 0) in snd_pcm_lib_writev_transfer()
2168 if ((err = substream->ops->copy(substream, c, hwoff, buf, frames)) < 0) in snd_pcm_lib_writev_transfer()
2189 snd_pcm_sframes_t snd_pcm_lib_writev(struct snd_pcm_substream *substream, in snd_pcm_lib_writev() argument
2197 err = pcm_sanity_check(substream); in snd_pcm_lib_writev()
2200 runtime = substream->runtime; in snd_pcm_lib_writev()
2201 nonblock = !!(substream->f_flags & O_NONBLOCK); in snd_pcm_lib_writev()
2205 return snd_pcm_lib_write1(substream, (unsigned long)bufs, frames, in snd_pcm_lib_writev()
2211 static int snd_pcm_lib_read_transfer(struct snd_pcm_substream *substream, in snd_pcm_lib_read_transfer() argument
2216 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_read_transfer()
2219 if (substream->ops->copy) { in snd_pcm_lib_read_transfer()
2220 if ((err = substream->ops->copy(substream, -1, hwoff, buf, frames)) < 0) in snd_pcm_lib_read_transfer()
2230 static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream, in snd_pcm_lib_read1() argument
2236 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_read1()
2245 snd_pcm_stream_lock_irq(substream); in snd_pcm_lib_read1()
2249 err = snd_pcm_start(substream); in snd_pcm_lib_read1()
2271 snd_pcm_update_hw_ptr(substream); in snd_pcm_lib_read1()
2279 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_lib_read1()
2288 err = wait_for_avail(substream, &avail); in snd_pcm_lib_read1()
2300 snd_pcm_stream_unlock_irq(substream); in snd_pcm_lib_read1()
2305 snd_pcm_stream_unlock_irq(substream); in snd_pcm_lib_read1()
2306 err = transfer(substream, appl_ofs, data, offset, frames); in snd_pcm_lib_read1()
2307 snd_pcm_stream_lock_irq(substream); in snd_pcm_lib_read1()
2324 if (substream->ops->ack) in snd_pcm_lib_read1()
2325 substream->ops->ack(substream); in snd_pcm_lib_read1()
2335 snd_pcm_update_state(substream, runtime); in snd_pcm_lib_read1()
2336 snd_pcm_stream_unlock_irq(substream); in snd_pcm_lib_read1()
2340 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
2346 err = pcm_sanity_check(substream); in snd_pcm_lib_read()
2349 runtime = substream->runtime; in snd_pcm_lib_read()
2350 nonblock = !!(substream->f_flags & O_NONBLOCK); in snd_pcm_lib_read()
2353 return snd_pcm_lib_read1(substream, (unsigned long)buf, size, nonblock, snd_pcm_lib_read_transfer); in snd_pcm_lib_read()
2358 static int snd_pcm_lib_readv_transfer(struct snd_pcm_substream *substream, in snd_pcm_lib_readv_transfer() argument
2363 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_readv_transfer()
2368 if (substream->ops->copy) { in snd_pcm_lib_readv_transfer()
2374 if ((err = substream->ops->copy(substream, c, hwoff, buf, frames)) < 0) in snd_pcm_lib_readv_transfer()
2394 snd_pcm_sframes_t snd_pcm_lib_readv(struct snd_pcm_substream *substream, in snd_pcm_lib_readv() argument
2402 err = pcm_sanity_check(substream); in snd_pcm_lib_readv()
2405 runtime = substream->runtime; in snd_pcm_lib_readv()
2409 nonblock = !!(substream->f_flags & O_NONBLOCK); in snd_pcm_lib_readv()
2412 …return snd_pcm_lib_read1(substream, (unsigned long)bufs, frames, nonblock, snd_pcm_lib_readv_trans… in snd_pcm_lib_readv()
2493 struct snd_pcm_substream *substream; in pcm_chmap_ctl_get() local
2498 substream = snd_pcm_chmap_substream(info, idx); in pcm_chmap_ctl_get()
2499 if (!substream) in pcm_chmap_ctl_get()
2503 if (!substream->runtime) in pcm_chmap_ctl_get()
2507 if (map->channels == substream->runtime->channels && in pcm_chmap_ctl_get()