sound/soc/codecs/ssm2602.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/ssm2602.c
Extension
.c
Size
19087 bytes
Lines
695
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

struct ssm2602_priv {
	unsigned int sysclk;
	const struct snd_pcm_hw_constraint_list *sysclk_constraints;

	struct regmap *regmap;

	enum ssm2602_type type;
	unsigned int clk_out_pwr;
};

/*
 * ssm2602 register cache
 * We can't read the ssm2602 register space when we are
 * using 2 wire for device control, so we cache them instead.
 * There is no point in caching the reset register
 */
static const struct reg_default ssm2602_reg[SSM2602_CACHEREGNUM] = {
	{ .reg = 0x00, .def = 0x0097 },
	{ .reg = 0x01, .def = 0x0097 },
	{ .reg = 0x02, .def = 0x0079 },
	{ .reg = 0x03, .def = 0x0079 },
	{ .reg = 0x04, .def = 0x000a },
	{ .reg = 0x05, .def = 0x0008 },
	{ .reg = 0x06, .def = 0x009f },
	{ .reg = 0x07, .def = 0x000a },
	{ .reg = 0x08, .def = 0x0000 },
	{ .reg = 0x09, .def = 0x0000 }
};

/*
 * ssm2602 register patch
 * Workaround for playback distortions after power up: activates digital
 * core, and then powers on output, DAC, and whole chip at the same time
 */

static const struct reg_sequence ssm2602_patch[] = {
	{ SSM2602_ACTIVE, 0x01 },
	{ SSM2602_PWR,    0x07 },
	{ SSM2602_RESET,  0x00 },
};


/*Appending several "None"s just for OSS mixer use*/
static const char *ssm2602_input_select[] = {
	"Line", "Mic",
};

static const char *ssm2602_deemph[] = {"None", "32Khz", "44.1Khz", "48Khz"};

static const struct soc_enum ssm2602_enum[] = {
	SOC_ENUM_SINGLE(SSM2602_APANA, 2, ARRAY_SIZE(ssm2602_input_select),
			ssm2602_input_select),
	SOC_ENUM_SINGLE(SSM2602_APDIGI, 1, ARRAY_SIZE(ssm2602_deemph),
			ssm2602_deemph),
};

static const DECLARE_TLV_DB_RANGE(ssm260x_outmix_tlv,
	0, 47, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
	48, 127, TLV_DB_SCALE_ITEM(-7400, 100, 0)
);

static const DECLARE_TLV_DB_SCALE(ssm260x_inpga_tlv, -3450, 150, 0);
static const DECLARE_TLV_DB_SCALE(ssm260x_sidetone_tlv, -1500, 300, 0);

static const struct snd_kcontrol_new ssm260x_snd_controls[] = {
SOC_DOUBLE_R_TLV("Capture Volume", SSM2602_LINVOL, SSM2602_RINVOL, 0, 45, 0,
	ssm260x_inpga_tlv),
SOC_DOUBLE_R("Capture Switch", SSM2602_LINVOL, SSM2602_RINVOL, 7, 1, 1),

SOC_SINGLE("ADC High Pass Filter Switch", SSM2602_APDIGI, 0, 1, 1),
SOC_SINGLE("Store DC Offset Switch", SSM2602_APDIGI, 4, 1, 0),

SOC_ENUM("Playback De-emphasis", ssm2602_enum[1]),
};

static const struct snd_kcontrol_new ssm2602_snd_controls[] = {
SOC_DOUBLE_R_TLV("Master Playback Volume", SSM2602_LOUT1V, SSM2602_ROUT1V,
	0, 127, 0, ssm260x_outmix_tlv),
SOC_DOUBLE_R("Master Playback ZC Switch", SSM2602_LOUT1V, SSM2602_ROUT1V,
	7, 1, 0),
SOC_SINGLE_TLV("Sidetone Playback Volume", SSM2602_APANA, 6, 3, 1,
	ssm260x_sidetone_tlv),

SOC_SINGLE("Mic Boost (+20dB)", SSM2602_APANA, 0, 1, 0),
SOC_SINGLE("Mic Boost2 (+20dB)", SSM2602_APANA, 8, 1, 0),
};

/* Output Mixer */
static const struct snd_kcontrol_new ssm260x_output_mixer_controls[] = {
SOC_DAPM_SINGLE("Line Bypass Switch", SSM2602_APANA, 3, 1, 0),

Annotation

Implementation Notes