• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2023 The Android Open Source Project.
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This is the private interface file for NFA_WLC
22  *
23  ******************************************************************************/
24 #ifndef NFA_WLC_INT_H
25 #define NFA_WLC_INT_H
26 
27 #include "nfa_api.h"
28 #include "nfa_sys.h"
29 #include "nfa_wlc_api.h"
30 #include "nfc_api.h"
31 
32 /*****************************************************************************
33 **  Constants and data types
34 *****************************************************************************/
35 #define WPT_DURATION_INT_MASK 0xC0
36 #define WPT_DURATION_INT_MAX 0x13
37 
38 #define POWER_ADJ_REQ_INC_MAX 0x14
39 #define POWER_ADJ_REQ_DEC_MIN 0xF6
40 
41 #define NCI_WPT_START_CMD_SIZE 6
42 
43 /* NFA_WLC flags */
44 /* WLC is enabled                                                        */
45 #define NFA_WLC_FLAGS_NON_AUTO_MODE_ENABLED 0x00000001
46 /* Waiting for end of power transfer phase                               */
47 #define NFA_WLC_FLAGS_WPT_NTF_PENDING 0x00000002
48 
49 /* WLC events */
50 enum {
51   /* device manager local device API events */
52   NFA_WLC_API_ENABLE_EVT = NFA_SYS_EVT_START(NFA_ID_WLC),
53   NFA_WLC_API_START_EVT,
54   // NFA_WLC_API_STOP_EVT,
55   NFA_WLC_API_NON_AUTO_START_WPT_EVT,
56   NFA_WLC_API_REMOVE_EP_EVT,
57 };
58 
59 /* WLC control block */
60 typedef struct {
61   uint32_t flags; /* NFA_WLC flags (see definitions for NFA_WLC_FLAGS_*)    */
62   tNFA_WLC_CBACK* p_wlc_cback; /* NFA WLC callback */
63 
64   /* NFCC power mode */
65   uint8_t wlc_mode;
66 } tNFA_WLC_CB;
67 extern tNFA_WLC_CB nfa_wlc_cb;
68 
69 /* data type for NFA_DM_API_ENABLE_EVT */
70 typedef struct {
71   NFC_HDR hdr;
72   // tNFA_DM_CBACK* p_dm_cback;
73   tNFA_WLC_CBACK* p_wlc_cback;
74 } tNFA_WLC_API_ENABLE;
75 
76 /* data type for NFA_WLC_API_START_EVT */
77 typedef struct {
78   NFC_HDR hdr;
79   tNFA_WLC_MODE mode;
80 } tNFA_WLC_API_START;
81 
82 /* data type for NFA_WLC_API_NON_AUTO_START_WPT_EVT */
83 typedef struct {
84   NFC_HDR hdr;
85   uint8_t power_adj_req;
86   uint8_t wpt_time_int;
87 } tNFA_WLC_API_NON_AUTO_START_WPT;
88 
89 /* union of all data types */
90 typedef union {
91   /* GKI event buffer header */
92   NFC_HDR hdr; /* For NFA_WLC_API_STOP_EVT */
93   tNFA_WLC_API_ENABLE enable;
94   tNFA_WLC_API_START start;
95   tNFA_WLC_API_NON_AUTO_START_WPT non_auto_start_wpt;
96 } tNFA_WLC_MSG;
97 
98 /* type definition for action functions */
99 typedef bool (*tNFA_WLC_ACTION)(tNFA_WLC_MSG* p_data);
100 
101 /* Action function prototypes */
102 extern bool nfa_wlc_enable(tNFA_WLC_MSG* p_data);
103 extern bool nfa_wlc_start(tNFA_WLC_MSG* p_data);
104 extern bool nfa_wlc_non_auto_start_wpt(tNFA_WLC_MSG* p_data);
105 
106 extern void nfa_wlc_init(void);
107 extern void nfa_wlc_event_notify(tNFA_WLC_EVT event, tNFA_WLC_EVT_DATA* p_data);
108 
109 #endif /* NFA_WLC_INT_H */
110