sound/soc/codecs/rt711.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/rt711.c
Extension
.c
Size
35808 bytes
Lines
1336
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

if (loop >= 500) {
			pr_err("%s, calibration time-out!\n",
							__func__);
			ret = -ETIMEDOUT;
			break;
		}
		loop++;

		usleep_range(10000, 11000);
		rt711_index_read(regmap, RT711_VENDOR_CALI,
			RT711_DAC_DC_CALI_CTL1, &val);
	}

	/* depop mode */
	rt711_index_update_bits(regmap, RT711_VENDOR_REG,
		RT711_FSM_CTL, 0xf, RT711_DEPOP_CTL);

	regmap_write(rt711->regmap,
		RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3);
	mutex_unlock(&rt711->calibrate_mutex);

	dev_dbg(dev, "%s calibration complete, ret=%d\n", __func__, ret);
	return ret;
}

static unsigned int rt711_button_detect(struct rt711_priv *rt711)
{
	unsigned int btn_type = 0, val80, val81;
	int ret;

	ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG,
				RT711_IRQ_FLAG_TABLE1, &val80);
	if (ret < 0)
		goto read_error;
	ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG,
					RT711_IRQ_FLAG_TABLE2, &val81);
	if (ret < 0)
		goto read_error;

	val80 &= 0x0381;
	val81 &= 0xff00;

	switch (val80) {
	case 0x0200:
	case 0x0100:
	case 0x0080:
		btn_type |= SND_JACK_BTN_0;
		break;
	case 0x0001:
		btn_type |= SND_JACK_BTN_3;
		break;
	}
	switch (val81) {
	case 0x8000:
	case 0x4000:
	case 0x2000:
		btn_type |= SND_JACK_BTN_1;
		break;
	case 0x1000:
	case 0x0800:
	case 0x0400:
		btn_type |= SND_JACK_BTN_2;
		break;
	case 0x0200:
	case 0x0100:
		btn_type |= SND_JACK_BTN_3;
		break;
	}
read_error:
	return btn_type;
}

static int rt711_headset_detect(struct rt711_priv *rt711)
{
	unsigned int buf, loop = 0;
	int ret;
	unsigned int jack_status = 0, reg;

	ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG,
				RT711_COMBO_JACK_AUTO_CTL2, &buf);
	if (ret < 0)
		goto io_error;

	while (loop < 500 &&
		(buf & RT711_COMBOJACK_AUTO_DET_STATUS) == 0) {
		loop++;

		usleep_range(9000, 10000);
		ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG,
					RT711_COMBO_JACK_AUTO_CTL2, &buf);

Annotation

Implementation Notes