From 2afd20942c0ae19e17e0a0af6cde3d14cfdfaf5d Mon Sep 17 00:00:00 2001 From: Roberto Gibellini Date: Thu, 5 Jan 2017 15:29:48 +0100 Subject: smdk4412-qcom : gps header inline with M aosp Change-Id: I6b470cd1541370b24ecbb6c6d213300bdda06e72 --- include/hardware/gps.h | 103 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 90 insertions(+), 13 deletions(-) diff --git a/include/hardware/gps.h b/include/hardware/gps.h index 61bea6f..e130d54 100644 --- a/include/hardware/gps.h +++ b/include/hardware/gps.h @@ -51,7 +51,10 @@ typedef uint32_t GpsPositionMode; #define GPS_POSITION_MODE_STANDALONE 0 /** AGPS MS-Based mode. */ #define GPS_POSITION_MODE_MS_BASED 1 -/** AGPS MS-Assisted mode. */ +/** + * AGPS MS-Assisted mode. This mode is not maintained by the platform anymore. + * It is strongly recommended to use GPS_POSITION_MODE_MS_BASE instead. + */ #define GPS_POSITION_MODE_MS_ASSISTED 2 /** Requested recurrence mode for GPS operation. */ @@ -309,6 +312,8 @@ typedef uint32_t GpsMeasurementFlags; #define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16) /** A valid 'used in fix' flag is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17) +/** The value of 'pseudorange rate' is uncorrected. */ +#define GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE (1<<18) /** * Enumeration of the available values for the GPS Measurement's loss of lock. @@ -334,6 +339,12 @@ typedef uint8_t GpsMultipathIndicator; /** * Flags indicating the GPS measurement state. + * The expected behavior here is for GPS HAL to set all the flags that applies. For + * example, if the state for a satellite is only C/A code locked and bit synchronized, + * and there is still millisecond ambiguity, the state should be set as: + * GPS_MEASUREMENT_STATE_CODE_LOCK|GPS_MEASUREMENT_STATE_BIT_SYNC|GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS + * If GPS is still searching for a satellite, the corresponding state should be set to + * GPS_MEASUREMENT_STATE_UNKNOWN(0). */ typedef uint16_t GpsMeasurementState; #define GPS_MEASUREMENT_STATE_UNKNOWN 0 @@ -341,6 +352,7 @@ typedef uint16_t GpsMeasurementState; #define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1) #define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2) #define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3) +#define GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4) /** * Flags indicating the Accumulated Delta Range's states. @@ -352,7 +364,7 @@ typedef uint16_t GpsAccumulatedDeltaRangeState; #define GPS_ADR_STATE_CYCLE_SLIP (1<<2) /** - * Enumeration of available values to indicate the available GPS Natigation message types. + * Enumeration of available values to indicate the available GPS Navigation message types. */ typedef uint8_t GpsNavigationMessageType; /** The message type is unknown. */ @@ -366,6 +378,19 @@ typedef uint8_t GpsNavigationMessageType; /** CNAV-2 message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4 +/** + * Status of Navigation Message + * When a message is received properly without any parity error in its navigation words, the + * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received + * with words that failed parity check, but GPS is able to correct those words, the status + * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT. + * No need to send any navigation message that contains words with parity error and cannot be + * corrected. + */ +typedef uint16_t NavigationMessageStatus; +#define NAV_MESSAGE_STATUS_UNKONW 0 +#define NAV_MESSAGE_STATUS_PARITY_PASSED (1<<0) +#define NAV_MESSAGE_STATUS_PARITY_REBUILT (1<<1) /** * Name for the GPS XTRA interface. @@ -622,6 +647,12 @@ typedef struct { * min_interval represents the time between fixes in milliseconds. * preferred_accuracy represents the requested fix accuracy in meters. * preferred_time represents the requested time to first fix in milliseconds. + * + * 'mode' parameter should be one of GPS_POSITION_MODE_MS_BASE + * or GPS_POSITION_MODE_STANDALONE. + * It is allowed by the platform (and it is recommended) to fallback to + * GPS_POSITION_MODE_MS_BASE if GPS_POSITION_MODE_MS_ASSISTED is passed in, and + * GPS_POSITION_MODE_MS_BASED is supported. */ int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence, uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); @@ -667,6 +698,12 @@ typedef struct { size_t (*get_internal_state)(char* buffer, size_t bufferSize); } GpsDebugInterface; +#pragma pack(push,4) +// We need to keep the alignment of this data structure to 4-bytes, to ensure that in 64-bit +// environments the size of this legacy definition does not collide with _v2. Implementations should +// be using _v2 and _v3, so it's OK to pay the 'unaligned' penalty in 64-bit if an old +// implementation is still in use. + /** Represents the status of AGPS. */ typedef struct { /** set to sizeof(AGpsStatus_v1) */ @@ -676,6 +713,8 @@ typedef struct { AGpsStatusValue status; } AGpsStatus_v1; +#pragma pack(pop) + /** Represents the status of AGPS augmented with a IPv4 address field. */ typedef struct { /** set to sizeof(AGpsStatus_v2) */ @@ -1358,6 +1397,9 @@ typedef struct { * * The value contains the 'drift uncertainty' in it. * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT. + * + * If GpsMeasurement's 'flags' field contains GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE, + * it is encouraged that this field is also provided. */ double drift_nsps; @@ -1411,17 +1453,25 @@ typedef struct { * Received GPS Time-of-Week at the measurement time, in nanoseconds. * The value is relative to the beginning of the current GPS week. * - * Given the sync state of GPS receiver, per each satellite, valid range for this field can be: - * Searching : [ 0 ] : GPS_MEASUREMENT_STATE_UNKNOWN - * Ranging code lock : [ 0 1ms ] : GPS_MEASUREMENT_STATE_CODE_LOCK is set - * Bit sync : [ 0 20ms ] : GPS_MEASUREMENT_STATE_BIT_SYNC is set - * Subframe sync : [ 0 6ms ] : GPS_MEASUREMENT_STATE_SUBFRAME_SYNC is set - * TOW decoded : [ 0 1week ] : GPS_MEASUREMENT_STATE_TOW_DECODED is set + * Given the highest sync state that can be achieved, per each satellite, valid range for + * this field can be: + * Searching : [ 0 ] : GPS_MEASUREMENT_STATE_UNKNOWN + * C/A code lock : [ 0 1ms ] : GPS_MEASUREMENT_STATE_CODE_LOCK is set + * Bit sync : [ 0 20ms ] : GPS_MEASUREMENT_STATE_BIT_SYNC is set + * Subframe sync : [ 0 6s ] : GPS_MEASUREMENT_STATE_SUBFRAME_SYNC is set + * TOW decoded : [ 0 1week ] : GPS_MEASUREMENT_STATE_TOW_DECODED is set + * + * However, if there is any ambiguity in integer millisecond, + * GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field. + * + * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN. */ int64_t received_gps_tow_ns; /** * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds. + * + * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN. */ int64_t received_gps_tow_uncertainty_ns; @@ -1435,11 +1485,23 @@ typedef struct { /** * Pseudorange rate at the timestamp in m/s. - * The value also includes the effects of the receiver clock frequency and satellite clock - * frequency errors. + * The correction of a given Pseudorange Rate value includes corrections for receiver and + * satellite clock frequency errors. + * + * If GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE is set in 'flags' field, this field must + * be populated with the 'uncorrected' reading. + * If GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE is not set in 'flags' field, this field + * must be populated with the 'corrected' reading. This is the default behavior. + * + * It is encouraged to provide the 'uncorrected' 'pseudorange rate', and provide GpsClock's + * 'drift' field as well. * * The value includes the 'pseudorange rate uncertainty' in it. - * A positive value indicates that the pseudorange is getting larger. + * A positive 'uncorrected' value indicates that the SV is moving away from the receiver. + * + * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler + * shift' is given by the equation: + * pseudorange rate = -k * doppler shift (where k is a constant) * * This is a Mandatory value. */ @@ -1463,13 +1525,21 @@ typedef struct { /** * Accumulated delta range since the last channel reset in meters. - * The data is available if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. + * A positive value indicates that the SV is moving away from the receiver. + * + * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase' + * is given by the equation: + * accumulated delta range = -k * carrier phase (where k is a constant) + * + * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. + * However, it is expected that the data is only accurate when: + * 'accumulated delta range state' == GPS_ADR_STATE_VALID. */ double accumulated_delta_range_m; /** * 1-Sigma uncertainty of the accumulated delta range in meters. - * The data is available if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. + * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. */ double accumulated_delta_range_uncertainty_m; @@ -1705,6 +1775,13 @@ typedef struct { */ GpsNavigationMessageType type; + /** + * The status of the received navigation message. + * No need to send any navigation message that contains words with parity error and cannot be + * corrected. + */ + NavigationMessageStatus status; + /** * Message identifier. * It provides an index so the complete Navigation Message can be assembled. i.e. fo L1 C/A -- cgit v1.2.3