sound/soc/codecs/tac5xx2-sdw.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/tac5xx2-sdw.c
Extension
.c
Size
57864 bytes
Lines
2038
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 tac_fw_hdr {
	u32 size;
	u32 version_offset;
	u32 plt_id;
	u32 ppc3_ver;
	u64 timestamp;
	u8 ddc_name[64];
};

/* Firmware file/chunk structure */
struct tac_fw_file {
	u32 vendor_id;
	u32 file_id;
	u32 version;
	u32 length;
	u32 dest_addr;
	u8 *fw_data;
};

/* TLV for volume control */
static const DECLARE_TLV_DB_SCALE(tac5xx2_amp_tlv, 0, 50, 0);
static const DECLARE_TLV_DB_SCALE(tac5xx2_dvc_tlv, -7200, 50, 0);

/* Q7.8 volume control parameters: range -72dB to +6dB, step 0.5dB */
#define TAC_DVC_STEP		128	/* 0.5 dB in Q7.8 format */
#define TAC_DVC_MIN		(-144)	/* -72 dB / 0.5 dB step */
#define TAC_DVC_MAX		12	/* +6 dB / 0.5 dB step */

/* TAC-specific stereo volume control macro using SDW_SDCA_CTL (single control for L/R) */
#define TAC_DOUBLE_Q78_TLV(name, func_id, ent_id) \
	SDCA_DOUBLE_Q78_TLV(name, \
			    SDW_SDCA_CTL(TAC_FUNCTION_ID_##func_id, TAC_SDCA_ENT_##ent_id, \
					 TAC_SDCA_CHANNEL_GAIN, TAC_CHANNEL_LEFT), \
			    SDW_SDCA_CTL(TAC_FUNCTION_ID_##func_id, TAC_SDCA_ENT_##ent_id, \
					 TAC_SDCA_CHANNEL_GAIN, TAC_CHANNEL_RIGHT), \
			    TAC_DVC_MIN, TAC_DVC_MAX, TAC_DVC_STEP, tac5xx2_dvc_tlv)

struct tac5xx2_prv {
	struct snd_soc_component *component;
	struct sdw_slave *sdw_peripheral;
	struct sdca_function_data *sa_func_data;
	struct sdca_function_data *sm_func_data;
	struct sdca_function_data *uaj_func_data;
	struct sdca_function_data *hid_func_data;
	enum sdw_slave_status status;
	struct regmap *regmap;
	struct device *dev;
	bool hw_init;
	bool first_hw_init_done;
	u32 part_id;
	struct snd_soc_jack *hs_jack;
	int jack_type;
	 /* Custom fw binary. UMP File Download is not used. */
	unsigned int fw_file_cnt;
	struct tac_fw_file *fw_files;
	struct completion fw_caching_complete;
	bool fw_dl_success;
	u8 fw_binaryname[64];
};

static const struct reg_default tac_reg_default[] = {
	{TAC_SW_RESET, 0x0},
	{TAC_SLEEP_MODEZ, 0x0},
	{TAC_FEATURE_PDZ, 0x0},
	{TAC_TX_CH_EN, 0xf0},
	{TAC_REG_SDW(0, 0, 0x5), 0xcf},
	{TAC_REG_SDW(0, 0, 0x6), 0xa},
	{TAC_REG_SDW(0, 0, 0x7), 0x0},
	{TAC_REG_SDW(0, 0, 0x8), 0xfe},
	{TAC_REG_SDW(0, 0, 0x9), 0x9},
	{TAC_REG_SDW(0, 0, 0xa), 0x28},
	{TAC_REG_SDW(0, 0, 0xb), 0x1},
	{TAC_REG_SDW(0, 0, 0xc), 0x11},
	{TAC_REG_SDW(0, 0, 0xd), 0x11},
	{TAC_REG_SDW(0, 0, 0xe), 0x61},
	{TAC_REG_SDW(0, 0, 0xf), 0x0},
	{TAC_REG_SDW(0, 0, 0x10), 0x50},
	{TAC_REG_SDW(0, 0, 0x11), 0x70},
	{TAC_REG_SDW(0, 0, 0x12), 0x60},
	{TAC_REG_SDW(0, 0, 0x13), 0x28},
	{TAC_REG_SDW(0, 0, 0x14), 0x0},
	{TAC_REG_SDW(0, 0, 0x15), 0x18},
	{TAC_REG_SDW(0, 0, 0x16), 0x20},
	{TAC_REG_SDW(0, 0, 0x17), 0x0},
	{TAC_REG_SDW(0, 0, 0x18), 0x18},
	{TAC_REG_SDW(0, 0, 0x19), 0x54},
	{TAC_REG_SDW(0, 0, 0x1a), 0x8},
	{TAC_REG_SDW(0, 0, 0x1b), 0x0},
	{TAC_REG_SDW(0, 0, 0x1c), 0x30},
	{TAC_REG_SDW(0, 0, 0x1d), 0x0},

Annotation

Implementation Notes