* $WIZ$ type = "enum"
* $WIZ$ value_list = "wm8731_bypass"
*/
-#define CONFIG_WM8731_BYPASS WM8731_BYPASS
+#define CONFIG_WM8731_BYPASS WM8731_DACSEL
/**
* Analog control: Side tone attenuation
*/
#define CONFIG_WM8731_SIDEATT WM8731_SIDEATT_6dB
+
+/**
+ * Digital Audio interface format.
+ * $WIZ$ type = "enum"
+ * $WIZ$ value_list = "wm8731_fmt"
+ */
+#define CONFIG_WM8731_INTERFACE_FORMAT WM8731_FORMAT_I2S
+
+/**
+ * Digital Audio data bit length.
+ * $WIZ$ type = "enum"
+ * $WIZ$ value_list = "wm8731_databit"
+ */
+#define CONFIG_WM8731_IWL_BITS WM8731_IWL_16_BIT
+
+/**
+ * Enable Master mode.
+ * $WIZ$ type = "boolean"
+ */
+#define CONFIG_WM8731_MS 0
+
+
+/**
+ * Data sampling rate, refer to datasheet for this value.
+ * $WIZ$ type = "hex"
+ */
+#define CONFIG_WM8731_SAMPLING_RATES 0x6
+
#endif /* CFG_WM8731_H */
/* Configure the codec */
wm8731_write(ctx, WM8731_REG_DIGITAL_PATH_CTRL, CONFIG_WM8731_DEEMP | CONFIG_WM8731_DAPC |
(CONFIG_WM8731_DACMU << WM8731_DACMU));
- wm8731_write(ctx, WM8731_REG_ANALOGUE_PATH_CTRL, (CONFIG_WM8731_MICBOOST ? WM8731_MICBOOST : ~WM8731_MICBOOST) |
+ wm8731_write(ctx, WM8731_REG_ANALOGUE_PATH_CTRL, (CONFIG_WM8731_MICBOOST ? BV(WM8731_MICBOOST) : ~BV(WM8731_MICBOOST)) |
CONFIG_WM8731_INSEL | CONFIG_WM8731_BYPASS | CONFIG_WM8731_SIDEATT);
-
- wm8731_write(ctx, WM8731_REG_DA_INTERFACE_FORMAT, 0x2);
- wm8731_write(ctx, WM8731_REG_SAMPLECTRL, 0x6);
-
- wm8731_write(ctx, WM8731_REG_ACTIVE_CTRL, 1);
+ wm8731_write(ctx, WM8731_REG_DA_INTERFACE_FORMAT, CONFIG_WM8731_INTERFACE_FORMAT | CONFIG_WM8731_IWL_BITS |
+ (CONFIG_WM8731_MS ? BV(WM8731_MS_BIT) : ~BV(WM8731_MS_BIT)));
+ wm8731_write(ctx, WM8731_REG_SAMPLECTRL, CONFIG_WM8731_SAMPLING_RATES);
/* By default we turn on all devices and disable only the outclock */
+ wm8731_write(ctx, WM8731_REG_ACTIVE_CTRL, 1);
wm8731_write(ctx, WM8731_REG_PWDOWN_CTRL, 0x47);
}
/* Analogue audio path control register*/
#define WM8731_REG_ANALOGUE_PATH_CTRL 0x4
-#define WM8731_MICBOOST BV(0) // Microphone Input Level Boost
+#define WM8731_MICBOOST 0 // Microphone Input Level Boost
#define WM8731_MUTEMIC 1 // Line input Mute to ADC
/**
* Input selector
/* Interface format register*/
#define WM8731_REG_DA_INTERFACE_FORMAT 0x7
+/**
+ * Audio format
+ * $WIZ$ wm8731_fmt = "WM8731_FORMAT_MSB_LEFT_JUSTIFIED", "WM8731_FORMAT_MSB_RIGHT_JUSTIFIED", "WM8731_FORMAT_I2S", "WM8731_FORMAT_DSP"
+ */
#define WM8731_FORMAT_BITS_MASK 0x3 // Format
#define WM8731_FORMAT_MSB_LEFT_JUSTIFIED 0x0 // MSB-First, left justified
#define WM8731_FORMAT_MSB_RIGHT_JUSTIFIED 0x1 // MSB-First, right justified
#define WM8731_FORMAT_I2S 0x2 //I2S Format, MSB-First left-1 justified
#define WM8731_FORMAT_DSP 0x3 //DSP Mode, frame sync + 2 data packed words
+/**
+ * Audio format
+ * $WIZ$ wm8731_databit = "WM8731_IWL_16_BIT", "WM8731_IWL_20_BIT", "WM8731_IWL_24_BIT", "WM8731_IWL_32_BIT"
+ */
#define WM8731_IWL_BITS 0xC // Input audio data bit length select
#define WM8731_IWL_16_BIT 0x0 // 16 bit
#define WM8731_IWL_20_BIT 0x4 // 20 bit