[Bugfix][T106BUG-325]fix in the process GNSS only can init once;and optimize init-time
Only Configure:No
Affected branch:master
Affected module:GNSS
Is it affected on both ZXIC and MTK:only ZXIC,
Self-test:Yes,
Doc Update:NO.
Change-Id: Iff0ffa60cf406f66dfcc016d973097dac6cd1a4e
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
index 686d86f..8dcdfb7 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
@@ -3,7 +3,7 @@
DESCRIPTION = "liblynq-qser-gnss"
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = "file://LICENSE;md5=3f86c7f456a6d0bbeca155e65084eee1"
-DEPENDS += "liblynq-log libxml2 liblynq-uci libsctel"
+DEPENDS += "liblynq-log libxml2 liblynq-uci libsctel libbsp"
#inherit workonsrc
WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-qser-gnss/"
FILESEXTRAPATHS_prepend :="${TOPDIR}/../src/lynq/lib/:"
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h
index d512dc1..ce124b2 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h
@@ -2,6 +2,7 @@
#include <stdint.h>
#ifndef __MBTK_GNSS_H__
#define __MBTK_GNSS_H__
+#include <sc_bsp.h>
#include "ringbuffer.h"
#ifdef __cplusplus
extern "C" {
@@ -270,8 +271,8 @@
};
-
-
+#define MAX_GPIO_NUM 144
+static void *test_gpio_handle[MAX_GPIO_NUM]={NULL};
static struct mopen_gnss_device_info_t mopen_gnss_device_info;
static struct mbtk_gnss_handle_t *mbtk_gnss_handle = NULL;
static int firmware_extren_state = 0;
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/makefile
index b08e590..0f99e4f 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/makefile
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/makefile
@@ -34,6 +34,7 @@
-lxml2 \
-llynq-uci \
-lsctel \
+ -lbsp \
SOURCES = $(wildcard *.c wildcard *.h src/*.cpp)
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
index 7a7aefe..a9a0b67 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
@@ -731,7 +731,7 @@
{
return -1;
}
- printf("send cmd: %s\n", &buf[size]);
+ ALOGD("send cmd: %s\n", &buf[size]);
size += size_written;
if(size_written != size_to_wr)
{
@@ -913,37 +913,20 @@
return -1;
}
+
int gpio21_value = -1;
int lynq_open_gps(int state)
{
int ret;
- int cn_enable = 86;
- int eur_enable = 84;
- int eur_boot = 15;
- char compare_buf[256] = {0};
- const char* compare_cmd = "echo '21' > /sys/class/gpio/export && cat /sys/class/gpio/gpio21/value";
- exec_cmd(compare_cmd,compare_buf);
- gpio21_value = (compare_buf[0] - '0');
- const char*compare_cmd2 = "echo '21' > /sys/class/gpio/unexport";
- exec_cmd(compare_cmd2,NULL);
+ /*when in Eur,GPIO21 value is 1; in CN,GPIO21 value is 0. so use it to determined CN or Eur*/
+ test_gpio_handle[21] = sc_gpio_init(21,0,0,0);
+ ret = sc_gpio_value_get(test_gpio_handle[21],&gpio21_value);
+ if(ret)
+ {
+ ALOGE("gpio21 value get error\n");
+ }
- /*this is CN GPIO*/
- char CN_Enable[128];
- sprintf(CN_Enable,"echo '%d' > /sys/class/gpio/export && cd /sys/class/gpio/gpio%d", cn_enable,cn_enable);
-
- /*this is Europe GPIO*/
- char Eur_Boot[128];
- sprintf(Eur_Boot,"echo '%d' > /sys/class/gpio/export && cd /sys/class/gpio/gpio%d", eur_boot,eur_boot);
- char Eur_Enable[128];
- sprintf(Eur_Enable,"echo '%d' > /sys/class/gpio/export && cd /sys/class/gpio/gpio%d", eur_enable,eur_enable);
-
- char CN_Enable_unexport[128];
- sprintf(CN_Enable_unexport,"echo '%d' > /sys/class/gpio/unexport", cn_enable);
- char Eur_Boot_unexport[128];
- sprintf(Eur_Boot_unexport,"echo '%d' > /sys/class/gpio/unexport", eur_boot);
- char Eur_Enable_unexport[128];
- sprintf(Eur_Enable_unexport,"echo '%d' > /sys/class/gpio/unexport", eur_enable);
-
+ /*in Eur,need set GPIO15 and 84 value; in CN,need set GPIO86 value*/
if(0 == state)
{
nmea_state = 0;
@@ -958,53 +941,31 @@
if(gpio21_value == 1)
{
- ret = exec_cmd(Eur_Boot,NULL);
- if(ret < 0)
+ test_gpio_handle[15] = sc_gpio_init(15,1,0,0);
+ test_gpio_handle[84] = sc_gpio_init(84,1,0,0);
+ ret = sc_gpio_value_set(test_gpio_handle[15],0);
+ if(ret)
{
- return -1;
+ ALOGE("gpio15 set value 0 error\n");
}
- ret = exec_cmd(Eur_Enable,NULL);
- if(ret < 0)
+ usleep(10000);
+ ret = sc_gpio_value_set(test_gpio_handle[84],0);
+ if(ret)
{
- return -1;
- }
-
- }
- else if(gpio21_value == 0)
- {
- ret = exec_cmd(CN_Enable,NULL);
- if(ret < 0)
- {
- return -1;
+ ALOGE("gpio84 set value 0 error\n");
}
}
- const char* CN_Enable2 = "echo '0' > /sys/class/gpio/gpio86/value";
- char Eur_Boot2[128];
- sprintf(Eur_Boot2,"echo 'out' > /sys/class/gpio/gpio%d/direction && echo '0' > /sys/class/gpio/gpio%d/value",eur_boot,eur_boot);
- char Eur_Enable2[128];
- sprintf(Eur_Enable2,"echo 'out' > /sys/class/gpio/gpio%d/direction && echo '0' > /sys/class/gpio/gpio%d/value",eur_enable,eur_enable);
- if(gpio21_value == 1)
- {
- exec_cmd(Eur_Boot2,NULL);
- exec_cmd(Eur_Enable2,NULL);
- exec_cmd(Eur_Boot_unexport,NULL);
- exec_cmd(Eur_Enable_unexport,NULL);
-
- }
else if(gpio21_value == 0)
{
- ret = exec_cmd(CN_Enable2,NULL);
- if(ret < 0)
+ test_gpio_handle[86] = sc_gpio_init(86,1,0,0);
+ ret = sc_gpio_value_set(test_gpio_handle[86],0);
+ if(ret)
{
- return -1;
- }
- ret = exec_cmd(CN_Enable_unexport,NULL);
- if(ret < 0)
- {
- return -1;
+ ALOGE("gpio86 set value 0 error\n");
}
}
+
}
else if(1 == state)
@@ -1012,51 +973,44 @@
nmea_state = 1;
if(gpio21_value == 1)
{
- ret = exec_cmd(Eur_Boot,NULL);
- if(ret < 0)
+ test_gpio_handle[15] = sc_gpio_init(15,1,0,0);
+ test_gpio_handle[84] = sc_gpio_init(84,1,0,0);
+ ret = sc_gpio_value_set(test_gpio_handle[15],1);
+ if(ret)
{
- return -1;
+ ALOGE("gpio15 set value 1 error\n");
}
- ret = exec_cmd(Eur_Enable,NULL);
- if(ret < 0)
+ usleep(10000);
+ ret = sc_gpio_value_set(test_gpio_handle[84],1);
+ if(ret)
{
- return -1;
+ ALOGE("gpio84 set value 1 error\n");
}
}
else if(gpio21_value == 0)
{
- ret = exec_cmd(CN_Enable,NULL);
- if(ret < 0)
+ test_gpio_handle[86] = sc_gpio_init(86,1,0,0);
+ ret = sc_gpio_value_set(test_gpio_handle[86],1);
+ if(ret)
{
- return -1;
+ ALOGE("gpio86 set value 1 error\n");
}
}
- char CN_Enable3[128] = "echo '1' > /sys/class/gpio/gpio86/value";
- char Eur_Boot3[128];
- sprintf(Eur_Boot3,"echo 'out' > /sys/class/gpio/gpio%d/direction && echo '1' > /sys/class/gpio/gpio%d/value",eur_boot,eur_boot);
- char Eur_Enable3[128];
- sprintf(Eur_Enable3,"echo 'out' > /sys/class/gpio/gpio%d/direction && echo '1' > /sys/class/gpio/gpio%d/value",eur_enable,eur_enable);
- if(gpio21_value == 1)
- {
- exec_cmd(Eur_Boot3,NULL);
- exec_cmd(Eur_Enable3,NULL);
- exec_cmd(Eur_Boot_unexport,NULL);
- exec_cmd(Eur_Enable_unexport,NULL);
-
- }
- else if(gpio21_value == 0)
- {
- ret = exec_cmd(CN_Enable3,NULL);
- if(ret < 0)
- {
- return -1;
- }
- ret = exec_cmd(CN_Enable_unexport,NULL);
- if(ret < 0)
- {
- return -1;
- }
- }
+ }
+
+ sc_gpio_uninit(test_gpio_handle[21]);
+ test_gpio_handle[21] = NULL;
+ if(gpio21_value == 1)
+ {
+ sc_gpio_uninit(test_gpio_handle[15]);
+ sc_gpio_uninit(test_gpio_handle[84]);
+ test_gpio_handle[15] = NULL;
+ test_gpio_handle[84] = NULL;
+ }
+ else if(gpio21_value == 0)
+ {
+ sc_gpio_uninit(test_gpio_handle[86]);
+ test_gpio_handle[86] = NULL;
}
return 0;
}
@@ -1082,26 +1036,9 @@
}
memset(mbtk_gnss_handle, 0, sizeof(struct mbtk_gnss_handle_t));
memset(&mopen_gnss_device_info, 0, sizeof(mopen_gnss_device_info));
- sleep(1);
lynq_open_gps(0);
mbtk_gnss_handle->dev_fd = mopen_gnss_open(MBTK_GNSS_DEV, 0);
- ret = auto_set_uart_baudrate(mbtk_gnss_handle->dev_fd);
- if(-1 == ret) {
- ret = -2;
- goto err;
- } else if (B9600 == ret) {
- ret = mopen_uart_change(mbtk_gnss_handle->dev_fd, 1);
- if(ret)
- {
- printf("GNSS Uart set B115200 error\n");
- mopen_gnss_close(mbtk_gnss_handle->dev_fd);
- return -1;
- }
- }
-
- printf("Gnss Config Uart Baudrate Successful.\n");
-
mbtk_gnss_handle->rb = (char*)malloc(MBTK_UART_RECV_BUFFER_SIZE);
if(NULL == mbtk_gnss_handle->rb)
{
@@ -1159,7 +1096,6 @@
{
int ret;
struct mbtk_gnss_handle_t *gnss_handle = (struct mbtk_gnss_handle_t *)h_gnss;
-
if(h_gnss == NULL)
{
gnss_log("ARG error or not inited.");
@@ -1187,10 +1123,13 @@
printf("GNSS close init error\n");
return -1;
}
-
firmware_extren_state = 0;
- if (gnss_handle->rb) free(gnss_handle->rb);
- free((void *)h_gnss);
+ if (gnss_handle->rb)
+ {
+ free(gnss_handle->rb);
+ }
+ free(mbtk_gnss_handle);
+ mbtk_gnss_handle = NULL;
return 0;
}