-/* $OpenBSD: tascodec.c,v 1.4 2022/07/25 16:35:41 kettenis Exp $ */
+/* $OpenBSD: tascodec.c,v 1.5 2022/09/02 16:53:28 kettenis Exp $ */
/*
* Copyright (c) 2022 Mark Kettenis <kettenis@openbsd.org>
*
#define TDM_CFG1_RX_EDGE (1 << 0)
#define TDM_CFG2 0x0c
#define TDM_CFG2_SCFG_MASK (3 << 4)
+#define TDM_CFG2_SCFG_MONO_LEFT (1 << 4)
+#define TDM_CFG2_SCFG_MONO_RIGHT (2 << 4)
#define TDM_CFG2_SCFG_STEREO_DOWNMIX (3 << 4)
+#define TDM_CFG3 0x0d
+#define TDM_CFG3_RX_SLOT_R_MASK 0xf0
+#define TDM_CFG3_RX_SLOT_R_SHIFT 4
+#define TDM_CFG3_RX_SLOT_L_MASK 0x0f
+#define TDM_CFG3_RX_SLOT_L_SHIFT 0
struct tascodec_softc {
struct device sc_dev;
};
int tascodec_set_format(void *, uint32_t, uint32_t, uint32_t);
+int tascodec_set_tdm_slot(void *, int);
int tascodec_set_port(void *, mixer_ctrl_t *);
int tascodec_get_port(void *, mixer_ctrl_t *);
sc->sc_dai.dd_cookie = sc;
sc->sc_dai.dd_hw_if = &tascodec_hw_if;
sc->sc_dai.dd_set_format = tascodec_set_format;
+ sc->sc_dai.dd_set_tdm_slot = tascodec_set_tdm_slot;
dai_register(&sc->sc_dai);
}
return 0;
}
+int
+tascodec_set_tdm_slot(void *cookie, int slot)
+{
+ struct tascodec_softc *sc = cookie;
+ uint8_t cfg2, cfg3;
+
+ if (slot < 0 || slot >= 16)
+ return EINVAL;
+
+ cfg2 = tascodec_read(sc, TDM_CFG2);
+ cfg3 = tascodec_read(sc, TDM_CFG3);
+ cfg2 &= ~TDM_CFG2_SCFG_MASK;
+ cfg2 |= TDM_CFG2_SCFG_MONO_LEFT;
+ cfg3 &= ~TDM_CFG3_RX_SLOT_L_MASK;
+ cfg3 |= slot << TDM_CFG3_RX_SLOT_L_SHIFT;
+ tascodec_write(sc, TDM_CFG2, cfg2);
+ tascodec_write(sc, TDM_CFG3, cfg3);
+
+ return 0;
+}
+
/*
* Mixer controls; the gain of the TAS2770 is determined by the
* amplifier gain and digital volume control setting, but we only
-/* $OpenBSD: ofw_misc.h,v 1.24 2022/03/21 19:22:40 miod Exp $ */
+/* $OpenBSD: ofw_misc.h,v 1.25 2022/09/02 16:53:28 kettenis Exp $ */
/*
* Copyright (c) 2017-2021 Mark Kettenis
*
const void *dd_hw_if;
int (*dd_set_format)(void *, uint32_t, uint32_t, uint32_t);
int (*dd_set_sysclk)(void *, uint32_t);
+ int (*dd_set_tdm_slot)(void *, int);
LIST_ENTRY(dai_device) dd_list;
uint32_t dd_phandle;