+extern void *get_ukdev(void);\r
+extern int key_unify_read(void *ukdev, char *keyname, unsigned char *keydata,\r
+ unsigned int datalen, unsigned int *reallen);\r
+extern int key_unify_size(void *ukdev, char *keyname, unsigned int *reallen);\r
\r
#include <typedefs.h>\r
#include <osl.h>\r
#include <dhd_dbg.h>\r
#include <wl_android.h>\r
\r
+static int getUnifyKey(char * inKeyName, unsigned char * outValueBuf, unsigned int inValueBufSize);\r
+static int askey_dhd_conf_preinit(struct dhd_conf *conf);\r
+static int askey_dhd_conf_read_unifykeys_wifi_disable_5g_band(dhd_pub_t *dhd);\r
+\r
+// kzalloc2getUnifyKey() will return a pointer to a memory allocated by kzalloc().\r
+// If the returned pointer is not NULL, remember to kfree the memory.\r
+static char * kzalloc2getUnifyKey(char * inKeyName);\r
+static int askey_dhd_conf_preinit_by_sn(struct dhd_conf *conf);\r
+\r
/* message levels */\r
#define CONFIG_ERROR_LEVEL (1 << 0)\r
#define CONFIG_TRACE_LEVEL (1 << 1)\r
return true;\r
}\r
\r
+static int askey_dhd_conf_read_unifykeys_wifi_disable_5g_band(dhd_pub_t *dhd) {\r
+ int state = 0;\r
+ char wifi_disable_5g_band[8] = {0};\r
+ char * wl_preinit = NULL;\r
+ int size = 0;\r
+ struct dhd_conf *conf = dhd->conf;\r
+\r
+ for (state = 1; state > 0;) {\r
+ switch (state) {\r
+ case 1:\r
+ if (0 != getUnifyKey("wifi_disable_5g_band", wifi_disable_5g_band, sizeof(wifi_disable_5g_band))) {\r
+ state = -1;\r
+ break;\r
+ }\r
+\r
+ if (conf->wl_preinit) {\r
+ // There is a setting for wl_preinit in the config file.\r
+ if (NULL != strstr(conf->wl_preinit, "disable_5g_band=")) {\r
+ /* Skip wifi_disable_5g_band of unifykeys because there\r
+ * is a setting for disable_5g_band in wl_preinit in the\r
+ * config file.\r
+ */\r
+ state = 0;\r
+ break;\r
+ }\r
+ // Backup conf->wl_preinit\r
+ size = strlen(conf->wl_preinit) + 1;\r
+ wl_preinit = kmalloc(size, GFP_KERNEL);\r
+ memset(wl_preinit, 0, size);\r
+ strcpy(wl_preinit, conf->wl_preinit);\r
+ kfree(conf->wl_preinit);\r
+ conf->wl_preinit = NULL;\r
+ }\r
+\r
+ // Create new wl_preinit with disable_5g_band and the backup wl_preinit\r
+ size = strlen("disable_5g_band=") + strlen("wifi_disable_5g_band");\r
+ if (wl_preinit) {\r
+ size += strlen(",") + strlen(wl_preinit);\r
+ }\r
+ size++;\r
+ conf->wl_preinit = kmalloc(size, GFP_KERNEL);\r
+ memset(conf->wl_preinit, 0, size);\r
+ strcpy(conf->wl_preinit, "disable_5g_band=");\r
+ strcat(conf->wl_preinit, wifi_disable_5g_band);\r
+ if (wl_preinit) {\r
+ strcat(conf->wl_preinit, ",");\r
+ strcat(conf->wl_preinit, wl_preinit);\r
+ kfree(wl_preinit);\r
+ wl_preinit = NULL;\r
+ }\r
+ state = 0;\r
+ break;\r
+\r
+ }\r
+ }\r
+\r
+ return state;\r
+}\r
+\r
int\r
dhd_conf_read_config(dhd_pub_t *dhd, char *conf_path)\r
{\r
conf_file_exists = ((conf_path != NULL) && (conf_path[0] != '\0'));\r
if (!conf_file_exists) {\r
CONFIG_MSG("config path %s\n", conf_path);\r
+ askey_dhd_conf_read_unifykeys_wifi_disable_5g_band(dhd);\r
return (0);\r
}\r
\r
if (image)\r
dhd_os_close_image1(dhd, image);\r
\r
+ askey_dhd_conf_read_unifykeys_wifi_disable_5g_band(dhd);\r
+\r
return bcmerror;\r
}\r
\r
\r
}\r
\r
+static int getUnifyKey(char * inKeyName, unsigned char * outValueBuf, unsigned int inValueBufSize) {\r
+ unsigned int keyLen = 0;\r
+ unsigned char * buf = NULL;\r
+\r
+ if (NULL == inKeyName || NULL == outValueBuf || 0 == inValueBufSize) {\r
+ return -1;\r
+ }\r
+ memset(outValueBuf, 0, inValueBufSize);\r
+ if (key_unify_size(get_ukdev(), inKeyName, &keyLen) < 0) {\r
+ return -1;\r
+ }\r
+ if (0 == keyLen) {\r
+ return -1;\r
+ }\r
+ if ((sizeof(unsigned char) * keyLen) > inValueBufSize) {\r
+ return -1;\r
+ }\r
+\r
+ if (NULL == (buf = kzalloc((sizeof(unsigned char) * keyLen), GFP_KERNEL))) {\r
+ return -1;\r
+ }\r
+\r
+ if (key_unify_read(get_ukdev(), inKeyName, buf, keyLen, &keyLen) < 0) {\r
+ kfree(buf);\r
+ buf = NULL;\r
+ return -1;\r
+ }\r
+\r
+ strcpy(outValueBuf, buf);\r
+\r
+ if (NULL != buf) {\r
+ kfree(buf);\r
+ buf = NULL;\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+char * kzalloc2getUnifyKey(char * inKeyName) {\r
+ unsigned int keyLen = 0;\r
+ unsigned char * buf = NULL;\r
+\r
+ if (NULL == inKeyName) {\r
+ return NULL;\r
+ }\r
+\r
+ if (key_unify_size(get_ukdev(), inKeyName, &keyLen) < 0) {\r
+ return NULL;\r
+ }\r
+\r
+ if (0 == keyLen) {\r
+ return NULL;\r
+ }\r
+\r
+ if (NULL == (buf = kzalloc(((sizeof(unsigned char) * keyLen) + 1), GFP_KERNEL))) {\r
+ return NULL;\r
+ }\r
+\r
+ if (key_unify_read(get_ukdev(), inKeyName, buf, keyLen, &keyLen) < 0) {\r
+ kfree(buf);\r
+ buf = NULL;\r
+ return NULL;\r
+ }\r
+\r
+ buf[keyLen] = '\0';\r
+\r
+ return buf;\r
+}\r
+\r
+int askey_dhd_conf_preinit_by_sn(struct dhd_conf *conf) {\r
+ char * usid = NULL;\r
+ int i = 0;\r
+ struct {\r
+ char * country;\r
+ char * ccode;\r
+ int regrev;\r
+ } tbl[] = {\r
+ {"USA", "US", 1}, // the default MUST be put at the first place of this table\r
+ {"JPN", "JP", 58},\r
+ {"AUS", "AU", 6},\r
+ {"NZL", "NZ", 4},\r
+ {"HKG", "HK", 2},\r
+ {"CAN", "CA", 2},\r
+ {"TWN", "TW", 1},\r
+ {"CHN", "CN", 38},\r
+ {"DEU", "DE", 7},\r
+ {"FRA", "FR", 5},\r
+ {"NLD", "NL", 4},\r
+ {"ITA", "IT", 4},\r
+ {"BGR", "BG", 4},\r
+ {"HUN", "HU", 4},\r
+ {"AUT", "AT", 4},\r
+ {"RUS", "RU", 986},\r
+ {"GBR", "GB", 6},\r
+ {"BRA", "BR", 4},\r
+ {"MEX", "MX", 20},\r
+ {"IND", "IN", 3},\r
+ {"PHL", "PH", 5},\r
+ {"SGP", "SG", 0},\r
+ {"MYS", "MY", 3},\r
+ {"AND", "AD", 0},\r
+ {"ARE", "AE", 6},\r
+ {"ATG", "AG", 2},\r
+ {"AIA", "AI", 1},\r
+ {"ALB", "AL", 2},\r
+ {"ASM", "AS", 12},\r
+ {"ABW", "AW", 2},\r
+ {"AZE", "AZ", 2},\r
+ {"BIH", "BA", 2},\r
+ {"BGD", "BD", 2},\r
+ {"BEL", "BE", 4},\r
+ {"BHR", "BH", 4},\r
+ {"BMU", "BM", 12},\r
+ {"BRN", "BN", 4},\r
+ {"BRA", "BR", 4},\r
+ {"BHS", "BS", 2},\r
+ {"BLR", "BY", 3},\r
+ {"CAN", "CA", 2},\r
+ {"CHE", "CH", 4},\r
+ {"COL", "CO", 17},\r
+ {"CRI", "CR", 17},\r
+ {"CYP", "CY", 4},\r
+ {"CZE", "CZ", 4},\r
+ {"DEU", "DE", 7},\r
+ {"DNK", "DK", 4},\r
+ {"ECU", "EC", 21},\r
+ {"EST", "EE", 4},\r
+ {"EGY", "EG", 0},\r
+ {"ESP", "ES", 4},\r
+ {"ETH", "ET", 2},\r
+ {"FIN", "FI", 4},\r
+ {"GRD", "GD", 2},\r
+ {"GEO", "GE", 0},\r
+ {"PYF", "GF", 2},\r
+ {"GRC", "GR", 4},\r
+ {"GTM", "GT", 1},\r
+ {"GUM", "GU", 12},\r
+ {"HRV", "HR", 4},\r
+ {"IDN", "ID", 13},\r
+ {"IRL", "IE", 5},\r
+ {"ISR", "IL", 7},\r
+ {"ISL", "IS", 4},\r
+ {"ITA", "IT", 4},\r
+ {"JOR", "JO", 3},\r
+ {"KHM", "KH", 2},\r
+ {"KOR", "KR", 57},\r
+ {"KWT", "KW", 5},\r
+ {"CYM", "KY", 3},\r
+ {"LAO", "LA", 2},\r
+ {"LBN", "LB", 5},\r
+ {"LIE", "LI", 4},\r
+ {"LKA", "LK", 1},\r
+ {"LSO", "LS", 2},\r
+ {"LTU", "LT", 4},\r
+ {"LUX", "LU", 3},\r
+ {"LVA", "LV", 4},\r
+ {"MAR", "MA", 2},\r
+ {"MCO", "MC", 1},\r
+ {"MDA", "MD", 2},\r
+ {"MNE", "ME", 2},\r
+ {"MKD", "MK", 2},\r
+ {"MNG", "MN", 1},\r
+ {"MRT", "MR", 2},\r
+ {"MLT", "MT", 4},\r
+ {"MUS", "MU", 2},\r
+ {"MDV", "MV", 3},\r
+ {"MWI", "MW", 1},\r
+ {"NIC", "NI", 2},\r
+ {"NLD", "NL", 4},\r
+ {"NOR", "NO", 4},\r
+ {"NZL", "NZ", 4},\r
+ {"OMN", "OM", 4},\r
+ {"PAN", "PA", 17},\r
+ {"PER", "PE", 20},\r
+ {"POL", "PL", 4},\r
+ {"PRI", "PR", 20},\r
+ {"PRT", "PT", 4},\r
+ {"PRY", "PY", 2},\r
+ {"REU", "RE", 2},\r
+ {"ROU", "RO", 4},\r
+ {"SRB", "RS", 2},\r
+ {"SWE", "SE", 4},\r
+ {"SVN", "SI", 4},\r
+ {"SVK", "SK", 4},\r
+ {"SMR", "SM", 0},\r
+ {"SOM", "SV", 19},\r
+ {"THA", "TH", 5},\r
+ {"TUN", "TN", 999},\r
+ {"TUR", "TR", 7},\r
+ {"TTO", "TT", 3},\r
+ {"UKR", "UA", 16},\r
+ {"VAT", "VA", 2},\r
+ {"VEN", "VE", 3},\r
+ {"VGB", "VG", 2},\r
+ {"VNM", "VN", 4},\r
+ {"MYT", "YT", 2},\r
+ {"ZAF", "ZA", 6},\r
+ {NULL, NULL, -1}\r
+ };\r
+\r
+ if (NULL == (usid = kzalloc2getUnifyKey("usid")) || strlen(usid) < 4) {\r
+ i = 0; // for using tbl[0] as the default\r
+ }else {\r
+ for (i = 0; NULL != tbl[i].country; i++) {\r
+ if (0 == strncmp(tbl[i].country, &usid[1], 3)) {\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ if (NULL == tbl[i].country) {\r
+ i = 0; // for using tbl[0] as the default\r
+ }\r
+ strcpy(conf->cspec.country_abbrev, tbl[i].ccode);\r
+ strcpy(conf->cspec.ccode, tbl[i].ccode);\r
+ conf->cspec.rev = tbl[i].regrev;\r
+\r
+ if (usid) {\r
+ kfree(usid);\r
+ usid = NULL;\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+static int askey_dhd_conf_preinit(struct dhd_conf *conf) {\r
+ char * wifi_country_abbrev_ptr = NULL;\r
+ char wifi_country_abbrev[4] = {0};\r
+ char wifi_ccode[4] = {0};\r
+ char wifi_regrev[4] = {0};\r
+ long regrev = 0;\r
+\r
+ if (NULL == conf) {\r
+ return -1;\r
+ }\r
+ if (0 == getUnifyKey("wifi_ccode", wifi_ccode, sizeof(wifi_ccode)) &&\r
+ 0 == getUnifyKey("wifi_regrev", wifi_regrev, sizeof(wifi_regrev)) &&\r
+ 0 == kstrtol(wifi_regrev, 10, ®rev)) {\r
+ if (0 == getUnifyKey("wifi_country_abbrev", wifi_country_abbrev, sizeof(wifi_country_abbrev))) {\r
+ wifi_country_abbrev_ptr = wifi_country_abbrev;\r
+ }else {\r
+ wifi_country_abbrev_ptr = wifi_ccode;\r
+ }\r
+ strcpy(conf->cspec.country_abbrev, wifi_country_abbrev_ptr);\r
+ strcpy(conf->cspec.ccode, wifi_ccode);\r
+ conf->cspec.rev = regrev;\r
+ }else {\r
+ strcpy(conf->cspec.country_abbrev, "CN");\r
+ strcpy(conf->cspec.ccode, "CN");\r
+ conf->cspec.rev = 38;\r
+ }\r
+ return 0;\r
+}\r
+\r
int\r
dhd_conf_preinit(dhd_pub_t *dhd)\r
{\r
} else if (conf->chip == BCM4335_CHIP_ID || conf->chip == BCM4339_CHIP_ID ||\r
conf->chip == BCM4354_CHIP_ID || conf->chip == BCM4356_CHIP_ID ||\r
conf->chip == BCM4345_CHIP_ID || conf->chip == BCM4371_CHIP_ID ||\r
- conf->chip == BCM43569_CHIP_ID || conf->chip == BCM4359_CHIP_ID) {\r
+ conf->chip == BCM43569_CHIP_ID || conf->chip == BCM4359_CHIP_ID ||\r
+ conf->chip == BCM4362_CHIP_ID || conf->chip == BCM43751_CHIP_ID) {\r
+#if 1\r
+ askey_dhd_conf_preinit(conf);\r
+ askey_dhd_conf_preinit_by_sn(conf);\r
+#else\r
strcpy(conf->cspec.country_abbrev, "CN");\r
strcpy(conf->cspec.ccode, "CN");\r
conf->cspec.rev = 38;\r
+#endif\r
} else {\r
strcpy(conf->cspec.country_abbrev, "CN");\r
strcpy(conf->cspec.ccode, "CN");\r