the maxinum limitation of speaker and headphone should be different,so when headphone and speaker auto routes, user will hear too loud sound. This patch added the dynamic control to prevent user's ears be harmed. After some test, select experience value 17/6 as rate. for example: the current register value is 10, output device is headphone. in below test steps, the register value will dynamically changed to: 1) HP removed: 10 * 6 / 10 = 6. 2) HP inserted: 6 * 17 / 10 = 10. HP will not hear a sudden big sound,it's more smooth.
Signed-off-by: xingchao <[email protected]> --- drivers/staging/intel_sst/intelmid_v2_control.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diff --git a/drivers/staging/intel_sst/intelmid_v2_control.c b/drivers/staging/intel_sst/intelmid_v2_control.c index 2010ba6..a7fdc0d 100644 --- a/drivers/staging/intel_sst/intelmid_v2_control.c +++ b/drivers/staging/intel_sst/intelmid_v2_control.c @@ -531,7 +531,25 @@ static int nc_set_selected_output_dev(u8 value) {RMUTE, 0x04, 0x06}, {DRVPOWERCTRL, 0x00, 0x06}, }; - int retval = 0; + struct sc_reg_access hp_spk[] = { + {AUDIOLVOL, 0x0, 0x1f}, + {AUDIORVOL, 0x0, 0x1f}, + }; + + int retval = 0, rate; + + if (snd_pmic_ops_nc.output_dev_id != value) { + sst_sc_reg_access(hp_spk, PMIC_READ, 2); + + if (value == STEREO_HEADPHONE) + rate = 17; + else + rate = 6; + + hp_spk[0].value = hp_spk[0].value * rate / 10; + hp_spk[1].value = hp_spk[1].value * rate / 10; + retval = sst_sc_reg_access(hp_spk, PMIC_READ_MODIFY, 2); + } snd_pmic_ops_nc.output_dev_id = value; if (snd_pmic_ops_nc.card_status == SND_CARD_UN_INIT) -- 1.7.1 _______________________________________________ MeeGo-kernel mailing list [email protected] http://lists.meego.com/listinfo/meego-kernel
