static int current_playback_target = PLAYBACK_TARGET_LOUDSPEAKER;
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.
* Logic is adjusted from the TSC2101 OSS code.
FN_IN;
maskedVal = 0xe0 & val;
- data = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_MIXER_PGA_CTRL);
+ data = omap_tsc2101_audio_read(TSC2101_MIXER_PGA_CTRL);
data &= ~MPC_MICSEL(7); /* clear all MICSEL bits */
data |= maskedVal;
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_MIXER_PGA_CTRL,
- data);
+ omap_tsc2101_audio_write(TSC2101_MIXER_PGA_CTRL, data);
current_rec_src = val;
FN_OUT(0);
volL = get_mixer_volume_as_dac_gain_control_volume(mixerVolL);
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 */
val &= ~(DGC_DALVL(OUTPUT_VOLUME_MIN) | DGC_DARVL(OUTPUT_VOLUME_MIN));
val |= DGC_DALVL(volL) | DGC_DARVL(volR);
retVal = 2;
if (retVal) {
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_DAC_GAIN_CTRL,
- val);
+ omap_tsc2101_audio_write(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);
return retVal;
int count;
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
* so if values are same, it's time to change the registry value.
*/
count++;
} /* R */
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",
IS_DGC_DALMU_UNMUTED(val),
IS_DGC_DARMU_UNMUTED(val));
/* Convert 0 -> 100 volume to 0x0(min) -> 0x7D(max) volume range */
/* NOTE: 0 is minimum volume and not mute */
volume = get_mixer_volume_as_headset_gain_control_volume(mixerVol);
- val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_HEADSET_GAIN_CTRL);
+ val = omap_tsc2101_audio_read(TSC2101_HEADSET_GAIN_CTRL);
/* preserve the old mute settings */
val &= ~(HGC_ADPGA_HED(INPUT_VOLUME_MAX));
val |= HGC_ADPGA_HED(volume);
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_HEADSET_GAIN_CTRL,
- val);
+ omap_tsc2101_audio_write(TSC2101_HEADSET_GAIN_CTRL, val);
retVal = 1;
M_DPRINTK("to registry = %d\n", val);
* NOTE: 0 is minimum volume and not mute
*/
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 */
val &= ~(HNGC_ADPGA_HND(INPUT_VOLUME_MAX));
val |= HNGC_ADPGA_HND(volume);
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_HANDSET_GAIN_CTRL,
- val);
+ omap_tsc2101_audio_write(TSC2101_HANDSET_GAIN_CTRL, val);
retVal = 1;
M_DPRINTK("to registry = %d\n", val);
* Cell Phone In not connected to ADC
* Input selected by MICSEL connected to ADC
*/
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_MIXER_PGA_CTRL,
+ omap_tsc2101_audio_write(TSC2101_MIXER_PGA_CTRL,
MPC_ASTMU | MPC_ASTG(0x40) | ~MPC_CPADC | MPC_MICADC);
/* Set record source, Select MIC_INHED input for headset */
set_record_source(REC_SRC_SINGLE_ENDED_MICIN_HED);
u16 val;
/* power down sp1, sp2 and loudspeaker */
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_CODEC_POWER_CTRL,
+ omap_tsc2101_audio_write(TSC2101_CODEC_POWER_CTRL,
CPC_SP1PWDN | CPC_SP2PWDN | CPC_LDAPWDF);
/* ADC, DAC, Analog Sidetone, cellphone, buzzer softstepping enabled
* 1dB AGC hysteresis
* MICes bias 2V
*/
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_AUDIO_CTRL_4,
- AC4_MB_HED(0));
+ omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_4, AC4_MB_HED(0));
/* DAC left and right routed to SPK1/SPK2
* SPK1/SPK2 unmuted
AC5_DAC2SPK2(3) | AC5_AST2SPK2 | AC5_KCL2SPK2 |
AC5_HDSCPTC;
val = val & ~AC5_HDSCPTC;
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_AUDIO_CTRL_5,
- val);
+ omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_5, val);
/* powerdown spk1/out32n and spk2 */
- val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_POWERDOWN_STS);
+ val = omap_tsc2101_audio_read(TSC2101_POWERDOWN_STS);
val = val & ~(~PS_SPK1FL | ~PS_HNDFL | PS_LSPKFL);
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_POWERDOWN_STS,
- val);
+ omap_tsc2101_audio_write(TSC2101_POWERDOWN_STS, val);
/* routing selected to SPK1 goes to OUT8P/OUT84 alsa. (loudspeaker)
* analog sidetone routed to loudspeaker
* Enable loudspeaker short protection control (0 = enable protection)
* VGND short protection control (0 = enable protection)
*/
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_AUDIO_CTRL_6,
+ omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_6,
AC6_SPL2LSK | AC6_AST2LSK | AC6_BUZ2LSK | AC6_KCL2LSK |
AC6_CPI2LSK | AC6_MIC2CPO | AC6_SPL2CPO |
~AC6_MUTLSPK | ~AC6_MUTSPK2 | ~AC6_LDSCPTC | ~AC6_VGNDSCPTC);
void set_headphone_to_playback_target(void)
{
/* power down sp1, sp2 and loudspeaker */
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_CODEC_POWER_CTRL,
+ omap_tsc2101_audio_write(TSC2101_CODEC_POWER_CTRL,
CPC_SP1PWDN | CPC_SP2PWDN | CPC_LDAPWDF);
/* ADC, DAC, Analog Sidetone, cellphone, buzzer softstepping enabled */
/* 1dB AGC hysteresis */
/* MICes bias 2V */
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_AUDIO_CTRL_4,
- AC4_MB_HED(0));
+ omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_4, AC4_MB_HED(0));
/* DAC left and right routed to SPK2 */
/* SPK1/2 unmuted */
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_AUDIO_CTRL_5,
+ omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_5,
AC5_DAC2SPK1(3) | AC5_AST2SPK1 | AC5_KCL2SPK1 |
AC5_DAC2SPK2(3) | AC5_AST2SPK2 | AC5_KCL2SPK2 |
AC5_HDSCPTC);
/* OUT8P/N muted, CPOUT muted */
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_AUDIO_CTRL_6,
+ omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_6,
AC6_MUTLSPK | AC6_MUTSPK2 | AC6_LDSCPTC |
AC6_VGNDSCPTC);
current_playback_target = PLAYBACK_TARGET_HEADPHONE;
u16 curVal;
curType = 0; /* not detected */
- curVal = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_AUDIO_CTRL_7);
+ curVal = omap_tsc2101_audio_read(TSC2101_AUDIO_CTRL_7);
curDetected = curVal & AC7_HDDETFL;
if (curDetected) {
printk("headset detected, checking type from %d \n", curVal);
* AGC enable for handset input
* Handset input not muted
*/
- val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_HANDSET_GAIN_CTRL);
+ val = omap_tsc2101_audio_read(TSC2101_HANDSET_GAIN_CTRL);
val = val | HNGC_AGCEN_HND;
val = val & ~HNGC_ADMUT_HND;
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_HANDSET_GAIN_CTRL,
- val);
+ omap_tsc2101_audio_write(TSC2101_HANDSET_GAIN_CTRL, val);
/* mic input volume control
* SET_MIC in the OSS driver
FN_IN;
/* Headset/Hook switch detect enabled */
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_AUDIO_CTRL_7,
- AC7_DETECT);
+ omap_tsc2101_audio_write(TSC2101_AUDIO_CTRL_7, AC7_DETECT);
init_record_sources();
init_playback_targets();
u16 volR;
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);
volL = DGC_DALVL_EXTRACT(val);
volR = DGC_DARVL_EXTRACT(val);
*/
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[1] = IS_DGC_DARMU_UNMUTED(val);
u16 val;
u16 vol;
- val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_HEADSET_GAIN_CTRL);
+ val = omap_tsc2101_audio_read(TSC2101_HEADSET_GAIN_CTRL);
M_DPRINTK("registry value = %d\n", val);
vol = HGC_ADPGA_HED_EXTRACT(val);
vol = vol & ~HGC_ADMUT_HED;
*/
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,
- TSC2101_HEADSET_GAIN_CTRL);
+ u16 val = omap_tsc2101_audio_read(TSC2101_HEADSET_GAIN_CTRL);
ucontrol->value.integer.value[0] = IS_DGC_HGCMU_UNMUTED(val);
return 0;
}
static int __headset_playback_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
{
int count = 0;
- u16 val = omap_tsc2101_read(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_HEADSET_GAIN_CTRL);
+ u16 val = omap_tsc2101_audio_read(TSC2101_HEADSET_GAIN_CTRL);
/* 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...
*/
M_DPRINTK("changed value, is_unmuted = %d\n", IS_DGC_HGCMU_UNMUTED(val));
}
if (count) {
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_HEADSET_GAIN_CTRL,
- val);
+ omap_tsc2101_audio_write(TSC2101_HEADSET_GAIN_CTRL, val);
}
return count;
}
u16 val;
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);
vol = HNGC_ADPGA_HND_EXTRACT(val);
vol = vol & ~HNGC_ADMUT_HND;
*/
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);
return 0;
}
static int __handset_playback_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
{
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
* so if values are same, it's time to change the registry value...
count++;
}
if (count) {
- omap_tsc2101_write(TSC2101_AUDIO_CODEC_REGISTERS_PAGE2,
- TSC2101_HANDSET_GAIN_CTRL,
- val);
+ omap_tsc2101_audio_write(TSC2101_HANDSET_GAIN_CTRL, val);
}
return count;
}