Skip to content
Snippets Groups Projects
Commit a17a340d authored by himta ram's avatar himta ram
Browse files

FM: Use btconfigstore interface to fetch vendor features

 Use btconfigstore interface to dynamically set and get property.

CRs-Fixed: 2445111
Change-Id: I42ed713a0ee2d1ae8be51816c3555d4c114d4153
parent f923ad54
Branches
No related tags found
No related merge requests found
...@@ -663,17 +663,37 @@ static fm_vendor_callbacks_t fm_callbacks = { ...@@ -663,17 +663,37 @@ static fm_vendor_callbacks_t fm_callbacks = {
fm_enable_softmute_cb fm_enable_softmute_cb
}; };
/* native interface */ /* 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<vendor_property_t> 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 static jint android_hardware_fmradio_FmReceiverJNI_acquireFdNative
(JNIEnv* env, jobject thiz, jstring path) (JNIEnv* env, jobject thiz, jstring path)
{ {
int fd; int fd;
int i, retval=0, err; int i, retval=0, err;
char value[PROPERTY_VALUE_MAX] = {'\0'}; char value[PROPERTY_VALUE_MAX] = {'\0'};
char versionStr[40] = {'\0'};
int init_success = 0; int init_success = 0;
jboolean isCopy; jboolean isCopy;
v4l2_capability cap; v4l2_capability cap;
const char* radio_path = env->GetStringUTFChars(path, &isCopy); const char* radio_path = env->GetStringUTFChars(path, &isCopy);
if(radio_path == NULL){ if(radio_path == NULL){
return FM_JNI_FAILURE; return FM_JNI_FAILURE;
} }
...@@ -689,26 +709,19 @@ static jint android_hardware_fmradio_FmReceiverJNI_acquireFdNative ...@@ -689,26 +709,19 @@ static jint android_hardware_fmradio_FmReceiverJNI_acquireFdNative
ALOGD("VIDIOC_QUERYCAP returns :%d: version: %d \n", err , cap.version ); ALOGD("VIDIOC_QUERYCAP returns :%d: version: %d \n", err , cap.version );
if( err >= 0 ) { if (is_soc_pronto())
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))
{ {
/*Set the mode for soc downloader*/ /*Set the mode for soc downloader*/
property_set("vendor.hw.fm.mode", "normal"); if (bt_configstore_intf != NULL) {
bt_configstore_intf->set_vendor_property(FM_PROP_HW_MODE, "normal");
/* Need to clear the hw.fm.init firstly */ /* Need to clear the hw.fm.init firstly */
property_set("vendor.hw.fm.init", "0"); bt_configstore_intf->set_vendor_property(FM_PROP_HW_INIT, "0");
property_set("ctl.start", "fm_dl"); bt_configstore_intf->set_vendor_property(FM_PROP_CTL_START, "fm_dl");
sched_yield(); sched_yield();
for(i=0; i<45; i++) { for(i=0; i<45; i++) {
property_get("vendor.hw.fm.init", value, NULL); get_property(FM_PROP_HW_INIT, value);
if (strcmp(value, "1") == 0) { if (strcmp(value, "1") == 0) {
init_success = 1; init_success = 1;
break; break;
...@@ -718,12 +731,13 @@ static jint android_hardware_fmradio_FmReceiverJNI_acquireFdNative ...@@ -718,12 +731,13 @@ static jint android_hardware_fmradio_FmReceiverJNI_acquireFdNative
} }
ALOGE("init_success:%d after %f seconds \n", init_success, 0.2*i); ALOGE("init_success:%d after %f seconds \n", init_success, 0.2*i);
if(!init_success) { if(!init_success) {
property_set("ctl.stop", "fm_dl"); bt_configstore_intf->set_vendor_property(FM_PROP_CTL_STOP,"fm_dl");
// close the fd(power down) // close the fd(power down)
close(fd); close(fd);
return FM_JNI_FAILURE; return FM_JNI_FAILURE;
} }
} }
}
return fd; return fd;
} }
...@@ -735,9 +749,9 @@ static jint android_hardware_fmradio_FmReceiverJNI_closeFdNative ...@@ -735,9 +749,9 @@ static jint android_hardware_fmradio_FmReceiverJNI_closeFdNative
int cleanup_success = 0; int cleanup_success = 0;
char retval =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); close(fd);
return FM_JNI_SUCCESS; return FM_JNI_SUCCESS;
...@@ -749,6 +763,7 @@ static bool is_soc_cherokee() { ...@@ -749,6 +763,7 @@ static bool is_soc_cherokee() {
else else
return false; return false;
} }
/******************************************************************** /********************************************************************
* Current JNI * Current JNI
*******************************************************************/ *******************************************************************/
...@@ -1204,19 +1219,23 @@ static jint android_hardware_fmradio_FmReceiverJNI_setNotchFilterNative(JNIEnv * ...@@ -1204,19 +1219,23 @@ static jint android_hardware_fmradio_FmReceiverJNI_setNotchFilterNative(JNIEnv *
int band; int band;
int err = 0; int err = 0;
if ((strcmp(soc_name, "rome") != 0) && (strcmp(soc_name, "hastings") != 0)) if (is_soc_pronto() && bt_configstore_intf != NULL)
{ {
/* Need to clear the hw.fm.init firstly */
bt_configstore_intf->set_vendor_property(FM_PROP_HW_INIT, "0");
/*Enable/Disable the WAN avoidance*/ /*Enable/Disable the WAN avoidance*/
property_set("vendor.hw.fm.init", "0");
if (aValue) if (aValue)
property_set("vendor.hw.fm.mode", "wa_enable"); bt_configstore_intf->set_vendor_property(FM_PROP_HW_MODE, "wa_enable");
else else
property_set("vendor.hw.fm.mode", "wa_disable"); bt_configstore_intf->set_vendor_property(FM_PROP_HW_MODE, "wa_disable");
bt_configstore_intf->set_vendor_property(FM_PROP_CTL_START, "fm_dl");
property_set("ctl.start", "fm_dl");
sched_yield(); sched_yield();
for(i=0; i<10; i++) { for(i=0; i<10; i++) {
property_get("vendor.hw.fm.init", value, NULL); get_property(FM_PROP_HW_INIT, value);
if (strcmp(value, "1") == 0) { if (strcmp(value, "1") == 0) {
init_success = 1; init_success = 1;
break; break;
...@@ -1226,7 +1245,7 @@ static jint android_hardware_fmradio_FmReceiverJNI_setNotchFilterNative(JNIEnv * ...@@ -1226,7 +1245,7 @@ static jint android_hardware_fmradio_FmReceiverJNI_setNotchFilterNative(JNIEnv *
} }
ALOGE("init_success:%d after %f seconds \n", init_success, 0.2*i); 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); ALOGE("Notch = %s",notch);
if (!strncmp("HIGH",notch,strlen("HIGH"))) if (!strncmp("HIGH",notch,strlen("HIGH")))
band = HIGH_BAND; band = HIGH_BAND;
...@@ -1256,33 +1275,10 @@ static jint android_hardware_fmradio_FmReceiverJNI_setNotchFilterNative(JNIEnv * ...@@ -1256,33 +1275,10 @@ static jint android_hardware_fmradio_FmReceiverJNI_setNotchFilterNative(JNIEnv *
/* native interface */ /* native interface */
static jint android_hardware_fmradio_FmReceiverJNI_setAnalogModeNative(JNIEnv * env, jobject thiz, jboolean aValue) static jint android_hardware_fmradio_FmReceiverJNI_setAnalogModeNative(JNIEnv * env, jobject thiz, jboolean aValue)
{ {
int i=0; /*DAC configuration is applicable only msm7627a target*/
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);
}
}
}
return 0; return 0;
} }
/* /*
* Interfaces added for Tx * Interfaces added for Tx
*/ */
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment