Lines Matching +full:min +full:- +full:sample +full:- +full:rate +full:- +full:hz
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
8 * Abramo Bagnara <abramo@alsa-project.org>
21 #define snd_pcm_substream_chip(substream) ((substream)->private_data)
22 #define snd_pcm_chip(pcm) ((pcm)->private_data)
36 unsigned int rate_min; /* min rate */
37 unsigned int rate_max; /* max rate */
38 unsigned int channels_min; /* min channels */
41 size_t period_bytes_min; /* min period size */
43 unsigned int periods_min; /* min # of periods */
85 #define SNDRV_PCM_DEVICES (SNDRV_OS_MINORS-2)
104 #define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)
107 #define SNDRV_PCM_RATE_5512 (1U<<0) /* 5512Hz */
108 #define SNDRV_PCM_RATE_8000 (1U<<1) /* 8000Hz */
109 #define SNDRV_PCM_RATE_11025 (1U<<2) /* 11025Hz */
110 #define SNDRV_PCM_RATE_16000 (1U<<3) /* 16000Hz */
111 #define SNDRV_PCM_RATE_22050 (1U<<4) /* 22050Hz */
112 #define SNDRV_PCM_RATE_32000 (1U<<5) /* 32000Hz */
113 #define SNDRV_PCM_RATE_44100 (1U<<6) /* 44100Hz */
114 #define SNDRV_PCM_RATE_48000 (1U<<7) /* 48000Hz */
115 #define SNDRV_PCM_RATE_64000 (1U<<8) /* 64000Hz */
116 #define SNDRV_PCM_RATE_88200 (1U<<9) /* 88200Hz */
117 #define SNDRV_PCM_RATE_96000 (1U<<10) /* 96000Hz */
118 #define SNDRV_PCM_RATE_176400 (1U<<11) /* 176400Hz */
119 #define SNDRV_PCM_RATE_192000 (1U<<12) /* 192000Hz */
120 #define SNDRV_PCM_RATE_352800 (1U<<13) /* 352800Hz */
121 #define SNDRV_PCM_RATE_384000 (1U<<14) /* 384000Hz */
124 #define SNDRV_PCM_RATE_KNOT (1U<<31) /* supports more non-continuos rates */
149 // available bit count in most significant bit. It's for the case of so-called 'left-justified' or
150 // `right-padding` sample which has less width than 32 bit.
240 struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK -
242 struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL -
252 return &constrs->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; in constrs_mask()
258 return &constrs->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; in constrs_interval()
294 * userspace-provided audio timestamp config to kernel,
306 config->type_requested = data & 0xF; in snd_pcm_unpack_audio_tstamp_config()
307 config->report_delay = (data >> 4) & 1; in snd_pcm_unpack_audio_tstamp_config()
311 * kernel-provided audio timestamp report to user-space
315 /* 6 of max 16 bits used for bit-fields */
333 tmp = report->accuracy_report; in snd_pcm_pack_audio_tstamp_report()
335 tmp |= report->actual_type; in snd_pcm_pack_audio_tstamp_report()
337 tmp |= report->valid; in snd_pcm_pack_audio_tstamp_report()
339 *data &= 0xffff; /* zero-clear MSBs */ in snd_pcm_pack_audio_tstamp_report()
341 *accuracy = report->accuracy; in snd_pcm_pack_audio_tstamp_report()
346 /* -- Status -- */
351 bool trigger_tstamp_latched; /* trigger timestamp latched in low-level driver/hardware */
359 u64 hw_ptr_wrap; /* offset for hw_ptr due to boundary wrap-around */
361 /* -- HW params -- */
365 unsigned int rate; /* rate in Hz */ member
370 snd_pcm_uframes_t min_align; /* Min alignment for the format */
379 /* -- SW params; see struct snd_pcm_sw_params for comments -- */
388 /* internal data of auto-silencer */
394 /* -- mmap -- */
398 /* -- locking / scheduling -- */
399 snd_pcm_uframes_t twake; /* do transfer (!poll) wakeup if non-zero */
407 /* -- private section -- */
411 /* -- hardware description -- */
415 /* -- timer -- */
419 /* -- DMA -- */
427 /* -- audio timestamp config -- */
433 /* -- OSS things -- */
450 void *private_data; /* copied from pcm->private_data */
458 /* -- hardware operations -- */
460 /* -- runtime information -- */
462 /* -- timer section -- */
466 /* -- next substream -- */
468 /* -- linked substreams -- */
472 /* -- assigned files -- */
479 /* -- OSS things -- */
490 #define SUBSTREAM_BUSY(substream) ((substream)->ref_count > 0)
496 /* -- substreams -- */
501 /* -- OSS things -- */
510 struct snd_kcontrol *chmap_kctl; /* channel-mapping controls */
529 bool nonatomic; /* whole PCM operations are in non-atomic context */
607 * snd_pcm_stream_linked - Check whether the substream is linked with others
614 return substream->group != &substream->self_group; in snd_pcm_stream_linked()
625 * snd_pcm_stream_lock_irqsave - Lock the PCM stream
642 * snd_pcm_stream_lock_irqsave_nested - Single-nested PCM stream locking
647 * the single-depth lockdep subclass.
656 * snd_pcm_group_for_each_entry - iterate over the linked substreams
665 list_for_each_entry(s, &substream->group->substreams, link_list)
673 * snd_pcm_running - Check whether the substream is in a running state
681 return (substream->runtime->state == SNDRV_PCM_STATE_RUNNING || in snd_pcm_running()
682 (substream->runtime->state == SNDRV_PCM_STATE_DRAINING && in snd_pcm_running()
683 substream->stream == SNDRV_PCM_STREAM_PLAYBACK)); in snd_pcm_running()
687 * __snd_pcm_set_state - Change the current PCM state
696 runtime->state = state; in __snd_pcm_set_state()
697 runtime->status->state = state; /* copy for mmap */ in __snd_pcm_set_state()
701 * bytes_to_samples - Unit conversion of the size from bytes to samples
709 return size * 8 / runtime->sample_bits; in bytes_to_samples()
713 * bytes_to_frames - Unit conversion of the size from bytes to frames
721 return size * 8 / runtime->frame_bits; in bytes_to_frames()
725 * samples_to_bytes - Unit conversion of the size from samples to bytes
733 return size * runtime->sample_bits / 8; in samples_to_bytes()
737 * frames_to_bytes - Unit conversion of the size from frames to bytes
745 return size * runtime->frame_bits / 8; in frames_to_bytes()
749 * frame_aligned - Check whether the byte size is aligned to frames
757 return bytes % runtime->byte_align == 0; in frame_aligned()
761 * snd_pcm_lib_buffer_bytes - Get the buffer size of the current PCM in bytes
768 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_buffer_bytes()
769 return frames_to_bytes(runtime, runtime->buffer_size); in snd_pcm_lib_buffer_bytes()
773 * snd_pcm_lib_period_bytes - Get the period size of the current PCM in bytes
780 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_period_bytes()
781 return frames_to_bytes(runtime, runtime->period_size); in snd_pcm_lib_period_bytes()
785 * snd_pcm_playback_avail - Get the available (writable) space for playback
788 * Result is between 0 ... (boundary - 1)
794 …snd_pcm_sframes_t avail = runtime->status->hw_ptr + runtime->buffer_size - runtime->control->appl_… in snd_pcm_playback_avail()
796 avail += runtime->boundary; in snd_pcm_playback_avail()
797 else if ((snd_pcm_uframes_t) avail >= runtime->boundary) in snd_pcm_playback_avail()
798 avail -= runtime->boundary; in snd_pcm_playback_avail()
803 * snd_pcm_capture_avail - Get the available (readable) space for capture
806 * Result is between 0 ... (boundary - 1)
812 snd_pcm_sframes_t avail = runtime->status->hw_ptr - runtime->control->appl_ptr; in snd_pcm_capture_avail()
814 avail += runtime->boundary; in snd_pcm_capture_avail()
819 * snd_pcm_playback_hw_avail - Get the queued space for playback
826 return runtime->buffer_size - snd_pcm_playback_avail(runtime); in snd_pcm_playback_hw_avail()
830 * snd_pcm_capture_hw_avail - Get the free space for capture
837 return runtime->buffer_size - snd_pcm_capture_avail(runtime); in snd_pcm_capture_hw_avail()
841 * snd_pcm_playback_ready - check whether the playback buffer is available
846 * Return: Non-zero if available, or zero if not.
850 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_ready()
851 return snd_pcm_playback_avail(runtime) >= runtime->control->avail_min; in snd_pcm_playback_ready()
855 * snd_pcm_capture_ready - check whether the capture buffer is available
860 * Return: Non-zero if available, or zero if not.
864 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_capture_ready()
865 return snd_pcm_capture_avail(runtime) >= runtime->control->avail_min; in snd_pcm_capture_ready()
869 * snd_pcm_playback_data - check whether any data exists on the playback buffer
874 * Return: Non-zero if any data exists, or zero if not. If stop_threshold
875 * is bigger or equal to boundary, then this function returns always non-zero.
879 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_data()
881 if (runtime->stop_threshold >= runtime->boundary) in snd_pcm_playback_data()
883 return snd_pcm_playback_avail(runtime) < runtime->buffer_size; in snd_pcm_playback_data()
887 * snd_pcm_playback_empty - check whether the playback buffer is empty
892 * Return: Non-zero if empty, or zero if not.
896 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_empty()
897 return snd_pcm_playback_avail(runtime) >= runtime->buffer_size; in snd_pcm_playback_empty()
901 * snd_pcm_capture_empty - check whether the capture buffer is empty
906 * Return: Non-zero if empty, or zero if not.
910 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_capture_empty()
915 * snd_pcm_trigger_done - Mark the master substream
920 * supports the single-shot operation, the driver calls this in the loop
931 substream->runtime->trigger_master = master; in snd_pcm_trigger_done()
949 return ¶ms->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; in hw_param_mask()
955 return ¶ms->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; in hw_param_interval()
961 return ¶ms->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; in hw_param_mask_c()
967 return ¶ms->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; in hw_param_interval_c()
971 * params_channels - Get the number of channels from the hw params
978 return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_CHANNELS)->min; in params_channels()
982 * params_rate - Get the sample rate from the hw params
985 * Return: the sample rate
989 return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_RATE)->min; in params_rate()
993 * params_period_size - Get the period size (in frames) from the hw params
1000 return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min; in params_period_size()
1004 * params_periods - Get the number of periods from the hw params
1011 return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_PERIODS)->min; in params_periods()
1015 * params_buffer_size - Get the buffer size (in frames) from the hw params
1022 return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_BUFFER_SIZE)->min; in params_buffer_size()
1026 * params_buffer_bytes - Get the buffer size (in bytes) from the hw params
1033 return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->min; in params_buffer_bytes()
1053 unsigned int min, unsigned int max);
1091 * snd_pcm_hw_constraint_single() - Constrain parameter to a single value
1111 #if 0 /* just for kernel-doc */
1113 * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian
1116 * Return: 1 if the given PCM format is CPU-endian, 0 if
1204 return snd_pcm_hw_limit_rates(&runtime->hw); in snd_pcm_limit_hw_rates()
1207 unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate);
1215 * snd_pcm_set_runtime_buffer - Set the PCM runtime buffer
1219 * Copy the buffer information to runtime->dma_buffer when @bufp is non-NULL.
1225 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_set_runtime_buffer()
1227 runtime->dma_buffer_p = bufp; in snd_pcm_set_runtime_buffer()
1228 runtime->dma_area = bufp->area; in snd_pcm_set_runtime_buffer()
1229 runtime->dma_addr = bufp->addr; in snd_pcm_set_runtime_buffer()
1230 runtime->dma_bytes = bufp->bytes; in snd_pcm_set_runtime_buffer()
1232 runtime->dma_buffer_p = NULL; in snd_pcm_set_runtime_buffer()
1233 runtime->dma_area = NULL; in snd_pcm_set_runtime_buffer()
1234 runtime->dma_addr = 0; in snd_pcm_set_runtime_buffer()
1235 runtime->dma_bytes = 0; in snd_pcm_set_runtime_buffer()
1240 * snd_pcm_gettime - Fill the timespec64 depending on the timestamp mode
1247 switch (runtime->tstamp_type) { in snd_pcm_gettime()
1282 * snd_pcm_set_fixed_buffer - Preallocate and set up the fixed size PCM buffer
1286 * @size: the requested pre-allocation size in bytes
1288 * This is a variant of snd_pcm_set_managed_buffer(), but this pre-allocates
1289 * only the given sized buffer and doesn't allow re-allocation nor dynamic
1291 * The function may return -ENOMEM error, hence the caller must check it.
1303 * snd_pcm_set_fixed_buffer_all - Preallocate and set up the fixed size PCM buffer
1307 * @size: the requested pre-allocation size in bytes
1310 * all substream. If any of allocation fails, it returns -ENOMEM, hence the
1328 * snd_pcm_lib_alloc_vmalloc_buffer - allocate virtual DMA buffer
1347 * snd_pcm_lib_alloc_vmalloc_32_buffer - allocate 32-bit-addressable buffer
1352 * vmalloc_32(), i.e., the pages are allocated from 32-bit-addressable memory.
1364 #define snd_pcm_get_dma_buf(substream) ((substream)->runtime->dma_buffer_p)
1367 * snd_pcm_sgbuf_get_addr - Get the DMA address at the corresponding offset
1380 * snd_pcm_sgbuf_get_chunk_size - Compute the max size that fits within the
1396 * snd_pcm_mmap_data_open - increase the mmap counter
1403 struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data; in snd_pcm_mmap_data_open()
1404 atomic_inc(&substream->mmap_count); in snd_pcm_mmap_data_open()
1408 * snd_pcm_mmap_data_close - decrease the mmap counter
1415 struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data; in snd_pcm_mmap_data_close()
1416 atomic_dec(&substream->mmap_count); in snd_pcm_mmap_data_close()
1421 /* mmap for io-memory area */
1431 * snd_pcm_limit_isa_dma_size - Get the max size fitting with ISA DMA transfer
1452 * snd_pcm_direction_name - Get a string naming the direction of a stream
1466 * snd_pcm_stream_str - Get a string naming the direction of a stream
1473 return snd_pcm_direction_name(substream->stream); in snd_pcm_stream_str()
1477 * PCM channel-mapping control API
1497 * snd_pcm_chmap_substream - get the PCM substream assigned to the given chmap info
1507 for (s = info->pcm->streams[info->stream].substream; s; s = s->next) in snd_pcm_chmap_substream()
1508 if (s->number == idx) in snd_pcm_chmap_substream()
1513 /* ALSA-standard channel maps (RL/RR prior to C/LFE) */
1530 * pcm_format_to_bits - Strong-typed conversion of pcm_format to bitwise
1541 * pcm_for_each_format - helper to iterate for each format type
1551 dev_err((pcm)->card->dev, fmt, ##args)
1553 dev_warn((pcm)->card->dev, fmt, ##args)
1555 dev_dbg((pcm)->card->dev, fmt, ##args)
1576 …__u32 audio_tstamp_data; /* needed for 64-bit alignment, used for configs/report to/from userspac…
1577 s64 audio_tstamp_sec; /* sample counter, wall clock, PHC or on-demand sync'ed */
1582 unsigned char reserved[52-4*sizeof(s64)]; /* must be filled with zero */
1601 u32 audio_tstamp_data; /* needed for 64-bit alignment, used for configs/report to/from userspace */
1602 s32 audio_tstamp_sec; /* sample counter, wall clock, PHC or on-demand sync'ed */
1607 unsigned char reserved[52-4*sizeof(s32)]; /* must be filled with zero */