Ejemplo n.º 1
0
static void matv_audio_path(char bEnable)
{
    if (bEnable == true)
    {
        Common_Audio_init();
#ifdef ANALOG_AUDIO
        ATV_AudAnalogPath(true);
#else
        Audio_MATV_I2S_Play(true);
#endif
    }
    else
    {
#ifdef ANALOG_AUDIO    
        ATV_AudAnalogPath(false);
#else
        Audio_MATV_I2S_Play(false);
#endif
        Common_Audio_deinit();
    }
}
Ejemplo n.º 2
0
int headset_PhoneTest_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct headset *hds = (struct headset *)priv;
    struct textview *tv;
    struct itemview *iv;

    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&hds->title, param->name, COLOR_YELLOW);
    init_text(&hds->text, &hds->info[0], COLOR_YELLOW);
    init_text(&hds->left_btn, "Fail", COLOR_YELLOW);
    init_text(&hds->center_btn, "Pass", COLOR_YELLOW);
    init_text(&hds->right_btn, "Back", COLOR_YELLOW);

    headset_phonetest_state = 0;

    if (!hds->iv)
    {
        iv = ui_new_itemview();
        if (!iv)
        {
            LOGD(TAG "No memory");
            return -1;
        }
        hds->iv = iv;
    }

    iv = hds->iv;
    iv->set_title(iv, &hds->title);
    iv->set_items(iv, headset_items_auto, 0);
    iv->set_text(iv, &hds->text);
    iv->start_menu(iv, 0);
    iv->redraw(iv);

    Common_Audio_init();

    memset(hds->info, 0, sizeof(hds->info) / sizeof(*(hds->info)));
    hds->recordDevice = BUILTIN_MIC;

    pthread_create(&hds->hRecordThread, NULL, Audio_Record_thread, priv);

    int    play_time = 3000;// 3s
    hds->mod->test_result = FTM_TEST_FAIL;
    ALOGD("start play and freq check");
    //----- Test CH1
    EarphoneTest(1);
    EarphoneTestLR(1);
    for (int i = 0; i < 100 ; i ++)
    {
        usleep(play_time * 10);
    }
    //----- Delay 0.5s
    headset_phonetest_state = 1;
    EarphoneTest(0);
    for (int i = 0; i < 100 ; i ++)
    {
        usleep(500 * 10);
    }
    //----- Test CH2
    EarphoneTest(1);
    EarphoneTestLR(0);
    for (int i = 0; i < 100 ; i ++)
    {
        if (strstr(hds->info, "Check freq pass"))
        {
            hds->mod->test_result = FTM_TEST_PASS;
            ALOGD("Check freq pass");
            //break;
        }
        usleep(play_time * 10);
    }
    EarphoneTest(0);
    ALOGD("stop play and freq check");
    if (hds->mod->test_result == FTM_TEST_FAIL)
    {
        ALOGD("Check freq fail");
    }

    headset_phonetest_state = 2;

    pthread_join(hds->hRecordThread, NULL);
    Common_Audio_deinit();

    LOGD(TAG "%s: End\n", __FUNCTION__);

    return 0;
}
Ejemplo n.º 3
0
int headset_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct headset *hds = (struct headset *)priv;
    struct textview *tv;
    struct itemview *iv;
    int privChosen = -1;
    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&hds->title, param->name, COLOR_YELLOW);
    init_text(&hds->text, &hds->info[0], COLOR_YELLOW);
    init_text(&hds->left_btn, "Fail", COLOR_YELLOW);
    init_text(&hds->center_btn, "Pass", COLOR_YELLOW);
    init_text(&hds->right_btn, "Back", COLOR_YELLOW);

    headset_update_info(hds, hds->info);

    hds->exit_thd = false;

    if (!hds->iv)
    {
        iv = ui_new_itemview();
        if (!iv)
        {
            LOGD(TAG "No memory");
            return -1;
        }
        hds->iv = iv;
    }

    iv = hds->iv;
    iv->set_title(iv, &hds->title);
    iv->set_items(iv, headset_items, 0);
    iv->set_text(iv, &hds->text);

    Common_Audio_init();

    pthread_create(&hds->headset_update_thd, NULL, headset_update_iv_thread, priv);
    do
    {
        chosen = iv->run(iv, &exit);
        switch (chosen)
        {
            case ITEM_RINGTONE:
                if (!hds->avail || privChosen == ITEM_RINGTONE)
                {
                    break;
                }
                if (privChosen == ITEM_HEADSET_MIC && hds->Headset_mic)
                {
                    HeadsetMic_EarphoneLR_Loopback(0, 1);
                }
                usleep(20000);
                EarphoneTest(1);
                privChosen = ITEM_RINGTONE;
                break;
            case ITEM_HEADSET_MIC:
                if (!hds->avail || privChosen == ITEM_HEADSET_MIC || !hds->Headset_mic)
                {
                    break;
                }
                if (privChosen == ITEM_RINGTONE)
                {
                    EarphoneTest(0);
                }
                usleep(20000);
                HeadsetMic_EarphoneLR_Loopback(1, 1);
                privChosen = ITEM_HEADSET_MIC;
                break;
            case ITEM_PASS:
            case ITEM_FAIL:
                if (chosen == ITEM_PASS)
                {
                    hds->mod->test_result = FTM_TEST_PASS;
                }
                else if (chosen == ITEM_FAIL)
                {
                    hds->mod->test_result = FTM_TEST_FAIL;
                }
                exit = true;
                break;
        }

        if (exit)
        {
            hds->exit_thd = true;
            break;
        }
    }
    while (1);

    if (privChosen == ITEM_RINGTONE)
    {
        EarphoneTest(0);
    }
    if (privChosen == ITEM_HEADSET_MIC)
    {
        HeadsetMic_EarphoneLR_Loopback(0, 1);
    }

    pthread_join(hds->headset_update_thd, NULL);

    Common_Audio_deinit();

    return 0;
}
Ejemplo n.º 4
0
//#else
int mAudio_headset_manual_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    char *inputType = NULL;
    struct headset *hds = (struct headset *)priv;
    struct textview *tv;
    struct itemview *iv;
    int privChosen = -1;
    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&hds->title, param->name, COLOR_YELLOW);
    init_text(&hds->text, &hds->info[0], COLOR_YELLOW);
    init_text(&hds->left_btn, "Fail", COLOR_YELLOW);
    init_text(&hds->center_btn, "Pass", COLOR_YELLOW);
    init_text(&hds->right_btn, "Back", COLOR_YELLOW);

    headset_update_info(hds, hds->info);

    hds->exit_thd = false;

    if (!hds->iv)
    {
        iv = ui_new_itemview();
        if (!iv)
        {
            LOGD(TAG "No memory");
            return -1;
        }
        hds->iv = iv;
    }

    iv = hds->iv;
    iv->set_title(iv, &hds->title);
    if (get_is_ata() == 0)
    {
        iv->set_items(iv, headset_items, 0);
    }
    else
    {
        iv->set_items(iv, headset_items_ex, 0);
    }
    iv->set_text(iv, &hds->text);

    Common_Audio_init();

    pthread_create(&hds->headset_update_thd, NULL, headset_update_iv_thread, priv);

    inputType = ftm_get_prop("Audio.Manual.InputType");
    if (inputType != NULL && (atoi(inputType) == 0 || atoi(inputType) == 1 || atoi(inputType) == 2 || atoi(inputType) == 3))
    {
        // @ input != NULL, PC command control mode
        ALOGD("Audio.Manual.InputType = %s", inputType);

        iv->redraw(iv);

        PhoneMic_EarphoneLR_Loopback(MIC1_OFF);
        usleep(20000);
        if (atoi(inputType) == 1)
        {
            ALOGD("Set Mic1 on");
            PhoneMic_EarphoneLR_Loopback(MIC1_ON);
        }
        else if (atoi(inputType) == 2)
        {
            ALOGD("Set Mic2 on");
            PhoneMic_EarphoneLR_Loopback(MIC2_ON);
        }
        else if (atoi(inputType) == 3)
        {
            ALOGD("Set headset Mic on");
            HeadsetMic_EarphoneLR_Loopback(1, 1);
        }

        hds->exit_thd = true;
        pthread_join(hds->headset_update_thd, NULL);
        hds->mod->test_result = FTM_TEST_PASS;

        if (atoi(inputType) == 0)
        {
            ALOGD("Audio Deinit");
            Common_Audio_deinit();
        }

    }
    else
    {
        // Original manual operating mode
        do
        {
            chosen = iv->run(iv, &exit);
            switch (chosen)
            {
                case ITEM_RINGTONE:
                    if (!hds->avail || privChosen == ITEM_RINGTONE)
                    {
                        break;
                    }
                    if (privChosen == ITEM_HEADSET_MIC && hds->Headset_mic)
                    {
                        HeadsetMic_EarphoneLR_Loopback(0, 1);
                    }
                    usleep(20000);
                    EarphoneTest(1);
                    privChosen = ITEM_RINGTONE;
                    break;
                case ITEM_MIC1:
                    if (!hds->avail || privChosen == ITEM_MIC1)
                    {
                        break;
                    }
                    if (privChosen == ITEM_RINGTONE)
                    {
                        EarphoneTest(0);
                    }
                    else if (privChosen == ITEM_MIC2)
                    {
                        PhoneMic_EarphoneLR_Loopback(MIC2_OFF);
                    }
                    else if (privChosen == ITEM_HEADSET_MIC)
                    {
                        HeadsetMic_EarphoneLR_Loopback(0, 1);
                    }

                    usleep(20000);
                    PhoneMic_EarphoneLR_Loopback(MIC1_ON);
                    privChosen = ITEM_MIC1;
                    break;
                case ITEM_MIC2:
                    if (!hds->avail || privChosen == ITEM_MIC2)
                    {
                        break;
                    }
                    if (privChosen == ITEM_RINGTONE)
                    {
                        EarphoneTest(0);
                    }
                    else if (privChosen == ITEM_MIC1)
                    {
                        PhoneMic_EarphoneLR_Loopback(MIC1_OFF);
                    }
                    else if (privChosen == ITEM_HEADSET_MIC)
                    {
                        HeadsetMic_EarphoneLR_Loopback(0, 1);
                    }

                    usleep(20000);
                    PhoneMic_EarphoneLR_Loopback(MIC2_ON);
                    privChosen = ITEM_MIC2;
                    break;
                case ITEM_HEADSET_MIC:
                    if (!hds->avail || privChosen == ITEM_HEADSET_MIC || !hds->Headset_mic)
                    {
                        break;
                    }
                    if (privChosen == ITEM_RINGTONE)
                    {
                        EarphoneTest(0);
                    }
                    else if (privChosen == ITEM_MIC1)
                    {
                        PhoneMic_EarphoneLR_Loopback(MIC1_OFF);
                    }
                    else if (privChosen == ITEM_MIC2)
                    {
                        PhoneMic_EarphoneLR_Loopback(MIC2_OFF);
                    }
                    usleep(20000);
                    HeadsetMic_EarphoneLR_Loopback(1, 1);
                    privChosen = ITEM_HEADSET_MIC;
                    break;
                case ITEM_PASS:
                case ITEM_FAIL:
                    if (chosen == ITEM_PASS)
                    {
                        hds->mod->test_result = FTM_TEST_PASS;
                    }
                    else if (chosen == ITEM_FAIL)
                    {
                        hds->mod->test_result = FTM_TEST_FAIL;
                    }
                    exit = true;
                    break;
            }

            if (exit)
            {
                hds->exit_thd = true;
                break;
            }
        }
        while (1);

        if (privChosen == ITEM_RINGTONE)
        {
            EarphoneTest(0);
        }
        if (privChosen == ITEM_MIC1)
        {
            PhoneMic_EarphoneLR_Loopback(MIC1_OFF);
        }
        if (privChosen == ITEM_MIC2)
        {
            PhoneMic_EarphoneLR_Loopback(MIC2_OFF);
        }
        if (privChosen == ITEM_HEADSET_MIC)
        {
            HeadsetMic_EarphoneLR_Loopback(0, 1);
        }

        pthread_join(hds->headset_update_thd, NULL);

        Common_Audio_deinit();
    }

    return 0;
}
Ejemplo n.º 5
0
int vibrator_manual_entry(struct ftm_param *param, void *priv)
{
	int chosen;
	bool exit = false;
	struct itemview *iv;
	text_t    title;
	char* vibr_time = NULL;
	struct ftm_module *mod = (struct ftm_module *)priv;

	LOGD("%s\n", __FUNCTION__);

	vibrator_test_exit = false;

	iv = ui_new_itemview();
	if (!iv) {
		LOGD("No memory");
		return -1;
	}
        init_text(&title, param->name, COLOR_YELLOW);

	iv->set_title(iv, &title);
	iv->set_items(iv, items, 0);

	vibr_time = ftm_get_prop("Vibrator_Last_Time");
	LOGD("%s: get vibrator last time=%s!\n", __FUNCTION__, vibr_time);
	if(vibr_time != NULL)
	{
		vibrator_time = (uint32_t)atoi(vibr_time);
		LOGD("%s: get vibrator last time=%d!\n", __FUNCTION__, vibrator_time);
	}
	else
	{
		LOGD("%s: get vibrator last time fail!\n", __FUNCTION__);
	}
//#if defined(MTK_VIBSPK_SUPPORT)
    if (IsFTMSupportVibSpk())
     Common_Audio_init();
//#endif
	pthread_create(&vibrator_thread, NULL, update_vibrator_thread, priv);
	
	iv->start_menu(iv, 0);
	iv->redraw(iv);
	do {
		if(param->test_type == FTM_MANUAL_ITEM){
		chosen = iv->run(iv, &exit);
		switch (chosen) {
		case ITEM_PASS:
		case ITEM_FAIL:
			if (chosen == ITEM_PASS) {
				mod->test_result = FTM_TEST_PASS;
			} else if (chosen == ITEM_FAIL) {
				mod->test_result = FTM_TEST_FAIL;
			}
			exit = true;
			break;
		}

		if (exit) {
			vibrator_test_exit = true;
			break;
		}
		}
		else{
			if(vibrator_test_exit)
				break;
		}
	} while (1);
	//pthread_join(vibrator_thread, NULL);

//    #if defined(MTK_VIBSPK_SUPPORT)
    if (IsFTMSupportVibSpk())
    Common_Audio_deinit();
//    #endif

	return 0;
}
Ejemplo n.º 6
0
int vibrator_autotest_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct mVibrator *mc = (struct mVibrator *)priv;
    struct textview *tv;
    struct itemview *iv;

    ALOGD(TAG "%s\n", __FUNCTION__);
    init_text(&mc->title, param->name, COLOR_YELLOW);
    init_text(&mc->text, "", COLOR_YELLOW);
    init_text(&mc->left_btn, uistr_key_fail, COLOR_YELLOW);
    init_text(&mc->center_btn, uistr_key_pass, COLOR_YELLOW);
    init_text(&mc->right_btn, uistr_key_back, COLOR_YELLOW);
    
    // init Audio
    Common_Audio_init();
    mc->exit_thd = false;
    vibrator_test_exit = false;

    // ui start
    if (!mc->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            ALOGD(TAG "No memory");
            return -1;
        }
        mc->iv = iv;
    }
    
    iv = mc->iv;
    iv->set_title(iv, &mc->title);
    iv->set_items(iv, items_auto, 0);
    iv->set_text(iv, &mc->text);
	iv->start_menu(iv,0);
    iv->redraw(iv);

    memset(mc->info, 0, sizeof(mc->info) / sizeof(*(mc->info)));
    mc->i4Playtime = 5*1000;//ms         //read_preferred_ringtone_time() = 5
    mc->recordDevice = WIRED_HEADSET;
    pthread_create(&mc->hHeadsetThread, NULL, update_vibrator_thread, priv);
    pthread_create(&mc->hRecordThread, NULL, Audio_Record_thread, priv);
    
    int    play_time = mc->i4Playtime;
    mc->mod->test_result = FTM_TEST_FAIL;

    int i;
    for(i = 0; i < 100 ; i ++)
    {
      //ALOGD("check mc info:%d",i);
      if (strstr(mc->info, "Check freq pass")) 
      {      
          mc->mod->test_result = FTM_TEST_PASS;
          ALOGD("Check freq pass");
          break;
      }
      usleep(play_time * 10);
    }

    if(mc->mod->test_result == FTM_TEST_FAIL)
       ALOGD("Check freq fail");

    if(mc->mod->test_result == FTM_TEST_PASS)
        usleep(2000000);

    mc->exit_thd = true;
    vibrator_test_exit = true;
	
    pthread_join(mc->hRecordThread, NULL);
    pthread_join(mc->hHeadsetThread, NULL);
    Common_Audio_deinit();
    
    LOGD(TAG "%s: End\n", __FUNCTION__);
    return 0;
}
Ejemplo n.º 7
0
int fmtx_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct fmtx_factory *fmtx = (struct fmtx_factory *)priv;
    struct textview *tv;
    struct itemview *iv;

    LOGD("%s\n", __FUNCTION__);

    memset(&fmtx->info[0], 0, sizeof(fmtx->info));
    memset(&fmtx->info[0], '\n', 10);

    init_text(&fmtx->title, param->name, COLOR_YELLOW);
    init_text(&fmtx->text, &fmtx->info[0], COLOR_YELLOW);

    /* show text view */
    if (!fmtx->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD("No memory for item view");
            return -1;
        }
        fmtx->iv = iv;
    }

    iv = fmtx->iv;
    iv->set_title(iv, &fmtx->title);
    iv->set_items(iv, fmtx_items, 0);
    iv->set_text(iv, &fmtx->text);
	 #ifdef MTK_AUDIO
    Common_Audio_init();
	 #endif

    /* initialize thread condition */
    read_preferred_freq();
    fmtx->exit_thd = false;
    fmtx->result = false;
    pthread_create(&fmtx->update_thd, NULL, fmtx_update_thread, priv);

    /* process procedure */
    do {
        chosen = iv->run(iv, &exit);
        switch (chosen) {
        case ITEM_FREQ0:
            g_txsetfreq = 1;
            g_txfreq_item = 0;
            break;
        case ITEM_FREQ1:
            g_txsetfreq = 1;
            g_txfreq_item = 1;
            break;
        case ITEM_FREQ2:
            g_txsetfreq = 1;
            g_txfreq_item = 2;
            break;
        case ITEM_FREQ3:
            g_txsetfreq = 1;
            g_txfreq_item = 3;
            break;
        case ITEM_FREQ4:
            g_txsetfreq = 1;
            g_txfreq_item = 4;
            break;
        case ITEM_FREQ5:
            g_txsetfreq = 1;
            g_txfreq_item = 5;
            break;
        case ITEM_FREQ6:
            g_txsetfreq = 1;
            g_txfreq_item = 6;
            break;
        case ITEM_FREQ7:
            g_txsetfreq = 1;
            g_txfreq_item = 7;
            break;
        case ITEM_FREQ8:
            g_txsetfreq = 1;
            g_txfreq_item = 8;
            break;
        case ITEM_FREQ9:
            g_txsetfreq = 1;
            g_txfreq_item = 9;
            break;
        case ITEM_PASS:
        case ITEM_FAIL:
//      case ITEM_RETURN:
            if (chosen == ITEM_PASS) {
                fmtx->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                fmtx->mod->test_result = FTM_TEST_FAIL;
            }
            g_txsetfreq = 0;        
            exit = true;
            break;
        }

        if (exit) {
            fmtx->exit_thd = true;
            break;
        }
    } while (1);
    pthread_join(fmtx->update_thd, NULL);
	 #ifdef MTK_AUDIO
    Common_Audio_deinit();
	 #endif

    return 0;
}