Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * pcm_local.h - a local header file for snd-pcm module.
0004  *
0005  * Copyright (c) Takashi Sakamoto <o-takashi@sakamocchi.jp>
0006  */
0007 
0008 #ifndef __SOUND_CORE_PCM_LOCAL_H
0009 #define __SOUND_CORE_PCM_LOCAL_H
0010 
0011 extern const struct snd_pcm_hw_constraint_list snd_pcm_known_rates;
0012 
0013 void snd_interval_mul(const struct snd_interval *a,
0014               const struct snd_interval *b, struct snd_interval *c);
0015 void snd_interval_div(const struct snd_interval *a,
0016               const struct snd_interval *b, struct snd_interval *c);
0017 void snd_interval_muldivk(const struct snd_interval *a,
0018               const struct snd_interval *b,
0019               unsigned int k, struct snd_interval *c);
0020 void snd_interval_mulkdiv(const struct snd_interval *a, unsigned int k,
0021               const struct snd_interval *b, struct snd_interval *c);
0022 
0023 int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime,
0024                    snd_pcm_hw_param_t var, u_int32_t mask);
0025 
0026 int pcm_lib_apply_appl_ptr(struct snd_pcm_substream *substream,
0027                snd_pcm_uframes_t appl_ptr);
0028 int snd_pcm_update_state(struct snd_pcm_substream *substream,
0029              struct snd_pcm_runtime *runtime);
0030 int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream);
0031 
0032 void snd_pcm_playback_silence(struct snd_pcm_substream *substream,
0033                   snd_pcm_uframes_t new_hw_ptr);
0034 
0035 static inline snd_pcm_uframes_t
0036 snd_pcm_avail(struct snd_pcm_substream *substream)
0037 {
0038     if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
0039         return snd_pcm_playback_avail(substream->runtime);
0040     else
0041         return snd_pcm_capture_avail(substream->runtime);
0042 }
0043 
0044 static inline snd_pcm_uframes_t
0045 snd_pcm_hw_avail(struct snd_pcm_substream *substream)
0046 {
0047     if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
0048         return snd_pcm_playback_hw_avail(substream->runtime);
0049     else
0050         return snd_pcm_capture_hw_avail(substream->runtime);
0051 }
0052 
0053 #ifdef CONFIG_SND_PCM_TIMER
0054 void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream);
0055 void snd_pcm_timer_init(struct snd_pcm_substream *substream);
0056 void snd_pcm_timer_done(struct snd_pcm_substream *substream);
0057 #else
0058 static inline void
0059 snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream) {}
0060 static inline void snd_pcm_timer_init(struct snd_pcm_substream *substream) {}
0061 static inline void snd_pcm_timer_done(struct snd_pcm_substream *substream) {}
0062 #endif
0063 
0064 void __snd_pcm_xrun(struct snd_pcm_substream *substream);
0065 void snd_pcm_group_init(struct snd_pcm_group *group);
0066 void snd_pcm_sync_stop(struct snd_pcm_substream *substream, bool sync_irq);
0067 
0068 #define PCM_RUNTIME_CHECK(sub) snd_BUG_ON(!(sub) || !(sub)->runtime)
0069 
0070 /* loop over all PCM substreams */
0071 #define for_each_pcm_substream(pcm, str, subs) \
0072     for ((str) = 0; (str) < 2; (str)++) \
0073         for ((subs) = (pcm)->streams[str].substream; (subs); \
0074              (subs) = (subs)->next)
0075 
0076 static inline void snd_pcm_dma_buffer_sync(struct snd_pcm_substream *substream,
0077                        enum snd_dma_sync_mode mode)
0078 {
0079     if (substream->runtime->info & SNDRV_PCM_INFO_EXPLICIT_SYNC)
0080         snd_dma_buffer_sync(snd_pcm_get_dma_buf(substream), mode);
0081 }
0082 
0083 #endif  /* __SOUND_CORE_PCM_LOCAL_H */