sound/ppc/pmac.c
Source file repositories/reference/linux-study-clean/sound/ppc/pmac.c
File Facts
- System
- Linux kernel
- Corpus path
sound/ppc/pmac.c- Extension
.c- Size
- 36520 bytes
- Lines
- 1364
- Domain
- Driver Families
- Bucket
- sound/ppc
- 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/io.hasm/irq.hlinux/init.hlinux/delay.hlinux/slab.hlinux/interrupt.hlinux/pci.hlinux/dma-mapping.hlinux/of_address.hlinux/of_irq.hsound/core.hpmac.hsound/pcm_params.hasm/pmac_feature.h
Detected Declarations
function snd_pmac_dbdma_allocfunction snd_pmac_dbdma_freefunction snd_pmac_rate_indexfunction another_streamfunction snd_pmac_wait_ackfunction definedfunction snd_pmac_dma_stopfunction snd_pmac_dma_set_commandfunction snd_pmac_dma_runfunction snd_pmac_pcm_preparefunction snd_pmac_pcm_triggerfunction scoped_guardfunction scoped_guardfunction snd_pmac_pcm_pointerfunction snd_pmac_playback_preparefunction snd_pmac_playback_triggerfunction snd_pmac_playback_pointerfunction snd_pmac_capture_preparefunction snd_pmac_capture_triggerfunction snd_pmac_capture_pointerfunction snd_pmac_pcm_dead_xferfunction snd_pmac_pcm_updatefunction snd_pmac_hw_rule_ratefunction snd_pmac_hw_rule_formatfunction snd_pmac_pcm_openfunction snd_pmac_pcm_closefunction snd_pmac_playback_openfunction snd_pmac_capture_openfunction snd_pmac_playback_closefunction snd_pmac_capture_closefunction snd_pmac_pcm_newfunction snd_pmac_dbdma_resetfunction snd_pmac_beep_dma_startfunction snd_pmac_beep_dma_stopfunction snd_pmac_tx_intrfunction snd_pmac_rx_intrfunction snd_pmac_ctrl_intrfunction snd_pmac_sound_featurefunction snd_pmac_freefunction snd_pmac_dev_freefunction byteswapfunction snd_pmac_detectfunction for_each_pci_devfunction pmac_auto_mute_getfunction pmac_auto_mute_putfunction pmac_hp_detect_getfunction snd_pmac_add_automutefunction snd_pmac_new
Annotated Snippet
scoped_guard(spinlock, &chip->reg_lock) {
snd_pmac_beep_stop(chip);
snd_pmac_pcm_set_format(chip);
for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++)
out_le16(&cp->command, command);
snd_pmac_dma_set_command(rec, &rec->cmd);
(void)in_le32(&rec->dma->status);
snd_pmac_dma_run(rec, RUN|WAKE);
rec->running = 1;
}
break;
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
scoped_guard(spinlock, &chip->reg_lock) {
rec->running = 0;
snd_pmac_dma_stop(rec);
for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++)
out_le16(&cp->command, DBDMA_STOP);
}
break;
default:
return -EINVAL;
}
return 0;
}
/*
* return the current pointer
*/
inline
static snd_pcm_uframes_t snd_pmac_pcm_pointer(struct snd_pmac *chip,
struct pmac_stream *rec,
struct snd_pcm_substream *subs)
{
int count = 0;
#if 1 /* hmm.. how can we get the current dma pointer?? */
int stat;
volatile struct dbdma_cmd __iomem *cp = &rec->cmd.cmds[rec->cur_period];
stat = le16_to_cpu(cp->xfer_status);
if (stat & (ACTIVE|DEAD)) {
count = in_le16(&cp->res_count);
if (count)
count = rec->period_size - count;
}
#endif
count += rec->cur_period * rec->period_size;
return bytes_to_frames(subs->runtime, count);
}
/*
* playback
*/
static int snd_pmac_playback_prepare(struct snd_pcm_substream *subs)
{
struct snd_pmac *chip = snd_pcm_substream_chip(subs);
return snd_pmac_pcm_prepare(chip, &chip->playback, subs);
}
static int snd_pmac_playback_trigger(struct snd_pcm_substream *subs,
int cmd)
{
struct snd_pmac *chip = snd_pcm_substream_chip(subs);
return snd_pmac_pcm_trigger(chip, &chip->playback, subs, cmd);
}
static snd_pcm_uframes_t snd_pmac_playback_pointer(struct snd_pcm_substream *subs)
{
struct snd_pmac *chip = snd_pcm_substream_chip(subs);
return snd_pmac_pcm_pointer(chip, &chip->playback, subs);
}
/*
* capture
*/
static int snd_pmac_capture_prepare(struct snd_pcm_substream *subs)
{
struct snd_pmac *chip = snd_pcm_substream_chip(subs);
return snd_pmac_pcm_prepare(chip, &chip->capture, subs);
}
static int snd_pmac_capture_trigger(struct snd_pcm_substream *subs,
int cmd)
{
Annotation
- Immediate include surface: `linux/io.h`, `asm/irq.h`, `linux/init.h`, `linux/delay.h`, `linux/slab.h`, `linux/interrupt.h`, `linux/pci.h`, `linux/dma-mapping.h`.
- Detected declarations: `function snd_pmac_dbdma_alloc`, `function snd_pmac_dbdma_free`, `function snd_pmac_rate_index`, `function another_stream`, `function snd_pmac_wait_ack`, `function defined`, `function snd_pmac_dma_stop`, `function snd_pmac_dma_set_command`, `function snd_pmac_dma_run`, `function snd_pmac_pcm_prepare`.
- Atlas domain: Driver Families / sound/ppc.
- 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.