rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* Copyright Statement: |
| 2 | * |
| 3 | * This software/firmware and related documentation ("MediaTek Software") are |
| 4 | * protected under relevant copyright laws. The information contained herein |
| 5 | * is confidential and proprietary to MediaTek Inc. and/or its licensors. |
| 6 | * Without the prior written permission of MediaTek inc. and/or its licensors, |
| 7 | * any reproduction, modification, use or disclosure of MediaTek Software, |
| 8 | * and information contained herein, in whole or in part, shall be strictly prohibited. |
| 9 | * |
| 10 | * MediaTek Inc. (C) 2016. All rights reserved. |
| 11 | * |
| 12 | * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 13 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 14 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON |
| 15 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 18 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 19 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 20 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH |
| 21 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES |
| 22 | * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES |
| 23 | * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK |
| 24 | * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR |
| 25 | * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND |
| 26 | * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 27 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 28 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO |
| 29 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 30 | * |
| 31 | * The following software/firmware and/or related documentation ("MediaTek Software") |
| 32 | * have been modified by MediaTek Inc. All revisions are subject to any receiver's |
| 33 | * applicable license agreements with MediaTek Inc. |
| 34 | */ |
| 35 | #ifndef __GPS_HAL_H__ |
| 36 | #define __GPS_HAL_H__ |
| 37 | |
| 38 | #include "hardware/gps_mtk.h" |
| 39 | #include <pthread.h> |
| 40 | |
| 41 | //========================================================= |
| 42 | |
| 43 | #define MAX_EPOLL_EVENT 50 |
| 44 | |
| 45 | //========================================================= |
| 46 | |
| 47 | typedef enum { // state order is important |
| 48 | GPSHAL_STATE_UNKNOWN, |
| 49 | GPSHAL_STATE_RESOURCE, |
| 50 | GPSHAL_STATE_CLEANUP, |
| 51 | GPSHAL_STATE_INIT, // == STOP |
| 52 | GPSHAL_STATE_STOP, // == INIT |
| 53 | GPSHAL_STATE_START |
| 54 | } gpshal_state; |
| 55 | |
| 56 | typedef struct { |
| 57 | int fd_mnl2hal; |
| 58 | int fd_worker_epoll; |
| 59 | pthread_t thd_worker; |
| 60 | |
| 61 | pthread_mutex_t mutex_gps_state_intent; |
| 62 | gpshal_state gps_state_intent; // what we want |
| 63 | gpshal_state gps_state; // what we are, but we may fail to change it |
| 64 | |
| 65 | GpsCallbacks_ext* gps_cbs; |
| 66 | AGpsCallbacks* agps_cbs; |
| 67 | GpsNiCallbacks* gpsni_cbs; |
| 68 | AGpsRilCallbacks* agpsril_cbs; |
| 69 | GpsMeasurementCallbacks_ext* meas_cbs; |
| 70 | GpsNavigationMessageCallbacks* navimsg_cbs; |
| 71 | GpsGeofenceCallbacks* geofence_cbs; |
| 72 | VzwDebugCallbacks* vzw_debug_cbs; |
| 73 | } gpshal_context_t; |
| 74 | |
| 75 | //========================================================= |
| 76 | |
| 77 | extern gpshal_context_t g_gpshal_ctx; |
| 78 | extern const AGpsInterface mtk_agps_inf; |
| 79 | extern const GpsNiInterface mtk_gps_ni_inf; |
| 80 | extern const AGpsRilInterface mtk_agps_ril_inf; |
| 81 | extern const GpsGeofencingInterface mtkGeofence_inf; |
| 82 | |
| 83 | |
| 84 | //========================================================= |
| 85 | |
| 86 | extern const char* gpshal_state_to_string(gpshal_state state); |
| 87 | |
| 88 | extern int gpshal_gpscbs_save(GpsCallbacks_ext* src); |
| 89 | |
| 90 | extern void gpshal_set_gps_state_intent(gpshal_state newState); |
| 91 | |
| 92 | extern void gpshal2mnl_gps_init(); |
| 93 | extern void gpshal2mnl_gps_start(); |
| 94 | extern void gpshal2mnl_gps_stop(); |
| 95 | extern void gpshal2mnl_gps_cleanup(); |
| 96 | |
| 97 | extern void gpshal_worker_thread(void *arg); |
| 98 | |
| 99 | #endif // __GPS_HAL_DEBUG_H__ |