Merge "apq8084: qca1530 configuration handling is added."

This commit is contained in:
Linux Build Service Account 2013-10-28 15:36:41 -07:00 committed by Gerrit - the friendly Code Review server
commit c00eaa276e
6 changed files with 124 additions and 36 deletions

View file

@ -64,7 +64,7 @@ LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask)
LocApiBase* locApi = NULL; LocApiBase* locApi = NULL;
// first if can not be MPQ // first if can not be MPQ
if (TARGET_MPQ != get_target()) { if (TARGET_MPQ != loc_get_target()) {
if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask))) { if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask))) {
// only RPC is the option now // only RPC is the option now
void* handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW); void* handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW);

View file

@ -140,7 +140,7 @@ static const AGpsRilInterface sLocEngAGpsRilInterface =
}; };
static loc_eng_data_s_type loc_afw_data; static loc_eng_data_s_type loc_afw_data;
static int gss_fd = 0; static int gss_fd = -1;
/*=========================================================================== /*===========================================================================
FUNCTION gps_get_hardware_interface FUNCTION gps_get_hardware_interface
@ -190,10 +190,14 @@ extern "C" const GpsInterface* get_gps_interface()
unsigned int target = TARGET_DEFAULT; unsigned int target = TARGET_DEFAULT;
loc_eng_read_config(); loc_eng_read_config();
target = get_target(); target = loc_get_target();
LOC_LOGD("Target name check returned %s", loc_get_target_name(target)); LOC_LOGD("Target name check returned %s", loc_get_target_name(target));
int gnssType = getTargetGnssType(target);
switch (gnssType)
{
case GNSS_GSS:
//APQ8064 //APQ8064
if( getTargetGnssType(target) == GNSS_GSS ) {
gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB);
gss_fd = open("/dev/gss", O_RDONLY); gss_fd = open("/dev/gss", O_RDONLY);
if (gss_fd < 0) { if (gss_fd < 0) {
@ -203,11 +207,16 @@ extern "C" const GpsInterface* get_gps_interface()
LOC_LOGD("GSS open success! CAPABILITIES %0lx\n", LOC_LOGD("GSS open success! CAPABILITIES %0lx\n",
gps_conf.CAPABILITIES); gps_conf.CAPABILITIES);
} }
} break;
//MPQ8064 case GNSS_NONE:
else if( getTargetGnssType(target) == GNSS_NONE) { //MPQ8064
LOC_LOGE("No GPS HW on this target (MPQ8064). Not returning interface"); LOC_LOGE("No GPS HW on this target. Not returning interface.");
return NULL; return NULL;
case GNSS_QCA1530:
// qca1530 chip is present
gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB);
LOC_LOGD("qca1530 present: CAPABILITIES %0lx\n", gps_conf.CAPABILITIES);
break;
} }
return &sLocEngInterface; return &sLocEngInterface;
} }
@ -297,13 +306,14 @@ static void loc_cleanup()
gps_loc_cb = NULL; gps_loc_cb = NULL;
gps_sv_cb = NULL; gps_sv_cb = NULL;
/* /*
* if (get_target() == TARGET_NAME_APQ8064_STANDALONE) if (gss_fd >= 0)
* { {
* close(gss_fd); close(gss_fd);
* LOC_LOGD("GSS shutdown.\n"); gss_fd = -1;
* } LOC_LOGD("GSS shutdown.\n");
*/ }
*/
EXIT_LOG(%s, VOID_RET); EXIT_LOG(%s, VOID_RET);
} }

View file

@ -1772,11 +1772,14 @@ int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data,
ENTRY_LOG_CALLFLOW(); ENTRY_LOG_CALLFLOW();
INIT_CHECK(loc_eng_data.adapter, return -1); INIT_CHECK(loc_eng_data.adapter, return -1);
// The position mode for APQ target can only be standalone int gnssType = getTargetGnssType(loc_get_target());
bool isAPQ = (getTargetGnssType(get_target()) == GNSS_GSS);
if (isAPQ && params.mode != LOC_POSITION_MODE_STANDALONE) { // The position mode for GSS/QCA1530 can only be standalone
bool is1530 = gnssType == GNSS_QCA1530;
bool isAPQ = gnssType == GNSS_GSS;
if ((isAPQ || is1530) && params.mode != LOC_POSITION_MODE_STANDALONE) {
params.mode = LOC_POSITION_MODE_STANDALONE; params.mode = LOC_POSITION_MODE_STANDALONE;
LOC_LOGD("Position mode changed to standalone for APQ target."); LOC_LOGD("Position mode changed to standalone for target with GSS/qca1530.");
} }
if(! loc_eng_data.adapter->getUlpProxy()->sendFixMode(params)) if(! loc_eng_data.adapter->getUlpProxy()->sendFixMode(params))
@ -2020,8 +2023,10 @@ void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsExtCallbacks* call
AGPS_TYPE_WIFI, AGPS_TYPE_WIFI,
true); true);
bool isAPQ = (getTargetGnssType(get_target()) == GNSS_GSS); int gnssType = getTargetGnssType(loc_get_target());
if (!isAPQ) { bool isAPQ = (gnssType == GNSS_GSS);
bool is1530 = (gnssType == GNSS_QCA1530);
if (!isAPQ && !is1530) {
loc_eng_data.agnss_nif = new AgpsStateMachine(servicerTypeAgps, loc_eng_data.agnss_nif = new AgpsStateMachine(servicerTypeAgps,
(void *)loc_eng_data.agps_status_cb, (void *)loc_eng_data.agps_status_cb,
AGPS_TYPE_SUPL, AGPS_TYPE_SUPL,

View file

@ -112,7 +112,7 @@ loc_name_val_s_type target_name[] =
NAME_VAL(GNSS_MSM), NAME_VAL(GNSS_MSM),
NAME_VAL(GNSS_GSS), NAME_VAL(GNSS_GSS),
NAME_VAL(GNSS_MDM), NAME_VAL(GNSS_MDM),
NAME_VAL(GNSS_GRIFFON), NAME_VAL(GNSS_QCA1530),
NAME_VAL(GNSS_UNKNOWN) NAME_VAL(GNSS_UNKNOWN)
}; };
@ -134,18 +134,18 @@ RETURN VALUE
const char *loc_get_target_name(unsigned int target) const char *loc_get_target_name(unsigned int target)
{ {
int index = 0; int index = 0;
char ret[BUFFER_SIZE]; static char ret[BUFFER_SIZE];
index = getTargetGnssType(target); index = getTargetGnssType(target);
if( index >= target_name_num || index < 0) if( index >= target_name_num || index < 0)
index = target_name_num - 1; index = target_name_num - 1;
if( (target & HAS_SSC) == HAS_SSC ) { if( (target & HAS_SSC) == HAS_SSC ) {
sprintf(ret, " %s with SSC", snprintf(ret, sizeof(ret), " %s with SSC",
loc_get_name_from_val(target_name, target_name_num, (long)index) ); loc_get_name_from_val(target_name, target_name_num, (long)index) );
} }
else { else {
sprintf(ret, " %s without SSC", snprintf(ret, sizeof(ret), " %s without SSC",
loc_get_name_from_val(target_name, target_name_num, (long)index) ); loc_get_name_from_val(target_name, target_name_num, (long)index) );
} }
return ret; return ret;

View file

@ -56,9 +56,11 @@
#define LENGTH(s) (sizeof(s) - 1) #define LENGTH(s) (sizeof(s) - 1)
#define GPS_CHECK_NO_ERROR 0 #define GPS_CHECK_NO_ERROR 0
#define GPS_CHECK_NO_GPS_HW 1 #define GPS_CHECK_NO_GPS_HW 1
#define QCA1530_DETECT_TIMEOUT 30
#define QCA1530_DETECT_PRESENT "yes"
#define QCA1530_DETECT_PROGRESS "detect"
static int gss_fd = 0; static unsigned int gTarget = (unsigned int)-1;
static unsigned int gTarget = TARGET_UNKNOWN;
static int read_a_line(const char * file_path, char * line, int line_size) static int read_a_line(const char * file_path, char * line, int line_size)
{ {
@ -82,22 +84,85 @@ static int read_a_line(const char * file_path, char * line, int line_size)
return result; return result;
} }
unsigned int get_target(void) /*!
* \brief Checks if QCA1530 is avalable.
*
* Function verifies if qca1530 SoC is configured on the device. The test is
* based on property value. For 1530 scenario, the value shall be one of the
* following: "yes", "no", "detect". All other values are treated equally to
* "no". When the value is "detect" the system waits for SoC detection to
* finish before returning result.
*
* \retval true - QCA1530 is available.
* \retval false - QCA1530 is not available.
*/
static bool is_qca1530(void)
{ {
if (gTarget != TARGET_UNKNOWN) static const char qca1530_property_name[] = "persist.qca1530";
bool res = false;
int ret, i;
char buf[PROPERTY_VALUE_MAX];
memset(buf, 0, sizeof(buf));
for (i = 0; i < QCA1530_DETECT_TIMEOUT; ++i)
{
ret = property_get(qca1530_property_name, buf, NULL);
if (ret < 0)
{
LOC_LOGV( "qca1530: property %s is not accessible, ret=%d",
qca1530_property_name,
ret);
break;
}
LOC_LOGV( "qca1530: property %s is set to %s",
qca1530_property_name,
buf);
if (!memcmp(buf, QCA1530_DETECT_PRESENT,
sizeof(QCA1530_DETECT_PRESENT)))
{
res = true;
break;
}
if (!memcmp(buf, QCA1530_DETECT_PROGRESS,
sizeof(QCA1530_DETECT_PROGRESS)))
{
LOC_LOGV("qca1530: SoC detection is in progress.");
sleep(1);
continue;
}
break;
}
LOC_LOGD("qca1530: detected=%s", res ? "true" : "false");
return res;
}
unsigned int loc_get_target(void)
{
if (gTarget != (unsigned int)-1)
return gTarget; return gTarget;
char hw_platform[] = "/sys/devices/soc0/hw_platform"; static const char hw_platform[] = "/sys/devices/soc0/hw_platform";
char id[] = "/sys/devices/soc0/soc_id"; static const char id[] = "/sys/devices/soc0/soc_id";
char hw_platform_dep[] = "/sys/devices/system/soc/soc0/hw_platform"; static const char hw_platform_dep[] =
char id_dep[] = "/sys/devices/system/soc/soc0/id"; "/sys/devices/system/soc/soc0/hw_platform";
char mdm[] = "/dev/mdm"; // No such file or directory static const char id_dep[] = "/sys/devices/system/soc/soc0/id";
static const char mdm[] = "/dev/mdm"; // No such file or directory
char rd_hw_platform[LINE_LEN]; char rd_hw_platform[LINE_LEN];
char rd_id[LINE_LEN]; char rd_id[LINE_LEN];
char rd_mdm[LINE_LEN]; char rd_mdm[LINE_LEN];
char baseband[LINE_LEN]; char baseband[LINE_LEN];
if (is_qca1530()) {
gTarget = TARGET_QCA1530;
goto detected;
}
property_get("ro.baseband", baseband, ""); property_get("ro.baseband", baseband, "");
if (!access(hw_platform, F_OK)) { if (!access(hw_platform, F_OK)) {
read_a_line(hw_platform, rd_hw_platform, LINE_LEN); read_a_line(hw_platform, rd_hw_platform, LINE_LEN);
@ -133,6 +198,11 @@ unsigned int get_target(void)
(!memcmp(rd_id, MSM8930_ID_2, LENGTH(MSM8930_ID_2)) (!memcmp(rd_id, MSM8930_ID_2, LENGTH(MSM8930_ID_2))
&& IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) ) && IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) )
gTarget = TARGET_MSM_NO_SSC; gTarget = TARGET_MSM_NO_SSC;
else
gTarget = TARGET_UNKNOWN;
} }
detected:
LOC_LOGD("HAL: %s returned %d", __FUNCTION__, gTarget);
return gTarget; return gTarget;
} }

View file

@ -34,6 +34,7 @@
#define TARGET_APQ_SA TARGET_SET(GNSS_GSS, NO_SSC) #define TARGET_APQ_SA TARGET_SET(GNSS_GSS, NO_SSC)
#define TARGET_MPQ TARGET_SET(GNSS_NONE,NO_SSC) #define TARGET_MPQ TARGET_SET(GNSS_NONE,NO_SSC)
#define TARGET_MSM_NO_SSC TARGET_SET(GNSS_MSM, NO_SSC) #define TARGET_MSM_NO_SSC TARGET_SET(GNSS_MSM, NO_SSC)
#define TARGET_QCA1530 TARGET_SET(GNSS_QCA1530, NO_SSC)
#define TARGET_UNKNOWN TARGET_SET(GNSS_UNKNOWN, NO_SSC) #define TARGET_UNKNOWN TARGET_SET(GNSS_UNKNOWN, NO_SSC)
#define getTargetGnssType(target) (target>>1) #define getTargetGnssType(target) (target>>1)
@ -42,14 +43,16 @@ extern "C"
{ {
#endif #endif
unsigned int get_target(void); unsigned int loc_get_target(void);
/* Please remember to update 'target_name' in loc_log.cpp,
if do any changes to this enum. */
typedef enum { typedef enum {
GNSS_NONE = 0, GNSS_NONE = 0,
GNSS_MSM, GNSS_MSM,
GNSS_GSS, GNSS_GSS,
GNSS_MDM, GNSS_MDM,
GNSS_GRIFFON, GNSS_QCA1530,
GNSS_UNKNOWN GNSS_UNKNOWN
}GNSS_TARGET; }GNSS_TARGET;