sound/soc/codecs/rt5660.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/rt5660.c
Extension
.c
Size
38780 bytes
Lines
1351
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 (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_ON) {
			clk_disable_unprepare(rt5660->mclk);
		} else {
			ret = clk_prepare_enable(rt5660->mclk);
			if (ret)
				return ret;
		}
		break;

	case SND_SOC_BIAS_STANDBY:
		if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) {
			snd_soc_component_update_bits(component, RT5660_PWR_ANLG1,
				RT5660_PWR_VREF1 | RT5660_PWR_MB |
				RT5660_PWR_BG | RT5660_PWR_VREF2,
				RT5660_PWR_VREF1 | RT5660_PWR_MB |
				RT5660_PWR_BG | RT5660_PWR_VREF2);
			usleep_range(10000, 15000);
			snd_soc_component_update_bits(component, RT5660_PWR_ANLG1,
				RT5660_PWR_FV1 | RT5660_PWR_FV2,
				RT5660_PWR_FV1 | RT5660_PWR_FV2);
		}
		break;

	case SND_SOC_BIAS_OFF:
		snd_soc_component_update_bits(component, RT5660_GEN_CTRL1,
			RT5660_DIG_GATE_CTRL, 0);
		break;

	default:
		break;
	}

	return 0;
}

static int rt5660_probe(struct snd_soc_component *component)
{
	struct rt5660_priv *rt5660 = snd_soc_component_get_drvdata(component);

	rt5660->component = component;

	return 0;
}

static void rt5660_remove(struct snd_soc_component *component)
{
	snd_soc_component_write(component, RT5660_RESET, 0);
}

#ifdef CONFIG_PM
static int rt5660_suspend(struct snd_soc_component *component)
{
	struct rt5660_priv *rt5660 = snd_soc_component_get_drvdata(component);

	regcache_cache_only(rt5660->regmap, true);
	regcache_mark_dirty(rt5660->regmap);

	return 0;
}

static int rt5660_resume(struct snd_soc_component *component)
{
	struct rt5660_priv *rt5660 = snd_soc_component_get_drvdata(component);

	if (rt5660->pdata.poweroff_codec_in_suspend)
		msleep(350);

	regcache_cache_only(rt5660->regmap, false);
	regcache_sync(rt5660->regmap);

	return 0;
}
#else
#define rt5660_suspend NULL
#define rt5660_resume NULL
#endif

#define RT5660_STEREO_RATES SNDRV_PCM_RATE_8000_192000
#define RT5660_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
			SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)

static const struct snd_soc_dai_ops rt5660_aif_dai_ops = {
	.hw_params = rt5660_hw_params,
	.set_fmt = rt5660_set_dai_fmt,
	.set_sysclk = rt5660_set_dai_sysclk,
	.set_pll = rt5660_set_dai_pll,
};

static struct snd_soc_dai_driver rt5660_dai[] = {
	{

Annotation

Implementation Notes