switch (samplerate) { case 32000:
sampling_freq = 0x03; break; case 44100:
sampling_freq = 0x00; break; case 48000:
sampling_freq = 0x02; break; case 88200:
sampling_freq = 0x08; break; case 96000:
sampling_freq = 0x0a; break; case 176400:
sampling_freq = 0x0c; break; case 192000:
sampling_freq = 0x0e; break; default:
dev_err(rtd->card->dev, "unsupported samplerate %d\n", samplerate); return -EINVAL;
}
if (samplerate % 16000)
clk_44 = true; /* use 44.1 kHz root frequency */ else
clk_44 = false;
if (!(IS_ERR_OR_NULL(ctx->gpio_44) ||
IS_ERR_OR_NULL(ctx->gpio_48))) { /* * ensure both GPIOs are LOW first, then drive the * relevant one to HIGH
*/ if (clk_44) {
gpiod_set_value_cansleep(ctx->gpio_48, !clk_44);
gpiod_set_value_cansleep(ctx->gpio_44, clk_44);
} else {
gpiod_set_value_cansleep(ctx->gpio_44, clk_44);
gpiod_set_value_cansleep(ctx->gpio_48, !clk_44);
}
}
snd_soc_dai_set_clkdiv(codec_dai, WM8804_MCLK_DIV, mclk_div);
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, sysclk, mclk_freq); if (ret < 0) {
dev_err(rtd->card->dev, "Failed to set WM8804 PLL\n"); return ret;
}
ret = snd_soc_dai_set_sysclk(codec_dai, WM8804_TX_CLKSRC_PLL,
sysclk, SND_SOC_CLOCK_OUT); if (ret < 0) {
dev_err(rtd->card->dev, "Failed to set WM8804 SYSCLK: %d\n", ret); return ret;
}
/* set sampling frequency status bits */
snd_soc_component_update_bits(codec, WM8804_SPDTX4, 0x0f,
sampling_freq);
/* i2c-<HID>:00 with HID being 8 chars */ staticchar codec_name[SND_ACPI_I2C_ID_LEN];
/* * to control the HifiBerry Digi+ PRO, it's required to toggle GPIO to * select the clock source. On the Up2 board, this means * Pin29/BCM5/Linux GPIO 430 and Pin 31/BCM6/ Linux GPIO 404. * * Using the ACPI device name is not very nice, but since we only use * the value for the Up2 board there is no risk of conflict with other * platforms.
*/
staticstruct gpiod_lookup_table up2_gpios_table = { /* .dev_id is set during probe */
.table = {
GPIO_LOOKUP("INT3452:01", 73, "BCM-GPIO5", GPIO_ACTIVE_HIGH),
GPIO_LOOKUP("INT3452:01", 74, "BCM-GPIO6", GPIO_ACTIVE_HIGH),
{ },
},
};
staticint sof_wm8804_probe(struct platform_device *pdev)
{ struct snd_soc_card *card; struct snd_soc_acpi_mach *mach; struct sof_card_private *ctx; struct acpi_device *adev; int dai_index = 0; int ret; int i;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM;
if (sof_wm8804_quirk & SOF_WM8804_UP2_QUIRK) {
up2_gpios_table.dev_id = dev_name(&pdev->dev);
gpiod_add_lookup_table(&up2_gpios_table);
/* * The gpios are required for specific boards with * local oscillators, and optional in other cases. * Since we can't identify when they are needed, use * the GPIO as non-optional
*/
ctx->gpio_44 = devm_gpiod_get(&pdev->dev, "BCM-GPIO5",
GPIOD_OUT_LOW); if (IS_ERR(ctx->gpio_44)) {
ret = PTR_ERR(ctx->gpio_44);
dev_err(&pdev->dev, "could not get BCM-GPIO5: %d\n",
ret); return ret;
}
ctx->gpio_48 = devm_gpiod_get(&pdev->dev, "BCM-GPIO6",
GPIOD_OUT_LOW); if (IS_ERR(ctx->gpio_48)) {
ret = PTR_ERR(ctx->gpio_48);
dev_err(&pdev->dev, "could not get BCM-GPIO6: %d\n",
ret); return ret;
}
}
/* fix index of codec dai */ for (i = 0; i < ARRAY_SIZE(dailink); i++) { if (!strcmp(dailink[i].codecs->name, "i2c-1AEC8804:00")) {
dai_index = i; break;
}
}
/* fixup codec name based on HID */
adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); if (adev) {
snprintf(codec_name, sizeof(codec_name), "%s%s", "i2c-", acpi_dev_name(adev));
dailink[dai_index].codecs->name = codec_name;
} else {
dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id); return -ENOENT;
}
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.