Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DYNAMIC_NV #1

Open
wants to merge 1 commit into
base: o-mr1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 7 additions & 107 deletions wcnss-service/wcnss_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,8 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cutils/properties.h>
#ifdef WCNSS_QMI
#include "wcnss_qmi_client.h"
#ifdef MDM_DETECT
#include "mdm_detect.h"
#endif
#endif
#ifdef WCNSS_QMI_OSS
#include <dlfcn.h>
#endif

#define SUCCESS 0
#define FAILED -1
Expand Down Expand Up @@ -85,14 +80,10 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define HEXA_A 10
#define HEX_BASE 16

#if defined (WCNSS_QMI) || defined(WCNSS_QMI_OSS)
#ifdef WCNSS_QMI
#define WLAN_ADDR_SIZE 6
unsigned char wlan_nv_mac_addr[WLAN_ADDR_SIZE];
#ifdef WCNSS_QMI_MAC_ADDR_REV
#define MAC_ADDR_ARRAY(a) (a)[5], (a)[4], (a)[3], (a)[2], (a)[1], (a)[0]
#else
#define MAC_ADDR_ARRAY(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
#endif
#define MAC_ADDRESS_STR "%02x:%02x:%02x:%02x:%02x:%02x"

/* As we Want to write in 00:0a:f5:11:22:33 format in sysfs file
Expand Down Expand Up @@ -400,7 +391,7 @@ unsigned int convert_string_to_hex(char* string)
}


#if defined(WCNSS_QMI) || defined(WCNSS_QMI_OSS)
#ifdef WCNSS_QMI
void setup_wcnss_parameters(int *cal, int nv_mac_addr)
#else
void setup_wcnss_parameters(int *cal)
Expand All @@ -418,7 +409,7 @@ void setup_wcnss_parameters(int *cal)
return;
}

rc = property_get("ro.wcnss.serialno", serial, "");
rc = property_get("ro.serialno", serial, "");
if (rc) {
serial_num = convert_string_to_hex(serial);
ALOGE("Serial Number is %x", serial_num);
Expand All @@ -437,27 +428,18 @@ void setup_wcnss_parameters(int *cal)
}
}

#if defined(WCNSS_QMI) || defined (WCNSS_QMI_OSS)
#ifdef WCNSS_QMI
if (SUCCESS == nv_mac_addr)
{
pos = 0;
msg[pos++] = WCNSS_USR_WLAN_MAC_ADDR >> BYTE_1;
msg[pos++] = WCNSS_USR_WLAN_MAC_ADDR >> BYTE_0;
#ifdef WCNSS_QMI_MAC_ADDR_REV
msg[pos++] = wlan_nv_mac_addr[5];
msg[pos++] = wlan_nv_mac_addr[4];
msg[pos++] = wlan_nv_mac_addr[3];
msg[pos++] = wlan_nv_mac_addr[2];
msg[pos++] = wlan_nv_mac_addr[1];
msg[pos++] = wlan_nv_mac_addr[0];
#else
msg[pos++] = wlan_nv_mac_addr[0];
msg[pos++] = wlan_nv_mac_addr[1];
msg[pos++] = wlan_nv_mac_addr[2];
msg[pos++] = wlan_nv_mac_addr[3];
msg[pos++] = wlan_nv_mac_addr[4];
msg[pos++] = wlan_nv_mac_addr[5];
#endif

ALOGI("WLAN MAC Addr:" MAC_ADDRESS_STR,
MAC_ADDR_ARRAY(wlan_nv_mac_addr));
Expand Down Expand Up @@ -518,7 +500,7 @@ void setup_wlan_driver_ath_prop()
property_set("wlan.driver.ath", WLAN_DRIVER_ATH_DEFAULT_VAL);
}

#ifdef MDM_DETECT
#ifdef WCNSS_QMI
int check_modem_compatability(struct dev_info *mdm_detect_info)
{
char args[MODEM_BASEBAND_PROPERTY_SIZE] = {0};
Expand Down Expand Up @@ -727,59 +709,7 @@ void dynamic_nv_replace()
}

ALOGI("dynamic nv replace sucessfully!\n");
}

#ifdef WCNSS_QMI_OSS
static void *wcnss_qmi_handle = NULL;
static int (*wcnss_init_qmi)(void) = NULL;
static int (*wcnss_qmi_get_wlan_address)(unsigned char *) = NULL;
static void (*wcnss_qmi_deinit)(void) = NULL;

static int setup_wcnss_qmi(void)
{
const char *error = NULL;

/* initialize the DMS client and request the wlan mac address */
wcnss_qmi_handle = dlopen("libwcnss_qmi.so", RTLD_NOW);
if (!wcnss_qmi_handle) {
ALOGE("Failed to open libwcnss_qmi.so: %s", dlerror());
goto dlopen_err;
}

dlerror();

wcnss_init_qmi = dlsym(wcnss_qmi_handle, "wcnss_init_qmi");
if ((error = dlerror()) != NULL) {
ALOGE("Failed to resolve function: %s: %s",
"wcnss_init_qmi", error);
goto dlsym_err;
}

dlerror();

wcnss_qmi_get_wlan_address = dlsym(wcnss_qmi_handle,
"wcnss_qmi_get_wlan_address");
if ((error = dlerror()) != NULL) {
ALOGE("Failed to resolve function: %s: %s",
"wcnss_qmi_get_wlan_address", error);
goto dlsym_err;
}

dlerror();

wcnss_qmi_deinit = dlsym(wcnss_qmi_handle, "wcnss_qmi_deinit");
if ((error = dlerror()) != NULL) {
ALOGE("Failed to resolve function: %s: %s",
"wcnss_qmi_deinit", error);
goto dlsym_err;
}

return SUCCESS;

dlsym_err:
dlclose(wcnss_qmi_handle);
dlopen_err:
return FAILED;
}
#endif

Expand All @@ -788,40 +718,15 @@ int main(int argc, char *argv[])
UNUSED(argc), UNUSED(argv);
int rc;
int fd_dev, ret_cal;
#if defined(WCNSS_QMI) || defined(WCNSS_QMI_OSS)
#ifdef WCNSS_QMI
int nv_mac_addr = FAILED;
#ifdef MDM_DETECT
struct dev_info mdm_detect_info;
int nom = 0;
#endif
#endif

setup_wlan_config_file();

#ifdef WCNSS_QMI_OSS
/* dlopen WCNSS QMI lib */

rc = setup_wcnss_qmi();
if (rc == SUCCESS) {
if (SUCCESS == (*wcnss_init_qmi)()) {
rc = (*wcnss_qmi_get_wlan_address)(wlan_nv_mac_addr);
if (rc == SUCCESS) {
nv_mac_addr = SUCCESS;
ALOGE("WLAN MAC Addr:" MAC_ADDRESS_STR,
MAC_ADDR_ARRAY(wlan_nv_mac_addr));
} else
ALOGE("Failed to Get MAC addr from modem");

(*wcnss_qmi_deinit)();
}
else
ALOGE("Failed to Initialize wcnss QMI Interface");
} else {
ALOGE("Failed to Initialize wcnss QMI interface library");
}
#endif
#ifdef WCNSS_QMI
#ifdef MDM_DETECT
/* Call ESOC API to get the number of modems.
If the number of modems is not zero, only then proceed
with the eap_proxy intialization.*/
Expand All @@ -843,7 +748,6 @@ int main(int argc, char *argv[])
ALOGE("wcnss_service: Target does not have external modem");
goto nomodem;
}
#endif

/* initialize the DMS client and request the wlan mac address */

Expand All @@ -870,7 +774,7 @@ int main(int argc, char *argv[])
dynamic_nv_replace();
#endif

#if defined(WCNSS_QMI) || defined(WCNSS_QMI_OSS)
#ifdef WCNSS_QMI
setup_wcnss_parameters(&ret_cal, nv_mac_addr);
#else
setup_wcnss_parameters(&ret_cal);
Expand Down Expand Up @@ -902,9 +806,5 @@ int main(int argc, char *argv[])

close(fd_dev);

#ifdef WCNSS_QMI_OSS
dlclose(wcnss_qmi_handle);
#endif

return rc;
}