sound/soc/fsl/fsl_asrc.c
Source file repositories/reference/linux-study-clean/sound/soc/fsl/fsl_asrc.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/fsl/fsl_asrc.c- Extension
.c- Size
- 45477 bytes
- Lines
- 1618
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/delay.hlinux/dma-mapping.hlinux/module.hlinux/of_platform.hlinux/dma/imx-dma.hlinux/pm_runtime.hsound/dmaengine_pcm.hsound/pcm_params.hfsl_asrc.h
Detected Declarations
function fsl_asrc_divider_availfunction fsl_asrc_sel_procfunction fsl_asrc_request_pairfunction fsl_asrc_release_pairfunction fsl_asrc_set_watermarksfunction fsl_asrc_cal_asrck_divisorfunction fsl_asrc_set_ideal_ratiofunction fsl_asrc_config_pairfunction fsl_asrc_start_pairfunction fsl_asrc_stop_pairfunction fsl_asrc_dai_startupfunction fsl_asrc_select_clkfunction fsl_asrc_dai_hw_paramsfunction fsl_asrc_dai_hw_freefunction fsl_asrc_dai_triggerfunction fsl_asrc_dai_probefunction fsl_asrc_readable_regfunction fsl_asrc_volatile_regfunction fsl_asrc_writeable_regfunction fsl_asrc_initfunction fsl_asrc_isrfunction fsl_asrc_get_fifo_addrfunction fsl_asrc_get_output_fifo_sizefunction fsl_asrc_m2m_output_readyfunction fsl_asrc_m2m_preparefunction fsl_asrc_m2m_startfunction fsl_asrc_m2m_stopfunction fsl_asrc_m2m_calc_out_lenfunction fsl_asrc_m2m_get_maxburstfunction fsl_asrc_m2m_get_capfunction fsl_asrc_m2m_pair_resumefunction fsl_asrc_probefunction of_device_is_compatiblefunction fsl_asrc_removefunction fsl_asrc_runtime_resumefunction fsl_asrc_runtime_suspendfunction fsl_asrc_suspendfunction fsl_asrc_resume
Annotated Snippet
else if (inrate * 8 > 15 * outrate) {
if (inrate > 152000)
*pre_proc = 2;
else
*pre_proc = 1;
} else if (inrate < 76000)
*pre_proc = 0;
else if (inrate > 152000)
*pre_proc = 2;
else
*pre_proc = 1;
/* Condition for selection of post-processing */
post_proc_cond2 = (inrate * 15 > outrate * 16 && outrate < 56000) ||
(inrate > 56000 && outrate < 56000);
post_proc_cond0 = inrate * 23 < outrate * 8;
if (post_proc_cond2)
*post_proc = 2;
else if (post_proc_cond0)
*post_proc = 0;
else
*post_proc = 1;
}
/**
* fsl_asrc_request_pair - Request ASRC pair
* @channels: number of channels
* @pair: pointer to pair
*
* It assigns pair by the order of A->C->B because allocation of pair B,
* within range [ANCA, ANCA+ANCB-1], depends on the channels of pair A
* while pair A and pair C are comparatively independent.
*/
static int fsl_asrc_request_pair(int channels, struct fsl_asrc_pair *pair)
{
enum asrc_pair_index index = ASRC_INVALID_PAIR;
struct fsl_asrc *asrc = pair->asrc;
struct device *dev = &asrc->pdev->dev;
unsigned long lock_flags;
int i, ret = 0;
spin_lock_irqsave(&asrc->lock, lock_flags);
for (i = ASRC_PAIR_A; i < ASRC_PAIR_MAX_NUM; i++) {
if (asrc->pair[i] != NULL)
continue;
index = i;
if (i != ASRC_PAIR_B)
break;
}
if (index == ASRC_INVALID_PAIR) {
dev_err(dev, "all pairs are busy now\n");
ret = -EBUSY;
} else if (asrc->channel_avail < channels) {
dev_err(dev, "can't afford required channels: %d\n", channels);
ret = -EINVAL;
} else {
asrc->channel_avail -= channels;
asrc->pair[index] = pair;
pair->channels = channels;
pair->index = index;
}
spin_unlock_irqrestore(&asrc->lock, lock_flags);
return ret;
}
/**
* fsl_asrc_release_pair - Release ASRC pair
* @pair: pair to release
*
* It clears the resource from asrc and releases the occupied channels.
*/
static void fsl_asrc_release_pair(struct fsl_asrc_pair *pair)
{
struct fsl_asrc *asrc = pair->asrc;
enum asrc_pair_index index = pair->index;
unsigned long lock_flags;
/* Make sure the pair is disabled */
regmap_update_bits(asrc->regmap, REG_ASRCTR,
ASRCTR_ASRCEi_MASK(index), 0);
spin_lock_irqsave(&asrc->lock, lock_flags);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/module.h`, `linux/of_platform.h`, `linux/dma/imx-dma.h`, `linux/pm_runtime.h`, `sound/dmaengine_pcm.h`.
- Detected declarations: `function fsl_asrc_divider_avail`, `function fsl_asrc_sel_proc`, `function fsl_asrc_request_pair`, `function fsl_asrc_release_pair`, `function fsl_asrc_set_watermarks`, `function fsl_asrc_cal_asrck_divisor`, `function fsl_asrc_set_ideal_ratio`, `function fsl_asrc_config_pair`, `function fsl_asrc_start_pair`, `function fsl_asrc_stop_pair`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.