diff --git a/repos/dde_bsd/README b/repos/dde_bsd/README index 80a1932b08..50748ddae9 100644 --- a/repos/dde_bsd/README +++ b/repos/dde_bsd/README @@ -74,6 +74,16 @@ Information about the available mixers and settings in general may be obtained by setting the 'verbose' to 'yes' in the config node. +When multiple microphones are present (e.g., internal microphone in a notebook +and a headset with a microphone), the preferred microphone can be configured +using the 'mic_priority' attribute in the '' node. Valid values are +"internal" and "external" (default). + +! + +The example above tells the driver to prioritize the internal microphone over a +headset. + Examples ======== diff --git a/repos/dde_bsd/src/lib/audio/driver.cc b/repos/dde_bsd/src/lib/audio/driver.cc index b30ddd463f..19ade56860 100644 --- a/repos/dde_bsd/src/lib/audio/driver.cc +++ b/repos/dde_bsd/src/lib/audio/driver.cc @@ -41,6 +41,8 @@ static dev_t const mdev = 0xc0; /* /dev/audioctl */ static bool adev_usuable = false; +/* prioritize mic of headset if plugged in over internal mic */ +static bool mic_priority_external = true; static bool drv_loaded() { @@ -389,6 +391,11 @@ static void configure_mixer(Genode::Env &env, Mixer &mixer, Genode::Xml_node con { using namespace Genode; + typedef String<9> Mic_mode; + + Mic_mode mode = config.attribute_value("mic_priority", Mic_mode("external")); + mic_priority_external = (mode == "internal") ? false : true; + config.for_each_sub_node("mixer", [&] (Xml_node node) { typedef String<32> Field; @@ -615,7 +622,8 @@ extern "C" void notify_record() extern "C" void notify_hp_sense(int const sense) { - set_mixer_value(mixer, "record.adc-0:1_source", sense ? "mic2" : "mic"); + set_mixer_value(mixer, "record.adc-0:1_source", + sense && mic_priority_external ? "mic2" : "mic"); report_mixer_state(mixer, nullptr); } @@ -630,6 +638,8 @@ void Audio::update_config(Genode::Env &env, Genode::Xml_node config) if (mixer.info == nullptr) { return; } configure_mixer(env, mixer, config); + + notify_hp_sense(headphone_plugged() ? 1 : 0); }