From 60ce44db389dcb748c618396996a98beaab70739 Mon Sep 17 00:00:00 2001 From: Satish Kodishala Date: Sun, 6 Apr 2014 02:43:03 +0530 Subject: FM: jni: Download patches to QCOM FM chips only. Download patches to QCOM FM chips only. Change-Id: I621ebd0c2c45e44cdfed0539f9937a4940ee45d5 --- jni/android_hardware_fm.cpp | 168 ++++++++++++++++++++++++++------------------ 1 file changed, 99 insertions(+), 69 deletions(-) (limited to 'jni') diff --git a/jni/android_hardware_fm.cpp b/jni/android_hardware_fm.cpp index 46ae7c4..5954be8 100644 --- a/jni/android_hardware_fm.cpp +++ b/jni/android_hardware_fm.cpp @@ -103,28 +103,35 @@ static jint android_hardware_fmradio_FmReceiverJNI_acquireFdNative } else { return FM_JNI_FAILURE; } - /*Set the mode for soc downloader*/ - property_set("hw.fm.mode", "normal"); - /* Need to clear the hw.fm.init firstly */ - property_set("hw.fm.init", "0"); - property_set("ctl.start", "fm_dl"); - sched_yield(); - for(i=0; i<45; i++) { - property_get("hw.fm.init", value, NULL); - if (strcmp(value, "1") == 0) { + + property_get("qcom.bluetooth.soc", value, NULL); + + ALOGD("BT soc is %s\n", value); + + if (strcmp(value, "rome") != 0) + { + /*Set the mode for soc downloader*/ + property_set("hw.fm.mode", "normal"); + /* Need to clear the hw.fm.init firstly */ + property_set("hw.fm.init", "0"); + property_set("ctl.start", "fm_dl"); + sched_yield(); + for(i=0; i<45; i++) { + property_get("hw.fm.init", value, NULL); + if (strcmp(value, "1") == 0) { init_success = 1; break; - } else { + } else { usleep(WAIT_TIMEOUT); - } - } - ALOGE("init_success:%d after %f seconds \n", init_success, 0.2*i); - if(!init_success) { - property_set("ctl.stop", "fm_dl"); - // close the fd(power down) - - close(fd); - return FM_JNI_FAILURE; + } + } + ALOGE("init_success:%d after %f seconds \n", init_success, 0.2*i); + if(!init_success) { + property_set("ctl.stop", "fm_dl"); + // close the fd(power down) + close(fd); + return FM_JNI_FAILURE; + } } return fd; } @@ -135,9 +142,17 @@ static jint android_hardware_fmradio_FmReceiverJNI_closeFdNative { int i = 0; int cleanup_success = 0; - char value = 0, retval =0; + char retval =0; + char value[PROPERTY_VALUE_MAX] = {'\0'}; + + property_get("qcom.bluetooth.soc", value, NULL); - property_set("ctl.stop", "fm_dl"); + ALOGD("BT soc is %s\n", value); + + if (strcmp(value, "rome") != 0) + { + property_set("ctl.stop", "fm_dl"); + } close(fd); return FM_JNI_SUCCESS; } @@ -418,40 +433,48 @@ static jint android_hardware_fmradio_FmReceiverJNI_setNotchFilterNative(JNIEnv * char notch[PROPERTY_VALUE_MAX] = {0x00}; struct v4l2_control control; int err; - /*Enable/Disable the WAN avoidance*/ - property_set("hw.fm.init", "0"); - if (aValue) - property_set("hw.fm.mode", "wa_enable"); - else - property_set("hw.fm.mode", "wa_disable"); - - property_set("ctl.start", "fm_dl"); - sched_yield(); - for(i=0; i<10; i++) { - property_get("hw.fm.init", value, NULL); - if (strcmp(value, "1") == 0) { - init_success = 1; - break; - } else { - usleep(WAIT_TIMEOUT); - } - } - ALOGE("init_success:%d after %f seconds \n", init_success, 0.2*i); - property_get("notch.value", notch, NULL); - ALOGE("Notch = %s",notch); - if (!strncmp("HIGH",notch,strlen("HIGH"))) - control.value = HIGH_BAND; - else if(!strncmp("LOW",notch,strlen("LOW"))) - control.value = LOW_BAND; - else - control.value = 0; - - ALOGE("Notch value : %d", control.value); - control.id = id; - err = ioctl(fd, VIDIOC_S_CTRL,&control ); - if(err < 0){ - return FM_JNI_FAILURE; + property_get("qcom.bluetooth.soc", value, NULL); + + ALOGD("BT soc is %s\n", value); + + if (strcmp(value, "rome") != 0) + { + /*Enable/Disable the WAN avoidance*/ + property_set("hw.fm.init", "0"); + if (aValue) + property_set("hw.fm.mode", "wa_enable"); + else + property_set("hw.fm.mode", "wa_disable"); + + property_set("ctl.start", "fm_dl"); + sched_yield(); + for(i=0; i<10; i++) { + property_get("hw.fm.init", value, NULL); + if (strcmp(value, "1") == 0) { + init_success = 1; + break; + } else { + usleep(WAIT_TIMEOUT); + } + } + ALOGE("init_success:%d after %f seconds \n", init_success, 0.2*i); + + property_get("notch.value", notch, NULL); + ALOGE("Notch = %s",notch); + if (!strncmp("HIGH",notch,strlen("HIGH"))) + control.value = HIGH_BAND; + else if(!strncmp("LOW",notch,strlen("LOW"))) + control.value = LOW_BAND; + else + control.value = 0; + + ALOGE("Notch value : %d", control.value); + control.id = id; + err = ioctl(fd, VIDIOC_S_CTRL,&control ); + if(err < 0){ + return FM_JNI_FAILURE; + } } return FM_JNI_SUCCESS; } @@ -464,22 +487,29 @@ static jint android_hardware_fmradio_FmReceiverJNI_setAnalogModeNative(JNIEnv * char value[PROPERTY_VALUE_MAX] = {'\0'}; char firmwareVersion[80]; - /*Enable/Disable Analog Mode FM*/ - property_set("hw.fm.init", "0"); - if (aValue) { - property_set("hw.fm.isAnalog", "true"); - } else { - property_set("hw.fm.isAnalog", "false"); - } - property_set("hw.fm.mode","config_dac"); - property_set("ctl.start", "fm_dl"); - sched_yield(); - for(i=0; i<10; i++) { - property_get("hw.fm.init", value, NULL); - if (strcmp(value, "1") == 0) { - return 1; + property_get("qcom.bluetooth.soc", value, NULL); + + ALOGD("BT soc is %s\n", value); + + if (strcmp(value, "rome") != 0) + { + /*Enable/Disable Analog Mode FM*/ + property_set("hw.fm.init", "0"); + if (aValue) { + property_set("hw.fm.isAnalog", "true"); } else { - usleep(WAIT_TIMEOUT); + property_set("hw.fm.isAnalog", "false"); + } + property_set("hw.fm.mode","config_dac"); + property_set("ctl.start", "fm_dl"); + sched_yield(); + for(i=0; i<10; i++) { + property_get("hw.fm.init", value, NULL); + if (strcmp(value, "1") == 0) { + return 1; + } else { + usleep(WAIT_TIMEOUT); + } } } -- cgit v1.2.3