sound/soc/codecs/tscs454.c

Source file repositories/reference/linux-study-clean/sound/soc/codecs/tscs454.c

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/tscs454.c
Extension
.c
Size
109660 bytes
Lines
3482
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 pll {
	int id;
	unsigned int users;
	struct mutex lock;
};

static inline void pll_init(struct pll *pll, int id)
{
	pll->id = id;
	mutex_init(&pll->lock);
}

struct internal_rate {
	struct pll *pll;
};

struct aif {
	unsigned int id;
	bool provider;
	struct pll *pll;
};

static inline void aif_init(struct aif *aif, unsigned int id)
{
	aif->id = id;
}

struct coeff_ram {
	u8 cache[COEFF_RAM_SIZE];
	bool synced;
	struct mutex lock;
};

static inline void init_coeff_ram_cache(u8 *cache)
{
	static const u8 norm_addrs[] = { 0x00, 0x05, 0x0a, 0x0f, 0x14, 0x19,
		0x1f, 0x20, 0x25, 0x2a, 0x2f, 0x34, 0x39, 0x3f, 0x40, 0x45,
		0x4a, 0x4f, 0x54, 0x59, 0x5f, 0x60, 0x65, 0x6a, 0x6f, 0x74,
		0x79, 0x7f, 0x80, 0x85, 0x8c, 0x91, 0x96, 0x97, 0x9c, 0xa3,
		0xa8, 0xad, 0xaf, 0xb0, 0xb5, 0xba, 0xbf, 0xc4, 0xc9};
	int i;

	for (i = 0; i < ARRAY_SIZE(norm_addrs); i++)
		cache[((norm_addrs[i] + 1) * COEFF_SIZE) - 1] = 0x40;
}

static inline void coeff_ram_init(struct coeff_ram *ram)
{
	init_coeff_ram_cache(ram->cache);
	mutex_init(&ram->lock);
}

struct aifs_status {
	u8 streams;
};

static inline void set_aif_status_active(struct aifs_status *status,
		int aif_id, bool playback)
{
	u8 mask = 0x01 << (aif_id * 2 + !playback);

	status->streams |= mask;
}

static inline void set_aif_status_inactive(struct aifs_status *status,
		int aif_id, bool playback)
{
	u8 mask = ~(0x01 << (aif_id * 2 + !playback));

	status->streams &= mask;
}

static bool aifs_active(struct aifs_status *status)
{
	return status->streams;
}

static bool aif_active(struct aifs_status *status, int aif_id)
{
	return (0x03 << aif_id * 2) & status->streams;
}

struct tscs454 {
	struct regmap *regmap;
	struct aif aifs[TSCS454_DAI_COUNT];

	struct aifs_status aifs_status;
	struct mutex aifs_status_lock;

	struct pll pll1;

Annotation

Implementation Notes