sound/soc/codecs/rt712-sdca.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/rt712-sdca.c
Extension
.c
Size
57595 bytes
Lines
1927
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

switch (buf[1] & 0xf0) {
		case 0x10:
			btn_type |= SND_JACK_BTN_2;
			break;
		case 0x20:
			btn_type |= SND_JACK_BTN_3;
			break;
		case 0x40:
			btn_type |= SND_JACK_BTN_0;
			break;
		case 0x80:
			btn_type |= SND_JACK_BTN_1;
			break;
		}
		switch (buf[2]) {
		case 0x01:
		case 0x10:
			btn_type |= SND_JACK_BTN_2;
			break;
		case 0x02:
		case 0x20:
			btn_type |= SND_JACK_BTN_3;
			break;
		case 0x04:
		case 0x40:
			btn_type |= SND_JACK_BTN_0;
			break;
		case 0x08:
		case 0x80:
			btn_type |= SND_JACK_BTN_1;
			break;
		}
	}

_end_btn_det_:
	/* Host is owner, so set back to device */
	if (owner == 0) {
		/* set owner to device */
		if (rt712->version_id == RT712_VA)
			regmap_write(rt712->regmap,
				SDW_SDCA_CTL(FUNC_NUM_HID, RT712_SDCA_ENT_HID01,
					RT712_SDCA_CTL_HIDTX_SET_OWNER_TO_DEVICE, 0), 0x01);
		else
			regmap_write(rt712->regmap,
				SDW_SDCA_CTL(FUNC_NUM_HID, RT712_SDCA_ENT_HID01,
					RT712_SDCA_CTL_HIDTX_CURRENT_OWNER, 0), 0x01);
	}

	return btn_type;
}

static int rt712_sdca_headset_detect(struct rt712_sdca_priv *rt712)
{
	unsigned int det_mode;
	int ret;

	/* get detected_mode */
	ret = regmap_read(rt712->regmap,
		SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_GE49, RT712_SDCA_CTL_DETECTED_MODE, 0),
		&det_mode);
	if (ret < 0)
		goto io_error;

	switch (det_mode) {
	case 0x00:
		rt712->jack_type = 0;
		break;
	case 0x03:
		rt712->jack_type = SND_JACK_HEADPHONE;
		break;
	case 0x05:
		rt712->jack_type = SND_JACK_HEADSET;
		break;
	}

	/* write selected_mode */
	if (det_mode) {
		ret = regmap_write(rt712->regmap,
			SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_GE49, RT712_SDCA_CTL_SELECTED_MODE, 0),
			det_mode);
		if (ret < 0)
			goto io_error;
	}

	dev_dbg(&rt712->slave->dev,
		"%s, detected_mode=0x%x\n", __func__, det_mode);

	return 0;

io_error:

Annotation

Implementation Notes