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.
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.
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.
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 memory from on-chip internal ram
Parameters
Description
This function requires iram phandle provided via of_node
free allocated specific memory from on-chip internal ram
Parameters
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().
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.
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 with division
Parameters
Description
c = a / b
Returns non-zero if the value is changed, zero if not changed.
refine the interval value
Parameters
Description
c = a * b / k
Returns non-zero if the value is changed, zero if not changed.
refine the interval value
Parameters
Description
c = a * k / b
Returns non-zero if the value is changed, zero if not changed.
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
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 32-bit mask parameter.
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.
choose a configuration defined by params
Parameters
Description
Choose one configuration from configuration space defined by params. The configuration chosen is that obtained fixing in this order: first access, first format, first subformat, min channels, min rate, min period time, max buffer size, min tick time
Return
Zero if successful, 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.
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().
start all linked streams
Parameters
Return
Zero if successful, or a negative error code.
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 DMA only when the given stream is playback
Parameters
Description
After stopping, the state is changed to SETUP. Unlike snd_pcm_stop(), this affects only the given stream.
Return
Zero if succesful, 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.
prepare the PCM substream to be triggerable
Parameters
Return
Zero if successful, 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.
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
Check the PCM format is signed linear
Parameters
Return
1 if the given PCM format is signed linear, 0 if unsigned linear, and a negative error code for non-linear formats.
Check the PCM format is unsigned linear
Parameters
Return
1 if the given PCM format is unsigned linear, 0 if signed linear, and a negative error code for non-linear formats.
Check the PCM format is linear
Parameters
Return
1 if the given PCM format is linear, 0 if not.
Check the PCM format is little-endian
Parameters
Return
1 if the given PCM format is little-endian, 0 if big-endian, or a negative error code if endian not specified.
Check the PCM format is big-endian
Parameters
Return
1 if the given PCM format is big-endian, 0 if little-endian, or a negative error code if endian not specified.
return the bit-width of the format
Parameters
Return
The bit-width of the format, or a negative error code if unknown format.
return the physical bit-width of the format
Parameters
Return
The physical bit-width of the format, or a negative error code if unknown format.
return the byte size of samples on the given format
Parameters
Return
The byte size of the given samples for the format, or a negative error code if unknown format.
return the silent data in 8 bytes array
Parameters
Return
The format pattern to fill or NULL if error.
set the silence data on the buffer
Parameters
Description
Sets the silence data on the buffer for the given samples.
Return
Zero if successful, or a negative error code on failure.
determine rate_min/rate_max fields
Parameters
Description
Determines the rate_min and rate_max fields from the rates bits of the given runtime->hw.
Return
Zero if successful.
converts sample rate to SNDRV_PCM_RATE_xxx bit
Parameters
Return
The SNDRV_PCM_RATE_xxx flag that corresponds to the given rate, or SNDRV_PCM_RATE_KNOT for an unknown rate.
converts SNDRV_PCM_RATE_xxx bit to sample rate
Parameters
Return
The sample rate that corresponds to the given SNDRV_PCM_RATE_xxx flag or 0 for an unknown rate bit.
computes the intersection between two rate masks
Parameters
Description
This function computes the rates that are supported by both rate masks passed to the function. It will take care of the special handling of SNDRV_PCM_RATE_CONTINUOUS and SNDRV_PCM_RATE_KNOT.
Return
A rate mask containing the rates that are supported by both rates_a and rates_b.
converts rate range to SNDRV_PCM_RATE_xxx bit
Parameters
Description
This function has an implicit assumption: the rates in the given range have only the pre-defined rates like 44100 or 16000.
Return
The SNDRV_PCM_RATE_xxx flag that corresponds to the given rate range, or SNDRV_PCM_RATE_KNOT for an unknown range.
release the preallocated buffer of the specified substream.
Parameters
Description
Releases the pre-allocated buffer of the given substream.
Return
Zero if successful, or a negative error code 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.
Convert hw_params to dma_slave_config
Parameters
Description
This function can be used to initialize a dma_slave_config from a substream and hw_params in a dmaengine based PCM driver implementation.
Initializes a dma slave config using DAI DMA data.
Parameters
Description
Initializes the {dst,src}_addr, {dst,src}_maxburst, {dst,src}_addr_width and slave_id fields of the DMA slave config from the same fields of the DAI DMA data struct. The src and dst fields will be initialized depending on the direction of the substream. If the substream is a playback stream the dst fields will be initialized, if it is a capture stream the src fields will be initialized. The {dst,src}_addr_width field will only be initialized if the SND_DMAENGINE_PCM_DAI_FLAG_PACK flag is set or if the addr_width field of the DAI DMA data struct is not equal to DMA_SLAVE_BUSWIDTH_UNDEFINED. If both conditions are met the latter takes priority.
dmaengine based PCM trigger implementation
Parameters
Description
Returns 0 on success, a negative error code otherwise.
This function can be used as the PCM trigger callback for dmaengine based PCM driver implementations.
dmaengine based PCM pointer implementation
Parameters
Description
This function is deprecated and should not be used by new drivers, as its results may be unreliable.
dmaengine based PCM pointer implementation
Parameters
Description
This function can be used as the PCM pointer callback for dmaengine based PCM driver implementations.
Request channel for the dmaengine PCM
Parameters
Description
Returns NULL or the requested DMA channel.
This function request a DMA channel for usage with dmaengine PCM.
Open a dmaengine based PCM substream
Parameters
Description
Returns 0 on success, a negative error code otherwise.
The function should usually be called from the pcm open callback. Note that this function will use private_data field of the substream’s runtime. So it is not available to your pcm driver implementation.
Open a dmaengine based PCM substream and request channel
Parameters
Description
Returns 0 on success, a negative error code otherwise.
This function will request a DMA channel using the passed filter function and data. The function should usually be called from the pcm open callback. Note that this function will use private_data field of the substream’s runtime. So it is not available to your pcm driver implementation.
Close a dmaengine based PCM substream
Parameters
Close a dmaengine based PCM substream and release channel
Parameters
Description
Releases the DMA channel associated with the PCM substream.
Get dma_transfer_direction for a PCM substream
Parameters
DAI DMA configuration data
Definition
struct snd_dmaengine_dai_dma_data {
dma_addr_t addr;
enum dma_slave_buswidth addr_width;
u32 maxburst;
unsigned int slave_id;
void * filter_data;
const char * chan_name;
unsigned int fifo_size;
unsigned int flags;
};
Members
Configuration data for dmaengine based PCM
Definition
struct snd_dmaengine_pcm_config {
int (* prepare_slave_config) (struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params,struct dma_slave_config *slave_config);
struct dma_chan *(* compat_request_channel) (struct snd_soc_pcm_runtime *rtd,struct snd_pcm_substream *substream);
dma_filter_fn compat_filter_fn;
struct device * dma_dev;
const char * chan_names[SNDRV_PCM_STREAM_LAST + 1];
const struct snd_pcm_hardware * pcm_hardware;
unsigned int prealloc_buffer_size;
};
Members
Note
If both compat_request_channel and compat_filter_fn are set compat_request_channel will be used to request the channel and compat_filter_fn will be ignored. Otherwise the channel will be requested using dma_request_channel with compat_filter_fn as the filter function.
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 new control instance with some elements
Parameters
Description
Allocates a memory object for a new control instance. The instance has elements as many as the given number (count). Each element has given access permissions (access). Each element is locked when file is given.
Return
0 on success, error code on failure
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.
remove and release the unlocked user control
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.
write a value on the given register
Parameters
Description
Writes a value on the given register. This will invoke the write callback directly after the register check. This function doesn’t change the register cache unlike #:c:func:snd_ca97_write_cache(), so use this only when you don’t want to reflect the change to the suspend/resume state.
read a value from the given register
Parameters
Description
Reads a value from the given register. This will invoke the read callback directly after the register check.
Return
The read value.
write a value on the given register and update the cache
Parameters
Description
Writes a value on the given register and updates the register cache. The cached values are used for the cached-read and the suspend/resume.
update the value on the given register
Parameters
Description
Compares the value with the register cache and updates the value only when the value is changed.
Return
1 if the value is changed, 0 if no change, or a negative code on failure.
update the bits on the given register
Parameters
Description
Updates the masked-bits on the given register only when the value is changed.
Return
1 if the bits are changed, 0 if no change, or a negative code on failure.
retrieve codec name
Parameters
Return
The short identifying name of the codec.
create an AC97 bus component
Parameters
Description
Creates an AC97 bus component. An struct snd_ac97_bus instance is newly allocated and initialized.
The ops table must include valid callbacks (at least read and write). The other callbacks, wait and reset, are not mandatory.
The clock is set to 48000. If another clock is needed, set (*rbus)->clock manually.
The AC97 bus instance is registered as a low-level device, so you don’t have to release it manually.
Return
Zero if successful, or a negative error code on failure.
create an Codec97 component
Parameters
Description
Creates an Codec97 component. An struct snd_ac97 instance is newly allocated and initialized from the template. The codec is then initialized by the standard procedure.
The template must include the codec number (num) and address (addr), and the private data (private_data).
The ac97 instance is registered as a low-level device, so you don’t have to release it manually.
Return
Zero if successful, or a negative error code on failure.
update the powerdown register
Parameters
Description
Update the AC97 powerdown register bits of the given part.
Return
Zero.
General suspend function for AC97 codec
Parameters
Description
Suspends the codec, power down the chip.
General resume function for AC97 codec
Parameters
Description
Do the standard resume procedure, power up and restoring the old register values.
tune up the hardware
Parameters
Description
Do some workaround for each pci device, such as renaming of the headphone (true line-out) control as “Master”. The quirk-list must be terminated with a zero-filled entry.
Return
Zero if successful, or a negative error code on failure.
change the rate of the given input/output.
Parameters
Description
Changes the rate of the given input/output on the codec. If the codec doesn’t support VAR, the rate must be 48000 (except for SPDIF).
The valid registers are AC97_PMC_MIC_ADC_RATE, AC97_PCM_FRONT_DAC_RATE, AC97_PCM_LR_ADC_RATE. AC97_PCM_SURR_DAC_RATE and AC97_PCM_LFE_DAC_RATE are accepted if the codec supports them. AC97_SPDIF is accepted as a pseudo register to modify the SPDIF status bits.
Return
Zero if successful, or a negative error code on failure.
assign AC97 slots to given PCM streams
Parameters
Description
It assigns available AC97 slots for given PCMs. If none or only some slots are available, pcm->xxx.slots and pcm->xxx.rslots[] members are reduced and might be zero.
Return
Zero if successful, or a negative error code on failure.
opens the given AC97 pcm
Parameters
Description
It locks the specified slots and sets the given rate to AC97 registers.
Return
Zero if successful, or a negative error code on failure.
closes the given AC97 pcm
Parameters
Description
It frees the locked AC97 slots.
Return
Zero.
set double rate constraints
Parameters
Description
Installs the hardware constraint rules to prevent using double rates and more than two channels at the same time.
Return
Zero if successful, or a negative error code on failure.
Create a virtual master control
Parameters
Description
Creates a virtual master control with the given name string.
After creating a vmaster element, you can add the slave controls via snd_ctl_add_slave() or snd_ctl_add_slave_uncached().
The optional argument tlv can be used to specify the TLV information for dB scale of the master control. It should be a single element with #SNDRV_CTL_TLVT_DB_SCALE, #SNDRV_CTL_TLV_DB_MINMAX or #SNDRV_CTL_TLVT_DB_MINMAX_MUTE type, and should be the max 0dB.
Return
The created control element, or NULL for errors (ENOMEM).
Add a hook to a vmaster control
Parameters
Description
Adds the given hook to the vmaster control element so that it’s called at each time when the value is changed.
Return
Zero.
Sync the vmaster slaves and hook
Parameters
Description
Forcibly call the put callback of each slave and call the hook function to synchronize with the current value of the given vmaster element. NOP when NULL is passed to kcontrol.
Add a virtual slave control
Parameters
Description
Add a virtual slave control to the given master element created via snd_ctl_create_virtual_master() beforehand.
All slaves must be the same type (returning the same information via info callback). The function doesn’t check it, so it’s your responsibility.
Also, some additional limitations: at most two channels, logarithmic volume control (dB level) thus no linear volume, master can only attenuate the volume without gain
Return
Zero if successful or a negative error code.
Add a virtual slave control
Parameters
Description
Add a virtual slave control to the given master. Unlike snd_ctl_add_slave(), the element added via this function is supposed to have volatile values, and get callback is called at each time queried from the master.
When the control peeks the hardware values directly and the value can be changed by other means than the put callback of the element, this function should be used to keep the value always up-to-date.
Return
Zero if successful or a negative error code.
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.
generic MPU401-UART interrupt handler
Parameters
Description
Processes the interrupt for MPU401-UART i/o.
Return
IRQ_HANDLED if the interrupt was handled. IRQ_NONE otherwise.
generic MPU401-UART transmit irq handler
Parameters
Description
Processes the interrupt for MPU401-UART output.
Return
IRQ_HANDLED if the interrupt was handled. IRQ_NONE otherwise.
create an MPU401-UART instance
Parameters
Description
Creates a new MPU-401 instance.
Note that the rawmidi instance is returned on the rrawmidi argument, not the mpu401 instance itself. To access to the mpu401 instance, cast from rawmidi->private_data (with struct snd_mpu401 magic-cast).
Return
Zero if successful, or a negative error code.
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.
Parameters
compressed buffer
Definition
struct snd_compressed_buffer {
__u32 fragment_size;
__u32 fragments;
};
Members
compressed stream params
Definition
struct snd_compr_params {
struct snd_compressed_buffer buffer;
struct snd_codec codec;
__u8 no_wake_mode;
};
Members
timestamp descriptor
Definition
struct snd_compr_tstamp {
__u32 byte_offset;
__u32 copied_total;
__u32 pcm_frames;
__u32 pcm_io_frames;
__u32 sampling_rate;
};
Members
avail descriptor
Definition
struct snd_compr_avail {
__u64 avail;
struct snd_compr_tstamp tstamp;
};
Members
caps descriptor
Definition
struct snd_compr_caps {
__u32 num_codecs;
__u32 direction;
__u32 min_fragment_size;
__u32 max_fragment_size;
__u32 min_fragments;
__u32 max_fragments;
__u32 codecs[MAX_NUM_CODECS];
__u32 reserved[11];
};
Members
query capability of codec
Definition
struct snd_compr_codec_caps {
__u32 codec;
__u32 num_descriptors;
struct snd_codec_desc descriptor[MAX_NUM_CODEC_DESCRIPTORS];
};
Members
Constants
compressed stream metadata
Definition
struct snd_compr_metadata {
__u32 key;
__u32 value[8];
};
Members
Parameters
Description
SNDRV_COMPRESS_GET_CAPS: Query capability of DSP SNDRV_COMPRESS_GET_CODEC_CAPS: Query capability of a codec SNDRV_COMPRESS_SET_PARAMS: Set codec and stream parameters
Note
only codec params can be changed runtime and stream params cant be SNDRV_COMPRESS_GET_PARAMS: Query codec params SNDRV_COMPRESS_TSTAMP: get the current timestamp value SNDRV_COMPRESS_AVAIL: get the current buffer avail value. This also queries the tstamp properties SNDRV_COMPRESS_PAUSE: Pause the running stream SNDRV_COMPRESS_RESUME: resume a paused stream SNDRV_COMPRESS_START: Start a stream SNDRV_COMPRESS_STOP: stop a running stream, discarding ring buffer content and the buffers currently with DSP SNDRV_COMPRESS_DRAIN: Play till end of buffers and stop after that SNDRV_COMPRESS_IOCTL_VERSION: Query the API version
Definition
struct snd_enc_vorbis {
__s32 quality;
__u32 managed;
__u32 max_bit_rate;
__u32 min_bit_rate;
__u32 downmix;
};
Members
Description
These options were extracted from the OpenMAX IL spec and Gstreamer vorbisenc properties
For best quality users should specify VBR mode and set quality levels.
Definition
struct snd_enc_real {
__u32 quant_bits;
__u32 start_region;
__u32 num_regions;
};
Members
Description
These options were extracted from the OpenMAX IL spec
Definition
struct snd_enc_flac {
__u32 num;
__u32 gain;
};
Members
Description
These options were extracted from the FLAC online documentation at http://flac.sourceforge.net/documentation_tools_flac.html
To make the API simpler, it is assumed that the user will select quality profiles. Additional options that affect encoding quality and speed can be added at a later stage if needed.
By default the Subset format is used by encoders.
TAGS such as pictures, etc, cannot be handled by an offloaded encoder and are not supported in this API.
Definition
struct snd_compr_runtime {
snd_pcm_state_t state;
struct snd_compr_ops * ops;
void * buffer;
u64 buffer_size;
u32 fragment_size;
u32 fragments;
u64 total_bytes_available;
u64 total_bytes_transferred;
wait_queue_head_t sleep;
void * private_data;
};
Members
Definition
struct snd_compr_stream {
const char * name;
struct snd_compr_ops * ops;
struct snd_compr_runtime * runtime;
struct snd_compr * device;
struct delayed_work error_work;
enum snd_compr_direction direction;
bool metadata_set;
bool next_track;
void * private_data;
};
Members
Definition
struct snd_compr_ops {
int (* open) (struct snd_compr_stream *stream);
int (* free) (struct snd_compr_stream *stream);
int (* set_params) (struct snd_compr_stream *stream,struct snd_compr_params *params);
int (* get_params) (struct snd_compr_stream *stream,struct snd_codec *params);
int (* set_metadata) (struct snd_compr_stream *stream,struct snd_compr_metadata *metadata);
int (* get_metadata) (struct snd_compr_stream *stream,struct snd_compr_metadata *metadata);
int (* trigger) (struct snd_compr_stream *stream, int cmd);
int (* pointer) (struct snd_compr_stream *stream,struct snd_compr_tstamp *tstamp);
int (* copy) (struct snd_compr_stream *stream, char __user *buf,size_t count);
int (* mmap) (struct snd_compr_stream *stream,struct vm_area_struct *vma);
int (* ack) (struct snd_compr_stream *stream, size_t bytes);
int (* get_caps) (struct snd_compr_stream *stream,struct snd_compr_caps *caps);
int (* get_codec_caps) (struct snd_compr_stream *stream,struct snd_compr_codec_caps *codec);
};
Members
Definition
struct snd_compr {
const char * name;
struct device dev;
struct snd_compr_ops * ops;
void * private_data;
struct snd_card * card;
unsigned int direction;
struct mutex lock;
int device;
#ifdef CONFIG_SND_VERBOSE_PROCFS
};
Members
Describes a pin to update based on jack detection
Definition
struct snd_soc_jack_pin {
struct list_head list;
const char * pin;
int mask;
bool invert;
};
Members
Describes voltage zones of jack detection
Definition
struct snd_soc_jack_zone {
unsigned int min_mv;
unsigned int max_mv;
unsigned int jack_type;
unsigned int debounce_time;
struct list_head list;
};
Members
Describes a gpio pin for jack detection
Definition
struct snd_soc_jack_gpio {
unsigned int gpio;
unsigned int idx;
struct device * gpiod_dev;
const char * name;
int report;
int invert;
int debounce_time;
bool wake;
int (* jack_status_check) (void *data);
};
Members
Casts a component to the CODEC it is embedded in
Parameters
Description
This function must only be used on components that are known to be CODECs. Otherwise the behavior is undefined.
Casts a component to the platform it is embedded in
Parameters
Description
This function must only be used on components that are known to be platforms. Otherwise the behavior is undefined.
Casts a DAPM context to the component it is embedded in
Parameters
Description
This function must only be used on DAPM contexts that are known to be part of a component (e.g. in a component driver). Otherwise the behavior is undefined.
Casts a DAPM context to the CODEC it is embedded in
Parameters
Description
This function must only be used on DAPM contexts that are known to be part of a CODEC (e.g. in a CODEC driver). Otherwise the behavior is undefined.
Casts a DAPM context to the platform it is embedded in
Parameters
Description
This function must only be used on DAPM contexts that are known to be part of a platform (e.g. in a platform driver). Otherwise the behavior is undefined.
Returns the DAPM context associated with a component
Parameters
Returns the DAPM context for the CODEC
Parameters
Note
Use this function instead of directly accessing the CODEC’s dapm field
Initialize CODEC DAPM bias level
Parameters
Description
Initializes the CODEC DAPM bias level. See snd_soc_dapm_init_bias_level().
Get current CODEC DAPM bias level
Parameters
Return
The current DAPM bias level of the CODEC.
Set the CODEC DAPM bias level
Parameters
Description
Forces the CODEC bias level to a specific state. See snd_soc_dapm_force_bias_level().
Returns the codec associated to a kcontrol
Parameters
Description
This function must only be used on DAPM contexts that are known to be part of a CODEC (e.g. in a CODEC driver). Otherwise the behavior is undefined.
Sync the register cache with the hardware
Parameters
Note
This function will call regcache_sync()
Initialize regmap instance for the CODEC
Parameters
Description
This function allows deferred assignment of the regmap instance that is associated with the CODEC. Only use this if the regmap instance is not yet ready when the CODEC is registered. The function must also be called before the first IO attempt of the CODEC.
De-initialize regmap instance for the CODEC
Parameters
Description
Calls regmap_exit() on the regmap instance associated to the CODEC and removes the regmap instance from the CODEC.
This function should only be used if snd_soc_codec_init_regmap() was used to initialize the regmap instance.
Returns the component that registered the control
Parameters
Note
This function will work correctly if the control has been registered for a component. Either with snd_soc_add_codec_controls() or snd_soc_add_platform_controls() or via table based setup for either a CODEC, a platform or component driver. Otherwise the behavior is undefined.
Returns the CODEC that registered the control
Parameters
Note
This function will only work correctly if the control has been registered with snd_soc_add_codec_controls() or via table based setup of snd_soc_codec_driver. Otherwise the behavior is undefined.
Returns the platform that registered the control
Parameters
Note
This function will only work correctly if the control has been registered with snd_soc_add_platform_controls() or via table based setup of a snd_soc_platform_driver. Otherwise the behavior is undefined.
Find a registered DAI
Parameters
Description
This function will search all regsitered components and their DAIs to find the DAI of the same name. The component’s of_node and name should also match if being specified.
Return
pointer of DAI, or NULL if not found.
Find a DAI link
Parameters
Description
This function will search all existing DAI links of the soc card to find the link of the same ID. Since DAI links may not have their unique ID, so name and stream name should also match if being specified.
Return
pointer of DAI link, or NULL if not found.
Add a DAI link dynamically
Parameters
Description
This function adds a DAI link to the ASoC card’s link list.
Note
Topology can use this API to add DAI links when probing the topology component. And machine drivers can still define static DAI links in dai_link array.
Remove a DAI link from the list
Parameters
Description
This function removes a DAI link from the ASoC card’s link list.
For DAI links previously added by topology, topology should remove them by using the dobj embedded in the link.
Change DAI link format for a ASoC runtime
Parameters
Description
This function updates the DAI link format for all DAIs connected to the DAI link for the specified runtime.
Note
For setups with a static format set the dai_fmt field in the corresponding snd_dai_link struct instead of using this function.
Returns 0 on success, otherwise a negative error code.
Register DMI names to card
Parameters
Description
An Intel machine driver may be used by many different devices but are difficult for userspace to differentiate, since machine drivers ususally use their own name as the card short name and leave the card long name blank. To differentiate such devices and fix bugs due to lack of device-specific configurations, this function allows DMI info to be used as the sound card long name, in the format of “vendor-product-version-board” (Character ‘-‘ is used to separate different DMI fields here). This will help the user space to load the device-specific Use Case Manager (UCM) configurations for the card.
Possible card long names may be: DellInc.-XPS139343-01-0310JH ASUSTeKCOMPUTERINC.-T100TA-1.0-T100TA Circuitco-MinnowboardMaxD0PLATFORM-D0-MinnowBoardMAX
This function also supports flavoring the card longname to provide the extra differentiation, like “vendor-product-version-board-flavor”.
We only keep number and alphabet characters and a few separator characters in the card long name since UCM in the user space uses the card long names as card configuration directory names and AudoConf cannot support special charactors like SPACE.
Returns 0 on success, otherwise a negative error code.
create new control
Parameters
Description
Create a new mixer control from a template control.
Returns 0 for success, else error.
Add an array of controls to a component.
Parameters
Return
0 for success, else error.
add an array of controls to a codec. Convenience function to add a list of controls. Many codecs were duplicating this code.
Parameters
Description
Return 0 for success, else error.
add an array of controls to a platform. Convenience function to add a list of controls.
Parameters
Description
Return 0 for success, else error.
add an array of controls to a SoC card. Convenience function to add a list of controls.
Parameters
Description
Return 0 for success, else error.
add an array of controls to a DAI. Convienience function to add a list of controls.
Parameters
Description
Return 0 for success, else error.
configure DAI system or master clock.
Parameters
Description
Configures the DAI master (MCLK) or system (SYSCLK) clocking.
configure CODEC system or master clock.
Parameters
Description
Configures the CODEC master (MCLK) or system (SYSCLK) clocking.
configure DAI clock dividers.
Parameters
Description
Configures the clock dividers. This is used to derive the best DAI bit and frame clocks from the system or master clock. It’s best to set the DAI bit and frame clocks as low as possible to save system power.
configure DAI PLL.
Parameters
Description
Configures and enables PLL to generate output clock based on input clock.
configure BCLK to sample rate ratio.
Parameters
Description
Configures the DAI for a preset BCLK to sample rate ratio.
configure DAI hardware audio format.
Parameters
Description
Configures the DAI hardware format and clocking.
generate tx/rx slot mask.
Parameters
Description
Generates the TDM tx and rx slot default masks for DAI.
Configures a DAI for TDM operation
Parameters
Description
This function configures the specified DAI for TDM operation. slot contains the total number of slots of the TDM stream and slot_with the width of each slot in bit clock cycles. tx_mask and rx_mask are bitmasks specifying the active slots of the TDM stream for the specified DAI, i.e. which slots the DAI should write to or read from. If a bit is set the corresponding slot is active, if a bit is cleared the corresponding slot is inactive. Bit 0 maps to the first slot, bit 1 to the second slot and so on. The first active slot maps to the first channel of the DAI, the second active slot to the second channel and so on.
TDM mode can be disabled by passing 0 for slots. In this case tx_mask, rx_mask and slot_width will be ignored.
Returns 0 on success, a negative error code otherwise.
configure DAI audio channel map
Parameters
Description
configure the relationship between channel number and TDM slot number.
configure DAI system or master clock.
Parameters
Description
Tristates the DAI so that others can use it.
configure DAI system or master clock.
Parameters
Description
Mutes the DAI DAC.
Register a card with the ASoC core
Parameters
Unregister a card with the ASoC core
Parameters
Unregister DAIs from the ASoC core
Parameters
Register a DAI with the ASoC core
Parameters
Register a DAI dynamically & create its widgets
Parameters
Description
Topology can use this API to register DAIs when probing a component. These DAIs’s widgets will be freed in the card cleanup and the DAIs will be freed in the component cleanup.
Initialize regmap instance for the component
Parameters
Description
This function allows deferred assignment of the regmap instance that is associated with the component. Only use this if the regmap instance is not yet ready when the component is registered. The function must also be called before the first IO attempt of the component.
De-initialize regmap instance for the component
Parameters
Description
Calls regmap_exit() on the regmap instance associated to the component and removes the regmap instance from the component.
This function should only be used if snd_soc_component_init_regmap() was used to initialize the regmap instance.
Parameters
Add a platform to the ASoC core
Parameters
Register a platform with the ASoC core
Parameters
Remove a platform from the ASoC core
Parameters
Parameters
Register a codec with the ASoC core
Parameters
Parameters
resource managed component registration
Parameters
Description
Register a component with automatic unregistration when the device is unregistered.
resource managed platform registration
Parameters
Description
Register a platform driver with automatic unregistration when the device is unregistered.
resource managed card registration
Parameters
Description
Register a card with automatic unregistration when the device is unregistered.
resource managed dmaengine PCM registration
Parameters
Description
Register a dmaengine based PCM device with automatic unregistration when the device is unregistered.
Read register value
Parameters
Return
0 on success, a negative error code otherwise.
Write register value
Parameters
Return
0 on success, a negative error code otherwise.
Perform read/modify/write cycle
Parameters
Return
1 if the operation was successful and the value of the register changed, 0 if the operation was successful, but the value did not change. Returns a negative error code otherwise.
Perform asynchronous read/modify/write cycle
Parameters
Description
This function is similar to snd_soc_component_update_bits(), but the update operation is scheduled asynchronously. This means it may not be completed when the function returns. To make sure that all scheduled updates have been completed snd_soc_component_async_complete() must be called.
Return
1 if the operation was successful and the value of the register changed, 0 if the operation was successful, but the value did not change. Returns a negative error code otherwise.
Ensure asynchronous I/O has completed
Parameters
Description
This function blocks until all asynchronous I/O which has previously been scheduled using snd_soc_component_update_bits_async() has completed.
Test register for change
Parameters
Description
Tests a register with a new value and checks if the new value is different from the old value.
Return
1 for change, otherwise 0.
update codec register bits
Parameters
Description
Writes new register value.
Returns 1 for change, 0 for no change, or negative error code.
test register for change
Parameters
Description
Tests a register with a new value and checks if the new value is different from the old value.
Returns 1 for change else 0.
Increment active count for PCM runtime components
Parameters
Description
Increments the active count for all the DAIs and components attached to a PCM runtime. Should typically be called when a stream is opened.
Must be called with the rtd->pcm_mutex being held
Decrement active count for PCM runtime components
Parameters
Description
Decrements the active count for all the DAIs and components attached to a PCM runtime. Should typically be called when a stream is closed.
Must be called with the rtd->pcm_mutex being held
Check whether to ignore the power down delay
Parameters
Description
This function checks whether the power down delay should be ignored for a specific PCM runtime. Returns true if the delay is 0, if it the DAI link has been configured to ignore the delay, or if none of the components benefits from having the delay.
set the runtime hardware parameters
Parameters
Description
Sets the substream runtime hardware parameters.
enumerated double mixer info callback
Parameters
Description
Callback to provide information about a double enumerated mixer control.
Returns 0 for success.
enumerated double mixer get callback
Parameters
Description
Callback to get the value of a double enumerated mixer.
Returns 0 for success.
enumerated double mixer put callback
Parameters
Description
Callback to set the value of a double enumerated mixer.
Returns 0 for success.
Read a codec register and interpret as signed value
Parameters
Description
This functions reads a codec register. The register value is shifted right by ‘shift’ bits and masked with the given ‘mask’. Afterwards it translates the given registervalue into a signed integer if sign_bit is non-zero.
Returns 0 on sucess, otherwise an error value
single mixer info callback
Parameters
Description
Callback to provide information about a single mixer control, or a double mixer control that spans 2 registers.
Returns 0 for success.
Mixer info callback for SX TLV controls
Parameters
Description
Callback to provide information about a single mixer control, or a double mixer control that spans 2 registers of the SX TLV type. SX TLV controls have a range that represents both positive and negative values either side of zero but without a sign bit.
Returns 0 for success.
single mixer get callback
Parameters
Description
Callback to get the value of a single mixer control, or a double mixer control that spans 2 registers.
Returns 0 for success.
single mixer put callback
Parameters
Description
Callback to set the value of a single mixer control, or a double mixer control that spans 2 registers.
Returns 0 for success.
single mixer get callback
Parameters
Description
Callback to get the value of a single mixer control, or a double mixer control that spans 2 registers.
Returns 0 for success.
double mixer set callback
Parameters
Description
Callback to set the value of a double mixer control that spans 2 registers.
Returns 0 for success.
single mixer info callback with range.
Parameters
Description
Callback to provide information, within a range, about a single mixer control.
returns 0 for success.
single mixer put value callback with range.
Parameters
Description
Callback to set the value, within a range, for a single mixer control.
Returns 0 for success.
single mixer get callback with range
Parameters
Description
Callback to get the value, within a range, of a single mixer control.
Returns 0 for success.
Set new limit to an existing volume control.
Parameters
Description
Return 0 for success, else error.
signed multi register info callback
Parameters
Description
Callback to provide information of a control that can span multiple codec registers which together forms a single signed value in a MSB/LSB manner.
Returns 0 for success.
signed multi register get callback
Parameters
Description
Callback to get the value of a control that can span multiple codec registers which together forms a single signed value in a MSB/LSB manner. The control supports specifying total no of bits used to allow for bitfields across the multiple codec registers.
Returns 0 for success.
signed multi register get callback
Parameters
Description
Callback to set the value of a control that can span multiple codec registers which together forms a single signed value in a MSB/LSB manner. The control supports specifying total no of bits used to allow for bitfields across the multiple codec registers.
Returns 0 for success.
strobe get callback
Parameters
Description
Callback get the value of a strobe mixer control.
Returns 0 for success.
strobe put callback
Parameters
Description
Callback strobe a register bit to high then low (or the inverse) in one pass of a single mixer enum control.
Returns 1 for success.
create a new compress.
Parameters
Return
0 for success, else error.
Returns the widget associated to a kcontrol
Parameters
Returns the dapm context associated to a kcontrol
Parameters
Note
This function must only be used on kcontrols that are known to have been registered for a CODEC. Otherwise the behaviour is undefined.
Sets the DAPM bias level
Parameters
Description
Forces the DAPM bias level to a specific state. It will call the bias level callback of DAPM context with the specified level. This will even happen if the context is already at the same level. Furthermore it will not go through the normal bias level sequencing, meaning any intermediate states between the current and the target state will not be entered.
Note that the change in bias level is only temporary and the next time snd_soc_dapm_sync() is called the state will be set to the level as determined by the DAPM core. The function is mainly intended to be used to used during probe or resume from suspend to power up the device so initialization can be done, before the DAPM core takes over.
set the bias level for the system
Parameters
Description
Configure the bias (power) levels for the SoC audio device.
Returns 0 for success else error.
query audio path and it’s widgets.
Parameters
Description
Queries DAPM graph as to whether a valid audio stream path exists for the initial stream specified by name. This takes into account current mixer and mux kcontrol settings. Creates list of valid widgets.
Optionally, can be supplied with a function acting as a stopping condition. This function takes the dapm widget currently being examined and the walk direction as an arguments, it should return true if the walk should be stopped and false otherwise.
Returns the number of valid paths or negative error.
scan and power dapm paths
Parameters
Description
Walks all dapm audio paths and powers widgets according to their stream or path usage.
Requires external locking.
Returns 0 for success.
scan and power dapm paths
Parameters
Description
Walks all dapm audio paths and powers widgets according to their stream or path usage.
Returns 0 for success.
Add routes between DAPM widgets
Parameters
Description
Connects 2 dapm widgets together via a named audio path. The sink is the widget receiving the audio signal, whilst the source is the sender of the audio signal.
Returns 0 for success else error. On error all resources can be freed with a call to snd_soc_card_free().
Remove routes between DAPM widgets
Parameters
Description
Removes routes from the DAPM context.
Mark routes between DAPM widgets as weak
Parameters
Description
Mark existing routes matching those specified in the passed array as being weak, meaning that they are ignored for the purpose of power decisions. The main intended use case is for sidetone paths which couple audio between other independent paths if they are both active in order to make the combination work better at the user level but which aren’t intended to be “used”.
Note that CODEC drivers should not use this as sidetone type paths can frequently also be used as bypass paths.
add new dapm widgets
Parameters
Description
Checks the codec for any new dapm widgets and creates them if found.
Returns 0 for success.
dapm mixer get callback
Parameters
Description
Callback to get the value of a dapm mixer control.
Returns 0 for success.
dapm mixer set callback
Parameters
Description
Callback to set the value of a dapm mixer control.
Returns 0 for success.
dapm enumerated double mixer get callback
Parameters
Description
Callback to get the value of a dapm enumerated double mixer control.
Returns 0 for success.
dapm enumerated double mixer set callback
Parameters
Description
Callback to set the value of a dapm enumerated double mixer control.
Returns 0 for success.
Info for a pin switch
Parameters
Description
Callback to provide information about a pin switch control.
Get information for a pin switch
Parameters
Set information for a pin switch
Parameters
create new dapm controls
Parameters
Description
Creates new DAPM controls based upon the templates.
Returns 0 for success else error.
send a stream event to the dapm core
Parameters
Description
Sends a stream event to the dapm core. The core then makes any necessary widget power changes.
Returns 0 for success else error.
enable pin.
Parameters
Description
Enables input/output pin and its parents or children widgets iff there is a valid audio route and active audio stream.
Requires external locking.
NOTE
snd_soc_dapm_sync() needs to be called after this for DAPM to do any widget power switching.
enable pin.
Parameters
Description
Enables input/output pin and its parents or children widgets iff there is a valid audio route and active audio stream.
NOTE
snd_soc_dapm_sync() needs to be called after this for DAPM to do any widget power switching.
force a pin to be enabled
Parameters
Description
Enables input/output pin regardless of any other state. This is intended for use with microphone bias supplies used in microphone jack detection.
Requires external locking.
NOTE
snd_soc_dapm_sync() needs to be called after this for DAPM to do any widget power switching.
force a pin to be enabled
Parameters
Description
Enables input/output pin regardless of any other state. This is intended for use with microphone bias supplies used in microphone jack detection.
NOTE
snd_soc_dapm_sync() needs to be called after this for DAPM to do any widget power switching.
disable pin.
Parameters
Description
Disables input/output pin and its parents or children widgets.
Requires external locking.
NOTE
snd_soc_dapm_sync() needs to be called after this for DAPM to do any widget power switching.
disable pin.
Parameters
Description
Disables input/output pin and its parents or children widgets.
NOTE
snd_soc_dapm_sync() needs to be called after this for DAPM to do any widget power switching.
permanently disable pin.
Parameters
Description
Marks the specified pin as being not connected, disabling it along any parent or child widgets. At present this is identical to snd_soc_dapm_disable_pin() but in future it will be extended to do additional things such as disabling controls which only affect paths through the pin.
Requires external locking.
NOTE
snd_soc_dapm_sync() needs to be called after this for DAPM to do any widget power switching.
permanently disable pin.
Parameters
Description
Marks the specified pin as being not connected, disabling it along any parent or child widgets. At present this is identical to snd_soc_dapm_disable_pin() but in future it will be extended to do additional things such as disabling controls which only affect paths through the pin.
NOTE
snd_soc_dapm_sync() needs to be called after this for DAPM to do any widget power switching.
get audio pin status
Parameters
Description
Get audio pin status - connected or disconnected.
Returns 1 for connected otherwise 0.
ignore suspend status for DAPM endpoint
Parameters
Description
Mark the given endpoint or pin as ignoring suspend. When the system is disabled a path between two endpoints flagged as ignoring suspend will not be disabled. The path must already be enabled via normal means at suspend time, it will not be turned on if it was not already enabled.
free dapm resources
Parameters
Description
Free all dapm widgets and resources.
Generic prepare_slave_config callback
Parameters
Description
This function can be used as a generic prepare_slave_config callback for platforms which make use of the snd_dmaengine_dai_dma_data struct for their DAI DMA data. Internally the function will first call snd_hwparams_to_dma_slave_config to fill in the slave config based on the hw_params, followed by snd_dmaengine_set_config_from_dai_data to fill in the remaining fields based on the DAI DMA data.
Register a dmaengine based PCM device
Parameters
Parameters
Description
Removes a dmaengine based PCM device previously registered with snd_dmaengine_pcm_register.
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.
Jack types which can be reported
Constants
Description
These values are used as a bitmask.
Note that this must be kept in sync with the lookup table in sound/core/jack.c.
Create a new snd_jack_kctl and add it to jack
Parameters
Description
Creates a new snd_kcontrol object and adds it to the jack kctl_list.
Return
Zero if successful, or a negative error code on failure.
Create a new jack
Parameters
Description
Creates a new jack object.
Return
Zero if successful, or a negative error code on failure. On success jjack will be initialised.
Set the parent device for a jack
Parameters
Description
Set the parent for the jack devices in the device tree. This function is only valid prior to registration of the jack. If no parent is configured then the parent device will be the sound card.
Set a key mapping on a jack
Parameters
Description
Map a SND_JACK_BTN_ button type to an input layer key, allowing reporting of keys on accessories via the jack abstraction. If no mapping is provided but keys are enabled in the jack type then BTN_n numeric buttons will be reported.
If jacks are not reporting via the input API this call will have no effect.
Note that this is intended to be use by simple devices with small numbers of keys that can be reported. It is also possible to access the input device directly - devices with complex input capabilities on accessories should consider doing this rather than using this abstraction.
This function may only be called prior to registration of the jack.
Return
Zero if successful, or a negative error code on failure.
Report the current status of a jack
Parameters
Create a new jack
Parameters
Description
Creates a new jack object.
Returns zero if successful, or a negative error code on failure. On success jack will be initialised.
Report the current status for a jack
Parameters
Description
If configured using snd_soc_jack_add_pins() then the associated DAPM pins will be enabled or disabled as appropriate and DAPM synchronised.
Note
This function uses mutexes and should be called from a context which can sleep (such as a workqueue).
Associate voltage zones with jack
Parameters
Description
After this function has been called the zones specified in the array will be associated with the jack.
Based on the mic bias value, this function returns the type of jack from the zones declared in the jack type
Parameters
Description
Based on the mic bias value passed, this function helps identify the type of jack from the already declared jack zones
Associate DAPM pins with an ASoC jack
Parameters
Description
After this function has been called the DAPM pins specified in the pins array will have their status updated to reflect the current state of the jack whenever the jack status is updated.
Register a notifier for jack status
Parameters
Description
Register for notification of the current status of the jack. Note that it is not possible to report additional jack events in the callback from the notifier, this is intended to support applications such as enabling electrical detection only when a mechanical detection event has occurred.
Unregister a notifier for jack status
Parameters
Description
Stop notifying for status changes.
Associate GPIO pins with an ASoC jack
Parameters
Description
This function will request gpio, set data direction and request irq for each gpio in the array.
Associate GPIO descriptor pins with an ASoC jack
Parameters
Description
This function will request gpio, set data direction and request irq for each gpio in the array.
Release GPIO pins’ resources of an ASoC jack
Parameters
Description
Release gpio and irq resources for gpio pins associated with an ASoC jack.
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.
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.