printk wrapper
Parameters
Description
Works like printk() but prints the file and the line of the caller when configured with CONFIG_SND_VERBOSE_PRINTK.
debug printk
Parameters
Description
Works like snd_printk() for debugging purposes. Ignored when CONFIG_SND_DEBUG is not set.
give a BUG warning message and stack trace
Parameters
Description
Calls WARN() if CONFIG_SND_DEBUG is set. Ignored when CONFIG_SND_DEBUG is not set.
Parameters
debugging check macro
Parameters
Description
Has the same behavior as WARN_ON when CONFIG_SND_DEBUG is set, otherwise just evaluates the conditional and returns the value.
debug printk
Parameters
Description
Works like snd_printk() for debugging purposes. Ignored when CONFIG_SND_DEBUG_VERBOSE is not set.
register a special sound node
Parameters
Description
Allocate a special sound device by minor number from the sound subsystem.
Return
register a mixer device
Parameters
Description
Allocate a mixer device. Unit is the number of the mixer requested. Pass -1 to request the next free mixer unit.
Return
register a midi device
Parameters
Description
Allocate a midi device. Unit is the number of the midi device requested. Pass -1 to request the next free midi unit.
Return
register a DSP device
Parameters
Description
Allocate a DSP device. Unit is the number of the DSP requested. Pass -1 to request the next free DSP unit.
This function allocates both the audio and dsp device entries together and will always allocate them as a matching pair - eg dsp3/audio3
Return
unregister a special sound device
Parameters
Description
Release a sound device that was allocated with register_sound_special(). The unit passed is the return value from the register function.
unregister a mixer
Parameters
Description
Release a sound device that was allocated with register_sound_mixer(). The unit passed is the return value from the register function.
unregister a midi device
Parameters
Description
Release a sound device that was allocated with register_sound_midi(). The unit passed is the return value from the register function.
unregister a DSP device
Parameters
Description
Release a sound device that was allocated with register_sound_dsp(). The unit passed is the return value from the register function.
Both of the allocated units are released together automatically.
Check whether the substream is linked with others
Parameters
Description
Returns true if the given substream is being linked with others.
Lock the PCM stream
Parameters
Description
This locks the PCM stream like snd_pcm_stream_lock() but with the local IRQ (only when nonatomic is false). In nonatomic case, this is identical as snd_pcm_stream_lock().
iterate over the linked substreams
Parameters
Description
Iterate over the all linked substreams to the given substream. When substream isn’t linked with any others, this gives returns substream itself once.
Check whether the substream is in a running state
Parameters
Description
Returns true if the given substream is in the state RUNNING, or in the state DRAINING for playback.
Unit conversion of the size from bytes to samples
Parameters
Unit conversion of the size from bytes to frames
Parameters
Unit conversion of the size from samples to bytes
Parameters
Unit conversion of the size from frames to bytes
Parameters
Check whether the byte size is aligned to frames
Parameters
Get the buffer size of the current PCM in bytes
Parameters
Get the period size of the current PCM in bytes
Parameters
Get the available (writable) space for playback
Parameters
Description
Result is between 0 ... (boundary - 1)
Get the available (readable) space for capture
Parameters
Description
Result is between 0 ... (boundary - 1)
Get the queued space for playback
Parameters
Get the free space for capture
Parameters
check whether the playback buffer is available
Parameters
Description
Checks whether enough free space is available on the playback buffer.
Return
Non-zero if available, or zero if not.
check whether the capture buffer is available
Parameters
Description
Checks whether enough capture data is available on the capture buffer.
Return
Non-zero if available, or zero if not.
check whether any data exists on the playback buffer
Parameters
Description
Checks whether any data exists on the playback buffer.
Return
Non-zero if any data exists, or zero if not. If stop_threshold is bigger or equal to boundary, then this function returns always non-zero.
check whether the playback buffer is empty
Parameters
Description
Checks whether the playback buffer is empty.
Return
Non-zero if empty, or zero if not.
check whether the capture buffer is empty
Parameters
Description
Checks whether the capture buffer is empty.
Return
Non-zero if empty, or zero if not.
Mark the master substream
Parameters
Description
When multiple substreams of the same card are linked and the hardware supports the single-shot operation, the driver calls this in the loop in snd_pcm_group_for_each_entry() for marking the substream as “done”. Then most of trigger operations are performed only to the given master substream.
The trigger_master mark is cleared at timestamp updates at the end of trigger operations.
Get the number of channels from the hw params
Parameters
Get the sample rate from the hw params
Parameters
Get the period size (in frames) from the hw params
Parameters
Get the number of periods from the hw params
Parameters
Get the buffer size (in frames) from the hw params
Parameters
Get the buffer size (in bytes) from the hw params
Parameters
Constrain parameter to a single value
Parameters
Return
Positive if the value is changed, zero if it’s not changed, or a negative error code.
Check the PCM format is CPU-endian
Parameters
Return
1 if the given PCM format is CPU-endian, 0 if opposite, or a negative error code if endian not specified.
Set the PCM runtime buffer
Parameters
Description
Copy the buffer information to runtime->dma_buffer when bufp is non-NULL. Otherwise it clears the current buffer information.
Fill the timespec depending on the timestamp mode
Parameters
allocate virtual DMA buffer
Parameters
Description
Allocates the PCM substream buffer using vmalloc(), i.e., the memory is contiguous in kernel virtual space, but not in physical memory. Use this if the buffer is accessed by kernel code but not by device DMA.
Return
1 if the buffer was changed, 0 if not changed, or a negative error code.
allocate 32-bit-addressable buffer
Parameters
Description
This function works like snd_pcm_lib_alloc_vmalloc_buffer(), but uses vmalloc_32(), i.e., the pages are allocated from 32-bit-addressable memory.
Return
1 if the buffer was changed, 0 if not changed, or a negative error code.
Get the DMA address at the corresponding offset
Parameters
Get the virtual address at the corresponding offset
Parameters
Compute the max size that fits within the contig. page from the given size
Parameters
increase the mmap counter
Parameters
Description
PCM mmap callback should handle this counter properly
decrease the mmap counter
Parameters
Description
PCM mmap callback should handle this counter properly
Get the max size fitting with ISA DMA transfer
Parameters
Get a string naming the direction of a stream
Parameters
Return
A string naming the direction of the stream.
get the PCM substream assigned to the given chmap info
Parameters
Strong-typed conversion of pcm_format to bitwise
Parameters
Return a name string for the given PCM format
Parameters
create a new PCM stream
Parameters
Description
Creates a new stream for the pcm. The corresponding stream on the pcm must have been empty before calling this, i.e. zero must be given to the argument of snd_pcm_new().
Return
Zero if successful, or a negative error code on failure.
create a new PCM instance
Parameters
Description
Creates a new PCM instance.
The pcm operators have to be set afterwards to the new instance via snd_pcm_set_ops().
Return
Zero if successful, or a negative error code on failure.
create a new internal PCM instance
Parameters
Description
Creates a new internal PCM instance with no userspace device or procfs entries. This is used by ASoC Back End PCMs in order to create a PCM that will only be used internally by kernel drivers. i.e. it cannot be opened by userspace. It provides existing ASoC components drivers with a substream and access to any private data.
The pcm operators have to be set afterwards to the new instance via snd_pcm_set_ops().
Return
Zero if successful, or a negative error code on failure.
Add/remove the notify list
Parameters
Description
This adds the given notifier to the global list so that the callback is called for each registered PCM devices. This exists only for PCM OSS emulation, so far.
create an ALSA device component
Parameters
Description
Creates a new device component for the given data pointer. The device will be assigned to the card and managed together by the card.
The data pointer plays a role as the identifier, too, so the pointer address must be unique and unchanged.
Return
Zero if successful, or a negative error code on failure.
disconnect the device
Parameters
Description
Turns the device into the disconnection state, invoking dev_disconnect callback, if the device was already registered.
Usually called from snd_card_disconnect().
Return
Zero if successful, or a negative error code on failure or if the device not found.
release the device from the card
Parameters
Description
Removes the device from the list on the card and invokes the callbacks, dev_disconnect and dev_free, corresponding to the state. Then release the device.
register the device
Parameters
Description
Registers the device which was already created via snd_device_new(). Usually this is called from snd_card_register(), but it can be called later if any new devices are created after invocation of snd_card_register().
Return
Zero if successful, or a negative error code on failure or if the device not found.
read one line from the procfs buffer
Parameters
Description
Reads one line from the buffer and stores the string.
Return
Zero if successful, or 1 if error or EOF.
parse a string token
Parameters
Description
Parses the original string and copy a token to the given string buffer.
Return
The updated pointer of the original string so that it can be used for the next call.
create an info entry for the given module
Parameters
Description
Creates a new info entry and assigns it to the given module.
Return
The pointer of the new instance, or NULL on failure.
create an info entry for the given card
Parameters
Description
Creates a new info entry and assigns it to the given card.
Return
The pointer of the new instance, or NULL on failure.
release the info entry
Parameters
Description
Releases the info entry.
register the info entry
Parameters
Description
Registers the proc info entry.
Return
Zero if successful, or a negative error code on failure.
receive the input data from the device
Parameters
Description
Reads the data from the internal buffer.
Return
The size of read data, or a negative error code on failure.
check whether the output buffer is empty
Parameters
Return
1 if the internal output buffer is empty, 0 if not.
copy data from the internal buffer
Parameters
Description
This is a variant of snd_rawmidi_transmit_peek() without spinlock.
copy data from the internal buffer
Parameters
Description
Copies data from the internal output buffer to the given buffer.
Call this in the interrupt handler when the midi output is ready, and call snd_rawmidi_transmit_ack() after the transmission is finished.
Return
The size of copied data, or a negative error code on failure.
acknowledge the transmission
Parameters
Description
This is a variant of __snd_rawmidi_transmit_ack() without spinlock.
acknowledge the transmission
Parameters
Description
Advances the hardware pointer for the internal output buffer with the given size and updates the condition. Call after the transmission is finished.
Return
The advanced size if successful, or a negative error code on failure.
copy from the buffer to the device
Parameters
Description
Copies data from the buffer to the device and advances the pointer.
Return
The copied size if successful, or a negative error code on failure.
create a rawmidi instance
Parameters
Description
Creates a new rawmidi instance. Use snd_rawmidi_set_ops() to set the operators to the new instance.
Return
Zero if successful, or a negative error code on failure.
set the rawmidi operators
Parameters
Description
Sets the rawmidi operators for the given stream direction.
try to load the card module
Parameters
Description
Tries to load the module “snd-card-X” for the given card number via request_module. Returns immediately if already loaded.
get user data of a registered device
Parameters
Description
Checks that a minor device with the specified type is registered, and returns its user data pointer.
This function increments the reference counter of the card instance if an associated instance with the given minor number and type is found. The caller must call snd_card_unref() appropriately later.
Return
The user data pointer if the specified device is found. NULL otherwise.
Register the ALSA device file for the card
Parameters
Description
Registers an ALSA device file for the given card. The operators have to be set in reg parameter.
Return
Zero if successful, or a negative error code on failure.
Parameters
Description
Unregisters the device file already registered via snd_register_device().
Return
Zero if successful, or a negative error code on failure.
copy data from mmio-space to user-space
Parameters
Description
Copies the data from mmio-space to user-space.
Return
Zero if successful, or non-zero on failure.
copy data from user-space to mmio-space
Parameters
Description
Copies the data from user-space to mmio-space.
Return
Zero if successful, or non-zero on failure.
release all pre-allocated buffers on the pcm
Parameters
Description
Releases all the pre-allocated buffers on the given pcm.
Return
Zero if successful, or a negative error code on failure.
pre-allocation for the given DMA type
Parameters
Description
Do pre-allocation for the given DMA buffer type.
Return
Zero if successful, or a negative error code on failure.
pre-allocation for continuous memory type (all substreams)
Parameters
Description
Do pre-allocation to all substreams of the given pcm for the specified DMA type.
Return
Zero if successful, or a negative error code on failure.
get the page struct at the given offset
Parameters
Description
Used as the page callback of PCM ops.
Return
The page struct at the given buffer offset. NULL on failure.
allocate the DMA buffer
Parameters
Description
Allocates the DMA buffer on the BUS type given earlier to snd_pcm_lib_preallocate_xxx_pages().
Return
1 if the buffer is changed, 0 if not changed, or a negative code on failure.
release the allocated DMA buffer.
Parameters
Description
Releases the DMA buffer allocated via snd_pcm_lib_malloc_pages().
Return
Zero if successful, or a negative error code on failure.
free vmalloc buffer
Parameters
Return
Zero if successful, or a negative error code on failure.
map vmalloc buffer offset to page struct
Parameters
Description
This function is to be used as the page callback in the PCM ops.
Return
The page struct, or NULL on failure.
Initialize struct device for sound devices
Parameters
create and initialize a soundcard structure
Parameters
Description
Creates and initializes a soundcard structure.
The function allocates snd_card instance via kzalloc with the given space for the driver to use freely. The allocated struct is stored in the given card_ret pointer.
Return
Zero if successful or a negative error code.
disconnect all APIs from the file-operations (user space)
Parameters
Description
Disconnects all APIs from the file-operations (user space).
Return
Zero, otherwise a negative error code.
Note
Disconnect the card, free it later eventually
Parameters
Description
Unlike snd_card_free(), this function doesn’t try to release the card resource immediately, but tries to disconnect at first. When the card is still in use, the function returns before freeing the resources. The card resources will be freed when the refcount gets to zero.
frees given soundcard structure
Parameters
Description
This function releases the soundcard structure and the all assigned devices automatically. That is, you don’t have to release the devices by yourself.
This function waits until the all resources are properly released.
Return
Zero. Frees all associated devices and frees the control interface associated to given soundcard.
set card identification name
Parameters
Description
This function sets the card identification and checks for name collisions.
Append a new sysfs attribute group to card
Parameters
register the soundcard
Parameters
Description
This function registers all the devices assigned to the soundcard. Until calling this, the ALSA control interface is blocked from the external accesses. Thus, you should call this function at the end of the initialization of the card.
Return
Zero otherwise a negative error code if the registration failed.
add a component string
Parameters
Description
This function adds the component id string to the supported list. The component can be referred from the alsa-lib.
Return
Zero otherwise a negative error code.
add the file to the file list of the card
Parameters
Description
This function adds the file to the file linked-list of the card. This linked-list is used to keep tracking the connection state, and to avoid the release of busy resources by hotplug.
Return
zero or a negative error code.
remove the file from the file list
Parameters
Description
This function removes the file formerly added to the card via snd_card_file_add() function. If all files are removed and snd_card_free_when_closed() was called beforehand, it processes the pending release of resources.
Return
Zero or a negative error code.
wait until the power-state is changed.
Parameters
Description
Waits until the power-state is changed.
Return
Zero if successful, or a negative error code.
Note
the power lock must be active before call.
program an ISA DMA transfer
Parameters
Description
Programs an ISA DMA transfer for the given buffer.
stop the ISA DMA transfer
Parameters
Description
Stops the ISA DMA transfer.
return the current pointer to DMA transfer buffer in bytes
Parameters
Return
The current pointer in DMA transfer buffer in bytes.
Send notification to user-space for a control change
Parameters
Description
This function adds an event record with the given id and mask, appends to the list and wakes up the user-space for notification. This can be called in the atomic context.
create a control instance from the template
Parameters
Description
Allocates a new struct snd_kcontrol instance and initialize from the given template. When the access field of ncontrol is 0, it’s assumed as READWRITE access. When the count field is 0, it’s assumes as one.
Return
The pointer of the newly generated instance, or NULL on failure.
release the control instance
Parameters
Description
Releases the control instance created via snd_ctl_new() or snd_ctl_new1(). Don’t call this after the control was added to the card.
add the control instance to the card
Parameters
Description
Adds the control instance created via snd_ctl_new() or snd_ctl_new1() to the given card. Assigns also an unique numid used for fast search.
It frees automatically the control which cannot be added.
Return
Zero if successful, or a negative error code on failure.
replace the control instance of the card
Parameters
Description
Replaces the given control. If the given control does not exist and the add_on_replace flag is set, the control is added. If the control exists, it is destroyed first.
It frees automatically the control which cannot be added or replaced.
Return
Zero if successful, or a negative error code on failure.
remove the control from the card and release it
Parameters
Description
Removes the control from the card and then releases the instance. You don’t need to call snd_ctl_free_one(). You must be in the write lock - down_write(card->controls_rwsem).
Return
0 if successful, or a negative error code on failure.
remove the control of the given id and release it
Parameters
Description
Finds the control instance with the given id, removes it from the card list and releases it.
Return
0 if successful, or a negative error code on failure.
activate/inactivate the control of the given id
Parameters
Description
Finds the control instance with the given id, and activate or inactivate the control together with notification, if changed. The given ID data is filled with full information.
Return
0 if unchanged, 1 if changed, or a negative error code on failure.
replace the id of a control on the card
Parameters
Description
Finds the control with the old id from the card, and replaces the id with the new one.
Return
Zero if successful, or a negative error code on failure.
find the control instance with the given number-id
Parameters
Description
Finds the control instance with the given number-id from the card.
The caller must down card->controls_rwsem before calling this function (if the race condition can happen).
Return
The pointer of the instance if found, or NULL if not.
find the control instance with the given id
Parameters
Description
Finds the control instance with the given id from the card.
The caller must down card->controls_rwsem before calling this function (if the race condition can happen).
Return
The pointer of the instance if found, or NULL if not.
register the device-specific control-ioctls
Parameters
Description
called from each device manager like pcm.c, hwdep.c, etc.
register the device-specific 32bit compat control-ioctls
Parameters
de-register the device-specific control-ioctls
Parameters
de-register the device-specific compat 32bit control-ioctls
Parameters
Helper function for a standard boolean info callback with a mono channel
Parameters
Description
This is a function that can be used as info callback for a standard boolean control with a single mono channel.
Helper function for a standard boolean info callback with stereo two channels
Parameters
Description
This is a function that can be used as info callback for a standard boolean control with stereo two channels.
fills the info structure for an enumerated control
Parameters
Description
Sets all required fields in info to their appropriate values. If the control’s accessibility is not the default (readable and writable), the caller has to fill info->access.
Return
Zero.
set the PCM operators
Parameters
Description
Sets the given PCM operators to the pcm instance.
set the PCM sync id
Parameters
Description
Sets the PCM sync identifier for the card.
refine the interval value of configurator
Parameters
Description
Refines the interval value with the reference value. The interval is changed to the range satisfying both intervals. The interval status (min, max, integer, etc.) are evaluated.
Return
Positive if the value is changed, zero if it’s not changed, or a negative error code.
refine the interval value
Parameters
Return
Positive if the value is changed, zero if it’s not changed, or a negative error code.
refine the interval value from the list
Parameters
Description
Refines the interval value from the list. When mask is non-zero, only the elements corresponding to bit 1 are evaluated.
Return
Positive if the value is changed, zero if it’s not changed, or a negative error code.
refine the interval value from the list of ranges
Parameters
Description
Refines the interval value from the list of ranges. When mask is non-zero, only the elements corresponding to bit 1 are evaluated.
Return
Positive if the value is changed, zero if it’s not changed, or a negative error code.
add the hw-constraint rule
Parameters
Return
Zero if successful, or a negative error code on failure.
apply the given bitmap mask constraint
Parameters
Description
Apply the constraint of the given bitmap mask to a 64-bit mask parameter.
Return
Zero if successful, or a negative error code on failure.
apply an integer constraint to an interval
Parameters
Description
Apply the constraint of integer to an interval parameter.
Return
Positive if the value is changed, zero if it’s not changed, or a negative error code.
apply a min/max range constraint to an interval
Parameters
Description
Apply the min/max range constraint to an interval parameter.
Return
Positive if the value is changed, zero if it’s not changed, or a negative error code.
apply a list of constraints to a parameter
Parameters
Description
Apply the list of constraints to an interval parameter.
Return
Zero if successful, or a negative error code on failure.
apply list of range constraints to a parameter
Parameters
Description
Apply the list of range constraints to an interval parameter.
Return
Zero if successful, or a negative error code on failure.
apply ratnums constraint to a parameter
Parameters
Return
Zero if successful, or a negative error code on failure.
apply ratdens constraint to a parameter
Parameters
Return
Zero if successful, or a negative error code on failure.
add a hw constraint msbits rule
Parameters
Description
This constraint will set the number of most significant bits (msbits) if a sample format with the specified width has been select. If width is set to 0 the msbits will be set for any sample format with a width larger than the specified msbits.
Return
Zero if successful, or a negative error code on failure.
add a hw constraint step rule
Parameters
Return
Zero if successful, or a negative error code on failure.
add a hw constraint power-of-2 rule
Parameters
Return
Zero if successful, or a negative error code on failure.
add a rule to allow disabling hw resampling
Parameters
Return
Zero if successful, or a negative error code on failure.
return params field var value
Parameters
Return
The value for field var if it’s fixed in configuration space defined by params. -EINVAL otherwise.
refine config space and return minimum value
Parameters
Description
Inside configuration space defined by params remove from var all values > minimum. Reduce configuration space accordingly.
Return
The minimum, or a negative error code on failure.
refine config space and return maximum value
Parameters
Description
Inside configuration space defined by params remove from var all values < maximum. Reduce configuration space accordingly.
Return
The maximum, or a negative error code on failure.
a generic PCM ioctl callback
Parameters
Description
Processes the generic ioctl commands for PCM. Can be passed as the ioctl callback for PCM ops.
Return
Zero if successful, or a negative error code on failure.
update the pcm status for the next period
Parameters
Description
This function is called from the interrupt handler when the PCM has processed the period size. It will update the current pointer, wake up sleepers, etc.
Even if more than one periods have elapsed since the last call, you have to call this only once.
create channel-mapping control elements
Parameters
Description
Create channel-mapping control elements assigned to the given PCM stream(s).
Return
Zero if successful, or a negative error value.
create a new hwdep instance
Parameters
Description
Creates a new hwdep instance with the given index on the card. The callbacks (hwdep->ops) must be set on the returned instance after this call manually by the caller.
Return
Zero if successful, or a negative error code on failure.
Lock the PCM stream
Parameters
Description
This locks the PCM stream’s spinlock or mutex depending on the nonatomic flag of the given substream. This also takes the global link rw lock (or rw sem), too, for avoiding the race with linked streams.
Unlock the PCM stream
Parameters
Description
This unlocks the PCM stream that has been locked via snd_pcm_stream_lock().
Lock the PCM stream
Parameters
Description
This locks the PCM stream like snd_pcm_stream_lock() and disables the local IRQ (only when nonatomic is false). In nonatomic case, this is identical as snd_pcm_stream_lock().
Unlock the PCM stream
Parameters
Description
This is a counter-part of snd_pcm_stream_lock_irq().
Unlock the PCM stream
Parameters
Description
This is a counter-part of snd_pcm_stream_lock_irqsave().
try to stop all running streams in the substream group
Parameters
Description
The state of each stream is then changed to the given state unconditionally.
Return
Zero if successful, or a negative error code.
stop the running streams as XRUN
Parameters
Description
This stops the given running substream (and all linked substreams) as XRUN. Unlike snd_pcm_stop(), this function takes the substream lock by itself.
Return
Zero if successful, or a negative error code.
trigger SUSPEND to all linked streams
Parameters
Description
After this call, all streams are changed to SUSPENDED state.
Return
Zero if successful (or substream is NULL), or a negative error code.
trigger SUSPEND to all substreams in the given pcm
Parameters
Description
After this call, all streams are changed to SUSPENDED state.
Return
Zero if successful (or pcm is NULL), or a negative error code.
Default PCM data mmap function
Parameters
Description
This is the default mmap handler for PCM data. When mmap pcm_ops is NULL, this function is invoked implicitly.
Default PCM data mmap function for I/O mem
Parameters
Description
When your hardware uses the iomapped pages as the hardware buffer and wants to mmap it, pass this function as mmap pcm_ops. Note that this is supposed to work only on limited architectures.
allocate pages with the given size
Parameters
Description
Allocates the physically contiguous pages with the given size.
Return
The pointer of the buffer, or NULL if no enough memory.
release the pages
Parameters
Description
Releases the buffer allocated via snd_malloc_pages().
allocate the buffer area according to the given type
Parameters
Description
Calls the memory-allocator function for the corresponding buffer type.
Return
Zero if the buffer with the given size is allocated successfully, otherwise a negative value on error.
allocate the buffer area according to the given type with fallback
Parameters
Description
Calls the memory-allocator function for the corresponding buffer type. When no space is left, this function reduces the size and tries to allocate again. The size actually allocated is stored in res_size argument.
Return
Zero if the buffer with the given size is allocated successfully, otherwise a negative value on error.
release the allocated buffer
Parameters
Description
Releases the allocated buffer via snd_dma_alloc_pages().