29 #include <linux/poll.h>
31 #include <linux/bitops.h>
34 #define snd_pcm_substream_chip(substream) ((substream)->private_data)
35 #define snd_pcm_chip(pcm) ((pcm)->private_data)
37 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
67 unsigned int cmd,
void *
arg);
89 #if defined(CONFIG_SND_DYNAMIC_MINORS)
90 #define SNDRV_PCM_DEVICES (SNDRV_OS_MINORS-2)
92 #define SNDRV_PCM_DEVICES 8
95 #define SNDRV_PCM_IOCTL1_FALSE ((void *)0)
96 #define SNDRV_PCM_IOCTL1_TRUE ((void *)1)
98 #define SNDRV_PCM_IOCTL1_RESET 0
99 #define SNDRV_PCM_IOCTL1_INFO 1
100 #define SNDRV_PCM_IOCTL1_CHANNEL_INFO 2
101 #define SNDRV_PCM_IOCTL1_GSTATE 3
102 #define SNDRV_PCM_IOCTL1_FIFO_SIZE 4
104 #define SNDRV_PCM_TRIGGER_STOP 0
105 #define SNDRV_PCM_TRIGGER_START 1
106 #define SNDRV_PCM_TRIGGER_PAUSE_PUSH 3
107 #define SNDRV_PCM_TRIGGER_PAUSE_RELEASE 4
108 #define SNDRV_PCM_TRIGGER_SUSPEND 5
109 #define SNDRV_PCM_TRIGGER_RESUME 6
111 #define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)
114 #define SNDRV_PCM_RATE_5512 (1<<0)
115 #define SNDRV_PCM_RATE_8000 (1<<1)
116 #define SNDRV_PCM_RATE_11025 (1<<2)
117 #define SNDRV_PCM_RATE_16000 (1<<3)
118 #define SNDRV_PCM_RATE_22050 (1<<4)
119 #define SNDRV_PCM_RATE_32000 (1<<5)
120 #define SNDRV_PCM_RATE_44100 (1<<6)
121 #define SNDRV_PCM_RATE_48000 (1<<7)
122 #define SNDRV_PCM_RATE_64000 (1<<8)
123 #define SNDRV_PCM_RATE_88200 (1<<9)
124 #define SNDRV_PCM_RATE_96000 (1<<10)
125 #define SNDRV_PCM_RATE_176400 (1<<11)
126 #define SNDRV_PCM_RATE_192000 (1<<12)
128 #define SNDRV_PCM_RATE_CONTINUOUS (1<<30)
129 #define SNDRV_PCM_RATE_KNOT (1<<31)
131 #define SNDRV_PCM_RATE_8000_44100 (SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_11025|\
132 SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_22050|\
133 SNDRV_PCM_RATE_32000|SNDRV_PCM_RATE_44100)
134 #define SNDRV_PCM_RATE_8000_48000 (SNDRV_PCM_RATE_8000_44100|SNDRV_PCM_RATE_48000)
135 #define SNDRV_PCM_RATE_8000_96000 (SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_64000|\
136 SNDRV_PCM_RATE_88200|SNDRV_PCM_RATE_96000)
137 #define SNDRV_PCM_RATE_8000_192000 (SNDRV_PCM_RATE_8000_96000|SNDRV_PCM_RATE_176400|\
138 SNDRV_PCM_RATE_192000)
139 #define _SNDRV_PCM_FMTBIT(fmt) (1ULL << (__force int)SNDRV_PCM_FORMAT_##fmt)
140 #define SNDRV_PCM_FMTBIT_S8 _SNDRV_PCM_FMTBIT(S8)
141 #define SNDRV_PCM_FMTBIT_U8 _SNDRV_PCM_FMTBIT(U8)
142 #define SNDRV_PCM_FMTBIT_S16_LE _SNDRV_PCM_FMTBIT(S16_LE)
143 #define SNDRV_PCM_FMTBIT_S16_BE _SNDRV_PCM_FMTBIT(S16_BE)
144 #define SNDRV_PCM_FMTBIT_U16_LE _SNDRV_PCM_FMTBIT(U16_LE)
145 #define SNDRV_PCM_FMTBIT_U16_BE _SNDRV_PCM_FMTBIT(U16_BE)
146 #define SNDRV_PCM_FMTBIT_S24_LE _SNDRV_PCM_FMTBIT(S24_LE)
147 #define SNDRV_PCM_FMTBIT_S24_BE _SNDRV_PCM_FMTBIT(S24_BE)
148 #define SNDRV_PCM_FMTBIT_U24_LE _SNDRV_PCM_FMTBIT(U24_LE)
149 #define SNDRV_PCM_FMTBIT_U24_BE _SNDRV_PCM_FMTBIT(U24_BE)
150 #define SNDRV_PCM_FMTBIT_S32_LE _SNDRV_PCM_FMTBIT(S32_LE)
151 #define SNDRV_PCM_FMTBIT_S32_BE _SNDRV_PCM_FMTBIT(S32_BE)
152 #define SNDRV_PCM_FMTBIT_U32_LE _SNDRV_PCM_FMTBIT(U32_LE)
153 #define SNDRV_PCM_FMTBIT_U32_BE _SNDRV_PCM_FMTBIT(U32_BE)
154 #define SNDRV_PCM_FMTBIT_FLOAT_LE _SNDRV_PCM_FMTBIT(FLOAT_LE)
155 #define SNDRV_PCM_FMTBIT_FLOAT_BE _SNDRV_PCM_FMTBIT(FLOAT_BE)
156 #define SNDRV_PCM_FMTBIT_FLOAT64_LE _SNDRV_PCM_FMTBIT(FLOAT64_LE)
157 #define SNDRV_PCM_FMTBIT_FLOAT64_BE _SNDRV_PCM_FMTBIT(FLOAT64_BE)
158 #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_LE)
159 #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_BE)
160 #define SNDRV_PCM_FMTBIT_MU_LAW _SNDRV_PCM_FMTBIT(MU_LAW)
161 #define SNDRV_PCM_FMTBIT_A_LAW _SNDRV_PCM_FMTBIT(A_LAW)
162 #define SNDRV_PCM_FMTBIT_IMA_ADPCM _SNDRV_PCM_FMTBIT(IMA_ADPCM)
163 #define SNDRV_PCM_FMTBIT_MPEG _SNDRV_PCM_FMTBIT(MPEG)
164 #define SNDRV_PCM_FMTBIT_GSM _SNDRV_PCM_FMTBIT(GSM)
165 #define SNDRV_PCM_FMTBIT_SPECIAL _SNDRV_PCM_FMTBIT(SPECIAL)
166 #define SNDRV_PCM_FMTBIT_S24_3LE _SNDRV_PCM_FMTBIT(S24_3LE)
167 #define SNDRV_PCM_FMTBIT_U24_3LE _SNDRV_PCM_FMTBIT(U24_3LE)
168 #define SNDRV_PCM_FMTBIT_S24_3BE _SNDRV_PCM_FMTBIT(S24_3BE)
169 #define SNDRV_PCM_FMTBIT_U24_3BE _SNDRV_PCM_FMTBIT(U24_3BE)
170 #define SNDRV_PCM_FMTBIT_S20_3LE _SNDRV_PCM_FMTBIT(S20_3LE)
171 #define SNDRV_PCM_FMTBIT_U20_3LE _SNDRV_PCM_FMTBIT(U20_3LE)
172 #define SNDRV_PCM_FMTBIT_S20_3BE _SNDRV_PCM_FMTBIT(S20_3BE)
173 #define SNDRV_PCM_FMTBIT_U20_3BE _SNDRV_PCM_FMTBIT(U20_3BE)
174 #define SNDRV_PCM_FMTBIT_S18_3LE _SNDRV_PCM_FMTBIT(S18_3LE)
175 #define SNDRV_PCM_FMTBIT_U18_3LE _SNDRV_PCM_FMTBIT(U18_3LE)
176 #define SNDRV_PCM_FMTBIT_S18_3BE _SNDRV_PCM_FMTBIT(S18_3BE)
177 #define SNDRV_PCM_FMTBIT_U18_3BE _SNDRV_PCM_FMTBIT(U18_3BE)
178 #define SNDRV_PCM_FMTBIT_G723_24 _SNDRV_PCM_FMTBIT(G723_24)
179 #define SNDRV_PCM_FMTBIT_G723_24_1B _SNDRV_PCM_FMTBIT(G723_24_1B)
180 #define SNDRV_PCM_FMTBIT_G723_40 _SNDRV_PCM_FMTBIT(G723_40)
181 #define SNDRV_PCM_FMTBIT_G723_40_1B _SNDRV_PCM_FMTBIT(G723_40_1B)
183 #ifdef SNDRV_LITTLE_ENDIAN
184 #define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_LE
185 #define SNDRV_PCM_FMTBIT_U16 SNDRV_PCM_FMTBIT_U16_LE
186 #define SNDRV_PCM_FMTBIT_S24 SNDRV_PCM_FMTBIT_S24_LE
187 #define SNDRV_PCM_FMTBIT_U24 SNDRV_PCM_FMTBIT_U24_LE
188 #define SNDRV_PCM_FMTBIT_S32 SNDRV_PCM_FMTBIT_S32_LE
189 #define SNDRV_PCM_FMTBIT_U32 SNDRV_PCM_FMTBIT_U32_LE
190 #define SNDRV_PCM_FMTBIT_FLOAT SNDRV_PCM_FMTBIT_FLOAT_LE
191 #define SNDRV_PCM_FMTBIT_FLOAT64 SNDRV_PCM_FMTBIT_FLOAT64_LE
192 #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE
194 #ifdef SNDRV_BIG_ENDIAN
195 #define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_BE
196 #define SNDRV_PCM_FMTBIT_U16 SNDRV_PCM_FMTBIT_U16_BE
197 #define SNDRV_PCM_FMTBIT_S24 SNDRV_PCM_FMTBIT_S24_BE
198 #define SNDRV_PCM_FMTBIT_U24 SNDRV_PCM_FMTBIT_U24_BE
199 #define SNDRV_PCM_FMTBIT_S32 SNDRV_PCM_FMTBIT_S32_BE
200 #define SNDRV_PCM_FMTBIT_U32 SNDRV_PCM_FMTBIT_U32_BE
201 #define SNDRV_PCM_FMTBIT_FLOAT SNDRV_PCM_FMTBIT_FLOAT_BE
202 #define SNDRV_PCM_FMTBIT_FLOAT64 SNDRV_PCM_FMTBIT_FLOAT64_BE
203 #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE
271 struct snd_pcm_hwptr_log;
351 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
356 #ifdef CONFIG_SND_PCM_XRUN_DEBUG
357 struct snd_pcm_hwptr_log *hwptr_log;
401 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
405 #ifdef CONFIG_SND_VERBOSE_PROCFS
418 #define SUBSTREAM_BUSY(substream) ((substream)->ref_count > 0)
428 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
432 #ifdef CONFIG_SND_VERBOSE_PROCFS
435 #ifdef CONFIG_SND_PCM_XRUN_DEBUG
459 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
478 int playback_count,
int capture_count,
481 int playback_count,
int capture_count,
503 int snd_pcm_suspend_all(
struct snd_pcm *pcm);
516 #ifdef CONFIG_SND_DEBUG
518 char *
name,
size_t len);
554 static inline void snd_pcm_stream_unlock_irq(
struct snd_pcm_substream *substream)
560 #define snd_pcm_stream_lock_irqsave(substream, flags) \
562 read_lock_irqsave(&snd_pcm_link_rwlock, (flags)); \
563 spin_lock(&substream->self_group.lock); \
566 #define snd_pcm_stream_unlock_irqrestore(substream, flags) \
568 spin_unlock(&substream->self_group.lock); \
569 read_unlock_irqrestore(&snd_pcm_link_rwlock, (flags)); \
572 #define snd_pcm_group_for_each_entry(s, substream) \
573 list_for_each_entry(s, &substream->group->substreams, link_list)
607 static inline size_t snd_pcm_lib_buffer_bytes(
struct snd_pcm_substream *substream)
610 return frames_to_bytes(runtime, runtime->
buffer_size);
613 static inline size_t snd_pcm_lib_period_bytes(
struct snd_pcm_substream *substream)
616 return frames_to_bytes(runtime, runtime->
period_size);
645 return runtime->
buffer_size - snd_pcm_playback_avail(runtime);
650 return runtime->
buffer_size - snd_pcm_capture_avail(runtime);
664 return snd_pcm_playback_avail(runtime) >= runtime->
control->avail_min;
678 return snd_pcm_capture_avail(runtime) >= runtime->
control->avail_min;
696 return snd_pcm_playback_avail(runtime) < runtime->
buffer_size;
710 return snd_pcm_playback_avail(runtime) >= runtime->
buffer_size;
724 return snd_pcm_capture_avail(runtime) == 0;
730 substream->
runtime->trigger_master = master;
733 static inline int hw_is_mask(
int var)
739 static inline int hw_is_interval(
int var)
769 #define params_channels(p) \
770 (hw_param_interval_c((p), SNDRV_PCM_HW_PARAM_CHANNELS)->min)
771 #define params_rate(p) \
772 (hw_param_interval_c((p), SNDRV_PCM_HW_PARAM_RATE)->min)
773 #define params_period_size(p) \
774 (hw_param_interval_c((p), SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min)
775 #define params_periods(p) \
776 (hw_param_interval_c((p), SNDRV_PCM_HW_PARAM_PERIODS)->min)
777 #define params_buffer_size(p) \
778 (hw_param_interval_c((p), SNDRV_PCM_HW_PARAM_BUFFER_SIZE)->min)
779 #define params_buffer_bytes(p) \
780 (hw_param_interval_c((p), SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->min)
790 const unsigned int *
list,
unsigned int mask);
792 unsigned int rats_count,
struct snd_ratnum *rats,
793 unsigned int *nump,
unsigned int *denp);
809 unsigned int min,
unsigned int max);
826 unsigned int msbits);
835 unsigned int base_rate);
857 #ifdef SNDRV_LITTLE_ENDIAN
858 #define snd_pcm_format_cpu_endian(format) snd_pcm_format_little_endian(format)
860 #define snd_pcm_format_cpu_endian(format) snd_pcm_format_big_endian(format)
873 unsigned int cmd,
void *
arg);
884 const void __user *
buf,
899 static inline void snd_pcm_set_runtime_buffer(
struct snd_pcm_substream *substream,
979 #define snd_pcm_lib_alloc_vmalloc_buffer(subs, size) \
980 _snd_pcm_lib_alloc_vmalloc_buffer \
981 (subs, size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO)
982 #define snd_pcm_lib_alloc_vmalloc_32_buffer(subs, size) \
983 _snd_pcm_lib_alloc_vmalloc_buffer \
984 (subs, size, GFP_KERNEL | GFP_DMA32 | __GFP_ZERO)
986 #define snd_pcm_get_dma_buf(substream) ((substream)->runtime->dma_buffer_p)
988 #ifdef CONFIG_SND_DMA_SGBUF
992 #define snd_pcm_substream_sgbuf(substream) \
993 snd_pcm_get_dma_buf(substream)->private_data
1001 #define snd_pcm_sgbuf_ops_page NULL
1010 static inline void *
1016 static inline unsigned int
1018 unsigned int ofs,
unsigned int size)
1024 static inline void snd_pcm_mmap_data_open(
struct vm_area_struct *area)
1030 static inline void snd_pcm_mmap_data_close(
struct vm_area_struct *area)
1039 #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_ALPHA)
1040 #define SNDRV_PCM_INFO_MMAP_IOMEM SNDRV_PCM_INFO_MMAP
1043 #define SNDRV_PCM_INFO_MMAP_IOMEM 0
1044 #define snd_pcm_lib_mmap_iomem NULL
1047 #define snd_pcm_lib_mmap_vmalloc NULL
1049 static inline void snd_pcm_limit_isa_dma_size(
int dma,
size_t *
max)
1051 *max = dma < 4 ? 64 * 1024 : 128 * 1024;
1058 #define SNDRV_PCM_DEFAULT_CON_SPDIF (IEC958_AES0_CON_EMPHASIS_NONE|\
1059 (IEC958_AES1_CON_ORIGINAL<<8)|\
1060 (IEC958_AES1_CON_PCM_CODER<<8)|\
1061 (IEC958_AES3_CON_FS_48000<<24))
1063 #define PCM_RUNTIME_CHECK(sub) snd_BUG_ON(!(sub) || !(sub)->runtime)
1071 static inline const char *snd_pcm_stream_str(
struct snd_pcm_substream *substream)
1104 for (s = info->
pcm->streams[info->
stream].substream; s; s = s->
next)
1116 #define SND_PCM_CHMAP_MASK_24 ((1U << 2) | (1U << 4))
1117 #define SND_PCM_CHMAP_MASK_246 (SND_PCM_CHMAP_MASK_24 | (1U << 6))
1118 #define SND_PCM_CHMAP_MASK_2468 (SND_PCM_CHMAP_MASK_246 | (1U << 8))
1123 unsigned long private_value,