示例#1
0
void audiohw_set_master_vol(int vol_l, int vol_r)
{
    unsigned int hph_r, hph_l;
    unsigned int mix_l, mix_r;

    if (vol_l == 0 && vol_r == 0) {
        audiohw_mute(true);
        return;
    }

    /* We combine the mixer/DAC channel volume range with the headphone volume
       range - keep first stage as loud as possible */

/*AS3543 mixer can go a little louder then the as3514, although 
 * it might be possible to go louder on the as3514 as well */
 
#if CONFIG_CPU == AS3525v2 
#define MIXER_MAX_VOLUME 0x1b
#else /* lets leave the AS3514 alone until its better tested*/
#define MIXER_MAX_VOLUME 0x16
#endif

    if (vol_r <= MIXER_MAX_VOLUME) {
        mix_r = vol_r;
        hph_r = 0;
    } else {
        mix_r = MIXER_MAX_VOLUME;
        hph_r = vol_r - MIXER_MAX_VOLUME;
    }

    if (vol_l <= MIXER_MAX_VOLUME) {
        mix_l = vol_l;
        hph_l = 0;
    } else {
        mix_l = MIXER_MAX_VOLUME;
        hph_l = vol_l - MIXER_MAX_VOLUME;
    }    


    as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK);
    as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK);
#if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
    as3514_write_masked(AS3514_LINE_IN_R, mix_r, AS3514_VOL_MASK);
    as3514_write_masked(AS3514_LINE_IN_L, mix_l, AS3514_VOL_MASK);
#endif
    as3514_write_masked(AS3514_HPH_OUT_R, hph_r, AS3514_VOL_MASK);
    as3514_write_masked(AS3514_HPH_OUT_L, hph_l, AS3514_VOL_MASK);

    audiohw_mute(false);
}
示例#2
0
文件: wm8975.c 项目: albb0920/rockbox
void audiohw_postinit(void)
{
    wm8975_regs[PWRMGMT1] &= ~PWRMGMT1_VMIDSEL_MASK;
    wm8975_regs[PWRMGMT1] |= PWRMGMT1_VMIDSEL_50K;
    wm8975_write(PWRMGMT1, wm8975_regs[PWRMGMT1]);
    audiohw_mute(false);
}
示例#3
0
void audiohw_postinit(void)
{
    cscodec_write(HPACTL, 0);
    cscodec_write(HPBCTL, 0);
    cscodec_write(LINEACTL, 0);
    cscodec_write(LINEBCTL, 0);
    cscodec_write(CLSHCTL, CLSHCTL_ADPTPWR_SIGNAL);
    audiohw_mute(false);
}
示例#4
0
/* Enable DACs and audio output after a short delay */
void audiohw_postinit(void)
{
    /* From app notes: allow Vref to stabilize to reduce clicks */
    sleep(HZ);

     /* 3. Enable DACs as required. */
    wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR);

     /* 4. Enable line and / or headphone output buffers as required. */
#if defined(MROBE_100) || defined(MPIO_HD200)
    wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR |
                  PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1);
#else
    wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR |
                  PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1 | PWRMGMT2_LOUT2 |
                  PWRMGMT2_ROUT2);
#endif

    wmcodec_write(ADDITIONAL1, ADDITIONAL1_TSDEN | ADDITIONAL1_TOEN |
                    ADDITIONAL1_DMONOMIX_LLRR | ADDITIONAL1_VSEL_DEFAULT);

    wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO | LEFTMIX1_LI2LO_DEFAULT);
    wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO | RIGHTMIX2_RI2RO_DEFAULT);

#ifdef TOSHIBA_GIGABEAT_F
#ifdef HAVE_HARDWARE_BEEP
    /* Single-ended mono input */
    wmcodec_write(MONOMIX1, 0);

    /* Route mono input to both outputs at 0dB */
    wmcodec_write(LEFTMIX2, LEFTMIX2_MI2LO | LEFTMIX2_MI2LOVOL(2));
    wmcodec_write(RIGHTMIX1, RIGHTMIX1_MI2RO | RIGHTMIX1_MI2ROVOL(2));
#endif
#endif

#ifdef MPIO_HD200
    /* Crude fix for high pitch noise at startup
     * I should find out what realy causes this
     */
    wmcodec_write(LOUT1, LOUT1_BITS|0x7f);
    wmcodec_write(ROUT1, ROUT1_BITS|0x7f);
    wmcodec_write(LOUT1, LOUT1_BITS);
    wmcodec_write(ROUT1, ROUT1_BITS);
#endif

    /* lower power consumption */
    wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_50K);

    audiohw_mute(false);

#ifdef MROBE_100
    /* enable headphone output */
    GPIOL_OUTPUT_VAL &= ~0x10;
    GPIOL_OUTPUT_EN  |=  0x10;
#endif
}
示例#5
0
文件: wm8975.c 项目: albb0920/rockbox
/* Nice shutdown of WM8975 codec */
void audiohw_close(void)
{
    audiohw_mute(true);

    /* 2. Disable all output buffers. */
    wm8975_write(PWRMGMT2, 0x0);

    /* 3. Switch off the power supplies. */
    wm8975_write(PWRMGMT1, 0x0);
}
示例#6
0
文件: wm8751.c 项目: eckyecky/rt-n56u
/* Nice shutdown of WM8751 codec */
void audiohw_close(void)
{
	/* 1. Set DACMU = 1 to soft-mute the audio DACs. */
	audiohw_mute(true);

	/* 2. Disable all output buffers. */
	wmcodec_write(PWRMGMT2, 0x0);

	/* 3. Switch off the power supplies. */
	wmcodec_write(PWRMGMT1, 0x0);
}
示例#7
0
/* Nice shutdown of CS42L55 codec */
void audiohw_close(void)
{
    audiohw_mute(true);
    cscodec_write(HPACTL, HPACTL_HPAMUTE);
    cscodec_write(HPBCTL, HPBCTL_HPBMUTE);
    cscodec_write(LINEACTL, LINEACTL_LINEAMUTE);
    cscodec_write(LINEBCTL, LINEBCTL_LINEBMUTE);
    cscodec_write(PWRCTL1, PWRCTL1_PDN_CHRG | PWRCTL1_PDN_ADCA
                         | PWRCTL1_PDN_ADCB | PWRCTL1_PDN_CODEC);
    cscodec_reset(true);
    cscodec_clock(false);
    cscodec_power(false);
}
void audiohw_postinit(void)
{
    sleep(HZ);

    audiohw_mute(false);

#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
    /* We need to enable bit 4 of GPIOL for output for sound on H10 */
    GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x10);
#elif defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330)
    GPO32_ENABLE |= 0x2;
    GPO32_VAL &= ~0x2;
#endif
}
示例#9
0
文件: wm8750.c 项目: jhbsz/wifiaudio
/* Nice shutdown of WM8751 codec */
void audiohw_close(void)
{
    /* 1. Set DACMU = 1 to soft-mute the audio DACs. */
    audiohw_mute(true);

    wmcodec_write(LADCVOL, 0);
    wmcodec_write(RADCVOL, 0);

    /* 2. Disable all output buffers. */
    wmcodec_write(PWRMGMT2, 0x0);

    /* 3. Switch off the power supplies. */
    wmcodec_write(PWRMGMT1, 0x0);

    memset(wmcodec_reg_data, 0 , sizeof(unsigned long)*48);
}
示例#10
0
文件: wm8751.c 项目: IlVerz/rockbox
/* Nice shutdown of WM8751 codec */
void audiohw_close(void)
{
    /* 1. Set DACMU = 1 to soft-mute the audio DACs. */
    audiohw_mute(true);

#ifdef MPIO_HD200
    /* disable headphone out */
    and_l(~(1<<25), &GPIO1_OUT);
#endif

    /* 2. Disable all output buffers. */
    wmcodec_set_reg(PWRMGMT2, 0x0);

    /* 3. Switch off the power supplies. */
    wmcodec_set_reg(PWRMGMT1, 0x0);
}
示例#11
0
void audiohw_close(void)
{
    /* 1. Mute all analogue outputs */
    audiohw_mute(true);
    audiohw_enable_headphone_jack(false);

    /* 2. Disable power management register 1. R1 = 00 */
    wmc_write(WMC_POWER_MANAGEMENT1, 0x000);

    /* 3. Disable power management register 2. R2 = 00 */
    wmc_write(WMC_POWER_MANAGEMENT2, 0x000);

    /* 4. Disable power management register 3. R3 = 00 */
    wmc_write(WMC_POWER_MANAGEMENT3, 0x000);

    /* 5. Remove external power supplies. */
}
示例#12
0
void audiohw_postinit(void)
{
    /* wait until outputs have stabilized */
    sleep(HZ/4);

#ifdef CPU_PP
    ascodec_suppressor_on(false);
#endif

#if defined(SANSA_E200V2) || defined(SANSA_FUZE)
    /* Set line out volume to 0dB */
    as3514_write_masked(AS3514_LINE_OUT_R, 0x1b, AS3514_VOL_MASK);
    as3514_write_masked(AS3514_LINE_OUT_L, 0x1b, AS3514_VOL_MASK);
#endif /* SANSA_E200V2 || SANSA_FUZE */

    audiohw_mute(false);
}
示例#13
0
/* Nice shutdown of AS3514 audio codec */
void audiohw_close(void)
{
    /* mute headphones */
    audiohw_mute(true);

#ifdef CPU_PP
    ascodec_suppressor_on(true);
#endif

    /* turn on common */
    as3514_clear(AS3514_AUDIOSET3, AUDIOSET3_HPCM_off);

    /* turn off everything */
    as3514_clear(AS3514_HPH_OUT_L, HPH_OUT_L_HP_ON);
    as3514_write(AS3514_AUDIOSET1, 0x0);

    /* Allow caps to discharge */
    sleep(HZ/4);
}
示例#14
0
/* Enable DACs and audio output after a short delay */
void audiohw_postinit(int bSlave, int Aout)
{
	int i;
    /* From app notes: allow Vref to stabilize to reduce clicks */
    for(i = 0; i < 1000*HZ; i++);

     /* 3. Enable DACs as required. */
    wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR);

     /* 4. Enable line and / or headphone output buffers as required. */
    wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR |
                  PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1 | PWRMGMT2_LOUT2 |
                 PWRMGMT2_ROUT2);

    wmcodec_write(ADDITIONAL1, ADDITIONAL1_TSDEN | ADDITIONAL1_TOEN |
                    ADDITIONAL1_DMONOMIX_LLRR | ADDITIONAL1_VSEL_DEFAULT);

	wmcodec_write(ADDITIONAL2, 0x08);


    wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO | LEFTMIX1_LI2LO_DEFAULT);
    wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO | RIGHTMIX2_RI2RO_DEFAULT);

	 /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
    /* IWL=00(16 bit) FORMAT=10(I2S format) */
	if(bSlave)
	{ 
		MSG("WM8751 slave.....\n");
		wmcodec_write(AINTFCE, AINTFCE_WL_16 | AINTFCE_FORMAT_I2S);
	}	
	else
	{
		MSG("WM8751 master.....\n");
  		/* AINTFCE_BCLKINV on or off depend on trying result */
    	wmcodec_write(AINTFCE, AINTFCE_MS | AINTFCE_WL_16 | AINTFCE_FORMAT_I2S);	
   	}


    audiohw_mute(false);
}
示例#15
0
void audiohw_postinit(void)
{
    audiohw_mute(false);
    //HP_turn_on();
}
void audiohw_close(void)
{
    /* mute headphones */
    audiohw_mute(true);
}
void audiohw_postinit(void)
{
    audiohw_mute(false);
}
示例#18
0
文件: wm8750.c 项目: jhbsz/wifiaudio
/* Enable DACs and audio output after a short delay */
void audiohw_postinit(int bSlave, int AIn, int AOut)
{
    int i;
    unsigned long data;

    if(wmcodec_reg_data[RESET]!=0xFFFF)
        return;

    /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
    /* IWL=00(16 bit) FORMAT=10(I2S format) */

    if(bSlave)
    {
        MSG("WM8750 slave.....\n");
        wmcodec_write(AINTFCE, AINTFCE_WL_16 | AINTFCE_FORMAT_I2S);
    }
    else
    {
        MSG("WM8750 master.....\n");
        /* AINTFCE_BCLKINV on or off depend on trying result */
        wmcodec_write(AINTFCE, AINTFCE_MS | AINTFCE_WL_16 | AINTFCE_FORMAT_I2S);
    }

    wmcodec_reg_data[RESET] = 0x5A5A;

    /* From app notes: allow Vref to stabilize to reduce clicks */
    for(i = 0; i < 1000*HZ; i++);

    data = wmcodec_reg_data[PWRMGMT1];

    if(AIn > 0)
        wmcodec_write(PWRMGMT1, data | PWRMGMT1_ADCL | PWRMGMT1_ADCR | PWRMGMT1_AINL | PWRMGMT1_AINR |PWRMGMT1_MICB);
    //wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_50K | PWRMGMT1_ADCL | PWRMGMT1_ADCR | PWRMGMT1_AINL | PWRMGMT1_AINR );

    /* 3. Enable DACs as required. */
    if(AOut > 0)
    {
        data = PWRMGMT2_DACL | PWRMGMT2_DACR;
        switch(AOut)
        {
        case 1:
            data |= PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1;
            break;
        case 2:
            data |= PWRMGMT2_LOUT2 | PWRMGMT2_ROUT2;
            break;
        case 3:
            data |= PWRMGMT2_OUT3;
            break;
        default:
            break;
        }
        wmcodec_write(PWRMGMT2,   data);
    }
    else
    {
        wmcodec_write(PWRMGMT2, 0);
    }

    /* 4. Enable line and / or headphone output buffers as required. */
    wmcodec_write(ADDITIONAL1, ADDITIONAL1_TOEN | ADDITIONAL1_DMONOMIX_LLRR | ADDITIONAL1_VSEL_DEFAULT);

    if(AOut==2)
    {
        wmcodec_write(ADDITIONAL2, ADDITIONAL2_HPSWEN|ADDITIONAL2_HPSWPOL);
    }
    else
    {
        wmcodec_write(ADDITIONAL2, ADDITIONAL2_LRCM_ON);
    }

    wmcodec_write(ADDITIONAL3, ADDITIONAL3_ADCLRM(0));

    wmcodec_write(RIGHTMIX1, 0);
    wmcodec_write(LEFTMIX2, 0);
    if(AOut > 0)
    {
        wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO);
        wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO);
        wmcodec_write(LOUT1, 0x179);
        wmcodec_write(ROUT1, 0x179);
        wmcodec_write(LEFTGAIN, 0x1FF);
        wmcodec_write(RIGHTGAIN, 0x1FF);
    }
    else
    {
        wmcodec_write(LEFTMIX1, 0);
        wmcodec_write(RIGHTMIX2, 0);
        wmcodec_write(LOUT1, 0);
        wmcodec_write(ROUT1, 0);
    }
    wmcodec_write(MONOMIX1, 0);
    wmcodec_write(MONOMIX2, 0);
    wmcodec_write(ADCCTRL, ADCCTRL_ADCHPD);
    if(AIn>0)
    {
        //wmcodec_write(LINV, LINV_LINVOL(0x00)|LINV_LIVU);
        //wmcodec_write(RINV, RINV_RINVOL(0x00)|RINV_RIVU);
        //wmcodec_write(LINV, 0x117);
        //wmcodec_write(RINV, 0x117);
        wmcodec_write(LINV, 0x100);
        wmcodec_write(RINV, 0x100);

        wmcodec_write(ALC1, 0);
        wmcodec_write(NOISEGATE, 0x03);
        //wmcodec_write(ALC1, ALC1_ALCL(0x01)|ALC1_SET_MAXGAIN(0x1)|ALC1_ALCSTEREO);
        //wmcodec_write(NOISEGATE, NOISEGATE_SET_NGTH(0x1F)|NOISEGATE_SET_NGG(0x01)|NOISEGATE_NGAT_ENABLE);

        audiohw_sel_input(AIn);
    }
    else
    {
        wmcodec_write(LINV, LINV_LINMUTE);
        wmcodec_write(RINV, RINV_RINMUTE);
    }

    //wmcodec_write(LEFTGAIN, 0x1FF);
    //wmcodec_write(RIGHTGAIN, 0x1FF);
    if(AOut > 0)
        audiohw_mute(false);
    else
        audiohw_mute(true);
}
示例#19
0
文件: wm8751.c 项目: IlVerz/rockbox
/* Enable DACs and audio output after a short delay */
void audiohw_postinit(void)
{
    /* From app notes: allow Vref to stabilize to reduce clicks */
    sleep(HZ);

#ifdef AUDIOHW_HAVE_DEPTH_3D
    wmcodec_set_bits(ENHANCE_3D, ENHANCE_3D_MODE3D_PLAYBACK);
#endif

     /* 3. Enable DACs as required. */
    wmcodec_set_bits(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR);

     /* 4. Enable line and / or headphone output buffers as required. */
#if defined(GIGABEAT_F)
    /* headphones + line-out */
    wmcodec_set_bits(PWRMGMT2, PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1 | 
                     PWRMGMT2_LOUT2 | PWRMGMT2_ROUT2);
#else
    /* headphones */
    wmcodec_set_bits(PWRMGMT2, PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1);
#endif

    /* Full -0dB on the DACS */
    wmcodec_set_bits(LEFTGAIN, 0xff);
    wmcodec_set_bits(RIGHTGAIN, RIGHTGAIN_RDVU | 0xff);

    /* Enable Thermal shutdown, Timeout when zero-crossing in use,
     * set analog bias for 3.3V, monomix to DACR
     */
    wmcodec_set_reg(ADDITIONAL1, ADDITIONAL1_TSDEN | ADDITIONAL1_TOEN |
                    ADDITIONAL1_DMONOMIX_LLRR | ADDITIONAL1_VSEL_DEFAULT);


    /* Enable zero-crossing in out stage */
    wmcodec_set_bits(LOUT1, LOUT1_LO1ZC);
    wmcodec_set_bits(ROUT1, ROUT1_RO1ZC);
    wmcodec_set_bits(LOUT2, LOUT2_LO2ZC);
    wmcodec_set_bits(ROUT2, ROUT2_RO2ZC);

    /* route signal from DAC to mixers */
    wmcodec_set_bits(LEFTMIX1, LEFTMIX1_LD2LO);
    wmcodec_set_bits(RIGHTMIX2, RIGHTMIX2_RD2RO);

#ifdef TOSHIBA_GIGABEAT_F
#ifdef HAVE_HARDWARE_BEEP
    /* Single-ended mono input */
    wmcodec_set_reg(MONOMIX1, 0x00);

    /* Route mono input to both outputs at 0dB */
    wmcodec_set_reg(LEFTMIX2, LEFTMIX2_MI2LO | LEFTMIX2_MI2LOVOL(2));
    wmcodec_set_reg(RIGHTMIX1, RIGHTMIX1_MI2RO | RIGHTMIX1_MI2ROVOL(2));
#endif
#endif

    /* lower power consumption */
    wmcodec_set_masked(PWRMGMT1, PWRMGMT1_VMIDSEL_50K,
                       PWRMGMT1_VMIDSEL_MASK);

    audiohw_mute(false);

#ifdef MROBE_100
    /* enable headphone output */
    GPIOL_OUTPUT_VAL &= ~0x10;
    GPIOL_OUTPUT_EN  |=  0x10;
#endif

#ifdef MPIO_HD200
   /* enable headphone output */
   or_l((1<<25),&GPIO1_OUT);
#endif
}