sound/soc/intel/catpt/loader.c

Source file repositories/reference/linux-study-clean/sound/soc/intel/catpt/loader.c

File Facts

System
Linux kernel
Corpus path
sound/soc/intel/catpt/loader.c
Extension
.c
Size
15492 bytes
Lines
668
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct catpt_fw_hdr {
	char signature[FW_SIGNATURE_SIZE];
	u32 file_size;
	u32 modules;
	u32 file_format;
	u32 reserved[4];
} __packed;

struct catpt_fw_mod_hdr {
	char signature[FW_SIGNATURE_SIZE];
	u32 mod_size;
	u32 blocks;
	u16 slot;
	u16 module_id;
	u32 entry_point;
	u32 persistent_size;
	u32 scratch_size;
} __packed;

enum catpt_ram_type {
	CATPT_RAM_TYPE_IRAM = 1,
	CATPT_RAM_TYPE_DRAM = 2,
	/* DRAM with module's initial state */
	CATPT_RAM_TYPE_INSTANCE = 3,
};

struct catpt_fw_block_hdr {
	u32 ram_type;
	u32 size;
	u32 ram_offset;
	u32 rsvd;
} __packed;

void catpt_sram_free(struct resource *sram)
{
	struct resource *res, *save;

	for (res = sram->child; res;) {
		save = res->sibling;
		release_resource(res);
		kfree(res);
		res = save;
	}
}

struct resource *
catpt_request_region(struct resource *root, resource_size_t size)
{
	struct resource *res = root->child;
	resource_size_t addr = root->start;

	for (;;) {
		if (res->start - addr >= size)
			break;
		addr = res->end + 1;
		res = res->sibling;
		if (!res)
			return NULL;
	}

	return __request_region(root, addr, size, NULL, 0);
}

int catpt_store_streams_context(struct catpt_dev *cdev, struct dma_chan *chan)
{
	struct catpt_stream_runtime *stream;

	/* Lockless as no streams can be added or removed during D3 -> D0 transition. */
	list_for_each_entry(stream, &cdev->stream_list, node) {
		u32 off, size;
		int ret;

		off = stream->persistent->start;
		size = resource_size(stream->persistent);
		dev_dbg(cdev->dev, "storing stream %d ctx: off 0x%08x size %d\n",
			stream->info.stream_hw_id, off, size);

		ret = catpt_dma_memcpy_fromdsp(cdev, chan,
					       cdev->dxbuf_paddr + off,
					       cdev->lpe_base + off,
					       ALIGN(size, 4));
		if (ret) {
			dev_err(cdev->dev, "memcpy fromdsp failed: %d\n", ret);
			return ret;
		}
	}

	return 0;
}

Annotation

Implementation Notes