/* The set of sample rates that can be supported depends on the * MCLK supplied to the CODEC - enforce this.
*/ if (!wm8523->sysclk) {
dev_err(component->dev, "No MCLK configured, call set_sysclk() on init\n"); return -EINVAL;
}
/* Find a supported LRCLK ratio */ for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) { if (wm8523->sysclk / params_rate(params) ==
lrclk_ratios[i].ratio) break;
}
/* Should never happen, should be handled by constraints */ if (i == ARRAY_SIZE(lrclk_ratios)) {
dev_err(component->dev, "MCLK/fs ratio %d unsupported\n",
wm8523->sysclk / params_rate(params)); return -EINVAL;
}
if (aifctrl1 & WM8523_AIF_MSTR) { /* Find a fs->bclk ratio */ for (i = 0; i < ARRAY_SIZE(bclk_ratios); i++) if (params_width(params) * 2 <= bclk_ratios[i].ratio) break;
if (i == ARRAY_SIZE(bclk_ratios)) {
dev_err(component->dev, "No matching BCLK/fs ratio for word length %d\n",
params_width(params)); return -EINVAL;
}
staticint wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsignedint freq, int dir)
{ struct snd_soc_component *component = codec_dai->component; struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component); unsignedint val; int i;
wm8523->sysclk = freq;
wm8523->rate_constraint.count = 0; for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) {
val = freq / lrclk_ratios[i].ratio; /* Check that it's a standard rate since core can't * cope with others and having the odd rates confuses * constraint matching.
*/ switch (val) { case 8000: case 11025: case 16000: case 22050: case 32000: case 44100: case 48000: case 64000: case 88200: case 96000: case 176400: case 192000:
dev_dbg(component->dev, "Supported sample rate: %dHz\n",
val);
wm8523->rate_constraint_list[i] = val;
wm8523->rate_constraint.count++; break; default:
dev_dbg(component->dev, "Skipping sample rate: %dHz\n",
val);
}
}
/* Need at least one supported rate... */ if (wm8523->rate_constraint.count == 0) return -EINVAL;
case SND_SOC_BIAS_PREPARE: /* Full power on */
snd_soc_component_update_bits(component, WM8523_PSCTRL1,
WM8523_SYS_ENA_MASK, 3); break;
case SND_SOC_BIAS_STANDBY: if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies),
wm8523->supplies); if (ret != 0) {
dev_err(component->dev, "Failed to enable supplies: %d\n",
ret); return ret;
}
/* Sync back default/cached values */
regcache_sync(wm8523->regmap);
/* Initial power up */
snd_soc_component_update_bits(component, WM8523_PSCTRL1,
WM8523_SYS_ENA_MASK, 1);
msleep(100);
}
/* Power up to mute */
snd_soc_component_update_bits(component, WM8523_PSCTRL1,
WM8523_SYS_ENA_MASK, 2);
break;
case SND_SOC_BIAS_OFF: /* The chip runs through the power down sequence for us. */
snd_soc_component_update_bits(component, WM8523_PSCTRL1,
WM8523_SYS_ENA_MASK, 0);
msleep(100);
wm8523->regmap = devm_regmap_init_i2c(i2c, &wm8523_regmap); if (IS_ERR(wm8523->regmap)) {
ret = PTR_ERR(wm8523->regmap);
dev_err(&i2c->dev, "Failed to create regmap: %d\n", ret); return ret;
}
for (i = 0; i < ARRAY_SIZE(wm8523->supplies); i++)
wm8523->supplies[i].supply = wm8523_supply_names[i];
ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8523->supplies),
wm8523->supplies); if (ret != 0) {
dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); return ret;
}
ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies),
wm8523->supplies); if (ret != 0) {
dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); return ret;
}
ret = regmap_read(wm8523->regmap, WM8523_DEVICE_ID, &val); if (ret < 0) {
dev_err(&i2c->dev, "Failed to read ID register\n"); goto err_enable;
} if (val != 0x8523) {
dev_err(&i2c->dev, "Device is not a WM8523, ID is %x\n", ret);
ret = -EINVAL; goto err_enable;
}
ret = regmap_read(wm8523->regmap, WM8523_REVISION, &val); if (ret < 0) {
dev_err(&i2c->dev, "Failed to read revision register\n"); goto err_enable;
}
dev_info(&i2c->dev, "revision %c\n",
(val & WM8523_CHIP_REV_MASK) + 'A');
ret = regmap_write(wm8523->regmap, WM8523_DEVICE_ID, 0x8523); if (ret != 0) {
dev_err(&i2c->dev, "Failed to reset device: %d\n", ret); goto err_enable;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.