static int aml_audio_hp_detect(struct aml_audio_private_data *p_aml_audio) { // return 0; int loop_num = 0; int ret; mutex_lock(&p_aml_audio->lock); while(loop_num < 2){ ret = hp_det_adc_value(p_aml_audio); if(p_aml_audio->hp_last_state != ret){ loop_num = 0; msleep(30); if(ret < 0){ ret = p_aml_audio->hp_last_state; }else { p_aml_audio->hp_last_state = ret; } }else{ msleep(30); loop_num = loop_num + 1; } } mutex_unlock(&p_aml_audio->lock); return ret; }
static int aml_audio_hp_detect(struct aml_audio_private_data *p_aml_audio) { int loop_num = 0; int ret; p_aml_audio->hp_det_status = false; // mutex_lock(&p_aml_audio->lock); while(loop_num < 3){ ret = hp_det_adc_value(p_aml_audio); if(p_aml_audio->hp_last_state != ret){ loop_num = 0; msleep_interruptible(50); if(ret < 0){ ret = p_aml_audio->hp_last_state; }else { p_aml_audio->hp_last_state = ret; } }else{ msleep_interruptible(50); loop_num = loop_num + 1; } } // mutex_unlock(&p_aml_audio->lock); return ret; }