xref: /aosp_15_r20/hardware/interfaces/gnss/1.0/IGnssBatching.hal (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1*4d7e907cSAndroid Build Coastguard Worker/*
2*4d7e907cSAndroid Build Coastguard Worker * Copyright (C) 2016 The Android Open Source Project
3*4d7e907cSAndroid Build Coastguard Worker *
4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*4d7e907cSAndroid Build Coastguard Worker *
8*4d7e907cSAndroid Build Coastguard Worker *      http://www.apache.org/licenses/LICENSE-2.0
9*4d7e907cSAndroid Build Coastguard Worker *
10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License.
15*4d7e907cSAndroid Build Coastguard Worker */
16*4d7e907cSAndroid Build Coastguard Worker
17*4d7e907cSAndroid Build Coastguard Workerpackage [email protected];
18*4d7e907cSAndroid Build Coastguard Worker
19*4d7e907cSAndroid Build Coastguard Workerimport IGnssBatchingCallback;
20*4d7e907cSAndroid Build Coastguard Worker
21*4d7e907cSAndroid Build Coastguard Worker/**
22*4d7e907cSAndroid Build Coastguard Worker * Extended interface for GNSS Batching support.
23*4d7e907cSAndroid Build Coastguard Worker *
24*4d7e907cSAndroid Build Coastguard Worker * If this interface is supported, this batching request must be able to run in
25*4d7e907cSAndroid Build Coastguard Worker * parallel with, or without, non-batched location requested by the
26*4d7e907cSAndroid Build Coastguard Worker * IGnss start() & stop() - i.e. both requests must be handled independently,
27*4d7e907cSAndroid Build Coastguard Worker * and not interfere with each other.
28*4d7e907cSAndroid Build Coastguard Worker *
29*4d7e907cSAndroid Build Coastguard Worker * For example, if a 1Hz continuous output is underway on the IGnssCallback,
30*4d7e907cSAndroid Build Coastguard Worker * due to an IGnss start() operation,
31*4d7e907cSAndroid Build Coastguard Worker * and then a IGnssBatching start() is called for a location every 10
32*4d7e907cSAndroid Build Coastguard Worker * seconds, the newly added batching request must not disrupt the 1Hz
33*4d7e907cSAndroid Build Coastguard Worker * continuous location output on the IGnssCallback.
34*4d7e907cSAndroid Build Coastguard Worker *
35*4d7e907cSAndroid Build Coastguard Worker * As with GNSS Location outputs, source of location must be GNSS satellite
36*4d7e907cSAndroid Build Coastguard Worker * measurements, optionally using interial and baro sensors to improve
37*4d7e907cSAndroid Build Coastguard Worker * relative motion filtering. No additional absolute positioning information,
38*4d7e907cSAndroid Build Coastguard Worker * such as WiFi derived location, may be mixed with the GNSS information.
39*4d7e907cSAndroid Build Coastguard Worker */
40*4d7e907cSAndroid Build Coastguard Worker
41*4d7e907cSAndroid Build Coastguard Workerinterface IGnssBatching {
42*4d7e907cSAndroid Build Coastguard Worker    /**
43*4d7e907cSAndroid Build Coastguard Worker     * Enum which holds the bit masks for batching control.
44*4d7e907cSAndroid Build Coastguard Worker     */
45*4d7e907cSAndroid Build Coastguard Worker    @export(name="", value_prefix="FLP_BATCH_")
46*4d7e907cSAndroid Build Coastguard Worker    enum Flag : uint8_t {
47*4d7e907cSAndroid Build Coastguard Worker        /**
48*4d7e907cSAndroid Build Coastguard Worker         * If this flag is set, the hardware implementation
49*4d7e907cSAndroid Build Coastguard Worker         * must wake up the application processor when the FIFO is full, and
50*4d7e907cSAndroid Build Coastguard Worker         * call IGnssBatchingCallback to return the locations.
51*4d7e907cSAndroid Build Coastguard Worker         *
52*4d7e907cSAndroid Build Coastguard Worker         * If the flag is not set, the hardware implementation must drop
53*4d7e907cSAndroid Build Coastguard Worker         * the oldest data when the FIFO is full.
54*4d7e907cSAndroid Build Coastguard Worker         */
55*4d7e907cSAndroid Build Coastguard Worker        WAKEUP_ON_FIFO_FULL = 0x01
56*4d7e907cSAndroid Build Coastguard Worker    };
57*4d7e907cSAndroid Build Coastguard Worker
58*4d7e907cSAndroid Build Coastguard Worker    struct Options {
59*4d7e907cSAndroid Build Coastguard Worker        /**
60*4d7e907cSAndroid Build Coastguard Worker         * Time interval between samples in the location batch, in nano
61*4d7e907cSAndroid Build Coastguard Worker         * seconds.
62*4d7e907cSAndroid Build Coastguard Worker         */
63*4d7e907cSAndroid Build Coastguard Worker        int64_t periodNanos;
64*4d7e907cSAndroid Build Coastguard Worker
65*4d7e907cSAndroid Build Coastguard Worker        /**
66*4d7e907cSAndroid Build Coastguard Worker         * Flags controlling how batching should behave.
67*4d7e907cSAndroid Build Coastguard Worker         */
68*4d7e907cSAndroid Build Coastguard Worker        bitfield<Flag> flags;
69*4d7e907cSAndroid Build Coastguard Worker    };
70*4d7e907cSAndroid Build Coastguard Worker
71*4d7e907cSAndroid Build Coastguard Worker    /**
72*4d7e907cSAndroid Build Coastguard Worker     * Opens the interface and provides the callback routines
73*4d7e907cSAndroid Build Coastguard Worker     * to the implementation of this interface.
74*4d7e907cSAndroid Build Coastguard Worker     *
75*4d7e907cSAndroid Build Coastguard Worker     * @param callback Callback interface for IGnssBatching.
76*4d7e907cSAndroid Build Coastguard Worker     *
77*4d7e907cSAndroid Build Coastguard Worker     * @return success Returns true on success.
78*4d7e907cSAndroid Build Coastguard Worker     */
79*4d7e907cSAndroid Build Coastguard Worker    init(IGnssBatchingCallback callback) generates (bool success);
80*4d7e907cSAndroid Build Coastguard Worker
81*4d7e907cSAndroid Build Coastguard Worker    /**
82*4d7e907cSAndroid Build Coastguard Worker     * Return the batch size (in number of GnssLocation objects)
83*4d7e907cSAndroid Build Coastguard Worker     * available in this hardware implementation.
84*4d7e907cSAndroid Build Coastguard Worker     *
85*4d7e907cSAndroid Build Coastguard Worker     * If the available size is variable, for example, based on other operations
86*4d7e907cSAndroid Build Coastguard Worker     * consuming memory, this is the minimum size guaranteed to be available
87*4d7e907cSAndroid Build Coastguard Worker     * for batching operations.
88*4d7e907cSAndroid Build Coastguard Worker     *
89*4d7e907cSAndroid Build Coastguard Worker     * This may, for example, be used by the upper layer, to decide on the
90*4d7e907cSAndroid Build Coastguard Worker     * batching interval and whether the AP should be woken up or not.
91*4d7e907cSAndroid Build Coastguard Worker     *
92*4d7e907cSAndroid Build Coastguard Worker     * @return batchSize number of location objects supported per batch
93*4d7e907cSAndroid Build Coastguard Worker     */
94*4d7e907cSAndroid Build Coastguard Worker    getBatchSize() generates (uint16_t batchSize);
95*4d7e907cSAndroid Build Coastguard Worker
96*4d7e907cSAndroid Build Coastguard Worker    /**
97*4d7e907cSAndroid Build Coastguard Worker     * Start batching locations. This API is primarily used when the AP is
98*4d7e907cSAndroid Build Coastguard Worker     * asleep and the device can batch locations in the hardware.
99*4d7e907cSAndroid Build Coastguard Worker     *
100*4d7e907cSAndroid Build Coastguard Worker     * IGnssBatchingCallback is used to return the locations.
101*4d7e907cSAndroid Build Coastguard Worker     *
102*4d7e907cSAndroid Build Coastguard Worker     * When the buffer is full and WAKEUP_ON_FIFO_FULL is used,
103*4d7e907cSAndroid Build Coastguard Worker     * IGnssBatchingCallback must be called to return the locations.
104*4d7e907cSAndroid Build Coastguard Worker     *
105*4d7e907cSAndroid Build Coastguard Worker     * When the buffer is full and WAKEUP_ON_FIFO_FULL is not set,
106*4d7e907cSAndroid Build Coastguard Worker     * the oldest location object is dropped. In this case the AP must not be
107*4d7e907cSAndroid Build Coastguard Worker     * woken up. The AP would then generally be responsible for using
108*4d7e907cSAndroid Build Coastguard Worker     * flushBatchedLocation to explicitly ask for the location as needed,
109*4d7e907cSAndroid Build Coastguard Worker     * to avoid it being dropped.
110*4d7e907cSAndroid Build Coastguard Worker     *
111*4d7e907cSAndroid Build Coastguard Worker     * @param options See struct Options definition.
112*4d7e907cSAndroid Build Coastguard Worker     *
113*4d7e907cSAndroid Build Coastguard Worker     * @return success Returns true on success.
114*4d7e907cSAndroid Build Coastguard Worker     */
115*4d7e907cSAndroid Build Coastguard Worker    start(Options options) generates (bool success);
116*4d7e907cSAndroid Build Coastguard Worker
117*4d7e907cSAndroid Build Coastguard Worker    /**
118*4d7e907cSAndroid Build Coastguard Worker     * Retrieve all batched locations currently stored.
119*4d7e907cSAndroid Build Coastguard Worker     *
120*4d7e907cSAndroid Build Coastguard Worker     * IGnssBatchingCallback is used to return the location.
121*4d7e907cSAndroid Build Coastguard Worker     *
122*4d7e907cSAndroid Build Coastguard Worker     * IGnssBatchingCallback must be called in response, even if there are
123*4d7e907cSAndroid Build Coastguard Worker     * no locations to flush (in which case the Location vector must be empty).
124*4d7e907cSAndroid Build Coastguard Worker     *
125*4d7e907cSAndroid Build Coastguard Worker     * Subsequent calls to flushBatchedLocation
126*4d7e907cSAndroid Build Coastguard Worker     * must not return any of the locations returned in this call.
127*4d7e907cSAndroid Build Coastguard Worker     */
128*4d7e907cSAndroid Build Coastguard Worker    flush();
129*4d7e907cSAndroid Build Coastguard Worker
130*4d7e907cSAndroid Build Coastguard Worker    /**
131*4d7e907cSAndroid Build Coastguard Worker     * Stop batching.
132*4d7e907cSAndroid Build Coastguard Worker     *
133*4d7e907cSAndroid Build Coastguard Worker     * @return success Returns true on success.
134*4d7e907cSAndroid Build Coastguard Worker     */
135*4d7e907cSAndroid Build Coastguard Worker    stop() generates (bool success);
136*4d7e907cSAndroid Build Coastguard Worker
137*4d7e907cSAndroid Build Coastguard Worker    /**
138*4d7e907cSAndroid Build Coastguard Worker     * Closes the interface. If any batch operations are in progress,
139*4d7e907cSAndroid Build Coastguard Worker     * they must be stopped.  If any locations are in the hardware batch, they
140*4d7e907cSAndroid Build Coastguard Worker     * must be deleted (and not sent via callback.)
141*4d7e907cSAndroid Build Coastguard Worker     *
142*4d7e907cSAndroid Build Coastguard Worker     * init() may be called again, after this, if the interface is to be restored
143*4d7e907cSAndroid Build Coastguard Worker     */
144*4d7e907cSAndroid Build Coastguard Worker    cleanup();
145*4d7e907cSAndroid Build Coastguard Worker
146*4d7e907cSAndroid Build Coastguard Worker};
147