Ejemplo n.º 1
0
void audiohw_set_prescaler(int value)
{
    cscodec_setbits(MSTAVOL, MSTAVOL_VOLUME_MASK,
                    (-value / 5) << MSTAVOL_VOLUME_SHIFT);
    cscodec_setbits(MSTBVOL, MSTBVOL_VOLUME_MASK,
                    (-value / 5) << MSTBVOL_VOLUME_SHIFT);
}
Ejemplo n.º 2
0
void audiohw_enable_lineout(bool enable)
{
    if (enable)
        cscodec_setbits(PWRCTL2, PWRCTL2_PDN_LINA_MASK | PWRCTL2_PDN_LINB_MASK,
                        PWRCTL2_PDN_LINA_NEVER | PWRCTL2_PDN_LINB_NEVER);
    else
        cscodec_setbits(PWRCTL2, PWRCTL2_PDN_LINA_MASK | PWRCTL2_PDN_LINB_MASK,
                        PWRCTL2_PDN_LINA_ALWAYS | PWRCTL2_PDN_LINB_ALWAYS);
}
Ejemplo n.º 3
0
void audiohw_set_lineout_volume(int vol_l, int vol_r)
{
    vol_l = vol_tenthdb2hw(vol_l);
    vol_r = vol_tenthdb2hw(vol_r);
    cscodec_setbits(LINEACTL, LINEACTL_LINEAVOL_MASK | LINEACTL_LINEAMUTE,
                    vol_l << LINEACTL_LINEAVOL_SHIFT);
    cscodec_setbits(LINEBCTL, LINEBCTL_LINEBVOL_MASK | LINEBCTL_LINEBMUTE,
                    vol_r << LINEBCTL_LINEBVOL_SHIFT);
}
Ejemplo n.º 4
0
void audiohw_set_volume(int vol_l, int vol_r)
{
    vol_l = vol_tenthdb2hw(vol_l);
    vol_r = vol_tenthdb2hw(vol_r);
    cscodec_setbits(HPACTL, HPACTL_HPAVOL_MASK | HPACTL_HPAMUTE,
                    vol_l << HPACTL_HPAVOL_SHIFT);
    cscodec_setbits(HPBCTL, HPBCTL_HPBVOL_MASK | HPBCTL_HPBMUTE,
                    vol_r << HPBCTL_HPBVOL_SHIFT);
}
Ejemplo n.º 5
0
void audiohw_enable_recording(bool source_mic)
{
    /* mute ADCs */
    cscodec_write(ADCCTL, ADCCTL_ADCAMUTE | ADCCTL_ADCBMUTE);

    /* from cs42l55 DS:
     *  PWRCTL1[3]: ADC charge pump, for optimal ADC performance
     *  and power consumption, set to ‘1’b when VA > 2.1 V and
     *  set to ‘0’b when VA < 2.1 V.
     */
    if (source_mic)
    {
        #ifdef MONO_MIC
        /* power-up CODEC, ADCA and ADC pump */
        cscodec_write(PWRCTL1, PWRCTL1_PDN_ADCB);
        #else
        /* power-up CODEC, ADCA, ADCB and ADC pump */
        cscodec_write(PWRCTL1, 0);
        #endif

        #ifdef BYPASS_PGA
        /* select PGA as input */
        cscodec_setbits(ALHMUX, ALHMUX_ADCAMUX_MASK | ALHMUX_ADCBMUX_MASK,
                            ALHMUX_ADCAMUX_PGAA | ALHMUX_ADCBMUX_PGAB);
        #endif

        /* configure PGA: select AIN2 and set gain */
        cscodec_write(PGAACTL, PGAACTL_MUX_AIN2A |
                            ((PGA_GAIN_DB << 1) & PGAACTL_VOLUME_MASK));
        #ifndef MONO_MIC
        cscodec_write(PGABCTL, PGABCTL_MUX_AIN2B |
                            ((PGA_GAIN_DB << 1) & PGABCTL_VOLUME_MASK));
        #endif
    }
    else /* line-in */
    {
        /* power-up CODEC, ADCA, ADCB and ADC pump */
        cscodec_write(PWRCTL1, 0);

        #ifdef BYPASS_PGA
        /* selects AIN1 as input (PGA is bypassed) */
        cscodec_setbits(ALHMUX, ALHMUX_ADCAMUX_MASK | ALHMUX_ADCBMUX_MASK,
                            ALHMUX_ADCAMUX_AIN1A | ALHMUX_ADCBMUX_AIN1B);
        #else
        /* configure PGA: select AIN1 and set gain to 0dB */
        cscodec_write(PGAACTL, PGAACTL_MUX_AIN1A);
        cscodec_write(PGABCTL, PGABCTL_MUX_AIN1B);
        #endif
    }

    cscodec_write(ADCCTL, 0);   /* unmute ADCs */
}
Ejemplo n.º 6
0
static void handle_tone_onoff(void)
{
    if (bass || treble)
    {
        handle_dsp_power(DSP_MODULE_TONE, 1);
        cscodec_setbits(BTCTL, 0, BTCTL_TCEN);
    }
    else
    {
        cscodec_setbits(BTCTL, BTCTL_TCEN, 0);
        handle_dsp_power(DSP_MODULE_TONE, 0);
    }
}
Ejemplo n.º 7
0
static void handle_dsp_power(void)
{
    if (bass || treble)
    {
        cscodec_setbits(PLAYCTL, PLAYCTL_PDN_DSP, 0);
        cscodec_setbits(BTCTL, 0, BTCTL_TCEN);
    }
    else
    {
        cscodec_setbits(BTCTL, BTCTL_TCEN, 0);
        cscodec_setbits(PLAYCTL, 0, PLAYCTL_PDN_DSP);
    }
}
Ejemplo n.º 8
0
static void handle_dsp_power(int dsp_module, bool onoff)
{
    if (onoff)
    {
        if (!active_dsp_modules)
            cscodec_setbits(PLAYCTL, PLAYCTL_PDN_DSP, 0);
        active_dsp_modules |= dsp_module;
    }
    else
    {
        active_dsp_modules &= ~dsp_module;
        if (!active_dsp_modules)
            cscodec_setbits(PLAYCTL, 0, PLAYCTL_PDN_DSP);
    }
}
Ejemplo n.º 9
0
void audiohw_set_treble(int value)
{
    treble = value;
    handle_tone_onoff();
    if (value >= -105 && value <= 120)
        cscodec_setbits(TONECTL, TONECTL_TREB_MASK,
                        (8 - value / 15) << TONECTL_TREB_SHIFT);
}
Ejemplo n.º 10
0
void audiohw_set_bass(int value)
{
    bass = value;
    handle_tone_onoff();
    if (value >= -105 && value <= 120)
        cscodec_setbits(TONECTL, TONECTL_BASS_MASK,
                        (8 - value / 15) << TONECTL_BASS_SHIFT);
}
Ejemplo n.º 11
0
void audiohw_disable_recording(void)
{
    /* reset used registers to default values */
    cscodec_write(PGAACTL, 0);
    cscodec_write(PGABCTL, 0);
#ifdef BYPASS_PGA
    cscodec_setbits(ALHMUX, ALHMUX_ADCAMUX_MASK | ALHMUX_ADCBMUX_MASK,
                        ALHMUX_ADCAMUX_PGAA | ALHMUX_ADCBMUX_PGAB);
#endif
    /* power-down ADC section */
    cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG |
                        PWRCTL1_PDN_ADCA | PWRCTL1_PDN_ADCB);
}
Ejemplo n.º 12
0
static void audiohw_mute(bool mute)
{
    if (mute) cscodec_setbits(PLAYCTL, 0, PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE);
    else cscodec_setbits(PLAYCTL, PLAYCTL_MSTAMUTE | PLAYCTL_MSTBMUTE, 0);
}
Ejemplo n.º 13
0
void audiohw_set_treble_cutoff(int value)
{
    cscodec_setbits(BTCTL, BTCTL_TREBCF_MASK,
                    (value - 1) << BTCTL_TREBCF_SHIFT);
}
Ejemplo n.º 14
0
void audiohw_set_bass_cutoff(int value)
{
    cscodec_setbits(BTCTL, BTCTL_BASSCF_MASK,
                    (value - 1) << BTCTL_BASSCF_SHIFT);
}