From: kn Date: Mon, 5 Apr 2021 14:36:18 +0000 (+0000) Subject: Set sysclk before using it X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=071459bed0e07d7e9d23770e16461c86b3753080;p=openbsd Set sysclk before using it simpleaudio_set_params() calls set_params() which reads sysclk off the "i2s_clk" property before it sets that very clock's rate with dd_set_sysclk() (in case there's multiplier specified). Hence reverse the order so set_params() can pick up the newly set rate. The rate is still off on the Pinebook Pro, but I came across this when reading the code; this also matches NetBSD's sys/dev/fdt/ausoc.c r1.6 "Set sysclk rate at set_format time, so the link set_format callback can read the new sysclk". OK kettenis patrick --- diff --git a/sys/dev/fdt/simpleaudio.c b/sys/dev/fdt/simpleaudio.c index 59cda075c0a..055f2e78e10 100644 --- a/sys/dev/fdt/simpleaudio.c +++ b/sys/dev/fdt/simpleaudio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: simpleaudio.c,v 1.1 2020/06/10 23:55:19 patrick Exp $ */ +/* $OpenBSD: simpleaudio.c,v 1.2 2021/04/05 14:36:18 kn Exp $ */ /* * Copyright (c) 2020 Patrick Wildt * @@ -300,24 +300,6 @@ simpleaudio_set_params(void *cookie, int setmode, int usemode, uint32_t rate; int 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 (error) - return error; - } - - dai = sc->sc_dai_codec; - hwif = dai->dd_hw_if; - if (hwif->set_params) { - error = hwif->set_params(dai->dd_cookie, - setmode, usemode, play, rec); - if (error) - return error; - } - if (sc->sc_mclk_fs) { if (setmode & AUMODE_PLAY) rate = play->sample_rate * sc->sc_mclk_fs; @@ -339,6 +321,24 @@ simpleaudio_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 (error) + return error; + } + + dai = sc->sc_dai_codec; + hwif = dai->dd_hw_if; + if (hwif->set_params) { + error = hwif->set_params(dai->dd_cookie, + setmode, usemode, play, rec); + if (error) + return error; + } + return 0; }