Example #1
0
static void aml_asoc_work_func(struct work_struct *work)
{
    struct aml_audio_private_data *p_aml_audio = NULL;
    struct snd_soc_card *card = NULL;
  //  int jack_type = 0;
    int flag = -1;
	int status = SND_JACK_HEADPHONE;
    p_aml_audio = container_of(work, struct aml_audio_private_data, work);
    card = (struct snd_soc_card *)p_aml_audio->data;

    flag = aml_audio_hp_detect(p_aml_audio);

    if(p_aml_audio->detect_flag != flag) {

        p_aml_audio->detect_flag = flag;
        
        if (flag & 0x1) {
            //amlogic_set_value(p_aml_audio->gpio_mute, 0, "mute_spk");
            switch_set_state(&p_aml_audio->sdev, 2);  // 1 :have mic ;  2 no mic
            adac_wr_reg (71, 0x0101); // use board mic
            printk(KERN_INFO "aml aduio hp pluged 3 jack_type: %d\n", SND_JACK_HEADPHONE);
            snd_soc_jack_report(&p_aml_audio->jack, status, SND_JACK_HEADPHONE);

           // mic port detect
           if(p_aml_audio->mic_det){
               if(flag & 0x8){
                  switch_set_state(&p_aml_audio->mic_sdev, 1);
                  adac_wr_reg (71, 0x0005); // use hp mic
                  printk(KERN_INFO "aml aduio mic pluged jack_type: %d\n", SND_JACK_MICROPHONE);
                  //snd_soc_jack_report(&p_aml_audio->jack, status, SND_JACK_HEADPHONE);
              }
           }

        } else if(flag & 0x2){
            //amlogic_set_value(p_aml_audio->gpio_mute, 0, "mute_spk");
            switch_set_state(&p_aml_audio->sdev, 1);  // 1 :have mic ;  2 no mic
            adac_wr_reg (71, 0x0005); // use hp mic
            printk(KERN_INFO "aml aduio hp pluged 4 jack_type: %d\n", SND_JACK_HEADSET);
            snd_soc_jack_report(&p_aml_audio->jack, status, SND_JACK_HEADPHONE);
        } else {
            printk(KERN_INFO "aml audio hp unpluged\n");
            //amlogic_set_value(p_aml_audio->gpio_mute, 1, "mute_spk");
            adac_wr_reg (71, 0x0101); // use board mic
            switch_set_state(&p_aml_audio->sdev, 0);
            snd_soc_jack_report(&p_aml_audio->jack, 0, SND_JACK_HEADPHONE);

            // mic port detect
            if(p_aml_audio->mic_det){
                if(flag & 0x8){
                   switch_set_state(&p_aml_audio->mic_sdev, 1);
                   adac_wr_reg (71, 0x0005); // use hp mic
                   printk(KERN_INFO "aml aduio mic pluged jack_type: %d\n", SND_JACK_MICROPHONE);
                   //snd_soc_jack_report(&p_aml_audio->jack, status, SND_JACK_HEADPHONE);
               }
            }
        }
        
    }
    p_aml_audio->hp_det_status = true;
}
Example #2
0
void adac_startup_seq(void)
{
    /* toggle pdz 0->1 */
    adac_wr_reg(17, adac_rd_reg(17) & ~0x80);
    adac_latch();
    adac_wr_reg(17, adac_rd_reg(17) | 0x80);
    adac_latch();

    /* toggle rstdpz 0->1 */
    adac_wr_reg(0, adac_rd_reg(0) & ~2);
    adac_latch();
    adac_wr_reg(0, adac_rd_reg(0) | 2);
    adac_latch();
}
Example #3
0
void adac_latch(void)
{
    adac_wr_reg(1, 1);
    adac_wr_reg(1, 0);
}
Example #4
0
void adac_power_up_mode_2(void)
{
    adac_wr_reg(224, 0x11);
}
Example #5
0
void wr_regbank (unsigned long rstdpz,
                 unsigned long mclksel, 
                 unsigned long i2sfsadc, 
                 unsigned long i2sfsdac, 
                 unsigned long i2ssplit, 
                 unsigned long i2smode, 
                 unsigned long pdauxdrvrz, 
                 unsigned long pdauxdrvlz, 
                 unsigned long pdhsdrvrz, 
                 unsigned long pdhsdrvlz, 
                 unsigned long pdlsdrvz, 
                 unsigned long pddacrz, 
                 unsigned long pddaclz, 
                 unsigned long pdz, 
                 unsigned long pdmbiasz, 
                 unsigned long pdvcmbufz,
                 unsigned long pdrpgaz, 
                 unsigned long pdlpgaz, 
                 unsigned long pdadcrz, 
                 unsigned long pdadclz, 
                 unsigned long hsmute, 
                 unsigned long recmute, 
                 unsigned long micmute, 
                 unsigned long lmmute, 
                 unsigned long lsmute, 
                 unsigned long lmmix, 
                 unsigned long recmix, 
                 unsigned long ctr, 
                 unsigned long enhp, 
                 unsigned long lmvol, 
                 unsigned long hsvol, 
                 unsigned long pbmix, 
                 unsigned long lsmix, 
                 unsigned long micvol, 
                 unsigned long recvol, 
                 unsigned long recsel) 
{
    adac_wr_reg(0, (rstdpz<<1));
    adac_wr_reg(2, (mclksel<<0));
    adac_wr_reg(12, (i2sfsadc<<4) | (i2sfsdac<<0));
    adac_wr_reg(13, (i2ssplit<<3) | (i2smode<<0));
    adac_wr_reg(16, (pdauxdrvrz<<7) | (pdauxdrvlz<<6) | (pdhsdrvrz<<5) | (pdhsdrvlz<<4) | (pdlsdrvz<<2) | (pddacrz<<1) | (pddaclz<<0));
    adac_wr_reg(17, (pdz<<7) | (pdmbiasz<<5) | (pdvcmbufz<<4) | (pdrpgaz<<3) | (pdlpgaz<<2) | (pdadcrz<<1) | (pdadclz<<0));
    adac_wr_reg(24, (hsmute<<6) | (recmute<<4) | (micmute<<2) | (lmmute<<0));
    adac_wr_reg(25, (lsmute<<2));
    adac_wr_reg(26, (lmmix<<5) | (recmix<<3) | (ctr<<1) | (enhp<<0));
    adac_wr_reg(32, (lmvol&0xff));
    adac_wr_reg(33, (lmvol>>8));
    adac_wr_reg(34, (hsvol&0xff));
    adac_wr_reg(35, (hsvol>>8));
    adac_wr_reg(36, (pbmix&0xff));
    adac_wr_reg(37, (pbmix>>8));
    adac_wr_reg(38, (lsmix&0xff));
    adac_wr_reg(39, (lsmix>>8));
    adac_wr_reg(64, (micvol&0xff));
    adac_wr_reg(65, (micvol>>8));
    adac_wr_reg(66, (recvol&0xff));
    adac_wr_reg(67, (recvol>>8));
    adac_wr_reg(72, (recsel&0xff));
    adac_wr_reg(73, (recsel>>8));
} /* wr_regbank */