From a17a340ddd594ab125002b330a51860cb0943e20 Mon Sep 17 00:00:00 2001 From: himta ram Date: Thu, 25 Apr 2019 17:13:28 +0530 Subject: FM: Use btconfigstore interface to fetch vendor features Use btconfigstore interface to dynamically set and get property. CRs-Fixed: 2445111 Change-Id: I42ed713a0ee2d1ae8be51816c3555d4c114d4153 --- jni/android_hardware_fm.cpp | 152 +++++++++++++++++++++----------------------- 1 file changed, 74 insertions(+), 78 deletions(-) diff --git a/jni/android_hardware_fm.cpp b/jni/android_hardware_fm.cpp index 451cbf0..1a5cbba 100644 --- a/jni/android_hardware_fm.cpp +++ b/jni/android_hardware_fm.cpp @@ -663,17 +663,37 @@ static fm_vendor_callbacks_t fm_callbacks = { fm_enable_softmute_cb }; /* native interface */ + +static bool is_soc_pronto() { + if(strcmp(soc_name, "pronto") == 0) + return true; + else + return false; +} + +static void get_property(int ptype, char *value) +{ + std::vector vPropList; + bt_configstore_intf->get_vendor_properties(ptype, vPropList); + + for (auto&& vendorProp : vPropList) { + if (vendorProp.type == ptype) { + strlcpy(value, vendorProp.value,PROPERTY_VALUE_MAX); + } + } +} + static jint android_hardware_fmradio_FmReceiverJNI_acquireFdNative (JNIEnv* env, jobject thiz, jstring path) { int fd; int i, retval=0, err; char value[PROPERTY_VALUE_MAX] = {'\0'}; - char versionStr[40] = {'\0'}; int init_success = 0; jboolean isCopy; v4l2_capability cap; const char* radio_path = env->GetStringUTFChars(path, &isCopy); + if(radio_path == NULL){ return FM_JNI_FAILURE; } @@ -689,39 +709,33 @@ static jint android_hardware_fmradio_FmReceiverJNI_acquireFdNative ALOGD("VIDIOC_QUERYCAP returns :%d: version: %d \n", err , cap.version ); - if( err >= 0 ) { - ALOGD("Driver Version(Same as ChipId): %x \n", cap.version ); - /*Conver the integer to string */ - snprintf(versionStr, sizeof(versionStr), "%d", cap.version); - property_set("vendor.hw.fm.version", versionStr); - } else { - close(fd); - return FM_JNI_FAILURE; - } - - if ((strcmp(soc_name, "rome") != 0) && (strcmp(soc_name, "hastings") != 0)) + if (is_soc_pronto()) { /*Set the mode for soc downloader*/ - property_set("vendor.hw.fm.mode", "normal"); - /* Need to clear the hw.fm.init firstly */ - property_set("vendor.hw.fm.init", "0"); - property_set("ctl.start", "fm_dl"); - sched_yield(); - for(i=0; i<45; i++) { - property_get("vendor.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); - if(!init_success) { - property_set("ctl.stop", "fm_dl"); - // close the fd(power down) - close(fd); - return FM_JNI_FAILURE; + if (bt_configstore_intf != NULL) { + bt_configstore_intf->set_vendor_property(FM_PROP_HW_MODE, "normal"); + + /* Need to clear the hw.fm.init firstly */ + bt_configstore_intf->set_vendor_property(FM_PROP_HW_INIT, "0"); + bt_configstore_intf->set_vendor_property(FM_PROP_CTL_START, "fm_dl"); + + sched_yield(); + for(i=0; i<45; i++) { + get_property(FM_PROP_HW_INIT, value); + 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); + if(!init_success) { + bt_configstore_intf->set_vendor_property(FM_PROP_CTL_STOP,"fm_dl"); + // close the fd(power down) + close(fd); + return FM_JNI_FAILURE; + } } } return fd; @@ -735,9 +749,9 @@ static jint android_hardware_fmradio_FmReceiverJNI_closeFdNative int cleanup_success = 0; char retval =0; - if ((strcmp(soc_name, "rome") != 0) && (strcmp(soc_name, "hastings") != 0)) + if (is_soc_pronto() && bt_configstore_intf != NULL) { - property_set("ctl.stop", "fm_dl"); + bt_configstore_intf->set_vendor_property(FM_PROP_CTL_STOP,"fm_dl"); } close(fd); return FM_JNI_SUCCESS; @@ -749,6 +763,7 @@ static bool is_soc_cherokee() { else return false; } + /******************************************************************** * Current JNI *******************************************************************/ @@ -1204,29 +1219,33 @@ static jint android_hardware_fmradio_FmReceiverJNI_setNotchFilterNative(JNIEnv * int band; int err = 0; - if ((strcmp(soc_name, "rome") != 0) && (strcmp(soc_name, "hastings") != 0)) + if (is_soc_pronto() && bt_configstore_intf != NULL) { - /*Enable/Disable the WAN avoidance*/ - property_set("vendor.hw.fm.init", "0"); - if (aValue) - property_set("vendor.hw.fm.mode", "wa_enable"); - else - property_set("vendor.hw.fm.mode", "wa_disable"); - - property_set("ctl.start", "fm_dl"); - sched_yield(); - for(i=0; i<10; i++) { - property_get("vendor.hw.fm.init", value, NULL); - if (strcmp(value, "1") == 0) { - init_success = 1; - break; - } else { - usleep(WAIT_TIMEOUT); - } - } + /* Need to clear the hw.fm.init firstly */ + bt_configstore_intf->set_vendor_property(FM_PROP_HW_INIT, "0"); + + /*Enable/Disable the WAN avoidance*/ + if (aValue) + bt_configstore_intf->set_vendor_property(FM_PROP_HW_MODE, "wa_enable"); + else + bt_configstore_intf->set_vendor_property(FM_PROP_HW_MODE, "wa_disable"); + + bt_configstore_intf->set_vendor_property(FM_PROP_CTL_START, "fm_dl"); + + sched_yield(); + for(i=0; i<10; i++) { + get_property(FM_PROP_HW_INIT, value); + + 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("vendor.notch.value", notch, NULL); + get_property(FM_PROP_NOTCH_VALUE, notch); ALOGE("Notch = %s",notch); if (!strncmp("HIGH",notch,strlen("HIGH"))) band = HIGH_BAND; @@ -1256,33 +1275,10 @@ static jint android_hardware_fmradio_FmReceiverJNI_setNotchFilterNative(JNIEnv * /* native interface */ static jint android_hardware_fmradio_FmReceiverJNI_setAnalogModeNative(JNIEnv * env, jobject thiz, jboolean aValue) { - int i=0; - char value[PROPERTY_VALUE_MAX] = {'\0'}; - char firmwareVersion[80]; - - if ((strcmp(soc_name, "rome") != 0) && (strcmp(soc_name, "hastings") != 0)) - { - /*Enable/Disable Analog Mode FM*/ - property_set("vendor.hw.fm.init", "0"); - property_set("vendor.hw.fm.mode","config_dac"); - property_set("ctl.start", "fm_dl"); - sched_yield(); - for(i=0; i<10; i++) { - property_get("vendor.hw.fm.init", value, NULL); - if (strcmp(value, "1") == 0) { - return 1; - } else { - usleep(WAIT_TIMEOUT); - } - } - } - + /*DAC configuration is applicable only msm7627a target*/ return 0; } - - - /* * Interfaces added for Tx */ -- cgit v1.2.3