summaryrefslogtreecommitdiff
path: root/include/audio_codec.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/audio_codec.h')
-rw-r--r--include/audio_codec.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/include/audio_codec.h b/include/audio_codec.h
index ab1c65ae61..29a61ed817 100644
--- a/include/audio_codec.h
+++ b/include/audio_codec.h
@@ -58,4 +58,61 @@ int audio_codec_register_shm(uint8_t shm_id, uint8_t cap,
*/
int audio_codec_memmap_ap_to_ec(uintptr_t ap_addr, uintptr_t *ec_addr);
+
+/*
+ * DMIC abstract layer
+ */
+
+/*
+ * Gets the maximum possible gain value. All channels share the same maximum
+ * gain value [0, max].
+ *
+ * The gain has no unit and should fit in a scale to represent relative dB.
+ *
+ * For example, suppose maximum possible gain value is 4, one could define a
+ * mapping:
+ * - 0 => -10 dB
+ * - 1 => -5 dB
+ * - 2 => 0 dB
+ * - 3 => 5 dB
+ * - 4 => 10 dB
+ *
+ * @max_gain is the destination address to put the gain value.
+ *
+ * Returns:
+ * EC_SUCCESS if success.
+ * EC_ERROR_UNKNOWN if internal error.
+ */
+int audio_codec_dmic_get_max_gain(uint8_t *max_gain);
+
+/*
+ * Sets the microphone gain for the specified channel.
+ *
+ * @channel is an integer from enum ec_codec_dmic_channel. The valid range
+ * is [0, 7].
+ * @gain is the target gain for the specified channel. The valid range
+ * is [0, max_gain]. See also audio_codec_dmic_get_max_gain.
+ *
+ * Returns:
+ * EC_SUCCESS if success.
+ * EC_ERROR_UNKNOWN if internal error.
+ * EC_ERROR_INVAL if channel does not look good.
+ * EC_ERROR_INVAL if gain does not look good.
+ */
+int audio_codec_dmic_set_gain_idx(uint8_t channel, uint8_t gain);
+
+/*
+ * Gets the microphone gain of the specified channel.
+ *
+ * @channel is an integer from enum ec_codec_dmic_channel. The valid range
+ * is [0, 7].
+ * @gain is the destination address to put the gain value of the channel.
+ *
+ * Returns:
+ * EC_SUCCESS if success.
+ * EC_ERROR_UNKNOWN if internal error.
+ * EC_ERROR_INVAL if channel does not look good.
+ */
+int audio_codec_dmic_get_gain_idx(uint8_t channel, uint8_t *gain);
+
#endif