Home | History | Annotate | Download | only in inc
      1 /*
      2  * Copyright (C) 2016 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 __HOSTINTF_H
     18 #define __HOSTINTF_H
     19 
     20 #include <stdint.h>
     21 #include <atomicBitset.h>
     22 #include <sensors.h>
     23 #include "toolchain.h"
     24 
     25 /**
     26  * System-facing hostIntf API
     27  */
     28 
     29 #define HOSTINTF_MAX_INTERRUPTS     256
     30 #define HOSTINTF_SENSOR_DATA_MAX    240
     31 
     32 enum HostIntfDataType
     33 {
     34     HOSTINTF_DATA_TYPE_LOG,
     35     HOSTINTF_DATA_TYPE_APP_TO_HOST,
     36     HOSTINTF_DATA_TYPE_RESET_REASON,
     37 };
     38 
     39 SET_PACKED_STRUCT_MODE_ON
     40 struct HostIntfDataBuffer
     41 {
     42     union
     43     {
     44         struct
     45         {
     46             uint8_t sensType;
     47             uint8_t length;
     48             uint8_t dataType;
     49             uint8_t interrupt;
     50         };
     51         uint32_t evtType;
     52     };
     53     union
     54     {
     55         struct
     56         {
     57             uint64_t referenceTime;
     58             union
     59             {
     60                 struct SensorFirstSample firstSample;
     61                 struct SingleAxisDataPoint single[HOSTINTF_SENSOR_DATA_MAX / sizeof(struct SingleAxisDataPoint)];
     62                 struct TripleAxisDataPoint triple[HOSTINTF_SENSOR_DATA_MAX / sizeof(struct TripleAxisDataPoint)];
     63                 struct RawTripleAxisDataPoint rawTriple[HOSTINTF_SENSOR_DATA_MAX / sizeof(struct RawTripleAxisDataPoint)];
     64             };
     65         };
     66         uint8_t buffer[sizeof(uint64_t) + HOSTINTF_SENSOR_DATA_MAX];
     67     };
     68 } ATTRIBUTE_PACKED;
     69 SET_PACKED_STRUCT_MODE_OFF
     70 
     71 void hostIntfCopyInterrupts(void *dst, uint32_t numBits);
     72 void hostIntfClearInterrupts();
     73 void hostIntfSetInterrupt(uint32_t bit);
     74 bool hostIntfGetInterrupt(uint32_t bit);
     75 void hostIntfClearInterrupt(uint32_t bit);
     76 void hostIntfSetInterruptMask(uint32_t bit);
     77 bool hostIntfGetInterruptMask(uint32_t bit);
     78 void hostIntfClearInterruptMask(uint32_t bit);
     79 void hostIntfPacketFree(void *ptr);
     80 bool hostIntfPacketDequeue(void *ptr, uint32_t *wakeup, uint32_t *nonwakeup);
     81 void hostIntfSetBusy(bool busy);
     82 void hostIntfRxPacket(bool wakeupActive);
     83 void hostIntfTxAck(void *buffer, uint8_t len);
     84 
     85 #endif /* __HOSTINTF_H */
     86