Commit 7dd5b706 authored by lamikr's avatar lamikr Committed by Tony Lindgren

[PATCH 2/5] omap-alsa-tsc2101-mixer: inline functions for registry read and write

omap-alsa-tsc2101-mixer: inline functions for registry read and write
Signed-off-by: default avatarlamikr <lamikr@cc.jyu.fi>
parent 394bf4ee
...@@ -68,6 +68,22 @@ ...@@ -68,6 +68,22 @@
static int current_playback_target = PLAYBACK_TARGET_LOUDSPEAKER; static int current_playback_target = PLAYBACK_TARGET_LOUDSPEAKER;
static int current_rec_src = REC_SRC_SINGLE_ENDED_MICIN_HED; static int current_rec_src = REC_SRC_SINGLE_ENDED_MICIN_HED;
/*
* Simplified write for the tsc2101 audio registers.
*/
inline void omap_tsc2101_audio_write(u8 address, u16 data)
{
omap_tsc2101_write(PAGE2_AUDIO_CODEC_REGISTERS, address, data);
}
/*
* Simplified read for the tsc2101 audio registers.
*/
inline u16 omap_tsc2101_audio_read(u8 address)
{
return (omap_tsc2101_read(PAGE2_AUDIO_CODEC_REGISTERS, address));
}
/* /*
* Used for switching between TSC2101 recourd sources. * Used for switching between TSC2101 recourd sources.
* Logic is adjusted from the TSC2101 OSS code. * Logic is adjusted from the TSC2101 OSS code.
...@@ -80,13 +96,10 @@ static int set_record_source(int val) ...@@ -80,13 +96,10 @@ static int set_record_source(int val)
FN_IN; FN_IN;
maskedVal = 0xe0 & val; maskedVal = 0xe0 & val;
data = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, data = omap_tsc2101_audio_read(TSC2101_MIXER_PGA_CTRL);
TSC2101_MIXER_PGA_CTRL);
data &= ~MPC_MICSEL(7); /* clear all MICSEL bits */ data &= ~MPC_MICSEL(7); /* clear all MICSEL bits */
data |= maskedVal; data |= maskedVal;
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_MIXER_PGA_CTRL, data);
TSC2101_MIXER_PGA_CTRL,
data);
current_rec_src = val; current_rec_src = val;
FN_OUT(0); FN_OUT(0);
...@@ -147,15 +160,13 @@ int set_mixer_volume_as_dac_gain_control_volume(int mixerVolL, int mixerVolR) ...@@ -147,15 +160,13 @@ int set_mixer_volume_as_dac_gain_control_volume(int mixerVolL, int mixerVolR)
volL = get_mixer_volume_as_dac_gain_control_volume(mixerVolL); volL = get_mixer_volume_as_dac_gain_control_volume(mixerVolL);
volR = get_mixer_volume_as_dac_gain_control_volume(mixerVolR); volR = get_mixer_volume_as_dac_gain_control_volume(mixerVolR);
val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, TSC2101_DAC_GAIN_CTRL); val = omap_tsc2101_audio_read(TSC2101_DAC_GAIN_CTRL);
/* keep the old mute bit settings */ /* keep the old mute bit settings */
val &= ~(DGC_DALVL(OUTPUT_VOLUME_MIN) | DGC_DARVL(OUTPUT_VOLUME_MIN)); val &= ~(DGC_DALVL(OUTPUT_VOLUME_MIN) | DGC_DARVL(OUTPUT_VOLUME_MIN));
val |= DGC_DALVL(volL) | DGC_DARVL(volR); val |= DGC_DALVL(volL) | DGC_DARVL(volR);
retVal = 2; retVal = 2;
if (retVal) { if (retVal) {
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_DAC_GAIN_CTRL, val);
TSC2101_DAC_GAIN_CTRL,
val);
} }
M_DPRINTK("to registry: left = %d, right = %d, total = %d\n", DGC_DALVL_EXTRACT(val), DGC_DARVL_EXTRACT(val), val); M_DPRINTK("to registry: left = %d, right = %d, total = %d\n", DGC_DALVL_EXTRACT(val), DGC_DARVL_EXTRACT(val), val);
return retVal; return retVal;
...@@ -167,7 +178,7 @@ int dac_gain_control_unmute_control(int muteLeft, int muteRight) ...@@ -167,7 +178,7 @@ int dac_gain_control_unmute_control(int muteLeft, int muteRight)
int count; int count;
count = 0; count = 0;
val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, TSC2101_DAC_GAIN_CTRL); val = omap_tsc2101_audio_read(TSC2101_DAC_GAIN_CTRL);
/* in alsa mixer 1 --> on, 0 == off. In tsc2101 registry 1 --> off, 0 --> on /* in alsa mixer 1 --> on, 0 == off. In tsc2101 registry 1 --> off, 0 --> on
* so if values are same, it's time to change the registry value. * so if values are same, it's time to change the registry value.
*/ */
...@@ -194,7 +205,7 @@ int dac_gain_control_unmute_control(int muteLeft, int muteRight) ...@@ -194,7 +205,7 @@ int dac_gain_control_unmute_control(int muteLeft, int muteRight)
count++; count++;
} /* R */ } /* R */
if (count) { if (count) {
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, TSC2101_DAC_GAIN_CTRL, val); omap_tsc2101_audio_write(TSC2101_DAC_GAIN_CTRL, val);
M_DPRINTK("changed value, is_unmuted left = %d, right = %d\n", M_DPRINTK("changed value, is_unmuted left = %d, right = %d\n",
IS_DGC_DALMU_UNMUTED(val), IS_DGC_DALMU_UNMUTED(val),
IS_DGC_DARMU_UNMUTED(val)); IS_DGC_DARMU_UNMUTED(val));
...@@ -271,14 +282,11 @@ int set_mixer_volume_as_headset_gain_control_volume(int mixerVol) ...@@ -271,14 +282,11 @@ int set_mixer_volume_as_headset_gain_control_volume(int mixerVol)
/* Convert 0 -> 100 volume to 0x0(min) -> 0x7D(max) volume range */ /* Convert 0 -> 100 volume to 0x0(min) -> 0x7D(max) volume range */
/* NOTE: 0 is minimum volume and not mute */ /* NOTE: 0 is minimum volume and not mute */
volume = get_mixer_volume_as_headset_gain_control_volume(mixerVol); volume = get_mixer_volume_as_headset_gain_control_volume(mixerVol);
val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, val = omap_tsc2101_audio_read(TSC2101_HEADSET_GAIN_CTRL);
TSC2101_HEADSET_GAIN_CTRL);
/* preserve the old mute settings */ /* preserve the old mute settings */
val &= ~(HGC_ADPGA_HED(INPUT_VOLUME_MAX)); val &= ~(HGC_ADPGA_HED(INPUT_VOLUME_MAX));
val |= HGC_ADPGA_HED(volume); val |= HGC_ADPGA_HED(volume);
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_HEADSET_GAIN_CTRL, val);
TSC2101_HEADSET_GAIN_CTRL,
val);
retVal = 1; retVal = 1;
M_DPRINTK("to registry = %d\n", val); M_DPRINTK("to registry = %d\n", val);
...@@ -305,13 +313,11 @@ int set_mixer_volume_as_handset_gain_control_volume(int mixerVol) ...@@ -305,13 +313,11 @@ int set_mixer_volume_as_handset_gain_control_volume(int mixerVol)
* NOTE: 0 is minimum volume and not mute * NOTE: 0 is minimum volume and not mute
*/ */
volume = get_mixer_volume_as_headset_gain_control_volume(mixerVol); volume = get_mixer_volume_as_headset_gain_control_volume(mixerVol);
val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, TSC2101_HANDSET_GAIN_CTRL); val = omap_tsc2101_audio_read(TSC2101_HANDSET_GAIN_CTRL);
/* preserve the old mute settigns */ /* preserve the old mute settigns */
val &= ~(HNGC_ADPGA_HND(INPUT_VOLUME_MAX)); val &= ~(HNGC_ADPGA_HND(INPUT_VOLUME_MAX));
val |= HNGC_ADPGA_HND(volume); val |= HNGC_ADPGA_HND(volume);
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_HANDSET_GAIN_CTRL, val);
TSC2101_HANDSET_GAIN_CTRL,
val);
retVal = 1; retVal = 1;
M_DPRINTK("to registry = %d\n", val); M_DPRINTK("to registry = %d\n", val);
...@@ -325,8 +331,7 @@ void init_record_sources(void) ...@@ -325,8 +331,7 @@ void init_record_sources(void)
* Cell Phone In not connected to ADC * Cell Phone In not connected to ADC
* Input selected by MICSEL connected to ADC * Input selected by MICSEL connected to ADC
*/ */
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_MIXER_PGA_CTRL,
TSC2101_MIXER_PGA_CTRL,
MPC_ASTMU | MPC_ASTG(0x40) | ~MPC_CPADC | MPC_MICADC); MPC_ASTMU | MPC_ASTG(0x40) | ~MPC_CPADC | MPC_MICADC);
/* Set record source, Select MIC_INHED input for headset */ /* Set record source, Select MIC_INHED input for headset */
set_record_source(REC_SRC_SINGLE_ENDED_MICIN_HED); set_record_source(REC_SRC_SINGLE_ENDED_MICIN_HED);
...@@ -337,16 +342,13 @@ void set_loudspeaker_to_playback_target(void) ...@@ -337,16 +342,13 @@ void set_loudspeaker_to_playback_target(void)
u16 val; u16 val;
/* power down sp1, sp2 and loudspeaker */ /* power down sp1, sp2 and loudspeaker */
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_CODEC_POWER_CTRL,
TSC2101_CODEC_POWER_CTRL,
CPC_SP1PWDN | CPC_SP2PWDN | CPC_LDAPWDF); CPC_SP1PWDN | CPC_SP2PWDN | CPC_LDAPWDF);
/* ADC, DAC, Analog Sidetone, cellphone, buzzer softstepping enabled /* ADC, DAC, Analog Sidetone, cellphone, buzzer softstepping enabled
* 1dB AGC hysteresis * 1dB AGC hysteresis
* MICes bias 2V * MICes bias 2V
*/ */
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_4, AC4_MB_HED(0));
TSC2101_AUDIO_CTRL_4,
AC4_MB_HED(0));
/* DAC left and right routed to SPK1/SPK2 /* DAC left and right routed to SPK1/SPK2
* SPK1/SPK2 unmuted * SPK1/SPK2 unmuted
...@@ -357,17 +359,12 @@ void set_loudspeaker_to_playback_target(void) ...@@ -357,17 +359,12 @@ void set_loudspeaker_to_playback_target(void)
AC5_DAC2SPK2(3) | AC5_AST2SPK2 | AC5_KCL2SPK2 | AC5_DAC2SPK2(3) | AC5_AST2SPK2 | AC5_KCL2SPK2 |
AC5_HDSCPTC; AC5_HDSCPTC;
val = val & ~AC5_HDSCPTC; val = val & ~AC5_HDSCPTC;
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_5, val);
TSC2101_AUDIO_CTRL_5,
val);
/* powerdown spk1/out32n and spk2 */ /* powerdown spk1/out32n and spk2 */
val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, val = omap_tsc2101_audio_read(TSC2101_POWERDOWN_STS);
TSC2101_POWERDOWN_STS);
val = val & ~(~PS_SPK1FL | ~PS_HNDFL | PS_LSPKFL); val = val & ~(~PS_SPK1FL | ~PS_HNDFL | PS_LSPKFL);
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_POWERDOWN_STS, val);
TSC2101_POWERDOWN_STS,
val);
/* routing selected to SPK1 goes to OUT8P/OUT84 alsa. (loudspeaker) /* routing selected to SPK1 goes to OUT8P/OUT84 alsa. (loudspeaker)
* analog sidetone routed to loudspeaker * analog sidetone routed to loudspeaker
...@@ -381,8 +378,7 @@ void set_loudspeaker_to_playback_target(void) ...@@ -381,8 +378,7 @@ void set_loudspeaker_to_playback_target(void)
* Enable loudspeaker short protection control (0 = enable protection) * Enable loudspeaker short protection control (0 = enable protection)
* VGND short protection control (0 = enable protection) * VGND short protection control (0 = enable protection)
*/ */
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_6,
TSC2101_AUDIO_CTRL_6,
AC6_SPL2LSK | AC6_AST2LSK | AC6_BUZ2LSK | AC6_KCL2LSK | AC6_SPL2LSK | AC6_AST2LSK | AC6_BUZ2LSK | AC6_KCL2LSK |
AC6_CPI2LSK | AC6_MIC2CPO | AC6_SPL2CPO | AC6_CPI2LSK | AC6_MIC2CPO | AC6_SPL2CPO |
~AC6_MUTLSPK | ~AC6_MUTSPK2 | ~AC6_LDSCPTC | ~AC6_VGNDSCPTC); ~AC6_MUTLSPK | ~AC6_MUTSPK2 | ~AC6_LDSCPTC | ~AC6_VGNDSCPTC);
...@@ -392,27 +388,22 @@ void set_loudspeaker_to_playback_target(void) ...@@ -392,27 +388,22 @@ void set_loudspeaker_to_playback_target(void)
void set_headphone_to_playback_target(void) void set_headphone_to_playback_target(void)
{ {
/* power down sp1, sp2 and loudspeaker */ /* power down sp1, sp2 and loudspeaker */
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_CODEC_POWER_CTRL,
TSC2101_CODEC_POWER_CTRL,
CPC_SP1PWDN | CPC_SP2PWDN | CPC_LDAPWDF); CPC_SP1PWDN | CPC_SP2PWDN | CPC_LDAPWDF);
/* ADC, DAC, Analog Sidetone, cellphone, buzzer softstepping enabled */ /* ADC, DAC, Analog Sidetone, cellphone, buzzer softstepping enabled */
/* 1dB AGC hysteresis */ /* 1dB AGC hysteresis */
/* MICes bias 2V */ /* MICes bias 2V */
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_4, AC4_MB_HED(0));
TSC2101_AUDIO_CTRL_4,
AC4_MB_HED(0));
/* DAC left and right routed to SPK2 */ /* DAC left and right routed to SPK2 */
/* SPK1/2 unmuted */ /* SPK1/2 unmuted */
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_5,
TSC2101_AUDIO_CTRL_5,
AC5_DAC2SPK1(3) | AC5_AST2SPK1 | AC5_KCL2SPK1 | AC5_DAC2SPK1(3) | AC5_AST2SPK1 | AC5_KCL2SPK1 |
AC5_DAC2SPK2(3) | AC5_AST2SPK2 | AC5_KCL2SPK2 | AC5_DAC2SPK2(3) | AC5_AST2SPK2 | AC5_KCL2SPK2 |
AC5_HDSCPTC); AC5_HDSCPTC);
/* OUT8P/N muted, CPOUT muted */ /* OUT8P/N muted, CPOUT muted */
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_6,
TSC2101_AUDIO_CTRL_6,
AC6_MUTLSPK | AC6_MUTSPK2 | AC6_LDSCPTC | AC6_MUTLSPK | AC6_MUTSPK2 | AC6_LDSCPTC |
AC6_VGNDSCPTC); AC6_VGNDSCPTC);
current_playback_target = PLAYBACK_TARGET_HEADPHONE; current_playback_target = PLAYBACK_TARGET_HEADPHONE;
...@@ -433,8 +424,7 @@ u16 get_headset_detected(void) ...@@ -433,8 +424,7 @@ u16 get_headset_detected(void)
u16 curVal; u16 curVal;
curType = 0; /* not detected */ curType = 0; /* not detected */
curVal = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, curVal = omap_tsc2101_audio_read(TSC2101_AUDIO_CTRL_7);
TSC2101_AUDIO_CTRL_7);
curDetected = curVal & AC7_HDDETFL; curDetected = curVal & AC7_HDDETFL;
if (curDetected) { if (curDetected) {
printk("headset detected, checking type from %d \n", curVal); printk("headset detected, checking type from %d \n", curVal);
...@@ -461,13 +451,10 @@ void init_playback_targets(void) ...@@ -461,13 +451,10 @@ void init_playback_targets(void)
* AGC enable for handset input * AGC enable for handset input
* Handset input not muted * Handset input not muted
*/ */
val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, val = omap_tsc2101_audio_read(TSC2101_HANDSET_GAIN_CTRL);
TSC2101_HANDSET_GAIN_CTRL);
val = val | HNGC_AGCEN_HND; val = val | HNGC_AGCEN_HND;
val = val & ~HNGC_ADMUT_HND; val = val & ~HNGC_ADMUT_HND;
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_HANDSET_GAIN_CTRL, val);
TSC2101_HANDSET_GAIN_CTRL,
val);
/* mic input volume control /* mic input volume control
* SET_MIC in the OSS driver * SET_MIC in the OSS driver
...@@ -490,9 +477,7 @@ void snd_omap_init_mixer(void) ...@@ -490,9 +477,7 @@ void snd_omap_init_mixer(void)
FN_IN; FN_IN;
/* Headset/Hook switch detect enabled */ /* Headset/Hook switch detect enabled */
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_7, AC7_DETECT);
TSC2101_AUDIO_CTRL_7,
AC7_DETECT);
init_record_sources(); init_record_sources();
init_playback_targets(); init_playback_targets();
...@@ -563,7 +548,7 @@ static int __pcm_playback_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_valu ...@@ -563,7 +548,7 @@ static int __pcm_playback_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_valu
u16 volR; u16 volR;
u16 val; u16 val;
val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, TSC2101_DAC_GAIN_CTRL); val = omap_tsc2101_audio_read(TSC2101_DAC_GAIN_CTRL);
M_DPRINTK("registry value = %d!\n", val); M_DPRINTK("registry value = %d!\n", val);
volL = DGC_DALVL_EXTRACT(val); volL = DGC_DALVL_EXTRACT(val);
volR = DGC_DARVL_EXTRACT(val); volR = DGC_DARVL_EXTRACT(val);
...@@ -603,7 +588,7 @@ static int __pcm_playback_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf ...@@ -603,7 +588,7 @@ static int __pcm_playback_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf
*/ */
static int __pcm_playback_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) static int __pcm_playback_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
{ {
u16 val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, TSC2101_DAC_GAIN_CTRL); u16 val = omap_tsc2101_audio_read(TSC2101_DAC_GAIN_CTRL);
ucontrol->value.integer.value[0] = IS_DGC_DALMU_UNMUTED(val); ucontrol->value.integer.value[0] = IS_DGC_DALMU_UNMUTED(val);
ucontrol->value.integer.value[1] = IS_DGC_DARMU_UNMUTED(val); ucontrol->value.integer.value[1] = IS_DGC_DARMU_UNMUTED(val);
...@@ -630,8 +615,7 @@ static int __headset_playback_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_ ...@@ -630,8 +615,7 @@ static int __headset_playback_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_
u16 val; u16 val;
u16 vol; u16 vol;
val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, val = omap_tsc2101_audio_read(TSC2101_HEADSET_GAIN_CTRL);
TSC2101_HEADSET_GAIN_CTRL);
M_DPRINTK("registry value = %d\n", val); M_DPRINTK("registry value = %d\n", val);
vol = HGC_ADPGA_HED_EXTRACT(val); vol = HGC_ADPGA_HED_EXTRACT(val);
vol = vol & ~HGC_ADMUT_HED; vol = vol & ~HGC_ADMUT_HED;
...@@ -662,8 +646,7 @@ static int __headset_playback_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem ...@@ -662,8 +646,7 @@ static int __headset_playback_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem
*/ */
static int __headset_playback_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) static int __headset_playback_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
{ {
u16 val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, u16 val = omap_tsc2101_audio_read(TSC2101_HEADSET_GAIN_CTRL);
TSC2101_HEADSET_GAIN_CTRL);
ucontrol->value.integer.value[0] = IS_DGC_HGCMU_UNMUTED(val); ucontrol->value.integer.value[0] = IS_DGC_HGCMU_UNMUTED(val);
return 0; return 0;
} }
...@@ -671,8 +654,7 @@ static int __headset_playback_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_ ...@@ -671,8 +654,7 @@ static int __headset_playback_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_
static int __headset_playback_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) static int __headset_playback_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
{ {
int count = 0; int count = 0;
u16 val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, u16 val = omap_tsc2101_audio_read(TSC2101_HEADSET_GAIN_CTRL);
TSC2101_HEADSET_GAIN_CTRL);
/* in alsa mixer 1 --> on, 0 == off. In tsc2101 registry 1 --> off, 0 --> on /* in alsa mixer 1 --> on, 0 == off. In tsc2101 registry 1 --> off, 0 --> on
* so if values are same, it's time to change the registry value... * so if values are same, it's time to change the registry value...
*/ */
...@@ -689,9 +671,7 @@ static int __headset_playback_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_ ...@@ -689,9 +671,7 @@ static int __headset_playback_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_
M_DPRINTK("changed value, is_unmuted = %d\n", IS_DGC_HGCMU_UNMUTED(val)); M_DPRINTK("changed value, is_unmuted = %d\n", IS_DGC_HGCMU_UNMUTED(val));
} }
if (count) { if (count) {
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_HEADSET_GAIN_CTRL, val);
TSC2101_HEADSET_GAIN_CTRL,
val);
} }
return count; return count;
} }
...@@ -710,7 +690,7 @@ static int __handset_playback_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_ ...@@ -710,7 +690,7 @@ static int __handset_playback_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_
u16 val; u16 val;
u16 vol; u16 vol;
val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, TSC2101_HANDSET_GAIN_CTRL); val = omap_tsc2101_audio_read(TSC2101_HANDSET_GAIN_CTRL);
M_DPRINTK("registry value = %d\n", val); M_DPRINTK("registry value = %d\n", val);
vol = HNGC_ADPGA_HND_EXTRACT(val); vol = HNGC_ADPGA_HND_EXTRACT(val);
vol = vol & ~HNGC_ADMUT_HND; vol = vol & ~HNGC_ADMUT_HND;
...@@ -740,7 +720,7 @@ static int __handset_playback_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem ...@@ -740,7 +720,7 @@ static int __handset_playback_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem
*/ */
static int __handset_playback_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) static int __handset_playback_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
{ {
u16 val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, TSC2101_HANDSET_GAIN_CTRL); u16 val = omap_tsc2101_audio_read(TSC2101_HANDSET_GAIN_CTRL);
ucontrol->value.integer.value[0] = IS_DGC_HNGCMU_UNMUTED(val); ucontrol->value.integer.value[0] = IS_DGC_HNGCMU_UNMUTED(val);
return 0; return 0;
} }
...@@ -748,7 +728,7 @@ static int __handset_playback_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_ ...@@ -748,7 +728,7 @@ static int __handset_playback_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_
static int __handset_playback_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) static int __handset_playback_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
{ {
int count = 0; int count = 0;
u16 val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, TSC2101_HANDSET_GAIN_CTRL); u16 val = omap_tsc2101_audio_read(TSC2101_HANDSET_GAIN_CTRL);
/* in alsa mixer 1 --> on, 0 == off. In tsc2101 registry 1 --> off, 0 --> on /* in alsa mixer 1 --> on, 0 == off. In tsc2101 registry 1 --> off, 0 --> on
* so if values are same, it's time to change the registry value... * so if values are same, it's time to change the registry value...
...@@ -766,9 +746,7 @@ static int __handset_playback_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_ ...@@ -766,9 +746,7 @@ static int __handset_playback_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_
count++; count++;
} }
if (count) { if (count) {
omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2, omap_tsc2101_audio_write(TSC2101_HANDSET_GAIN_CTRL, val);
TSC2101_HANDSET_GAIN_CTRL,
val);
} }
return count; return count;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment