Lines Matching +full:assigned +full:- +full:resolution +full:- +full:bits
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
8 * Abramo Bagnara <abramo@alsa-project.org>
20 #define snd_pcm_substream_chip(substream) ((substream)->private_data)
21 #define snd_pcm_chip(pcm) ((pcm)->private_data)
87 #define SNDRV_PCM_DEVICES (SNDRV_OS_MINORS-2)
106 #define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)
126 #define SNDRV_PCM_RATE_KNOT (1<<31) /* supports more non-continuos rates */
239 struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK -
241 struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL -
251 return &constrs->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; in constrs_mask()
257 return &constrs->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; in constrs_interval()
293 * userspace-provided audio timestamp config to kernel,
297 /* 5 of max 16 bits used */
305 config->type_requested = data & 0xF; in snd_pcm_unpack_audio_tstamp_config()
306 config->report_delay = (data >> 4) & 1; in snd_pcm_unpack_audio_tstamp_config()
310 * kernel-provided audio timestamp report to user-space
314 /* 6 of max 16 bits used for bit-fields */
332 tmp = report->accuracy_report; in snd_pcm_pack_audio_tstamp_report()
334 tmp |= report->actual_type; in snd_pcm_pack_audio_tstamp_report()
336 tmp |= report->valid; in snd_pcm_pack_audio_tstamp_report()
338 *data &= 0xffff; /* zero-clear MSBs */ in snd_pcm_pack_audio_tstamp_report()
340 *accuracy = report->accuracy; in snd_pcm_pack_audio_tstamp_report()
345 /* -- Status -- */
348 bool trigger_tstamp_latched; /* trigger timestamp latched in low-level driver/hardware */
356 u64 hw_ptr_wrap; /* offset for hw_ptr due to boundary wrap-around */
358 /* -- HW params -- */
376 /* -- SW params -- */
391 /* -- mmap -- */
395 /* -- locking / scheduling -- */
396 snd_pcm_uframes_t twake; /* do transfer (!poll) wakeup if non-zero */
403 /* -- private section -- */
407 /* -- hardware description -- */
411 /* -- timer -- */
412 unsigned int timer_resolution; /* timer resolution */
415 /* -- DMA -- */
423 /* -- audio timestamp config -- */
429 /* -- OSS things -- */
446 void *private_data; /* copied from pcm->private_data */
454 /* -- hardware operations -- */
456 /* -- runtime information -- */
458 /* -- timer section -- */
462 /* -- next substream -- */
464 /* -- linked substreams -- */
468 /* -- assigned files -- */
475 /* -- OSS things -- */
486 #define SUBSTREAM_BUSY(substream) ((substream)->ref_count > 0)
492 /* -- substreams -- */
497 /* -- OSS things -- */
506 struct snd_kcontrol *chmap_kctl; /* channel-mapping controls */
525 bool nonatomic; /* whole PCM operations are in non-atomic context */
603 * snd_pcm_stream_linked - Check whether the substream is linked with others
610 return substream->group != &substream->self_group; in snd_pcm_stream_linked()
620 * snd_pcm_stream_lock_irqsave - Lock the PCM stream
637 * snd_pcm_group_for_each_entry - iterate over the linked substreams
646 list_for_each_entry(s, &substream->group->substreams, link_list)
654 * snd_pcm_running - Check whether the substream is in a running state
662 return (substream->runtime->status->state == SNDRV_PCM_STATE_RUNNING || in snd_pcm_running()
663 (substream->runtime->status->state == SNDRV_PCM_STATE_DRAINING && in snd_pcm_running()
664 substream->stream == SNDRV_PCM_STREAM_PLAYBACK)); in snd_pcm_running()
668 * bytes_to_samples - Unit conversion of the size from bytes to samples
674 return size * 8 / runtime->sample_bits; in bytes_to_samples()
678 * bytes_to_frames - Unit conversion of the size from bytes to frames
684 return size * 8 / runtime->frame_bits; in bytes_to_frames()
688 * samples_to_bytes - Unit conversion of the size from samples to bytes
694 return size * runtime->sample_bits / 8; in samples_to_bytes()
698 * frames_to_bytes - Unit conversion of the size from frames to bytes
704 return size * runtime->frame_bits / 8; in frames_to_bytes()
708 * frame_aligned - Check whether the byte size is aligned to frames
714 return bytes % runtime->byte_align == 0; in frame_aligned()
718 * snd_pcm_lib_buffer_bytes - Get the buffer size of the current PCM in bytes
723 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_buffer_bytes()
724 return frames_to_bytes(runtime, runtime->buffer_size); in snd_pcm_lib_buffer_bytes()
728 * snd_pcm_lib_period_bytes - Get the period size of the current PCM in bytes
733 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_period_bytes()
734 return frames_to_bytes(runtime, runtime->period_size); in snd_pcm_lib_period_bytes()
738 * snd_pcm_playback_avail - Get the available (writable) space for playback
741 * Result is between 0 ... (boundary - 1)
745 …snd_pcm_sframes_t avail = runtime->status->hw_ptr + runtime->buffer_size - runtime->control->appl_… in snd_pcm_playback_avail()
747 avail += runtime->boundary; in snd_pcm_playback_avail()
748 else if ((snd_pcm_uframes_t) avail >= runtime->boundary) in snd_pcm_playback_avail()
749 avail -= runtime->boundary; in snd_pcm_playback_avail()
754 * snd_pcm_capture_avail - Get the available (readable) space for capture
757 * Result is between 0 ... (boundary - 1)
761 snd_pcm_sframes_t avail = runtime->status->hw_ptr - runtime->control->appl_ptr; in snd_pcm_capture_avail()
763 avail += runtime->boundary; in snd_pcm_capture_avail()
768 * snd_pcm_playback_hw_avail - Get the queued space for playback
773 return runtime->buffer_size - snd_pcm_playback_avail(runtime); in snd_pcm_playback_hw_avail()
777 * snd_pcm_capture_hw_avail - Get the free space for capture
782 return runtime->buffer_size - snd_pcm_capture_avail(runtime); in snd_pcm_capture_hw_avail()
786 * snd_pcm_playback_ready - check whether the playback buffer is available
791 * Return: Non-zero if available, or zero if not.
795 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_ready()
796 return snd_pcm_playback_avail(runtime) >= runtime->control->avail_min; in snd_pcm_playback_ready()
800 * snd_pcm_capture_ready - check whether the capture buffer is available
805 * Return: Non-zero if available, or zero if not.
809 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_capture_ready()
810 return snd_pcm_capture_avail(runtime) >= runtime->control->avail_min; in snd_pcm_capture_ready()
814 * snd_pcm_playback_data - check whether any data exists on the playback buffer
819 * Return: Non-zero if any data exists, or zero if not. If stop_threshold
820 * is bigger or equal to boundary, then this function returns always non-zero.
824 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_data()
826 if (runtime->stop_threshold >= runtime->boundary) in snd_pcm_playback_data()
828 return snd_pcm_playback_avail(runtime) < runtime->buffer_size; in snd_pcm_playback_data()
832 * snd_pcm_playback_empty - check whether the playback buffer is empty
837 * Return: Non-zero if empty, or zero if not.
841 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_empty()
842 return snd_pcm_playback_avail(runtime) >= runtime->buffer_size; in snd_pcm_playback_empty()
846 * snd_pcm_capture_empty - check whether the capture buffer is empty
851 * Return: Non-zero if empty, or zero if not.
855 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_capture_empty()
860 * snd_pcm_trigger_done - Mark the master substream
865 * supports the single-shot operation, the driver calls this in the loop
876 substream->runtime->trigger_master = master; in snd_pcm_trigger_done()
894 return ¶ms->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; in hw_param_mask()
900 return ¶ms->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; in hw_param_interval()
906 return ¶ms->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; in hw_param_mask_c()
912 return ¶ms->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; in hw_param_interval_c()
916 * params_channels - Get the number of channels from the hw params
921 return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_CHANNELS)->min; in params_channels()
925 * params_rate - Get the sample rate from the hw params
930 return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_RATE)->min; in params_rate()
934 * params_period_size - Get the period size (in frames) from the hw params
939 return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min; in params_period_size()
943 * params_periods - Get the number of periods from the hw params
948 return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_PERIODS)->min; in params_periods()
952 * params_buffer_size - Get the buffer size (in frames) from the hw params
957 return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_BUFFER_SIZE)->min; in params_buffer_size()
961 * params_buffer_bytes - Get the buffer size (in bytes) from the hw params
966 return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->min; in params_buffer_bytes()
1024 * snd_pcm_hw_constraint_single() - Constrain parameter to a single value
1044 #if 0 /* just for kernel-doc */
1046 * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian
1049 * Return: 1 if the given PCM format is CPU-endian, 0 if
1059 int snd_pcm_format_width(snd_pcm_format_t format); /* in bits */
1060 int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */
1136 return snd_pcm_hw_limit_rates(&runtime->hw); in snd_pcm_limit_hw_rates()
1147 * snd_pcm_set_runtime_buffer - Set the PCM runtime buffer
1151 * Copy the buffer information to runtime->dma_buffer when @bufp is non-NULL.
1157 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_set_runtime_buffer()
1159 runtime->dma_buffer_p = bufp; in snd_pcm_set_runtime_buffer()
1160 runtime->dma_area = bufp->area; in snd_pcm_set_runtime_buffer()
1161 runtime->dma_addr = bufp->addr; in snd_pcm_set_runtime_buffer()
1162 runtime->dma_bytes = bufp->bytes; in snd_pcm_set_runtime_buffer()
1164 runtime->dma_buffer_p = NULL; in snd_pcm_set_runtime_buffer()
1165 runtime->dma_area = NULL; in snd_pcm_set_runtime_buffer()
1166 runtime->dma_addr = 0; in snd_pcm_set_runtime_buffer()
1167 runtime->dma_bytes = 0; in snd_pcm_set_runtime_buffer()
1172 * snd_pcm_gettime - Fill the timespec64 depending on the timestamp mode
1179 switch (runtime->tstamp_type) { in snd_pcm_gettime()
1219 * snd_pcm_lib_alloc_vmalloc_buffer - allocate virtual DMA buffer
1238 * snd_pcm_lib_alloc_vmalloc_32_buffer - allocate 32-bit-addressable buffer
1243 * vmalloc_32(), i.e., the pages are allocated from 32-bit-addressable memory.
1255 #define snd_pcm_get_dma_buf(substream) ((substream)->runtime->dma_buffer_p)
1259 * SG-buffer handling
1262 snd_pcm_get_dma_buf(substream)->private_data
1266 * snd_pcm_sgbuf_get_addr - Get the DMA address at the corresponding offset
1277 * snd_pcm_sgbuf_get_ptr - Get the virtual address at the corresponding offset
1288 * snd_pcm_sgbuf_get_chunk_size - Compute the max size that fits within the
1302 * snd_pcm_mmap_data_open - increase the mmap counter
1309 struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data; in snd_pcm_mmap_data_open()
1310 atomic_inc(&substream->mmap_count); in snd_pcm_mmap_data_open()
1314 * snd_pcm_mmap_data_close - decrease the mmap counter
1321 struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data; in snd_pcm_mmap_data_close()
1322 atomic_dec(&substream->mmap_count); in snd_pcm_mmap_data_close()
1327 /* mmap for io-memory area */
1337 * snd_pcm_limit_isa_dma_size - Get the max size fitting with ISA DMA transfer
1358 * snd_pcm_stream_str - Get a string naming the direction of a stream
1365 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_stream_str()
1372 * PCM channel-mapping control API
1382 struct snd_pcm *pcm; /* assigned PCM instance */
1392 * snd_pcm_chmap_substream - get the PCM substream assigned to the given chmap info
1400 for (s = info->pcm->streams[info->stream].substream; s; s = s->next) in snd_pcm_chmap_substream()
1401 if (s->number == idx) in snd_pcm_chmap_substream()
1406 /* ALSA-standard channel maps (RL/RR prior to C/LFE) */
1423 * pcm_format_to_bits - Strong-typed conversion of pcm_format to bitwise
1432 * pcm_for_each_format - helper to iterate for each format type
1442 dev_err((pcm)->card->dev, fmt, ##args)
1444 dev_warn((pcm)->card->dev, fmt, ##args)
1446 dev_dbg((pcm)->card->dev, fmt, ##args)
1462 …__u32 audio_tstamp_data; /* needed for 64-bit alignment, used for configs/report to/from userspac…
1463 s64 audio_tstamp_sec; /* sample counter, wall clock, PHC or on-demand sync'ed */
1468 unsigned char reserved[52-4*sizeof(s64)]; /* must be filled with zero */
1487 u32 audio_tstamp_data; /* needed for 64-bit alignment, used for configs/report to/from userspace */
1488 s32 audio_tstamp_sec; /* sample counter, wall clock, PHC or on-demand sync'ed */
1493 unsigned char reserved[52-4*sizeof(s32)]; /* must be filled with zero */