blob: b32199e884feda4e2492eed7e71218fa1bb68d1a [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_INCLUDE_HARDWARE_GPS_MTK_H
18#define ANDROID_INCLUDE_HARDWARE_GPS_MTK_H
19
20#include <hardware/gps_internal.h>
21
22__BEGIN_DECLS
23
24// MTK extended GpsAidingData values.
25#define GPS_DELETE_HOT_STILL 0x2000
26#define GPS_DELETE_EPO 0x4000
27
28// ====================vzw debug screen API =================
29/**
30 * Name for the VZW debug interface.
31 */
32#define VZW_DEBUG_INTERFACE "vzw-debug"
33
34#define VZW_DEBUG_STRING_MAXLEN 200
35
36/** Represents data of VzwDebugData. */
37typedef struct {
38 /** set to sizeof(VzwDebugData) */
39 size_t size;
40
41 char vzw_msg_data[VZW_DEBUG_STRING_MAXLEN];
42} VzwDebugData;
43
44
45typedef void (* vzw_debug_callback)(VzwDebugData* vzw_message);
46
47/** Callback structure for the Vzw debug interface. */
48typedef struct {
49 vzw_debug_callback vzw_debug_cb;
50} VzwDebugCallbacks;
51
52
53/** Extended interface for VZW DEBUG support. */
54typedef struct {
55 /** set to sizeof(VzwDebugInterface) */
56 size_t size;
57
58 /** Registers the callbacks for Vzw debug message. */
59 int (*init)( VzwDebugCallbacks* callbacks );
60
61 /** Set Vzw debug screen enable/disable **/
62 void (*set_vzw_debug_screen)(bool enabled);
63} VzwDebugInterface;
64
65////////////////////// GNSS HIDL v1.0 ////////////////////////////
66
67/** Represents a location. */
68typedef struct {
69 GpsLocation legacyLocation;
70 /**
71 * Represents expected horizontal position accuracy, radial, in meters
72 * (68% confidence).
73 */
74 float horizontalAccuracyMeters;
75
76 /**
77 * Represents expected vertical position accuracy in meters
78 * (68% confidence).
79 */
80 float verticalAccuracyMeters;
81
82 /**
83 * Represents expected speed accuracy in meter per seconds
84 * (68% confidence).
85 */
86 float speedAccuracyMetersPerSecond;
87
88 /**
89 * Represents expected bearing accuracy in degrees
90 * (68% confidence).
91 */
92 float bearingAccuracyDegrees;
93
94} GpsLocation_ext;
95
96
97typedef struct {
98 GnssSvInfo legacySvInfo;
99
100 /// v1.0 ///
101 float carrier_frequency;
102
103} GnssSvInfo_ext;
104
105/**
106 * Represents SV status.
107 */
108typedef struct {
109 /** set to sizeof(GnssSvStatus) */
110 size_t size;
111
112 /** Number of GPS SVs currently visible, refers to the SVs stored in sv_list */
113 int num_svs;
114 /**
115 * Pointer to an array of SVs information for all GNSS constellations,
116 * except GPS, which is reported using sv_list
117 */
118 GnssSvInfo_ext gnss_sv_list[GNSS_MAX_SVS];
119
120} GnssSvStatus_ext;
121
122/**
123 * Callback with location information. Can only be called from a thread created
124 * by create_thread_cb.
125 */
126typedef void (* gps_location_ext_callback)(GpsLocation_ext* location);
127
128/**
129 * Callback with SV status information.
130 * Can only be called from a thread created by create_thread_cb.
131 */
132typedef void (* gnss_sv_status_ext_callback)(GnssSvStatus_ext* sv_info);
133
134/**
135 * The callback associated with the geofence.
136 * Parameters:
137 * geofence_id - The id associated with the add_geofence_area.
138 * location - The current GPS location.
139 * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED,
140 * GPS_GEOFENCE_UNCERTAIN.
141 * timestamp - Timestamp when the transition was detected.
142 *
143 * The callback should only be called when the caller is interested in that
144 * particular transition. For instance, if the caller is interested only in
145 * ENTERED transition, then the callback should NOT be called with the EXITED
146 * transition.
147 *
148 * IMPORTANT: If a transition is triggered resulting in this callback, the GPS
149 * subsystem will wake up the application processor, if its in suspend state.
150 */
151typedef void (*gps_geofence_transition_ext_callback) (int32_t geofence_id,
152 GpsLocation_ext* location, int32_t transition, GpsUtcTime timestamp);
153
154/**
155 * The callback associated with the availability of the GPS system for geofencing
156 * monitoring. If the GPS system determines that it cannot monitor geofences
157 * because of lack of reliability or unavailability of the GPS signals, it will
158 * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter.
159 *
160 * Parameters:
161 * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE.
162 * last_location - Last known location.
163 */
164typedef void (*gps_geofence_status_ext_callback) (int32_t status,
165 GpsLocation_ext* last_location);
166
167typedef struct {
168 gps_geofence_transition_ext_callback geofence_transition_callback;
169 gps_geofence_status_ext_callback geofence_status_callback;
170 gps_geofence_add_callback geofence_add_callback;
171 gps_geofence_remove_callback geofence_remove_callback;
172 gps_geofence_pause_callback geofence_pause_callback;
173 gps_geofence_resume_callback geofence_resume_callback;
174 gps_create_thread create_thread_cb;
175} GpsGeofenceCallbacks_ext;
176
177/** Extended interface for GPS_Geofencing support */
178typedef struct {
179 /** set to sizeof(GpsGeofencingInterface) */
180 size_t size;
181
182 /**
183 * Opens the geofence interface and provides the callback routines
184 * to the implementation of this interface.
185 */
186 void (*init)( GpsGeofenceCallbacks_ext* callbacks );
187
188 /**
189 * Add a geofence area. This api currently supports circular geofences.
190 * Parameters:
191 * geofence_id - The id for the geofence. If a geofence with this id
192 * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS)
193 * should be returned.
194 * latitude, longtitude, radius_meters - The lat, long and radius
195 * (in meters) for the geofence
196 * last_transition - The current state of the geofence. For example, if
197 * the system already knows that the user is inside the geofence,
198 * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it
199 * will be GPS_GEOFENCE_UNCERTAIN.
200 * monitor_transition - Which transitions to monitor. Bitwise OR of
201 * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
202 * GPS_GEOFENCE_UNCERTAIN.
203 * notification_responsiveness_ms - Defines the best-effort description
204 * of how soon should the callback be called when the transition
205 * associated with the Geofence is triggered. For instance, if set
206 * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback
207 * should be called 1000 milliseconds within entering the geofence.
208 * This parameter is defined in milliseconds.
209 * NOTE: This is not to be confused with the rate that the GPS is
210 * polled at. It is acceptable to dynamically vary the rate of
211 * sampling the GPS for power-saving reasons; thus the rate of
212 * sampling may be faster or slower than this.
213 * unknown_timer_ms - The time limit after which the UNCERTAIN transition
214 * should be triggered. This parameter is defined in milliseconds.
215 * See above for a detailed explanation.
216 */
217 void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude,
218 double radius_meters, int last_transition, int monitor_transitions,
219 int notification_responsiveness_ms, int unknown_timer_ms);
220
221 /**
222 * Pause monitoring a particular geofence.
223 * Parameters:
224 * geofence_id - The id for the geofence.
225 */
226 void (*pause_geofence) (int32_t geofence_id);
227
228 /**
229 * Resume monitoring a particular geofence.
230 * Parameters:
231 * geofence_id - The id for the geofence.
232 * monitor_transitions - Which transitions to monitor. Bitwise OR of
233 * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and
234 * GPS_GEOFENCE_UNCERTAIN.
235 * This supersedes the value associated provided in the
236 * add_geofence_area call.
237 */
238 void (*resume_geofence) (int32_t geofence_id, int monitor_transitions);
239
240 /**
241 * Remove a geofence area. After the function returns, no notifications
242 * should be sent.
243 * Parameter:
244 * geofence_id - The id for the geofence.
245 */
246 void (*remove_geofence_area) (int32_t geofence_id);
247} GpsGeofencingInterface_ext;
248
249typedef struct {
250 GnssMeasurement legacyMeasurement;
251
252 /**
253 * Automatic gain control (AGC) level. AGC acts as a variable gain
254 * amplifier adjusting the power of the incoming signal. The AGC level
255 * may be used to indicate potential interference. When AGC is at a
256 * nominal level, this value must be set as 0. Higher gain (and/or lower
257 * input power) must be output as a positive number. Hence in cases of
258 * strong jamming, in the band of this signal, this value must go more
259 * negative.
260 *
261 * Note: Different hardware designs (e.g. antenna, pre-amplification, or
262 * other RF HW components) may also affect the typical output of of this
263 * value on any given hardware design in an open sky test - the
264 * important aspect of this output is that changes in this value are
265 * indicative of changes on input signal power in the frequency band for
266 * this measurement.
267 */
268 double agc_level_db;
269} GnssMeasurement_ext;
270
271/**
272 * Represents a reading of GNSS measurements. For devices where GnssSystemInfo's
273 * year_of_hw is set to 2016+, it is mandatory that these be provided, on
274 * request, when the GNSS receiver is searching/tracking signals.
275 *
276 * - Reporting of GPS constellation measurements is mandatory.
277 * - Reporting of all tracked constellations are encouraged.
278 */
279typedef struct {
280 /** set to sizeof(GnssData) */
281 size_t size;
282
283 /** Number of measurements. */
284 size_t measurement_count;
285
286 /** The array of measurements. */
287 GnssMeasurement_ext measurements[GNSS_MAX_MEASUREMENT];
288
289 /** The GPS clock time reading. */
290 GnssClock clock;
291} GnssData_ext;
292
293/**
294 * The callback for to report measurements from the HAL.
295 *
296 * Parameters:
297 * data - A data structure containing the measurements.
298 */
299typedef void (*gnss_measurement_ext_callback) (GnssData_ext* data);
300
301typedef struct {
302 /** set to sizeof(GpsMeasurementCallbacks) */
303 size_t size;
304 gps_measurement_callback measurement_callback;
305 gnss_measurement_ext_callback gnss_measurement_callback;
306} GpsMeasurementCallbacks_ext;
307
308
309/////// Gnss debug ////
310
311/** Milliseconds since January 1, 1970 */
312typedef int64_t GnssUtcTime;
313
314typedef enum {
315 /** Ephemeris is known for this satellite. */
316 EPHEMERIS,
317 /**
318 * Ephemeris is not known, but Almanac (approximate location) is known.
319 */
320 ALMANAC_ONLY,
321 /**
322 * Both ephemeris & almanac are not known (e.g. during a cold start
323 * blind search.)
324 */
325 NOT_AVAILABLE
326} SatelliteEphemerisType;
327
328typedef enum {
329 /**
330 * The ephemeris (or almanac only) information was demodulated from the
331 * signal received on the device
332 */
333 DEMODULATED,
334 /**
335 * The ephemeris (or almanac only) information was received from a SUPL
336 * server.
337 */
338 SUPL_PROVIDED,
339 /**
340 * The ephemeris (or almanac only) information was provided by another
341 * server.
342 */
343 OTHER_SERVER_PROVIDED,
344 /**
345 * The ephemeris (or almanac only) information was provided by another
346 * method, e.g. injected via a local debug tool, from build defaults
347 * (e.g. almanac), or is from a satellite
348 * with SatelliteEphemerisType::NOT_AVAILABLE.
349 */
350 OTHER
351} SatelliteEphemerisSource;
352
353typedef enum {
354 /** The ephemeris is known good. */
355 GOOD,
356 /** The ephemeris is known bad. */
357 BAD,
358 /** The ephemeris is unknown to be good or bad. */
359 UNKNOWN
360} SatelliteEphemerisHealth;
361
362/**
363 * Provides the current best known position from any
364 * source (GNSS or injected assistance).
365 */
366typedef struct {
367 /**
368 * Validity of the data in this struct. False only if no
369 * latitude/longitude information is known.
370 */
371 bool valid;
372 /** Latitude expressed in degrees */
373 double latitudeDegrees;
374 /** Longitude expressed in degrees */
375 double longitudeDegrees;
376 /** Altitude above ellipsoid expressed in meters */
377 float altitudeMeters;
378 /** Represents horizontal speed in meters per second. */
379 float speedMetersPerSec;
380 /** Represents heading in degrees. */
381 float bearingDegrees;
382 /**
383 * Estimated horizontal accuracy of position expressed in meters,
384 * radial, 68% confidence.
385 */
386 double horizontalAccuracyMeters;
387 /**
388 * Estimated vertical accuracy of position expressed in meters, with
389 * 68% confidence.
390 */
391 double verticalAccuracyMeters;
392 /**
393 * Estimated speed accuracy in meters per second with 68% confidence.
394 */
395 double speedAccuracyMetersPerSecond;
396 /**
397 * estimated bearing accuracy degrees with 68% confidence.
398 */
399 double bearingAccuracyDegrees;
400 /**
401 * Time duration before this report that this position information was
402 * valid. This can, for example, be a previous injected location with
403 * an age potentially thousands of seconds old, or
404 * extrapolated to the current time (with appropriately increased
405 * accuracy estimates), with a (near) zero age.
406 */
407 float ageSeconds;
408} PositionDebug;
409
410/**
411 * Provides the current best known UTC time estimate.
412 * If no fresh information is available, e.g. after a delete all,
413 * then whatever the effective defaults are on the device must be
414 * provided (e.g. Jan. 1, 2017, with an uncertainty of 5 years) expressed
415 * in the specified units.
416 */
417typedef struct {
418 /** UTC time estimate. */
419 GnssUtcTime timeEstimate;
420 /** 68% error estimate in time. */
421 float timeUncertaintyNs;
422 /**
423 * 68% error estimate in local clock drift,
424 * in nanoseconds per second (also known as parts per billion - ppb.)
425 */
426 float frequencyUncertaintyNsPerSec;
427} TimeDebug;
428
429/**
430 * Provides a single satellite info that has decoded navigation data.
431 */
432typedef struct {
433 /** Satellite vehicle ID number */
434 int16_t svid;
435 /** Defines the constellation type of the given SV. */
436 GnssConstellationType constellation;
437
438 /**
439 * Defines the standard broadcast ephemeris or almanac availability for
440 * the satellite. To report status of predicted orbit and clock
441 * information, see the serverPrediction fields below.
442 */
443 SatelliteEphemerisType ephemerisType;
444 /** Defines the ephemeris source of the satellite. */
445 SatelliteEphemerisSource ephemerisSource;
446 /**
447 * Defines whether the satellite is known healthy
448 * (safe for use in location calculation.)
449 */
450 SatelliteEphemerisHealth ephemerisHealth;
451 /**
452 * Time duration from this report (current time), minus the
453 * effective time of the ephemeris source (e.g. TOE, TOA.)
454 * Set to 0 when ephemerisType is NOT_AVAILABLE.
455 */
456 float ephemerisAgeSeconds;
457
458 /**
459 * True if a server has provided a predicted orbit and clock model for
460 * this satellite.
461 */
462 bool serverPredictionIsAvailable;
463 /**
464 * Time duration from this report (current time) minus the time of the
465 * start of the server predicted information. For example, a 1 day
466 * old prediction would be reported as 86400 seconds here.
467 */
468 float serverPredictionAgeSeconds;
469} SatelliteData;
470
471/**
472 * Provides a set of debug information that is filled by the GNSS chipset
473 * when the method getDebugData() is invoked.
474 */
475typedef struct {
476 /** Current best known position. */
477 PositionDebug position;
478 /** Current best know time estimate */
479 TimeDebug time;
480 /**
481 * Provides a list of the available satellite data, for all
482 * satellites and constellations the device can track,
483 * including GnssConstellationType UNKNOWN.
484 */
485 SatelliteData satelliteDataArray[GNSS_MAX_SVS];
486} DebugData;
487
488
489/** Extended interface for DEBUG support. */
490typedef struct {
491 /** set to sizeof(GpsDebugInterface) */
492 size_t size;
493
494 /**
495 * This function should return any information that the native
496 * implementation wishes to include in a bugreport.
497 */
498 // size_t (*get_internal_state)(char* buffer, size_t bufferSize);
499 /// v1.0 ///
500 bool (*get_internal_state)(DebugData* debugData);
501} GpsDebugInterface_ext;
502
503
504////////////////////// GNSS HIDL v1.1 ////////////////////////////
505
506/**
507 * Callback for reporting driver name information.
508 */
509typedef void (* gnss_set_name_callback)(const char* name, int length);
510
511/**
512 * Callback for requesting framework NLP or Fused location injection.
513 */
514typedef void (* gnss_request_location_callback)(bool independentFromGnss);
515
516/** New GPS callback structure. */
517typedef struct {
518 /** set to sizeof(GpsCallbacks) */
519 size_t size;
520 gps_location_ext_callback location_cb;
521 gps_status_callback status_cb;
522 gps_sv_status_callback sv_status_cb;
523 gps_nmea_callback nmea_cb;
524 gps_set_capabilities set_capabilities_cb;
525 gps_acquire_wakelock acquire_wakelock_cb;
526 gps_release_wakelock release_wakelock_cb;
527 gps_create_thread create_thread_cb;
528 gps_request_utc_time request_utc_time_cb;
529
530 gnss_set_system_info set_system_info_cb;
531 gnss_sv_status_ext_callback gnss_sv_status_cb;
532
533 /////v1.1////
534 gnss_set_name_callback set_name_cb;
535 gnss_request_location_callback request_location_cb;
536} GpsCallbacks_ext;
537
538
539/** Represents the standard GPS interface. */
540typedef struct {
541 /** set to sizeof(GpsInterface) */
542 size_t size;
543 /**
544 * Opens the interface and provides the callback routines
545 * to the implementation of this interface.
546 */
547 /// v1.0 ///
548// int (*init)( GpsCallbacks* callbacks );
549 /// v1.1 ///
550 int (*init)( GpsCallbacks_ext* callbacks );
551
552 /** Starts navigating. */
553 int (*start)( void );
554
555 /** Stops navigating. */
556 int (*stop)( void );
557
558 /** Closes the interface. */
559 void (*cleanup)( void );
560
561 /** Injects the current time. */
562 int (*inject_time)(GpsUtcTime time, int64_t timeReference,
563 int uncertainty);
564
565 /**
566 * Injects current location from another location provider (typically cell
567 * ID). Latitude and longitude are measured in degrees expected accuracy is
568 * measured in meters
569 */
570 int (*inject_location)(double latitude, double longitude, float accuracy);
571
572 /**
573 * Specifies that the next call to start will not use the
574 * information defined in the flags. GPS_DELETE_ALL is passed for
575 * a cold start.
576 */
577 void (*delete_aiding_data)(GpsAidingData flags);
578
579 /**
580 * min_interval represents the time between fixes in milliseconds.
581 * preferred_accuracy represents the requested fix accuracy in meters.
582 * preferred_time represents the requested time to first fix in milliseconds.
583 *
584 * 'mode' parameter should be one of GPS_POSITION_MODE_MS_BASED
585 * or GPS_POSITION_MODE_STANDALONE.
586 * It is allowed by the platform (and it is recommended) to fallback to
587 * GPS_POSITION_MODE_MS_BASED if GPS_POSITION_MODE_MS_ASSISTED is passed in, and
588 * GPS_POSITION_MODE_MS_BASED is supported.
589 */
590 /// v1.0 ///
591// int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence,
592// uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time);
593 /// v1.1 ///
594 int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence,
595 uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time,
596 bool lowPowerMode);
597
598
599 /** Get a pointer to extension information. */
600 const void* (*get_extension)(const char* name);
601
602 /// v1.1 ///
603 int (*inject_fused_location)(double latitude, double longitude, float accuracy);
604
605} GpsInterface_ext;
606
607
608/**
609 * Extended interface for GPS Measurements support.
610 */
611typedef struct {
612 /** Set to sizeof(GpsMeasurementInterface_ext) */
613 size_t size;
614
615 /**
616 * Initializes the interface and registers the callback routines with the HAL.
617 * After a successful call to 'init' the HAL must begin to provide updates at its own phase.
618 *
619 * Status:
620 * GPS_MEASUREMENT_OPERATION_SUCCESS
621 * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a
622 * corresponding call to 'close'
623 * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL
624 * will not generate any updates upon returning this error code.
625 */
626 /// v1.0 ///
627// int (*init) (GpsMeasurementCallbacks* callbacks);
628 /// v1.1 ///
629 int (*init) (GpsMeasurementCallbacks_ext* callbacks, bool enableFullTracking);
630
631 /**
632 * Stops updates from the HAL, and unregisters the callback routines.
633 * After a call to stop, the previously registered callbacks must be considered invalid by the
634 * HAL.
635 * If stop is invoked without a previous 'init', this function should perform no work.
636 */
637 void (*close) ();
638
639} GpsMeasurementInterface_ext;
640
641
642/**
643 * Interface for passing GNSS configuration contents from platform to HAL.
644 */
645typedef struct {
646 /** Set to sizeof(GnssConfigurationInterface) */
647 size_t size;
648
649 /**
650 * Deliver GNSS configuration contents to HAL.
651 * Parameters:
652 * config_data - a pointer to a char array which holds what usually is expected from
653 file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'.
654 * length - total number of UTF8 characters in configuraiton data.
655 *
656 * IMPORTANT:
657 * GPS HAL should expect this function can be called multiple times. And it may be
658 * called even when GpsLocationProvider is already constructed and enabled. GPS HAL
659 * should maintain the existing requests for various callback regardless the change
660 * in configuration data.
661 */
662 void (*configuration_update) (const char* config_data, int32_t length);
663
664 //// v1.1 ////
665 void (*setBlacklist) (long long* blacklist, int32_t size);
666} GnssConfigurationInterface_ext;
667
668struct gps_device_t_ext {
669 struct hw_device_t common;
670
671 /**
672 * Set the provided lights to the provided values.
673 *
674 * Returns: 0 on succes, error code on failure.
675 */
676 const GpsInterface_ext* (*get_gps_interface)(struct gps_device_t_ext* dev);
677};
678
679__END_DECLS
680
681#endif /* ANDROID_INCLUDE_HARDWARE_GPS_MTK_H */
682