Module Name: src
Committed By: jmcneill
Date: Sat Oct 29 19:07:39 UTC 2022
Modified Files:
src/sys/arch/arm/sunxi: sun8i_codec.c
Log Message:
sun8icodec: Update for binding spec changes.
The allwinner,sun8i-a33-codec binding spec has changed[1] to allow for
#sound-dai-cells to be either 0 or 1, to allow exporting multiple DAIs
from the codec.
This change updates the driver to allow #sound-dai-cells of either 0 or 1
while still only supporting AIF1 for the time being.
[1]
https://github.com/torvalds/linux/commit/880e007f15a31f446b9e1713720c6ae5a539f3f4
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sun8i_codec.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/arm/sunxi/sun8i_codec.c
diff -u src/sys/arch/arm/sunxi/sun8i_codec.c:1.9 src/sys/arch/arm/sunxi/sun8i_codec.c:1.10
--- src/sys/arch/arm/sunxi/sun8i_codec.c:1.9 Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/sunxi/sun8i_codec.c Sat Oct 29 19:07:39 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: sun8i_codec.c,v 1.9 2021/01/27 03:10:20 thorpej Exp $ */
+/* $NetBSD: sun8i_codec.c,v 1.10 2022/10/29 19:07:39 jmcneill Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sun8i_codec.c,v 1.9 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun8i_codec.c,v 1.10 2022/10/29 19:07:39 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -174,11 +174,31 @@ static audio_dai_tag_t
sun8i_codec_dai_get_tag(device_t dev, const void *data, size_t len)
{
struct sun8i_codec_softc * const sc = device_private(dev);
+ const u_int sound_dai_cells = len / 4;
- if (len != 4)
- return NULL;
+ KASSERT(sound_dai_cells > 0);
- return &sc->sc_dai;
+ /*
+ * This driver only supports AIF1 with CPU DAI at the moment.
+ * When #sound-dai-cells is 0, return this tag. When #sound-dai-cells
+ * is 1, return this tag only when the second cell contains the
+ * value 0.
+ *
+ * Update this when support for multiple interfaces is added to
+ * this driver.
+ */
+ if (sound_dai_cells == 1) {
+ return &sc->sc_dai;
+ }
+
+ if (sound_dai_cells == 2) {
+ const u_int iface = be32dec((const u_int *)data + 1);
+ if (iface == 0) {
+ return &sc->sc_dai;
+ }
+ }
+
+ return NULL;
}
static struct fdtbus_dai_controller_func sun8i_codec_dai_funcs = {