From 6be80976517709e16d587e3e30f020e41610be42 Mon Sep 17 00:00:00 2001 From: Andrew Ryabinin Date: Fri, 12 Apr 2013 10:08:37 +0400 Subject: hm60x/hm801: Fix balance by enabling sw volume control. Change-Id: I8760b58d5b801409f35370d812d72f8d578d2889 --- firmware/drivers/audio/dummy_codec.c | 14 +++++++++++++- firmware/export/config/hifimanhm60x.h | 2 ++ firmware/export/config/hifimanhm801.h | 2 ++ firmware/export/dummy_codec.h | 3 ++- 4 files changed, 19 insertions(+), 2 deletions(-) (limited to 'firmware') diff --git a/firmware/drivers/audio/dummy_codec.c b/firmware/drivers/audio/dummy_codec.c index ca51d95265..94ba04b56a 100644 --- a/firmware/drivers/audio/dummy_codec.c +++ b/firmware/drivers/audio/dummy_codec.c @@ -23,9 +23,11 @@ #include "config.h" #include "audio.h" #include "audiohw.h" +#include "system.h" +#include "pcm_sw_volume.h" const struct sound_settings_info audiohw_settings[] = { - [SOUND_VOLUME] = {"dB", 0, 1, -1, 0, 0}, + [SOUND_VOLUME] = {"dB", 0, 1, VOLUME_MIN/10, VOLUME_MAX/10, 0}, /* HAVE_SW_TONE_CONTROLS */ [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0}, [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0}, @@ -44,3 +46,13 @@ void audiohw_set_frequency(int fsel) { (void)fsel; } + +#ifdef HAVE_SW_VOLUME_CONTROL +void audiohw_set_master_vol(int vol_l, int vol_r) +{ + /* SW volume for <= 1.0 gain, HW at unity, < VOLUME_MIN == MUTE */ + int sw_volume_l = vol_l < VOLUME_MIN ? PCM_MUTE_LEVEL : MIN(vol_l, 0); + int sw_volume_r = vol_r < VOLUME_MIN ? PCM_MUTE_LEVEL : MIN(vol_r, 0); + pcm_set_master_volume(sw_volume_l, sw_volume_r); +} +#endif /* HAVE_SW_VOLUME_CONTROL */ diff --git a/firmware/export/config/hifimanhm60x.h b/firmware/export/config/hifimanhm60x.h index 088cc12b09..f5b768defe 100644 --- a/firmware/export/config/hifimanhm60x.h +++ b/firmware/export/config/hifimanhm60x.h @@ -53,6 +53,8 @@ #define CONFIG_NAND NAND_RK27XX #define HAVE_SW_TONE_CONTROLS +#define HAVE_SW_VOLUME_CONTROL + /* commented for now */ /* #define HAVE_HOTSWAP */ diff --git a/firmware/export/config/hifimanhm801.h b/firmware/export/config/hifimanhm801.h index e253fa0051..bcbf5e82f5 100644 --- a/firmware/export/config/hifimanhm801.h +++ b/firmware/export/config/hifimanhm801.h @@ -50,6 +50,8 @@ #define CONFIG_NAND NAND_RK27XX #define HAVE_SW_TONE_CONTROLS +#define HAVE_SW_VOLUME_CONTROL + /* commented for now */ /* #define HAVE_HOTSWAP */ diff --git a/firmware/export/dummy_codec.h b/firmware/export/dummy_codec.h index b85ec8fb0e..122b55ef2f 100644 --- a/firmware/export/dummy_codec.h +++ b/firmware/export/dummy_codec.h @@ -22,8 +22,9 @@ #ifndef __DUMMY_CODEC_H_ #define __DUMMY_CODEC_H_ -#define VOLUME_MIN -1 +#define VOLUME_MIN -730 #define VOLUME_MAX 0 +void audiohw_set_master_vol(int vol_l, int vol_r); #endif /* __DUMMY_CODEC_H_ */ -- cgit v1.2.3