-/* $OpenBSD: aplaudio.c,v 1.4 2022/10/28 15:09:45 kn Exp $ */
+/* $OpenBSD: aplaudio.c,v 1.5 2022/12/05 07:30:51 kettenis Exp $ */
/*
* Copyright (c) 2022 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2020 Patrick Wildt <patrick@blueri.se>
struct aplaudio_softc {
struct device sc_dev;
- uint32_t sc_mclk_fs;
-
struct dai_device *sc_dai_cpu;
struct dai_device *sc_dai_codec[6];
};
if (count > 1)
aplaudio_set_tdm_slots(sc);
- sc->sc_mclk_fs = OF_getpropint(node, "mclk-fs", 0);
-
/* XXX Parameters are missing from the device tree? */
fmt = DAI_FORMAT_LJ;
pol = 0;
int error;
int i;
- if (sc->sc_mclk_fs) {
- if (setmode & AUMODE_PLAY)
- rate = play->sample_rate * sc->sc_mclk_fs;
- else
- rate = rec->sample_rate * sc->sc_mclk_fs;
+ dai = sc->sc_dai_cpu;
+ hwif = dai->dd_hw_if;
+ if (hwif->set_params) {
+ error = hwif->set_params(dai->dd_cookie,
+ setmode, usemode, play, rec);
+ if (error)
+ return error;
+ }
- for (i = 0; i < nitems(sc->sc_dai_codec); i++) {
- dai = sc->sc_dai_codec[i];
- if (dai == NULL)
- continue;
- if (dai->dd_set_sysclk) {
- error = dai->dd_set_sysclk(dai->dd_cookie, rate);
- if (error)
- return error;
- }
- }
+ if (setmode & AUMODE_PLAY)
+ rate = play->sample_rate * play->channels * play->bps * 8;
+ else
+ rate = rec->sample_rate * rec->channels * rec->bps * 8;
- dai = sc->sc_dai_cpu;
+ for (i = 0; i < nitems(sc->sc_dai_codec); i++) {
+ dai = sc->sc_dai_codec[i];
+ if (dai == NULL)
+ continue;
if (dai->dd_set_sysclk) {
error = dai->dd_set_sysclk(dai->dd_cookie, rate);
if (error)
}
dai = sc->sc_dai_cpu;
- hwif = dai->dd_hw_if;
- if (hwif->set_params) {
- error = hwif->set_params(dai->dd_cookie,
- setmode, usemode, play, rec);
+ if (dai->dd_set_sysclk) {
+ error = dai->dd_set_sysclk(dai->dd_cookie, rate);
if (error)
return error;
}