sound/soc/codecs/rt5514.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/rt5514.c
Extension
.c
Size
39508 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 (rt5514->dsp_enabled) {
			if (rt5514->pdata.dsp_calib_clk_name &&
				!IS_ERR(rt5514->dsp_calib_clk)) {
				if (clk_set_rate(rt5514->dsp_calib_clk,
					rt5514->pdata.dsp_calib_clk_rate))
					dev_err(component->dev,
						"Can't set rate for mclk");

				if (clk_prepare_enable(rt5514->dsp_calib_clk))
					dev_err(component->dev,
						"Can't enable dsp_calib_clk");

				rt5514_calibration(rt5514, true);

				msleep(20);
#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI)
				rt5514_spi_burst_read(RT5514_PLL3_CALIB_CTRL6 |
					RT5514_DSP_MAPPING, buf, sizeof(buf));
#else
				dev_err(component->dev, "There is no SPI driver for"
					" loading the firmware\n");
				memset(buf, 0, sizeof(buf));
#endif
				rt5514->pll3_cal_value = buf[0] | buf[1] << 8 |
					buf[2] << 16 | buf[3] << 24;

				rt5514_calibration(rt5514, false);
				clk_disable_unprepare(rt5514->dsp_calib_clk);
			}

			rt5514_enable_dsp_prepare(rt5514);

			request_firmware(&fw, RT5514_FIRMWARE1, component->dev);
			if (fw) {
#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI)
				rt5514_spi_burst_write(0x4ff60000, fw->data,
					((fw->size/8)+1)*8);
#else
				dev_err(component->dev, "There is no SPI driver for"
					" loading the firmware\n");
#endif
				release_firmware(fw);
				fw = NULL;
			}

			request_firmware(&fw, RT5514_FIRMWARE2, component->dev);
			if (fw) {
#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI)
				rt5514_spi_burst_write(0x4ffc0000, fw->data,
					((fw->size/8)+1)*8);
#else
				dev_err(component->dev, "There is no SPI driver for"
					" loading the firmware\n");
#endif
				release_firmware(fw);
				fw = NULL;
			}

			/* DSP run */
			regmap_write(rt5514->i2c_regmap, 0x18002f00,
				0x00055148);

			if (rt5514->pdata.dsp_calib_clk_name &&
				!IS_ERR(rt5514->dsp_calib_clk)) {
				msleep(20);

				regmap_write(rt5514->i2c_regmap, 0x1800211c,
					rt5514->pll3_cal_value);
				regmap_write(rt5514->i2c_regmap, 0x18002124,
					0x00220012);
				regmap_write(rt5514->i2c_regmap, 0x18002124,
					0x80220042);
				regmap_write(rt5514->i2c_regmap, 0x18002124,
					0xe0220042);
			}
		} else {
			regmap_multi_reg_write(rt5514->i2c_regmap,
				rt5514_i2c_patch, ARRAY_SIZE(rt5514_i2c_patch));
			regcache_mark_dirty(rt5514->regmap);
			regcache_sync(rt5514->regmap);
		}
	}

	return 1;
}

static const struct snd_kcontrol_new rt5514_snd_controls[] = {
	SOC_DOUBLE_TLV("MIC Boost Volume", RT5514_ANA_CTRL_MICBST,
		RT5514_SEL_BSTL_SFT, RT5514_SEL_BSTR_SFT, 8, 0, bst_tlv),
	SOC_DOUBLE_R_TLV("ADC1 Capture Volume", RT5514_DOWNFILTER0_CTRL1,

Annotation

Implementation Notes