diff options
author | UK KIM <w0806.kim@samsung.com> | 2010-10-19 23:47:43 -0700 |
---|---|---|
committer | Arve Hjønnevåg <arve@android.com> | 2011-11-17 17:50:11 -0800 |
commit | bfaeee91ce5a03c8e0481a1b660c99e7c6b86a35 (patch) | |
tree | 10f880bb3478d471512bf8bd3aceaee10b49aee5 | |
parent | fe9fd2ce97dc63c0862091cd0ba06057a6a412b2 (diff) | |
download | kernel_samsung_crespo-bfaeee91ce5a03c8e0481a1b660c99e7c6b86a35.zip kernel_samsung_crespo-bfaeee91ce5a03c8e0481a1b660c99e7c6b86a35.tar.gz kernel_samsung_crespo-bfaeee91ce5a03c8e0481a1b660c99e7c6b86a35.tar.bz2 |
S5PC11X: SOUND: devide gain table using gain code
devide gain table with default table not to effect default gain table value.
Change-Id: I369fa9e3dfe3c733e0ba6797a44d75b0c26baf15
Signed-off-by: UK KIM <w0806.kim@samsung.com>
-rw-r--r-- | sound/soc/codecs/wm8994_herring.c | 56 | ||||
-rwxr-xr-x | sound/soc/codecs/wm8994_samsung.c | 26 | ||||
-rwxr-xr-x | sound/soc/codecs/wm8994_samsung.h | 5 |
3 files changed, 84 insertions, 3 deletions
diff --git a/sound/soc/codecs/wm8994_herring.c b/sound/soc/codecs/wm8994_herring.c index 78ec973..70f0e07 100644 --- a/sound/soc/codecs/wm8994_herring.c +++ b/sound/soc/codecs/wm8994_herring.c @@ -447,6 +447,40 @@ struct gain_info_t recording_gain_table[RECORDING_GAIN_NUM] = { }, }; +struct gain_info_t gain_code_table[VOICECALL_GAIN_NUM] = { + { /* RCV */ + .mode = VOICECALL_RCV | GAIN_DIVISION_BIT, + .reg = WM8994_LEFT_LINE_INPUT_1_2_VOLUME, /* 18h */ + .mask = WM8994_IN1L_VOL_MASK, + .gain = WM8994_IN1L_VU | 0x18 + }, {/* SPK */ + .mode = VOICECALL_SPK | GAIN_DIVISION_BIT, + .reg = WM8994_LEFT_LINE_INPUT_1_2_VOLUME, /* 18h */ + .mask = WM8994_IN1L_VOL_MASK, + .gain = WM8994_IN1L_VU | 0x11 + }, { + .mode = VOICECALL_SPK | GAIN_DIVISION_BIT, + .reg = WM8994_SPEAKER_VOLUME_LEFT, /* 26h */ + .mask = WM8994_SPKOUTL_VOL_MASK, + .gain = WM8994_SPKOUT_VU | 0x37 + }, {/* HP */ + .mode = VOICECALL_HP | GAIN_DIVISION_BIT, + .reg = WM8994_RIGHT_LINE_INPUT_1_2_VOLUME, /* 1Ah */ + .mask = WM8994_IN1R_VOL_MASK, + .gain = WM8994_IN1R_VU | 0x1F + }, { + .mode = VOICECALL_HP | GAIN_DIVISION_BIT, + .reg = WM8994_LEFT_OUTPUT_VOLUME, /* 1Ch */ + .mask = WM8994_HPOUT1L_VOL_MASK, + .gain = WM8994_HPOUT1_VU | 0x33 + }, { + .mode = VOICECALL_HP | GAIN_DIVISION_BIT, + .reg = WM8994_RIGHT_OUTPUT_VOLUME, /* 1Dh */ + .mask = WM8994_HPOUT1R_VOL_MASK, + .gain = WM8994_HPOUT1_VU | 0x33 + }, +}; + /* S5P_SLEEP_CONFIG must be controlled by codec if codec use XUSBTI */ int wm8994_configure_clock(struct snd_soc_codec *codec, int en) { @@ -2252,8 +2286,9 @@ void wm8994_set_voicecall_bluetooth(struct snd_soc_codec *codec) int wm8994_set_codec_gain(struct snd_soc_codec *codec, u16 mode, u16 device) { + struct wm8994_priv *wm8994 = codec->drvdata; int i; - int gain_set_bits = COMMON_SET_BIT; + u32 gain_set_bits = COMMON_SET_BIT; u16 val; struct gain_info_t *default_gain_table_p = NULL; int table_num = 0; @@ -2342,7 +2377,8 @@ int wm8994_set_codec_gain(struct snd_soc_codec *codec, u16 mode, u16 device) } DEBUG_LOG("Set gain mode = 0x%x, device = 0x%x, gain_bits = 0x%x,\ - table_num=%d\n", mode, device, gain_set_bits, table_num); + table_num=%d, gain_code = %d\n", + mode, device, gain_set_bits, table_num, wm8994->gain_code); /* default gain table setting */ for (i = 0; i < table_num; i++) { @@ -2354,6 +2390,22 @@ int wm8994_set_codec_gain(struct snd_soc_codec *codec, u16 mode, u16 device) } } + if (wm8994->gain_code) { + gain_set_bits &= ~(COMMON_SET_BIT); + gain_set_bits |= GAIN_DIVISION_BIT; + default_gain_table_p = gain_code_table; + table_num = GAIN_CODE_NUM; + + for (i = 0; i < table_num; i++) { + if ((default_gain_table_p + i)->mode == gain_set_bits) { + val = wm8994_read(codec, (default_gain_table_p + i)->reg); + val &= ~((default_gain_table_p + i)->mask); + val |= (default_gain_table_p + i)->gain; + wm8994_write(codec, (default_gain_table_p + i)->reg, val); + } + } + + } return 0; } diff --git a/sound/soc/codecs/wm8994_samsung.c b/sound/soc/codecs/wm8994_samsung.c index c872249..7eadc6a 100755 --- a/sound/soc/codecs/wm8994_samsung.c +++ b/sound/soc/codecs/wm8994_samsung.c @@ -133,6 +133,8 @@ select_mic_route universal_wm8994_mic_paths[] = { select_clock_control universal_clock_controls = wm8994_configure_clock; +int gain_code; + /* * Implementation of I2C functions */ @@ -1190,6 +1192,28 @@ struct snd_soc_dai wm8994_dai = { .ops = &wm8994_ops, }; +static int __init gain_code_setup(char *str) +{ + + gain_code = 0; + + if (!strcmp(str, "")) { + pr_info("gain_code field is empty. use default value\n"); + return 0; + } + + if (!strcmp(str, "1")) + gain_code = 1; + + return 0; +} +__setup("gain_code=", gain_code_setup); + +int gain_code_check(void) +{ + return gain_code; +} + /* * initialise the WM8994 driver * register the mixer and dsp interfaces with the kernel @@ -1229,6 +1253,8 @@ static int wm8994_init(struct wm8994_priv *wm8994_private, wm8994->ringtone_active = RING_OFF; wm8994->pdata = pdata; + wm8994->gain_code = gain_code_check(); + wm8994->universal_clock_control(codec, CODEC_ON); wm8994->codec_clk = clk_get(NULL, "usb_osc"); diff --git a/sound/soc/codecs/wm8994_samsung.h b/sound/soc/codecs/wm8994_samsung.h index 0967f5b..a42ec56 100755 --- a/sound/soc/codecs/wm8994_samsung.h +++ b/sound/soc/codecs/wm8994_samsung.h @@ -49,6 +49,7 @@ extern struct snd_soc_dai wm8994_dai; #define RECORDING_MODE (0x01 << 2) #define FMRADIO_MODE (0x01 << 3) +#define GAIN_DIVISION_BIT (0x01 << 16) #define COMMON_SET_BIT (0x01 << 0) #define PLAYBACK_RCV (0x01 << 1) #define PLAYBACK_SPK (0x01 << 2) @@ -74,7 +75,7 @@ extern struct snd_soc_dai wm8994_dai; #define PLAYBACK_GAIN_NUM 39 #define VOICECALL_GAIN_NUM 26 #define RECORDING_GAIN_NUM 16 - +#define GAIN_CODE_NUM 6 /* * Definitions of enum type */ @@ -119,6 +120,7 @@ struct wm8994_priv { select_clock_control universal_clock_control; struct wm8994_platform_data *pdata; struct clk *codec_clk; + int gain_code; }; struct gain_info_t { @@ -161,4 +163,5 @@ void wm8994_set_voicecall_headset(struct snd_soc_codec *codec); void wm8994_set_voicecall_speaker(struct snd_soc_codec *codec); void wm8994_set_voicecall_bluetooth(struct snd_soc_codec *codec); int wm8994_set_codec_gain(struct snd_soc_codec *codec, u16 mode, u16 device); +extern int gain_code_check(void); #endif |