summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2018-11-29 14:13:39 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-12-04 00:11:29 -0800
commit213bed526730738b6b62e4680317241c00d1f89d (patch)
tree809c8a11baca63c9ee5433abfd6f98edac6b85f3
parent27f5840ddd13333176dfebded72cb32703744e10 (diff)
downloadchrome-ec-213bed526730738b6b62e4680317241c00d1f89d.tar.gz
wov: Split i2s_set_config into 2 functions
This API was intended to be used to set both the I2S format and BCLK rate. However, the audio codec API has separate methods to set each of these parameters. This CL splits wov_i2s_set_config() into 2 functions: wov_i2s_set_fmt() - called by codec_i2s_set_fmt host command wov_i2s_set_bclk() - called by codec_i2s_set_bclk host command BRANCH=none BUG=b:116766596 TEST=On cheza verifed recording works using the following kernel commands and the loading the audio file into audacity. amixer -c 0 cset iface=MIXER,name='MultiMedia1 Mixer SEC_MI2S_TX' on amixer -c0 cset numid=27 30,30 arecord -D hw:0,0 -f dat /tmp/rec.wav -d 5 Change-Id: Id840ecf1b4c00762091d71b6cc10b00acc774eb2 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1356182 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: CH Lin <chlin56@nuvoton.com> Reviewed-by: Wai-Hong Tam <waihong@google.com>
-rw-r--r--chip/npcx/wov.c29
-rw-r--r--chip/npcx/wov_chip.h16
2 files changed, 34 insertions, 11 deletions
diff --git a/chip/npcx/wov.c b/chip/npcx/wov.c
index a4f03a25e8..c18ef01c0f 100644
--- a/chip/npcx/wov.c
+++ b/chip/npcx/wov.c
@@ -1685,26 +1685,39 @@ int wov_get_vad_sensitivity(void)
}
/**
- * Configure I2S bus. (Sample rate and size are determined via common
+ * Configure I2S bus format. (Sample rate and size are determined via common
* config functions.)
*
- * @param i2s_clock - I2S clock frequency in Hz (needed in order to
- * configure the internal PLL for 12MHz)
* @param format - one of the following: I2S mode, Right Justified mode,
* Left Justified mode, PCM A Audio, PCM B Audio and
* Time Division Multiplexing
* @return EC error code.
*/
-void wov_set_i2s_config(uint32_t i2s_clock, enum wov_dai_format format)
+void wov_set_i2s_fmt(enum wov_dai_format format)
{
if (wov_conf.mode != WOV_MODE_OFF)
return;
- wov_conf.i2s_clock = i2s_clock;
wov_conf.dai_format = format;
}
/**
+ * Configure I2S bus clock. (Sample rate and size are determined via common
+ * config functions.)
+ *
+ * @param i2s_clock - I2S clock frequency in Hz (needed in order to
+ * configure the internal PLL for 12MHz)
+ * @return EC error code.
+ */
+void wov_set_i2s_bclk(uint32_t i2s_clock)
+{
+ if (wov_conf.mode != WOV_MODE_OFF)
+ return;
+
+ wov_conf.i2s_clock = i2s_clock;
+}
+
+/**
* Configure I2S bus. (Sample rate and size are determined via common
* config functions.)
*
@@ -1871,7 +1884,8 @@ static int command_wov(int argc, char **argv)
else
return EC_ERROR_INVAL;
- wov_set_i2s_config(bit_clk, i2s_fmt);
+ wov_set_i2s_fmt(i2s_fmt);
+ wov_set_i2s_bclk(bit_clk);
return EC_SUCCESS;
}
if (strcasecmp(argv[1], "cfgfmt") == 0) {
@@ -1890,7 +1904,8 @@ static int command_wov(int argc, char **argv)
else
return EC_ERROR_INVAL;
- wov_set_i2s_config(bit_clk, i2s_fmt);
+ wov_set_i2s_fmt(i2s_fmt);
+ wov_set_i2s_bclk(bit_clk);
return EC_SUCCESS;
}
if (strcasecmp(argv[1], "cfgdckV") == 0) {
diff --git a/chip/npcx/wov_chip.h b/chip/npcx/wov_chip.h
index efd5863975..dcc17dcf77 100644
--- a/chip/npcx/wov_chip.h
+++ b/chip/npcx/wov_chip.h
@@ -388,17 +388,25 @@ int wov_set_vad_sensitivity(int sensitivity_db);
int wov_get_vad_sensitivity(void);
/**
- * Configure I2S bus. (Sample rate and size are determined via common
+ * Configure I2S bus format. (Sample rate and size are determined via common
* config functions.)
*
- * @param i2s_clock - I2S clock frequency in Hz (needed in order to
- * configure the internal PLL for 12MHz)
* @param format - one of the following: I2S mode, Right Justified mode,
* Left Justified mode, PCM A Audio, PCM B Audio and
* Time Division Multiplexing
* @return EC error code.
*/
-void wov_set_i2s_config(uint32_t i2s_clock, enum wov_dai_format format);
+void wov_set_i2s_fmt(enum wov_dai_format format);
+
+/**
+ * Configure I2S bus clock. (Sample rate and size are determined via common
+ * config functions.)
+ *
+ * @param i2s_clock - I2S clock frequency in Hz (needed in order to
+ * configure the internal PLL for 12MHz)
+ * @return EC error code.
+ */
+void wov_set_i2s_bclk(uint32_t i2s_clock);
/**
* Configure I2S bus. (Sample rate and size are determined via common