sound/soc/sti/uniperif_player.c
Source file repositories/reference/linux-study-clean/sound/soc/sti/uniperif_player.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sti/uniperif_player.c- Extension
.c- Size
- 31833 bytes
- Lines
- 1144
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/mfd/syscon.hsound/asoundef.hsound/soc.huniperif.h
Detected Declarations
function uni_player_irq_handlerfunction UNIPERIF_ITM_UNDERFLOW_REC_FAILED_MASKfunction uni_player_clk_set_ratefunction uni_player_set_channel_statusfunction uni_player_prepare_iec958function uni_player_prepare_pcmfunction subframefunction uni_player_prepare_tdmfunction uni_player_ctl_iec958_infofunction uni_player_ctl_iec958_getfunction uni_player_ctl_iec958_putfunction scoped_guardfunction snd_sti_clk_adjustment_infofunction snd_sti_clk_adjustment_getfunction snd_sti_clk_adjustment_putfunction uni_player_startupfunction uni_player_set_sysclkfunction uni_player_preparefunction uni_player_startfunction uni_player_stopfunction uni_player_resumefunction uni_player_triggerfunction uni_player_shutdownfunction uni_player_parse_dt_audio_gluefunction uni_player_initexport uni_player_resumeexport uni_player_init
Annotated Snippet
if (player->underflow_enabled) {
/* Update state to underflow */
player->state = UNIPERIF_STATE_UNDERFLOW;
} else {
/* Disable interrupt so doesn't continually fire */
SET_UNIPERIF_ITM_BCLR_FIFO_ERROR(player);
/* Stop the player */
snd_pcm_stop(player->substream, SNDRV_PCM_STATE_XRUN);
}
ret = IRQ_HANDLED;
}
/* Check for dma error (overrun) */
if (unlikely(status & UNIPERIF_ITS_DMA_ERROR_MASK(player))) {
dev_err(player->dev, "DMA error detected\n");
/* Disable interrupt so doesn't continually fire */
SET_UNIPERIF_ITM_BCLR_DMA_ERROR(player);
/* Stop the player */
snd_pcm_stop(player->substream, SNDRV_PCM_STATE_XRUN);
ret = IRQ_HANDLED;
}
/* Check for underflow recovery done */
if (unlikely(status & UNIPERIF_ITM_UNDERFLOW_REC_DONE_MASK(player))) {
if (!player->underflow_enabled) {
dev_err(player->dev,
"unexpected Underflow recovering\n");
ret = -EPERM;
snd_pcm_stream_unlock(player->substream);
return ret;
}
/* Read the underflow recovery duration */
tmp = GET_UNIPERIF_STATUS_1_UNDERFLOW_DURATION(player);
dev_dbg(player->dev, "Underflow recovered (%d LR clocks max)\n",
tmp);
/* Clear the underflow recovery duration */
SET_UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION(player);
/* Update state to started */
player->state = UNIPERIF_STATE_STARTED;
ret = IRQ_HANDLED;
}
/* Check if underflow recovery failed */
if (unlikely(status &
UNIPERIF_ITM_UNDERFLOW_REC_FAILED_MASK(player))) {
dev_err(player->dev, "Underflow recovery failed\n");
/* Stop the player */
snd_pcm_stop(player->substream, SNDRV_PCM_STATE_XRUN);
ret = IRQ_HANDLED;
}
snd_pcm_stream_unlock(player->substream);
return ret;
}
static int uni_player_clk_set_rate(struct uniperif *player, unsigned long rate)
{
int rate_adjusted, rate_achieved, delta, ret;
int adjustment = player->clk_adj;
/*
* a
* F = f + --------- * f = f + d
* 1000000
*
* a
* d = --------- * f
* 1000000
*
* where:
* f - nominal rate
* a - adjustment in ppm (parts per milion)
* F - rate to be set in synthesizer
* d - delta (difference) between f and F
*/
if (adjustment < 0) {
/* div64_64 operates on unsigned values... */
delta = -1;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/mfd/syscon.h`, `sound/asoundef.h`, `sound/soc.h`, `uniperif.h`.
- Detected declarations: `function uni_player_irq_handler`, `function UNIPERIF_ITM_UNDERFLOW_REC_FAILED_MASK`, `function uni_player_clk_set_rate`, `function uni_player_set_channel_status`, `function uni_player_prepare_iec958`, `function uni_player_prepare_pcm`, `function subframe`, `function uni_player_prepare_tdm`, `function uni_player_ctl_iec958_info`, `function uni_player_ctl_iec958_get`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.