summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorValeri Atamaniouk <valeria@codeaurora.org>2013-10-25 06:47:17 +0300
committerValeri Atamaniouk <valeria@codeaurora.org>2013-10-25 06:47:17 +0300
commit3b4d23e9cc0d7cd45d2db9ff00631dbeec88e0a6 (patch)
tree90724fb944c1af59b150fa3d4335ee103a87bfb9 /utils
parent5ef02d7c6d38aec99e0cd9067187059a2834364d (diff)
downloadgps-3b4d23e9cc0d7cd45d2db9ff00631dbeec88e0a6.tar.gz
apq8084: qca1530 configuration handling is added.
Provide function for qca1530 detection. Rename 'get_target' to 'loc_get_target'. Fix loc_get_target state detection to avoid double detection. Fix few minor code defects. Change-Id: I3daaff99598771742572aab407475474fad41e93
Diffstat (limited to 'utils')
-rw-r--r--utils/loc_log.cpp8
-rw-r--r--utils/loc_target.cpp88
-rw-r--r--utils/loc_target.h7
3 files changed, 88 insertions, 15 deletions
diff --git a/utils/loc_log.cpp b/utils/loc_log.cpp
index f755d70..597b5b6 100644
--- a/utils/loc_log.cpp
+++ b/utils/loc_log.cpp
@@ -112,7 +112,7 @@ loc_name_val_s_type target_name[] =
NAME_VAL(GNSS_MSM),
NAME_VAL(GNSS_GSS),
NAME_VAL(GNSS_MDM),
- NAME_VAL(GNSS_GRIFFON),
+ NAME_VAL(GNSS_QCA1530),
NAME_VAL(GNSS_UNKNOWN)
};
@@ -134,18 +134,18 @@ RETURN VALUE
const char *loc_get_target_name(unsigned int target)
{
int index = 0;
- char ret[BUFFER_SIZE];
+ static char ret[BUFFER_SIZE];
index = getTargetGnssType(target);
if( index >= target_name_num || index < 0)
index = target_name_num - 1;
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) );
}
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) );
}
return ret;
diff --git a/utils/loc_target.cpp b/utils/loc_target.cpp
index cd781c0..a3ef6b3 100644
--- a/utils/loc_target.cpp
+++ b/utils/loc_target.cpp
@@ -56,9 +56,11 @@
#define LENGTH(s) (sizeof(s) - 1)
#define GPS_CHECK_NO_ERROR 0
#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 = TARGET_UNKNOWN;
+static unsigned int gTarget = (unsigned int)-1;
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;
}
-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)
+{
+ 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 != TARGET_UNKNOWN)
+ if (gTarget != (unsigned int)-1)
return gTarget;
- char hw_platform[] = "/sys/devices/soc0/hw_platform";
- char id[] = "/sys/devices/soc0/soc_id";
- char hw_platform_dep[] = "/sys/devices/system/soc/soc0/hw_platform";
- char id_dep[] = "/sys/devices/system/soc/soc0/id";
- char mdm[] = "/dev/mdm"; // No such file or directory
+ static const char hw_platform[] = "/sys/devices/soc0/hw_platform";
+ static const char id[] = "/sys/devices/soc0/soc_id";
+ static const char hw_platform_dep[] =
+ "/sys/devices/system/soc/soc0/hw_platform";
+ 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_id[LINE_LEN];
char rd_mdm[LINE_LEN];
char baseband[LINE_LEN];
+ if (is_qca1530()) {
+ gTarget = TARGET_QCA1530;
+ goto detected;
+ }
+
property_get("ro.baseband", baseband, "");
if (!access(hw_platform, F_OK)) {
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))
&& IS_STR_END(rd_id[LENGTH(MSM8930_ID_2)])) )
gTarget = TARGET_MSM_NO_SSC;
+ else
+ gTarget = TARGET_UNKNOWN;
}
+
+detected:
+ LOC_LOGD("HAL: %s returned %d", __FUNCTION__, gTarget);
return gTarget;
}
diff --git a/utils/loc_target.h b/utils/loc_target.h
index be68f92..4aebb85 100644
--- a/utils/loc_target.h
+++ b/utils/loc_target.h
@@ -34,6 +34,7 @@
#define TARGET_APQ_SA TARGET_SET(GNSS_GSS, NO_SSC)
#define TARGET_MPQ TARGET_SET(GNSS_NONE,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 getTargetGnssType(target) (target>>1)
@@ -42,14 +43,16 @@ extern "C"
{
#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 {
GNSS_NONE = 0,
GNSS_MSM,
GNSS_GSS,
GNSS_MDM,
- GNSS_GRIFFON,
+ GNSS_QCA1530,
GNSS_UNKNOWN
}GNSS_TARGET;