mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-17 14:48:20 +00:00
dde_bsd: query initial head-phone state
Account for the situation where the driver is started while the HP is already plugged in and configure the mixer accordingly. Thanks to Peter for the patch. Issue #3929.
This commit is contained in:
committed by
Christian Helmuth
parent
1b4444ce9e
commit
b6912a3d87
@ -216,7 +216,7 @@ static bool set_mixer_value(Mixer &mixer, char const * const field,
|
||||
}
|
||||
|
||||
|
||||
static char const *get_mixer_value(mixer_devinfo_t *info)
|
||||
static char const *get_mixer_value(mixer_devinfo_t const *info)
|
||||
{
|
||||
static char buffer[128];
|
||||
|
||||
@ -272,6 +272,33 @@ static char const *get_mixer_value(mixer_devinfo_t *info)
|
||||
}
|
||||
|
||||
|
||||
static bool headphone_plugged()
|
||||
{
|
||||
for (unsigned i = 0; i < mixer.num; i++) {
|
||||
mixer_devinfo_t const &info = mixer.info[i];
|
||||
|
||||
if (info.type == AUDIO_MIXER_CLASS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned const mixer_class = info.mixer_class;
|
||||
char const * const class_name = mixer.info[mixer_class].label.name;
|
||||
char const * const name = info.label.name;
|
||||
|
||||
Genode::String<64> const control { class_name, ".", name };
|
||||
if (control != "outputs.hp_sense") {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto const result = get_mixer_value(&info);
|
||||
|
||||
return Genode::strcmp("plugged", result) == 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static void dump_mixer(Mixer const &mixer)
|
||||
{
|
||||
Genode::log("--- mixer information ---");
|
||||
@ -406,6 +433,8 @@ static bool configure_audio_device(Genode::Env &env, dev_t dev, Genode::Xml_node
|
||||
|
||||
configure_mixer(env, mixer, config);
|
||||
|
||||
notify_hp_sense(headphone_plugged() ? 1: 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -561,6 +590,12 @@ 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");
|
||||
}
|
||||
|
||||
|
||||
/*****************************
|
||||
** private Audio namespace **
|
||||
*****************************/
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2017 Genode Labs GmbH
|
||||
* Copyright (C) 2014-2020 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
@ -28,6 +28,7 @@
|
||||
|
||||
void notify_play();
|
||||
void notify_record();
|
||||
void notify_hp_sense(int const);
|
||||
|
||||
|
||||
/*****************
|
||||
|
Reference in New Issue
Block a user