summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2022-12-05 07:30:52 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2022-12-05 07:30:52 +0000
commit4f927caa8fe965af3d2cfaa7c55f293d92b6d500 (patch)
treec9f313c343c10ade56c5c4c4d83c7c0d588c12ed /sys/arch
parent1c8462390a1e5c6b86c5107db6c81cb0905bcba9 (diff)
Calculate the bit clock based on number of channels, bytes/sample and
sample rate instead of relying on the "mclk-fs" property. This property is no longer present in upstream device trees. ok ratchov@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/arm64/dev/aplaudio.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/sys/arch/arm64/dev/aplaudio.c b/sys/arch/arm64/dev/aplaudio.c
index 9f097b752fe..6c3665440ae 100644
--- a/sys/arch/arm64/dev/aplaudio.c
+++ b/sys/arch/arm64/dev/aplaudio.c
@@ -1,4 +1,4 @@
-/* $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>
@@ -36,8 +36,6 @@
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];
};
@@ -155,8 +153,6 @@ aplaudio_attach(struct device *parent, struct device *self, void *aux)
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;
@@ -274,24 +270,24 @@ aplaudio_set_params(void *cookie, int setmode, int usemode,
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)
@@ -300,10 +296,8 @@ aplaudio_set_params(void *cookie, int setmode, int usemode,
}
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;
}