loc_api: Repackage as a new GPS HAL module.
Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
parent
4633218609
commit
300b715b0d
10 changed files with 94 additions and 17 deletions
|
@ -6,6 +6,6 @@
|
|||
# · Neither the name of the QUALCOMM USA, INC. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
ifeq ($(BOARD_GPS_LIBRARIES),libloc_api)
|
||||
ifneq ($(GPS_LOC_API_HARDWARE),)
|
||||
include $(call all-subdir-makefiles)
|
||||
endif
|
||||
|
|
|
@ -6,14 +6,12 @@
|
|||
#· Neither the name of the QUALCOMM USA, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
ifneq ($(BUILD_TINY_ANDROID),true)
|
||||
|
||||
AMSS_VERSION:=6356
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libloc_api
|
||||
LOCAL_MODULE := gps.$(GPS_LOC_API_HARDWARE)
|
||||
|
||||
LOCAL_STATIC_LIBRARIES:= \
|
||||
libloc_api-rpc
|
||||
|
@ -27,7 +25,8 @@ LOCAL_SRC_FILES += \
|
|||
loc_eng.cpp \
|
||||
loc_eng_ioctl.cpp \
|
||||
loc_eng_xtra.cpp \
|
||||
loc_eng_ni.cpp
|
||||
loc_eng_ni.cpp \
|
||||
gps.c
|
||||
|
||||
LOCAL_CFLAGS += \
|
||||
-fno-short-enums
|
||||
|
@ -39,7 +38,7 @@ LOCAL_C_INCLUDES:= \
|
|||
$(TARGET_OUT_HEADERS)/librpc
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
endif # not BUILD_TINY_ANDROID
|
||||
|
||||
|
|
66
loc_api/libloc_api/gps.c
Normal file
66
loc_api/libloc_api/gps.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
/******************************************************************************
|
||||
@file: gps.c
|
||||
@brief:
|
||||
|
||||
DESCRIPTION
|
||||
This file defines the implemenation for GPS hardware abstraction layer.
|
||||
|
||||
INITIALIZATION AND SEQUENCING REQUIREMENTS
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Copyright (c) 2009, QUALCOMM USA, INC.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
· Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
· Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
· Neither the name of the QUALCOMM USA, INC. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <hardware/gps.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
extern const GpsInterface* get_gps_interface();
|
||||
|
||||
const GpsInterface* gps__get_gps_interface(struct gps_device_t* dev)
|
||||
{
|
||||
return get_gps_interface();
|
||||
}
|
||||
|
||||
static int open_gps(const struct hw_module_t* module, char const* name,
|
||||
struct hw_device_t** device)
|
||||
{
|
||||
struct gps_device_t *dev = malloc(sizeof(struct gps_device_t));
|
||||
memset(dev, 0, sizeof(*dev));
|
||||
|
||||
dev->common.tag = HARDWARE_DEVICE_TAG;
|
||||
dev->common.version = 0;
|
||||
dev->common.module = (struct hw_module_t*)module;
|
||||
dev->get_gps_interface = gps__get_gps_interface;
|
||||
|
||||
*device = (struct hw_device_t*)dev;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct hw_module_methods_t gps_module_methods = {
|
||||
.open = open_gps
|
||||
};
|
||||
|
||||
const struct hw_module_t HAL_MODULE_INFO_SYM = {
|
||||
.tag = HARDWARE_MODULE_TAG,
|
||||
.version_major = 1,
|
||||
.version_minor = 0,
|
||||
.id = GPS_HARDWARE_MODULE_ID,
|
||||
.name = "loc_api GPS Module",
|
||||
.author = "Qualcomm USA, Inc.",
|
||||
.methods = &gps_module_methods,
|
||||
};
|
|
@ -46,7 +46,6 @@ $Author: $
|
|||
#include "loc_api_rpc_glue.h"
|
||||
#include "loc_apicb_appinit.h"
|
||||
|
||||
#include <hardware_legacy/gps.h>
|
||||
#include <cutils/properties.h>
|
||||
#include <cutils/sched_policy.h>
|
||||
#include <utils/SystemClock.h>
|
||||
|
@ -101,6 +100,7 @@ static int set_agps_server();
|
|||
// Defines the GpsInterface in gps.h
|
||||
static const GpsInterface sLocEngInterface =
|
||||
{
|
||||
sizeof(GpsInterface),
|
||||
loc_eng_init,
|
||||
loc_eng_start,
|
||||
loc_eng_stop,
|
||||
|
@ -114,6 +114,7 @@ static const GpsInterface sLocEngInterface =
|
|||
|
||||
static const AGpsInterface sLocEngAGpsInterface =
|
||||
{
|
||||
sizeof(AGpsInterface),
|
||||
loc_eng_agps_init,
|
||||
loc_eng_agps_data_conn_open,
|
||||
loc_eng_agps_data_conn_closed,
|
||||
|
@ -708,7 +709,8 @@ static void loc_eng_report_position (const rpc_loc_parsed_position_s_type *locat
|
|||
LOGV ("loc_eng_report_position: location report, valid mask = 0x%x, sess status = %d\n",
|
||||
(uint32) location_report_ptr->valid_mask, location_report_ptr->session_status);
|
||||
|
||||
memset (&location, 0, sizeof (GpsLocation));
|
||||
memset (&location, 0, sizeof(location));
|
||||
location.size = sizeof(location);
|
||||
if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_SESSION_STATUS)
|
||||
{
|
||||
// Not a position report, return
|
||||
|
@ -818,6 +820,7 @@ static void loc_eng_report_sv (const rpc_loc_gnss_info_s_type *gnss_report_ptr)
|
|||
{
|
||||
if (sv_info_ptr->system == RPC_LOC_SV_SYSTEM_GPS)
|
||||
{
|
||||
SvStatus.sv_list[SvStatus.num_svs].size = sizeof(GpsSvStatus);
|
||||
SvStatus.sv_list[SvStatus.num_svs].prn = sv_info_ptr->prn;
|
||||
|
||||
// We only have the data field to report gps eph and alm mask
|
||||
|
@ -906,7 +909,8 @@ static void loc_eng_report_status (const rpc_loc_status_event_s_type *status_rep
|
|||
|
||||
LOGV ("loc_eng_report_status: event = %d\n", status_report_ptr->event);
|
||||
|
||||
memset (&status, 0, sizeof (GpsStatus));
|
||||
memset (&status, 0, sizeof(status));
|
||||
status.size = sizeof(status);
|
||||
status.status = GPS_STATUS_NONE;
|
||||
if (status_report_ptr->event == RPC_LOC_STATUS_EVENT_ENGINE_STATE)
|
||||
{
|
||||
|
@ -1351,6 +1355,7 @@ SIDE EFFECTS
|
|||
static void* loc_eng_process_deferred_action (void* arg)
|
||||
{
|
||||
AGpsStatus status;
|
||||
status.size = sizeof(status);
|
||||
status.type = AGPS_TYPE_SUPL;
|
||||
|
||||
LOGD("loc_eng_process_deferred_action started\n");
|
||||
|
@ -1428,3 +1433,9 @@ static void* loc_eng_process_deferred_action (void* arg)
|
|||
LOGD("loc_eng_process_deferred_action thread exiting\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// for gps.c
|
||||
extern "C" const GpsInterface* get_gps_interface()
|
||||
{
|
||||
return &sLocEngInterface;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ typedef unsigned char boolean;
|
|||
|
||||
#include <loc_eng_ioctl.h>
|
||||
#include <loc_eng_xtra.h>
|
||||
#include <hardware_legacy/gps_ni.h>
|
||||
#include <hardware/gps.h>
|
||||
|
||||
#define LOC_IOCTL_DEFAULT_TIMEOUT 1000 // 1000 milli-seconds
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ $Author: $
|
|||
#include <rpc/rpc.h>
|
||||
#include <loc_api_rpc_glue.h>
|
||||
|
||||
#include <hardware_legacy/gps.h>
|
||||
#include <hardware/gps.h>
|
||||
|
||||
#include <loc_eng.h>
|
||||
|
||||
|
|
|
@ -37,8 +37,6 @@ $Id:
|
|||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <hardware_legacy/gps.h>
|
||||
|
||||
#include <rpc/rpc.h>
|
||||
#include <loc_api_rpc_glue.h>
|
||||
#include <loc_eng.h>
|
||||
|
@ -59,6 +57,7 @@ $Id:
|
|||
|
||||
const GpsNiInterface sLocEngNiInterface =
|
||||
{
|
||||
sizeof(GpsNiInterface),
|
||||
loc_eng_ni_init,
|
||||
loc_eng_ni_respond,
|
||||
};
|
||||
|
@ -251,6 +250,7 @@ RETURN VALUE
|
|||
static void loc_ni_request_handler(const char *msg, const rpc_loc_ni_event_s_type *ni_req)
|
||||
{
|
||||
GpsNiNotification notif;
|
||||
notif.size = sizeof(notif);
|
||||
strlcpy(notif.text, "[text]", sizeof notif.text); // defaults
|
||||
strlcpy(notif.requestor_id, "[requestor id]", sizeof notif.requestor_id);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ $Id:
|
|||
#ifndef LOC_ENG_NI_H
|
||||
#define LOC_ENG_NI_H
|
||||
|
||||
#include <hardware_legacy/gps_ni.h>
|
||||
#include <hardware/gps.h>
|
||||
|
||||
#define LOC_NI_NO_RESPONSE_TIME 20 /* secs */
|
||||
|
||||
|
|
|
@ -43,8 +43,6 @@ $Author: $
|
|||
#include <rpc/rpc.h>
|
||||
#include <loc_api_rpc_glue.h>
|
||||
|
||||
#include <hardware_legacy/gps.h>
|
||||
|
||||
#include <loc_eng.h>
|
||||
|
||||
#define LOG_TAG "lib_locapi"
|
||||
|
@ -62,6 +60,7 @@ static int qct_loc_eng_inject_xtra_data(char* data, int length);
|
|||
|
||||
const GpsXtraInterface sLocEngXTRAInterface =
|
||||
{
|
||||
sizeof(GpsXtraInterface),
|
||||
qct_loc_eng_xtra_init,
|
||||
qct_loc_eng_inject_xtra_data,
|
||||
};
|
||||
|
|
|
@ -34,6 +34,8 @@ $Author: $
|
|||
#ifndef LOC_ENG_XTRA_H
|
||||
#define LOC_ENG_XTRA_H
|
||||
|
||||
#include <hardware/gps.h>
|
||||
|
||||
extern const GpsXtraInterface sLocEngXTRAInterface;
|
||||
|
||||
// Module data
|
||||
|
|
Loading…
Reference in a new issue