diff options
author | SIMOND François <francois@lienweb.fr> | 2011-03-24 09:10:43 +0100 |
---|---|---|
committer | KalimochoAz <calimochoazucarado@gmail.com> | 2011-12-19 12:15:34 +0100 |
commit | 78f73e2b57f548b72f1042547c2c89b937a3ac64 (patch) | |
tree | a4c9b9ff7fca056a700efb4e89e8acd448a1330e /sound/soc/codecs | |
parent | 0b428f20378355340e9ad4bc74bf70b3fe0d138c (diff) | |
download | kernel_samsung_crespo-78f73e2b57f548b72f1042547c2c89b937a3ac64.zip kernel_samsung_crespo-78f73e2b57f548b72f1042547c2c89b937a3ac64.tar.gz kernel_samsung_crespo-78f73e2b57f548b72f1042547c2c89b937a3ac64.tar.bz2 |
Voodoo sound: modularization-related change and path management improvements
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r-- | sound/soc/codecs/Kconfig.voodoo | 8 | ||||
-rw-r--r-- | sound/soc/codecs/Makefile | 4 | ||||
-rw-r--r-- | sound/soc/codecs/wm8994_voodoo.c | 95 | ||||
-rw-r--r-- | sound/soc/codecs/wm8994_voodoo.h | 2 |
4 files changed, 96 insertions, 13 deletions
diff --git a/sound/soc/codecs/Kconfig.voodoo b/sound/soc/codecs/Kconfig.voodoo index af418fb..5f85148 100644 --- a/sound/soc/codecs/Kconfig.voodoo +++ b/sound/soc/codecs/Kconfig.voodoo @@ -44,6 +44,14 @@ config SND_VOODOO_FM help Adds a control to enable or disable the high-pass filter on FM radio + +config SND_VOODOO_MODULE + tristate "Build also as module (incomplete)" + depends on SND_VOODOO && m + default n + help + requires additionnal source + config SND_VOODOO_DEBUG bool "Codec development tools (unsafe and introduce sound skipping)" depends on SND_VOODOO diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 7f456c7..fa6ba22 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -186,3 +186,7 @@ obj-$(CONFIG_SND_SOC_MAX9877) += snd-soc-max9877.o obj-$(CONFIG_SND_SOC_TPA6130A2) += snd-soc-tpa6130a2.o obj-$(CONFIG_SND_SOC_WM2000) += snd-soc-wm2000.o obj-$(CONFIG_SND_SOC_WM9090) += snd-soc-wm9090.o + +ifeq ($(CONFIG_SND_VOODOO_MODULE),m) +obj-$(CONFIG_SND_VOODOO_MODULE) += voodoo-sound-tegrak-module/ +endif diff --git a/sound/soc/codecs/wm8994_voodoo.c b/sound/soc/codecs/wm8994_voodoo.c index d9bcb90..9ead386 100644 --- a/sound/soc/codecs/wm8994_voodoo.c +++ b/sound/soc/codecs/wm8994_voodoo.c @@ -23,6 +23,24 @@ #define SUBJECT "wm8994_voodoo.c" #define VOODOO_SOUND_VERSION 6 + +#ifdef MODULE +#include "tegrak_voodoo_sound.h" + +// wm8994_write -> tegrak_wm8994_write for dynamic link +#ifdef wm8994_write +#undef wm8994_write +#endif + +// wm8994_read -> tegrak_wm8994_read for dynamic link +#ifdef wm8994_read +#undef wm8994_read +#endif +#define wm8994_write(codec, reg, value) tegrak_wm8994_write(codec, reg, value) +#define wm8994_read(codec, reg) tegrak_wm8994_read(codec, reg) +#endif + + bool bypass_write_hook = false; #ifdef CONFIG_SND_VOODOO_HP_LEVEL_CONTROL @@ -115,9 +133,10 @@ void update_hpvol() void update_fm_radio_headset_restore_freqs(bool with_mute) { unsigned short val; + DECLARE_WM8994(codec_) + bypass_write_hook = true; // apply only when FM radio is active - DECLARE_WM8994(codec_) if (wm8994->fmradio_path == FMR_OFF) return; @@ -159,12 +178,15 @@ void update_fm_radio_headset_restore_freqs(bool with_mute) val &= ~(WM8994_AIF2DAC_MUTE_MASK); wm8994_write(codec_, WM8994_AIF2_DAC_FILTERS_1, val); } + bypass_write_hook = false; } void update_fm_radio_headset_normalize_gain(bool with_mute) { - // apply only when FM radio is active DECLARE_WM8994(codec_) + + bypass_write_hook = true; + // apply only when FM radio is active if (wm8994->fmradio_path == FMR_OFF) return; @@ -190,6 +212,7 @@ void update_fm_radio_headset_normalize_gain(bool with_mute) wm8994_write(codec_, WM8994_AIF2_DRC_5, 0x0000); wm8994_write(codec_, WM8994_AIF2_DRC_1, 0x019C); } + bypass_write_hook = false; } #endif @@ -316,12 +339,28 @@ bool is_path(int unified_path) #endif #endif + // FM Radio on headphones + case RADIO_HEADPHONES: +#ifdef NEXUS_S + return false; +#else +#ifdef M110S + return false; +#else +#ifdef GALAXY_TAB + return (wm8994->codec_state & FMRADIO_ACTIVE) && (wm8994->fmradio_path == FMR_HP); +#else + return (wm8994->codec_state & FMRADIO_ACTIVE) && (wm8994->fmradio_path == FMR_HP); +#endif +#endif +#endif + // headphones // FIXME: be sure dac_direct doesn't break phone calls on TAB // with these spath detection settings (HP4P) case MAIN_MICROPHONE: - return (wm8994->rec_path == MAIN); + return (wm8994->codec_state & CAPTURE_ACTIVE) && (wm8994->rec_path == MAIN); } return false; @@ -330,7 +369,8 @@ bool is_path(int unified_path) #ifdef NEXUS_S void update_speaker_tuning(bool with_mute) { - if (is_path(SPEAKER)) + DECLARE_WM8994(codec_) + if (is_path(SPEAKER) && !(wm8994->codec_state & CALL_ACTIVE)) { printk("We are on speaker!\n"); if (speaker_tuning) @@ -464,7 +504,12 @@ void update_mono_downmix(bool with_mute) unsigned short dac_direct_get_value(unsigned short val) { - if (is_path(HEADPHONES)) + DECLARE_WM8994(codec_) + + if (is_path(HEADPHONES) && + (wm8994->codec_state & PLAYBACK_ACTIVE) && + !(wm8994->codec_state & CALL_ACTIVE) && + !(wm8994->stream_state & PCM_STREAM_PLAYBACK)) { if (dac_direct) val = (val == WM8994_DAC1L_TO_MIXOUTL) ? WM8994_DAC1L_TO_HPOUT1L : val; @@ -644,6 +689,7 @@ static ssize_t voodoo_sound_version(struct device *dev, struct device_attribute } +#ifndef MODULE DECLARE_BOOL_SHOW(enable) static ssize_t enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { @@ -660,7 +706,7 @@ static ssize_t enable_store(struct device *dev, struct device_attribute *attr, c } return size; } - +#endif #ifdef CONFIG_SND_VOODOO_HP_LEVEL_CONTROL static DEVICE_ATTR(headphone_amplifier_level, S_IRUGO | S_IWUGO , headphone_amplifier_level_show, headphone_amplifier_level_store); @@ -687,7 +733,9 @@ static DEVICE_ATTR(wm8994_write, S_IWUSR , NULL, store_wm8994_write); #endif static DEVICE_ATTR(version, S_IRUGO , voodoo_sound_version, NULL); +#ifndef MODULE static DEVICE_ATTR(enable, S_IRUGO | S_IWUGO , enable_show, enable_store); +#endif static struct attribute *voodoo_sound_attributes[] = { #ifdef CONFIG_SND_VOODOO_HP_LEVEL_CONTROL @@ -717,29 +765,34 @@ static struct attribute *voodoo_sound_attributes[] = { NULL }; +#ifndef MODULE static struct attribute *voodoo_sound_control_attributes[] = { &dev_attr_enable.attr, NULL }; +#endif static struct attribute_group voodoo_sound_group = { .attrs = voodoo_sound_attributes, }; +#ifndef MODULE static struct attribute_group voodoo_sound_control_group = { .attrs = voodoo_sound_control_attributes, }; +#endif static struct miscdevice voodoo_sound_device = { .minor = MISC_DYNAMIC_MINOR, .name = "voodoo_sound", }; +#ifndef MODULE static struct miscdevice voodoo_sound_control_device = { .minor = MISC_DYNAMIC_MINOR, .name = "voodoo_sound_control", }; - +#endif void voodoo_hook_wm8994_pcm_remove() { printk("Voodoo sound: removing driver v%d\n", VOODOO_SOUND_VERSION); @@ -764,7 +817,6 @@ void update_enable() voodoo_hook_wm8994_pcm_remove(); } - /* * * Driver Hooks @@ -820,6 +872,8 @@ void voodoo_hook_playback_speaker() unsigned int voodoo_hook_wm8994_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { + DECLARE_WM8994(codec) + // global kill switch if (! enable) return value; @@ -830,8 +884,9 @@ unsigned int voodoo_hook_wm8994_write(struct snd_soc_codec *codec, unsigned int if (! bypass_write_hook) { + #ifdef CONFIG_SND_VOODOO_HP_LEVEL_CONTROL - if (is_path(HEADPHONES)) + if (is_path(HEADPHONES) && !(wm8994->codec_state & CALL_ACTIVE)) { if (reg == WM8994_LEFT_OUTPUT_VOLUME) value = (WM8994_HPOUT1_VU | WM8994_HPOUT1L_MUTE_N | hplvol); @@ -839,6 +894,15 @@ unsigned int voodoo_hook_wm8994_write(struct snd_soc_codec *codec, unsigned int value = (WM8994_HPOUT1_VU | WM8994_HPOUT1R_MUTE_N | hprvol); } #endif + +#ifdef CONFIG_SND_VOODOO_FM + if (is_path(RADIO_HEADPHONES)) + { + if (reg == WM8994_INPUT_MIXER_2 || reg == WM8994_AIF2_DRC_1 || reg == WM8994_ANALOGUE_HP_1) + voodoo_hook_fmradio_headset(); + } +#endif + if (reg == WM8994_OVERSAMPLING) value = osr128_get_value(value); if (reg == WM8994_FLL1_CONTROL_4) @@ -853,11 +917,16 @@ unsigned int voodoo_hook_wm8994_write(struct snd_soc_codec *codec, unsigned int // log every write to dmesg printk("Voodoo sound: wm8994_write register= [%X] value= [%X]\n", reg, value); #ifdef NEXUS_S - printk("Voodoo sound: cur_path=%i, rec_path=%i, power_state=%i\n", + printk("Voodoo sound: codec_state=%u, stream_state=%u, cur_path=%i, rec_path=%i, power_state=%i\n", + wm8994->codec_state, wm8994->stream_state, wm8994->cur_path, wm8994->rec_path, wm8994->power_state); #else - printk("Voodoo sound: cur_path=%i, rec_path=%i, fmradio_path=%i, fmr_mix_path=%i, power_state=%i, recognition_active=%i, ringtone_active=%i\n", - wm8994->cur_path, wm8994->rec_path, wm8994->fmradio_path, wm8994->fmr_mix_path, wm8994->power_state, wm8994->recognition_active, wm8994->ringtone_active); + printk("Voodoo sound: codec_state=%u, stream_state=%u, cur_path=%i, rec_path=%i, fmradio_path=%i, fmr_mix_path=%i, power_state=%i, recognition_active=%i, ringtone_active=%i\n", + wm8994->codec_state, wm8994->stream_state, + wm8994->cur_path, wm8994->rec_path, + wm8994->fmradio_path, wm8994->fmr_mix_path, + wm8994->power_state, + wm8994->recognition_active, wm8994->ringtone_active); #endif #endif return value; @@ -869,12 +938,14 @@ void voodoo_hook_wm8994_pcm_probe(struct snd_soc_codec *codec) enable = true; update_enable(); +#ifndef MODULE misc_register(&voodoo_sound_control_device); if (sysfs_create_group(&voodoo_sound_control_device.this_device->kobj, &voodoo_sound_control_group) < 0) { printk("%s sysfs_create_group fail\n", __FUNCTION__); pr_err("Failed to create sysfs group for device (%s)!\n", voodoo_sound_control_device.name); } +#endif // make a copy of the codec pointer codec_ = codec; diff --git a/sound/soc/codecs/wm8994_voodoo.h b/sound/soc/codecs/wm8994_voodoo.h index e7a31b0..bb87c68 100644 --- a/sound/soc/codecs/wm8994_voodoo.h +++ b/sound/soc/codecs/wm8994_voodoo.h @@ -37,4 +37,4 @@ unsigned short tune_fll_value(unsigned short val); #define M110S #endif -enum unified_path { HEADPHONES, SPEAKER, MAIN_MICROPHONE }; +enum unified_path { HEADPHONES, RADIO_HEADPHONES, SPEAKER, MAIN_MICROPHONE }; |