From ac423ee76949d5e7068c197d8d4c1ca25e3b9412 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sun, 6 Aug 2017 12:43:39 -0700 Subject: [PATCH] Audio: Add codec config methods for external I2S master. --- firmware/common/ak4951.cpp | 6 ++++++ firmware/common/ak4951.hpp | 1 + firmware/common/wm8731.cpp | 12 ++++++++++++ firmware/common/wm8731.hpp | 1 + 4 files changed, 20 insertions(+) diff --git a/firmware/common/ak4951.cpp b/firmware/common/ak4951.cpp index 94f8f430..3556e0a5 100644 --- a/firmware/common/ak4951.cpp +++ b/firmware/common/ak4951.cpp @@ -46,6 +46,12 @@ void AK4951::configure_digital_interface_external_slave() { update(Register::PowerManagement2); } +void AK4951::configure_digital_interface_external_master() { + map.r.power_management_2.MS = 1; // Master mode + map.r.power_management_2.PMPLL = 0; // EXT mode + update(Register::PowerManagement2); +} + void AK4951::init() { reset(); diff --git a/firmware/common/ak4951.hpp b/firmware/common/ak4951.hpp index a1f4254b..ab7d3b81 100644 --- a/firmware/common/ak4951.hpp +++ b/firmware/common/ak4951.hpp @@ -866,6 +866,7 @@ private: void configure_digital_interface_i2s(); void configure_digital_interface_external_slave(); + void configure_digital_interface_external_master(); void set_digtal_volume_control(const reg_t value); void set_dac_power(const bool enable); void set_headphone_power(const bool enable); diff --git a/firmware/common/wm8731.cpp b/firmware/common/wm8731.cpp index 2965ad26..9bd73977 100644 --- a/firmware/common/wm8731.cpp +++ b/firmware/common/wm8731.cpp @@ -37,6 +37,18 @@ void WM8731::configure_interface_i2s_slave() { }); } +void WM8731::configure_interface_i2s_master() { + write(DigitalAudioInterfaceFormat { + .format = 2, + .iwl = 0, + .lrp = 0, + .lrswap = 0, + .ms = 1, + .bclkinv = 0, + .reserved0 = 0, + }); +} + void WM8731::init() { reset(); diff --git a/firmware/common/wm8731.hpp b/firmware/common/wm8731.hpp index f4128658..0d1b15b7 100644 --- a/firmware/common/wm8731.hpp +++ b/firmware/common/wm8731.hpp @@ -376,6 +376,7 @@ private: volume_t headphone_volume = -60.0_dB; void configure_interface_i2s_slave(); + void configure_interface_i2s_master(); bool write(const Register reg);