sound/soc/codecs/cs42l43-jack.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/cs42l43-jack.c
Extension
.c
Size
29158 bytes
Lines
990
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 (ret < 0) {
			dev_err(priv->dev, "Property cirrus,buttons-ohms malformed: %d\n",
				ret);
			goto error;
		}

		if (ret > CS42L43_N_BUTTONS) {
			ret = -EINVAL;
			dev_err(priv->dev, "Property cirrus,buttons-ohms too many entries\n");
			goto error;
		}

		ret = device_property_read_u32_array(cs42l43->dev, "cirrus,buttons-ohms",
						     priv->buttons, ret);
		if (ret < 0) {
			dev_err(priv->dev, "Property cirrus,button-ohms malformed: %d\n",
				ret);
			goto error;
		}
	} else {
		priv->buttons[0] = 70;
		priv->buttons[1] = 185;
		priv->buttons[2] = 355;
		priv->buttons[3] = 735;
	}

	ret = cs42l43_find_index(priv, "cirrus,detect-us", 50000, &priv->detect_us,
				 cs42l43_accdet_us, ARRAY_SIZE(cs42l43_accdet_us));
	if (ret < 0)
		goto error;

	hs2 |= ret << CS42L43_AUTO_HSDET_TIME_SHIFT;

	priv->bias_low = device_property_read_bool(cs42l43->dev, "cirrus,bias-low");

	ret = cs42l43_find_index(priv, "cirrus,bias-ramp-ms", 170,
				 &priv->bias_ramp_ms, cs42l43_accdet_ramp_ms,
				 ARRAY_SIZE(cs42l43_accdet_ramp_ms));
	if (ret < 0)
		goto error;

	hs2 |= ret << CS42L43_HSBIAS_RAMP_SHIFT;

	ret = cs42l43_find_index(priv, "cirrus,bias-sense-microamp", 14,
				 &priv->bias_sense_ua, cs42l43_accdet_bias_sense,
				 ARRAY_SIZE(cs42l43_accdet_bias_sense));
	if (ret < 0)
		goto error;

	if (priv->bias_sense_ua)
		autocontrol |= ret << CS42L43_HSBIAS_SENSE_TRIP_SHIFT;

	if (!device_property_read_bool(cs42l43->dev, "cirrus,button-automute"))
		autocontrol |= CS42L43_S0_AUTO_ADCMUTE_DISABLE_MASK;

	ret = device_property_read_u32(cs42l43->dev, "cirrus,tip-debounce-ms",
				       &priv->tip_debounce_ms);
	if (ret < 0 && ret != -EINVAL) {
		dev_err(priv->dev, "Property cirrus,tip-debounce-ms malformed: %d\n", ret);
		goto error;
	}

	/* This tip sense invert is set normally, as TIPSENSE_INV already inverted */
	if (device_property_read_bool(cs42l43->dev, "cirrus,tip-invert"))
		autocontrol |= 0x1 << CS42L43_JACKDET_INV_SHIFT;

	if (device_property_read_bool(cs42l43->dev, "cirrus,tip-disable-pullup"))
		autocontrol |= 0x1 << CS42L43_JACKDET_MODE_SHIFT;
	else
		autocontrol |= 0x3 << CS42L43_JACKDET_MODE_SHIFT;

	ret = cs42l43_find_index(priv, "cirrus,tip-fall-db-ms", 500,
				 &priv->tip_fall_db_ms, cs42l43_accdet_db_ms,
				 ARRAY_SIZE(cs42l43_accdet_db_ms));
	if (ret < 0)
		goto error;

	tip_deb |= ret << CS42L43_TIPSENSE_FALLING_DB_TIME_SHIFT;

	ret = cs42l43_find_index(priv, "cirrus,tip-rise-db-ms", 500,
				 &priv->tip_rise_db_ms, cs42l43_accdet_db_ms,
				 ARRAY_SIZE(cs42l43_accdet_db_ms));
	if (ret < 0)
		goto error;

	tip_deb |= ret << CS42L43_TIPSENSE_RISING_DB_TIME_SHIFT;

	if (device_property_read_bool(cs42l43->dev, "cirrus,use-ring-sense")) {
		unsigned int ring_deb = 0;

Annotation

Implementation Notes