#include <cafe/mic.h>

typedef enum {
} mic_state_t;


mic_state_sample_rate Read-only value. DRC microphone sample rate. Always 32,000Hz.
mic_state_gain_db Microphone gain value, in the UAC sense: S7.8 fixed point notation, in units of dB. For a further description, see below.
mic_state_gain_min Read-only value. Minimum gain device supports. Defined in the UAC sense.
mic_state_gain_max Read-only value. Maximum gain device supports. Defined in the UAC sense.
mic_state_gain_step Read-only value. Gain adjustment granularity of the device. Defined in the UAC sense.
mic_state_mute Mute state of the device. Not yet supported.
mic_state_echo_cancellation DRC's microphone echo cancellation on/off state. Applies echo cancellation for DRC speaker output only and not for television speaker output.
mic_state_auto_selection DRC's microphone auto selection on/off. It decides which microphone (internal/external) is used as source device when external microphone is plugged in.
mic_state_digital_gain_db Works like mic_state_gain_db, except that it is applied to the incoming PCM bitstream. Due to an implementation error the gain factor that is applied is twice as great as it should be. E.g., a gain of 0x0600 (6dB) results in a gain factor of 4 instead of the expected value of 2. For a further description, see below.


This structure defines state of the device as described in the table above.

There are two state variables affecting the gain that is applied to the PCM bitstream. mic_state_gain_db is applied in the analog circuits that feed the ADC. The gain applied here has some effect on the quality and functioning of the DRC's echo cancellation since it is applied before the bitstream is put through the echo cancellation system. Conversely, mic_state_digital_gain_db is applied to the PCM bitstream in the host. It applies not only to the microphone signal, but all downstream noise sources, such as preamplifier, quantization, and echo cancellation system's noise. Saturating arithmetic is used when applying the digital gain. The effect of these two state variables is cumulative.

When the DRC is queried for gain values, it may return a value of 0x8000 (short int, becomes 0xFFFF8000 when cast to int) to indicate a device not ready condition. The DRC will return this value for 100s of milliseconds after a headset has been plugged in or removed. Because a headset can be plugged in or removed at any time, software needs to query the current gain value and check for 0x8000 and only program a new gain value if the device is ready. Otherwise, software needs to wait, 100ms intervals are recommended, before repeating the process of getting and then setting a gain value.

See Also


Revision History

2014/04/03 Added paragraph about device not ready.
2014/02/11 Updated description for 'mic_state_echo_cancellation'.
2013/05/08 Automated cleanup pass.
2012/06/08 Update to match SDK 2.06.
2011/12/22 Initial version.