Loading...
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * pcm_local.h - a local header file for snd-pcm module.
4 *
5 * Copyright (c) Takashi Sakamoto <o-takashi@sakamocchi.jp>
6 */
7
8#ifndef __SOUND_CORE_PCM_LOCAL_H
9#define __SOUND_CORE_PCM_LOCAL_H
10
11extern const struct snd_pcm_hw_constraint_list snd_pcm_known_rates;
12
13void snd_interval_mul(const struct snd_interval *a,
14 const struct snd_interval *b, struct snd_interval *c);
15void snd_interval_div(const struct snd_interval *a,
16 const struct snd_interval *b, struct snd_interval *c);
17void snd_interval_muldivk(const struct snd_interval *a,
18 const struct snd_interval *b,
19 unsigned int k, struct snd_interval *c);
20void snd_interval_mulkdiv(const struct snd_interval *a, unsigned int k,
21 const struct snd_interval *b, struct snd_interval *c);
22
23int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream);
24int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream);
25
26int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime,
27 snd_pcm_hw_param_t var, u_int32_t mask);
28
29int pcm_lib_apply_appl_ptr(struct snd_pcm_substream *substream,
30 snd_pcm_uframes_t appl_ptr);
31int snd_pcm_update_state(struct snd_pcm_substream *substream,
32 struct snd_pcm_runtime *runtime);
33int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream);
34
35void snd_pcm_playback_silence(struct snd_pcm_substream *substream,
36 snd_pcm_uframes_t new_hw_ptr);
37
38static inline snd_pcm_uframes_t
39snd_pcm_avail(struct snd_pcm_substream *substream)
40{
41 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
42 return snd_pcm_playback_avail(substream->runtime);
43 else
44 return snd_pcm_capture_avail(substream->runtime);
45}
46
47static inline snd_pcm_uframes_t
48snd_pcm_hw_avail(struct snd_pcm_substream *substream)
49{
50 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
51 return snd_pcm_playback_hw_avail(substream->runtime);
52 else
53 return snd_pcm_capture_hw_avail(substream->runtime);
54}
55
56#ifdef CONFIG_SND_PCM_TIMER
57void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream);
58void snd_pcm_timer_init(struct snd_pcm_substream *substream);
59void snd_pcm_timer_done(struct snd_pcm_substream *substream);
60#else
61static inline void
62snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream) {}
63static inline void snd_pcm_timer_init(struct snd_pcm_substream *substream) {}
64static inline void snd_pcm_timer_done(struct snd_pcm_substream *substream) {}
65#endif
66
67void __snd_pcm_xrun(struct snd_pcm_substream *substream);
68void snd_pcm_group_init(struct snd_pcm_group *group);
69
70#endif /* __SOUND_CORE_PCM_LOCAL_H */
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * pcm_local.h - a local header file for snd-pcm module.
4 *
5 * Copyright (c) Takashi Sakamoto <o-takashi@sakamocchi.jp>
6 */
7
8#ifndef __SOUND_CORE_PCM_LOCAL_H
9#define __SOUND_CORE_PCM_LOCAL_H
10
11extern const struct snd_pcm_hw_constraint_list snd_pcm_known_rates;
12
13void snd_interval_mul(const struct snd_interval *a,
14 const struct snd_interval *b, struct snd_interval *c);
15void snd_interval_div(const struct snd_interval *a,
16 const struct snd_interval *b, struct snd_interval *c);
17void snd_interval_muldivk(const struct snd_interval *a,
18 const struct snd_interval *b,
19 unsigned int k, struct snd_interval *c);
20void snd_interval_mulkdiv(const struct snd_interval *a, unsigned int k,
21 const struct snd_interval *b, struct snd_interval *c);
22
23int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime,
24 snd_pcm_hw_param_t var, u_int32_t mask);
25
26int pcm_lib_apply_appl_ptr(struct snd_pcm_substream *substream,
27 snd_pcm_uframes_t appl_ptr);
28int snd_pcm_update_state(struct snd_pcm_substream *substream,
29 struct snd_pcm_runtime *runtime);
30int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream);
31
32void snd_pcm_playback_silence(struct snd_pcm_substream *substream,
33 snd_pcm_uframes_t new_hw_ptr);
34
35static inline snd_pcm_uframes_t
36snd_pcm_avail(struct snd_pcm_substream *substream)
37{
38 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
39 return snd_pcm_playback_avail(substream->runtime);
40 else
41 return snd_pcm_capture_avail(substream->runtime);
42}
43
44static inline snd_pcm_uframes_t
45snd_pcm_hw_avail(struct snd_pcm_substream *substream)
46{
47 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
48 return snd_pcm_playback_hw_avail(substream->runtime);
49 else
50 return snd_pcm_capture_hw_avail(substream->runtime);
51}
52
53#ifdef CONFIG_SND_PCM_TIMER
54void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream);
55void snd_pcm_timer_init(struct snd_pcm_substream *substream);
56void snd_pcm_timer_done(struct snd_pcm_substream *substream);
57#else
58static inline void
59snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream) {}
60static inline void snd_pcm_timer_init(struct snd_pcm_substream *substream) {}
61static inline void snd_pcm_timer_done(struct snd_pcm_substream *substream) {}
62#endif
63
64void __snd_pcm_xrun(struct snd_pcm_substream *substream);
65void snd_pcm_group_init(struct snd_pcm_group *group);
66
67#ifdef CONFIG_SND_DMA_SGBUF
68struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream,
69 unsigned long offset);
70#endif
71
72#define PCM_RUNTIME_CHECK(sub) snd_BUG_ON(!(sub) || !(sub)->runtime)
73
74#endif /* __SOUND_CORE_PCM_LOCAL_H */