sound/soc/amd/acp/acp-platform.c

Source file repositories/reference/linux-study-clean/sound/soc/amd/acp/acp-platform.c

File Facts

System
Linux kernel
Corpus path
sound/soc/amd/acp/acp-platform.c
Extension
.c
Size
10563 bytes
Lines
361
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.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (stream->dai_id) {
		case I2S_SP_INSTANCE:
			if (stream->dir == SNDRV_PCM_STREAM_PLAYBACK)
				val = 0x0;
			else
				val = 0x1000;
			break;
		case I2S_BT_INSTANCE:
			if (stream->dir == SNDRV_PCM_STREAM_PLAYBACK)
				val = 0x2000;
			else
				val = 0x3000;
			break;
		case I2S_HS_INSTANCE:
			if (stream->dir == SNDRV_PCM_STREAM_PLAYBACK)
				val = 0x4000;
			else
				val = 0x5000;
			break;
		case DMIC_INSTANCE:
			val = 0x6000;
			break;
		default:
			dev_err(chip->dev, "Invalid dai id %x\n", stream->dai_id);
			return;
		}
		break;
	default:
		val = stream->pte_offset;
		break;
	}

	for (page_idx = 0; page_idx < num_pages; page_idx++) {
		/* Load the low address of page int ACP SRAM through SRBM */
		low = lower_32_bits(addr);
		high = upper_32_bits(addr);
		writel(low, chip->base + rsrc->scratch_reg_offset + val);
		high |= BIT(31);
		writel(high, chip->base + rsrc->scratch_reg_offset + val + 4);

		/* Move to next physically contiguous page */
		val += 8;
		addr += PAGE_SIZE;
	}
}
EXPORT_SYMBOL_NS_GPL(config_acp_dma, "SND_SOC_ACP_COMMON");

static int acp_dma_open(struct snd_soc_component *component, struct snd_pcm_substream *substream)
{
	struct snd_pcm_runtime *runtime = substream->runtime;
	struct device *dev = component->dev;
	struct acp_chip_info *chip;
	struct acp_stream *stream;
	int ret;

	stream = kzalloc_obj(*stream);
	if (!stream)
		return -ENOMEM;

	stream->substream = substream;
	chip = dev_get_drvdata(dev->parent);
	switch (chip->acp_rev) {
	case ACP63_PCI_ID:
	case ACP70_PCI_ID:
	case ACP71_PCI_ID:
	case ACP72_PCI_ID:
		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
			runtime->hw = acp6x_pcm_hardware_playback;
		else
			runtime->hw = acp6x_pcm_hardware_capture;
		break;
	default:
		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
			runtime->hw = acp_pcm_hardware_playback;
		else
			runtime->hw = acp_pcm_hardware_capture;
		break;
	}

	ret = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, DMA_SIZE);
	if (ret) {
		dev_err(component->dev, "set hw constraint HW_PARAM_PERIOD_BYTES failed\n");
		kfree(stream);
		return ret;
	}

	ret = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, DMA_SIZE);
	if (ret) {
		dev_err(component->dev, "set hw constraint HW_PARAM_BUFFER_BYTES failed\n");
		kfree(stream);

Annotation

Implementation Notes