1 /*
2  * Copyright 2024 NXP
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 /* NCI GID index*/
18 #define NCI_GID_INDEX 0
19 /* NCI OID index*/
20 #define NCI_OID_INDEX 1
21 /* NCI message length index*/
22 #define NCI_MSG_LEN_INDEX 2
23 /* NCI message index for feature*/
24 #define NCI_MSG_INDEX_FOR_FEATURE 3
25 /* NCI message index feature value*/
26 #define NCI_MSG_INDEX_FEATURE_VALUE 4
27 #define NCI_GID_PROP 0x0F
28 #define NCI_HEADER_MIN_LEN 3  // GID + OID + LENGTH
29 #define RF_DISC_CMD_NO_OF_CONFIG_INDEX 3
30 #define RF_DISC_CMD_CONFIG_START_INDEX 4
31 // RF tech mode and Disc Frequency values
32 #define RF_DISC_CMD_EACH_CONFIG_LENGTH 2
33 #define NFCEE_MODE_SET_CMD_MODE_INDEX 4
34 
35 /* Android Parameters */
36 #define NCI_ANDROID_GET_CAPABILITY 0x00
37 #define NCI_ANDROID_POWER_SAVING 0x01
38 #define NCI_ANDROID_OBSERVER_MODE 0x02
39 #define NCI_ANDROID_GET_OBSERVER_MODE_STATUS 0x04
40 
41 /* Android Power Saving Params */
42 #define NCI_ANDROID_POWER_SAVING_PARAM_SIZE 2
43 #define NCI_ANDROID_POWER_SAVING_PARAM_DISABLE 0
44 #define NCI_ANDROID_POWER_SAVING_PARAM_ENABLE 1
45 
46 #define NCI_RSP_SIZE 2
47 #define NCI_RSP_OK 0
48 #define NCI_RSP_FAIL 3
49 
50 #define NCI_PROP_NTF_GID 0x6F
51 #define NCI_PROP_LX_NTF_OID 0x36
52 #define NCI_PROP_NTF_ANDROID_OID 0x0C
53 
54 #define NCI_RF_DISC_COMMD_GID 0x21
55 #define NCI_RF_DISC_COMMAND_OID 0x03
56 #define NFC_A_PASSIVE_LISTEN_MODE 0x80
57 #define NFC_B_PASSIVE_LISTEN_MODE 0x81
58 #define NFC_F_PASSIVE_LISTEN_MODE 0x82
59 #define NFC_ACTIVE_LISTEN_MODE 0x83
60 #define OBSERVE_MODE_RF_TECH_AND_MODE 0xFF
61 #define OBSERVE_MODE_DISCOVERY_CYCLE 0x01
62 
63 // Observe mode constants
64 #define L2_EVT_TAG 0x01
65 #define CMA_EVT_TAG 0x0A
66 #define CMA_EVT_EXTRA_DATA_TAG 0x07
67 #define MIN_LEN_NON_CMA_EVT 7
68 #define MIN_LEN_CMA_EVT 6
69 #define INDEX_OF_L2_EVT_TYPE 6
70 #define INDEX_OF_L2_EVT_GAIN 5
71 #define INDEX_OF_CMA_EVT_TYPE 4
72 #define INDEX_OF_CMA_EVT_DATA 5
73 #define INDEX_OF_CMA_DATA 7
74 #define MIN_LEN_NON_CMA_EVT 7
75 #define MIN_LEN_CMA_EVT 6
76 #define MIN_LEN_CMA_EXTRA_DATA_EVT 1
77 #define L2_EVENT_TRIGGER_TYPE 0x1
78 #define CMA_EVENT_TRIGGER_TYPE 0x02
79 #define CMA_DATA_TRIGGER_TYPE 0x0E
80 // Event types to send upper layer
81 #define TYPE_RF_FLAG 0x00
82 #define TYPE_MOD_A 0x01
83 #define TYPE_MOD_B 0x02
84 #define TYPE_MOD_F 0x03
85 #define TYPE_UNKNOWN 0x07
86 #define EVENT_UNKNOWN 0x00
87 #define EVENT_MOD_A 0x01
88 #define EVENT_MOD_B 0x02
89 #define EVENT_MOD_F 0x03
90 #define EVENT_RF_ON 0x08
91 #define EVENT_RF_OFF 0x09
92 #define REQ_A 0x26
93 #define WUP_A 0x52
94 #define TYPE_B_APF 0x05
95 #define TYPE_F_CMD_LENGH 0x06
96 #define TYPE_F_ID 0xFF
97 #define OBSERVE_MODE_OP_CODE 0x03
98 #define GAIN_FIELD_LENGTH 1
99 #define OP_CODE_FIELD_LENGTH 1
100 #define EVENT_TYPE_FIELD_LENGTH 1
101 #define RF_STATE_FIELD_LENGTH 1
102 #define NCI_MESSAGE_OFFSET 3
103 #define LX_TYPE_MASK 0x0F
104 #define LX_EVENT_MASK 0xF0
105 #define LX_LENGTH_MASK 0x0F
106 #define LX_TAG_MASK 0xF0
107 #define SHORT_FLAG 0x00
108 #define TYPE_ALL_EVENTS 0x00
109 #define TYPE_ONLY_MOD_EVENTS 0x01
110 #define TYPE_ONLY_CMA_EVENTS 0x02
111