1e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/******************************************************************************
2e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *
385b7e84f6cc61506c94e98844cac9ce50bbbe9dcEvan Chu *  Copyright (C) 2010-2013 Broadcom Corporation
4e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *
5e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *  Licensed under the Apache License, Version 2.0 (the "License");
6e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *  you may not use this file except in compliance with the License.
7e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *  You may obtain a copy of the License at:
8e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *
9e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *  http://www.apache.org/licenses/LICENSE-2.0
10e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *
11e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *  Unless required by applicable law or agreed to in writing, software
12e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *  distributed under the License is distributed on an "AS IS" BASIS,
13e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *  See the License for the specific language governing permissions and
15e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *  limitations under the License.
16e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *
17e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project ******************************************************************************/
18e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
195c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen
20e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/******************************************************************************
21e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *
22e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *  This file contains the action functions for device manager state
23e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *  machine.
24e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project *
25e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project ******************************************************************************/
26e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include <string.h>
27e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include "nfa_sys.h"
28e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include "nfa_api.h"
29e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include "nfa_dm_int.h"
30e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include "nfa_sys_int.h"
31e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include "nfa_ce_int.h"
32e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include "nfc_api.h"
33e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include "nfa_rw_int.h"
34e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include "nfa_rw_api.h"
35e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include "nfa_p2p_int.h"
36e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include "nci_hmsgs.h"
37e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
385c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen#if (defined (NFA_CHO_INCLUDED) && (NFA_CHO_INCLUDED==TRUE))
395c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen#include "nfa_cho_int.h"
405c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen#endif
415c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen
42e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#if (NFC_NFCEE_INCLUDED == TRUE)
43e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include "nfa_ee_int.h"
44e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include "nfa_hci_int.h"
45e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#endif
46e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
47e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#if (defined (NFA_SNEP_INCLUDED) && (NFA_SNEP_INCLUDED==TRUE))
48e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#include "nfa_snep_int.h"
49e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#endif
50e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
51e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/* This is the timeout value to guarantee disable is performed within reasonable amount of time */
52e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#ifndef NFA_DM_DISABLE_TIMEOUT_VAL
53e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#define NFA_DM_DISABLE_TIMEOUT_VAL         1000
54e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#endif
55e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
56e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic void nfa_dm_set_init_nci_params (void);
57e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic tNFA_STATUS nfa_dm_start_polling (void);
58e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic BOOLEAN nfa_dm_deactivate_polling (void);
59e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic void nfa_dm_excl_disc_cback (tNFA_DM_RF_DISC_EVT event, tNFC_DISCOVER *p_data);
60e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic void nfa_dm_poll_disc_cback (tNFA_DM_RF_DISC_EVT event, tNFC_DISCOVER *p_data);
61e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
62e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
63e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
64e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
65e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_module_init_cback
66e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
67e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Processing initialization complete event from sub-modules
68e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
69e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          None
70e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
71e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
72e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic void nfa_dm_module_init_cback (void)
73e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
74e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_DM_CBACK_DATA dm_cback_data;
75e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
76e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_cb.flags &= ~NFA_DM_FLAGS_ENABLE_EVT_PEND;
77e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
78e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* All subsystem are initialized */
79e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    dm_cback_data.status = NFA_STATUS_OK;
80e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    (*nfa_dm_cb.p_dm_cback) (NFA_DM_ENABLE_EVT, &dm_cback_data);
81e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
82e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
83e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
84e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
85e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_nfcc_power_mode_proc_complete_cback
86e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
87e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Processing complete of processing NFCC power state change
88e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**                  from all sub-modules
89e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
90e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          None
91e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
92e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
93e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic void nfa_dm_nfcc_power_mode_proc_complete_cback (void)
94e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
95e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_DM_PWR_MODE_CHANGE power_mode_change;
96e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
97e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG1 ("nfa_dm_nfcc_power_mode_proc_complete_cback () nfcc_pwr_mode = 0x%x",
98e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                      nfa_dm_cb.nfcc_pwr_mode);
99e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
100e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* if NFCC power state is change to full power */
101e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (nfa_dm_cb.nfcc_pwr_mode != NFA_DM_PWR_MODE_OFF_SLEEP)
102e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
103e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.flags &= ~NFA_DM_FLAGS_NFCC_IS_RESTORING;
104e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
105e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* reconfigure BRCM NFCC */
106e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_disc_sm_execute (NFA_DM_RF_DISCOVER_CMD, NULL);
107e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
108e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
109e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_cb.flags &= ~NFA_DM_FLAGS_SETTING_PWR_MODE;
110e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
111e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    power_mode_change.status     = NFA_STATUS_OK;
112e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    power_mode_change.power_mode = nfa_dm_cb.nfcc_pwr_mode;
113e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    (*nfa_dm_cb.p_dm_cback) (NFA_DM_PWR_MODE_CHANGE_EVT, (tNFA_DM_CBACK_DATA*) &power_mode_change);
114e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
115e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
116e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
117e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_sys_enable
118e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
119e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      This function on enable
120e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
121e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          void
122e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
123e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
124e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectvoid nfa_dm_sys_enable (void)
125e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
126e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_set_init_nci_params ();
127e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
128e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
129e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
130e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
131e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_set_init_nci_params
132e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
133e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Set initial NCI configuration parameters
134e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
135e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          void
136e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
137e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
138e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic void nfa_dm_set_init_nci_params (void)
139e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
140e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    UINT8   xx;
141e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
142e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* set NCI default value if other than zero */
143e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
144e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* LF_T3T_IDENTIFIERS_1/2/.../16 */
145e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    for (xx = 0; xx < NFA_CE_LISTEN_INFO_MAX; xx++)
146e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
147e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.params.lf_t3t_id[xx][0] = 0xFF;
148e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.params.lf_t3t_id[xx][1] = 0xFF;
149e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.params.lf_t3t_id[xx][2] = 0x02;
150e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.params.lf_t3t_id[xx][2] = 0xFE;
151e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
152e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
153e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* LF_T3T_PMM */
154e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    for (xx = 0; xx < NCI_PARAM_LEN_LF_T3T_PMM; xx++)
155e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
156e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.params.lf_t3t_pmm[xx] = 0xFF;
157e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
158e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
159e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* LF_T3T_FLAGS:
160e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    ** DH needs to set this configuration, even if default value (not listening) is used,
161e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    ** to let NFCC know of intention (not listening) of DH.
162e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    */
163e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
164e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* FWI */
165e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_cb.params.fwi[0] = 0x04;
166e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
167e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* WT */
168e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_cb.params.wt[0] = 14;
169e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
170e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* Set CE default configuration */
171e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (p_nfa_dm_ce_cfg[0])
172e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
173e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_check_set_config (p_nfa_dm_ce_cfg[0], &p_nfa_dm_ce_cfg[1], FALSE);
174e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
175e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
176e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* Set optional general default configuration */
177e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (p_nfa_dm_gen_cfg && p_nfa_dm_gen_cfg[0])
178e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
179e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_check_set_config (p_nfa_dm_gen_cfg[0], &p_nfa_dm_gen_cfg[1], FALSE);
180e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
181e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
182e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (p_nfa_dm_interface_mapping && nfa_dm_num_dm_interface_mapping)
183e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
184e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        NFC_DiscoveryMap (nfa_dm_num_dm_interface_mapping, p_nfa_dm_interface_mapping, NULL);
185e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
186e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
187e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
188e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
189e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
190e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_proc_nfcc_power_mode
191e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
192e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Processing NFCC power mode changes
193e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
194e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          None
195e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
196e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
197e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectvoid nfa_dm_proc_nfcc_power_mode (UINT8 nfcc_power_mode)
198e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
199e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG1 ("nfa_dm_proc_nfcc_power_mode (): nfcc_power_mode=%d",
200e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                       nfcc_power_mode);
201e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
202e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* if NFCC power mode is change to full power */
203e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (nfcc_power_mode == NFA_DM_PWR_MODE_FULL)
204e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
205e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        memset (&nfa_dm_cb.params, 0x00, sizeof (tNFA_DM_PARAMS));
20685b7e84f6cc61506c94e98844cac9ce50bbbe9dcEvan Chu        NFA_TRACE_DEBUG2 ("setcfg_pending_mask=0x%x, setcfg_pending_num=%d",
20785b7e84f6cc61506c94e98844cac9ce50bbbe9dcEvan Chu            nfa_dm_cb.setcfg_pending_mask, nfa_dm_cb.setcfg_pending_num);
208e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.setcfg_pending_mask = 0;
209e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.setcfg_pending_num  = 0;
21085b7e84f6cc61506c94e98844cac9ce50bbbe9dcEvan Chu
211e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_set_init_nci_params ();
212e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
213e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
214e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_sys_cback_notify_nfcc_power_mode_proc_complete (NFA_ID_DM);
215e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
216e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
217e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
218e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
219e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_disable_event
220e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
221e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      report disable event
222e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
223e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          void
224e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
225e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
226e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic void nfa_dm_disable_event (void)
227e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
228e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* Deregister DM from sys */
229e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_sys_deregister (NFA_ID_DM);
230e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
231e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* Notify app */
232e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_cb.flags &= ~(NFA_DM_FLAGS_DM_IS_ACTIVE
233e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                        |NFA_DM_FLAGS_DM_DISABLING_NFC
234e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                        |NFA_DM_FLAGS_ENABLE_EVT_PEND);
235e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    (*nfa_dm_cb.p_dm_cback) (NFA_DM_DISABLE_EVT, NULL);
236e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
237e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
238e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
239e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
240e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_nfc_response_cback
241e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
242e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Call DM event hanlder with NFC response callback data
243e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
244e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          void
245e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
246e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
247e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic void nfa_dm_nfc_response_cback (tNFC_RESPONSE_EVT event, tNFC_RESPONSE *p_data)
248e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
249e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_DM_CBACK_DATA dm_cback_data;
250e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_GET_CONFIG   *p_nfa_get_confg;
251e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_CONN_EVT_DATA conn_evt;
252e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    UINT8 dm_cback_evt;
253d23e0531b6835ab75b543dd51cfe5edec8edefe4Evan Chu    UINT8 max_ee = 0;
254e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
255e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#if (BT_TRACE_VERBOSE == TRUE)
256e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG2 ("nfa_dm_nfc_response_cback () %s(0x%x)", nfa_dm_nfc_revt_2_str (event), event);
257e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#else
258e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG1 ("nfa_dm_nfc_response_cback () event=0x%x", event);
259e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#endif
260e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
261e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    switch (event)
262e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
263e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_ENABLE_REVT:                        /* 0  Enable event */
264e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
265e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* NFC stack enabled. Enable nfa sub-systems */
266e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (p_data->enable.status == NFC_STATUS_OK)
267e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
268d23e0531b6835ab75b543dd51cfe5edec8edefe4Evan Chu            if (nfa_ee_max_ee_cfg != 0)
269d23e0531b6835ab75b543dd51cfe5edec8edefe4Evan Chu            {
270d23e0531b6835ab75b543dd51cfe5edec8edefe4Evan Chu                if (nfa_dm_cb.get_max_ee)
271d23e0531b6835ab75b543dd51cfe5edec8edefe4Evan Chu                {
272d23e0531b6835ab75b543dd51cfe5edec8edefe4Evan Chu                    max_ee = nfa_dm_cb.get_max_ee ();
273d23e0531b6835ab75b543dd51cfe5edec8edefe4Evan Chu                    if (max_ee)
274d23e0531b6835ab75b543dd51cfe5edec8edefe4Evan Chu                    {
275d23e0531b6835ab75b543dd51cfe5edec8edefe4Evan Chu                        nfa_ee_max_ee_cfg = max_ee;
276d23e0531b6835ab75b543dd51cfe5edec8edefe4Evan Chu                    }
277d23e0531b6835ab75b543dd51cfe5edec8edefe4Evan Chu                }
278d23e0531b6835ab75b543dd51cfe5edec8edefe4Evan Chu            }
279e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* Initialize NFA subsystems */
280e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_sys_enable_subsystems ();
281e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
282e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else if (nfa_dm_cb.flags & NFA_DM_FLAGS_ENABLE_EVT_PEND)
283e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
284e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* Notify app */
285e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.flags &= ~(NFA_DM_FLAGS_ENABLE_EVT_PEND | NFA_DM_FLAGS_DM_IS_ACTIVE);
286e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            dm_cback_data.status = p_data->enable.status;
287e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            (*nfa_dm_cb.p_dm_cback) (NFA_DM_ENABLE_EVT, &dm_cback_data);
288e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
289e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
290e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
291e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_DISABLE_REVT:                       /* 1  Disable event */
292e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_disable_event ();
293e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
294e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
295e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_SET_CONFIG_REVT:                    /* 2  Set Config Response */
296e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* If this setconfig was due to NFA_SetConfig, then notify the app */
297e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.setcfg_pending_mask & 1)      /* lsb=whether last NCI_SET_CONFIG was due to NFA_SetConfig */
298e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
299e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            dm_cback_data.set_config.status         = p_data->set_config.status;
300e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            dm_cback_data.set_config.num_param_id   = p_data->set_config.num_param_id;
301e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            memcpy (dm_cback_data.set_config.param_ids, p_data->set_config.param_ids, p_data->set_config.num_param_id);
302e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            (*nfa_dm_cb.p_dm_cback) (NFA_DM_SET_CONFIG_EVT, &dm_cback_data);
303e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
304e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
305e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* Update the pending mask */
306e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.setcfg_pending_num>0)
307e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
308e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.setcfg_pending_mask >>= 1;
309e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.setcfg_pending_num--;
310e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
311e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else
312e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
313e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* This should not occur (means we got a SET_CONFIG_NTF that's unaccounted for */
314e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            NFA_TRACE_ERROR0 ("NFA received unexpected NFC_SET_CONFIG_REVT");
315e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
316e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
317e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
318e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_GET_CONFIG_REVT:                    /* 3  Get Config Response */
319e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (p_data->get_config.status == NFC_STATUS_OK)
320e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
321e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            if ((p_nfa_get_confg = (tNFA_GET_CONFIG *) GKI_getbuf ((UINT16) (sizeof (tNFA_GET_CONFIG) + p_data->get_config.tlv_size))) != NULL)
322e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
323e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                p_nfa_get_confg->status = NFA_STATUS_OK;
324e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                p_nfa_get_confg->tlv_size = p_data->get_config.tlv_size;
325e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                memcpy (p_nfa_get_confg->param_tlvs, p_data->get_config.p_param_tlvs, p_data->get_config.tlv_size);
326e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                (*nfa_dm_cb.p_dm_cback) (NFA_DM_GET_CONFIG_EVT, (tNFA_DM_CBACK_DATA *) p_nfa_get_confg);
327e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
328e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                GKI_freebuf (p_nfa_get_confg);
329e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                return;
330e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
331e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            else
332e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
333e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                NFA_TRACE_DEBUG0 ("nfa_dm_nfc_response_cback unable to allocate buffer");
334e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
335e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
336e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
337e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* Return result of getconfig to the app */
338e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        dm_cback_data.get_config.status = NFA_STATUS_FAILED;
339e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        (*nfa_dm_cb.p_dm_cback) (NFA_DM_GET_CONFIG_EVT, &dm_cback_data);
340e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
341e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
342e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#if (NFC_NFCEE_INCLUDED == TRUE)
343e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCEE_DISCOVER_REVT:                /* NFCEE Discover response */
344e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCEE_INFO_REVT:                    /* NFCEE Discover Notification */
345e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_EE_ACTION_REVT:                     /* EE Action notification */
346e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCEE_MODE_SET_REVT:                /* NFCEE Mode Set response */
3475c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen        nfa_ee_proc_evt (event, p_data);
3485c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen        break;
3495c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen
350e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_EE_DISCOVER_REQ_REVT:               /* EE Discover Req notification */
3515c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen        if (nfa_dm_is_active() &&
3525c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen            (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_DISCOVERY) )
3535c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen        {
3545c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen            nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_IDLE);
3555c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen        }
356e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_ee_proc_evt (event, p_data);
357e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
358e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#endif
359e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
360e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_RF_FIELD_REVT:                      /* RF Field information            */
361e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        dm_cback_data.rf_field.status          = NFA_STATUS_OK;
362e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        dm_cback_data.rf_field.rf_field_status = p_data->rf_field.rf_field;
363e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        (*nfa_dm_cb.p_dm_cback) (NFA_DM_RF_FIELD_EVT, &dm_cback_data);
364e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
365e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
366e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_SET_ROUTING_REVT:                   /* Configure Routing response */
367e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
368e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
369e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_GET_ROUTING_REVT:                   /* Retrieve Routing response */
370e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
371e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
372e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_GEN_ERROR_REVT:                     /* generic error command or notification */
373e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
374e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
375e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCC_RESTART_REVT:                  /* NFCC has been re-initialized */
376e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
377e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (p_data->status == NFC_STATUS_OK)
378e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
379e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.nfcc_pwr_mode = NFA_DM_PWR_MODE_FULL;
380e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.flags |= NFA_DM_FLAGS_NFCC_IS_RESTORING;
381e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
382e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* NFCC will start from IDLE when turned on again */
383e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.disc_cb.disc_flags &= ~NFA_DM_DISC_FLAGS_W4_RSP;
384e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.disc_cb.disc_flags &= ~NFA_DM_DISC_FLAGS_W4_NTF;
385e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.disc_cb.disc_state = NFA_DM_RFST_IDLE;
386e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
387e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else
388e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
389e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.nfcc_pwr_mode = NFA_DM_PWR_MODE_OFF_SLEEP;
390e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
391e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* Notify NFA submodules change of NFCC power mode */
392e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_sys_cback_reg_nfcc_power_mode_proc_complete (nfa_dm_nfcc_power_mode_proc_complete_cback);
393e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_sys_notify_nfcc_power_mode (nfa_dm_cb.nfcc_pwr_mode);
394e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
395e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
396e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCC_TIMEOUT_REVT:
397e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCC_TRANSPORT_ERR_REVT:
398e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        NFA_TRACE_DEBUG1 ("flags:0x%08x", nfa_dm_cb.flags);
399e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        dm_cback_evt = (event == NFC_NFCC_TIMEOUT_REVT) ? NFA_DM_NFCC_TIMEOUT_EVT : NFA_DM_NFCC_TRANSPORT_ERR_EVT;
400e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        (*nfa_dm_cb.p_dm_cback) (dm_cback_evt, NULL);
401e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
402e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
403e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCC_POWER_OFF_REVT:
404e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.nfcc_pwr_mode = NFA_DM_PWR_MODE_OFF_SLEEP;
405e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
406e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* Notify NFA submodules change of NFCC power mode */
407e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_sys_cback_reg_nfcc_power_mode_proc_complete (nfa_dm_nfcc_power_mode_proc_complete_cback);
408e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_sys_notify_nfcc_power_mode (NFA_DM_PWR_MODE_OFF_SLEEP);
409e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
410e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
411e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_RF_COMM_PARAMS_UPDATE_REVT:
412e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        conn_evt.status = p_data->status;
413e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_conn_cback_event_notify (NFA_UPDATE_RF_PARAM_RESULT_EVT, &conn_evt);
414e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
415e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
4165c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen
417e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    default:
418e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
419e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
420e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
421e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
422e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
423e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
424e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
425e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_enable
426e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
427e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Initialises the NFC device manager
428e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
429e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
430e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
431e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
432e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_enable (tNFA_DM_MSG *p_data)
433e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
434e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_DM_CBACK_DATA dm_cback_data;
435e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_enable ()");
436e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
437e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* Check if NFA is already enabled */
438e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (!(nfa_dm_cb.flags & NFA_DM_FLAGS_DM_IS_ACTIVE))
439e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
440e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* Initialize BRCM control block, it musb be called before setting any flags */
441e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.flags |= (NFA_DM_FLAGS_DM_IS_ACTIVE | NFA_DM_FLAGS_ENABLE_EVT_PEND);
442e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_sys_cback_reg_enable_complete (nfa_dm_module_init_cback);
443e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
444e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
445e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* Store Enable parameters */
446e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.p_dm_cback    = p_data->enable.p_dm_cback;
447e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.p_conn_cback  = p_data->enable.p_conn_cback;
448e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
449e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* Enable NFC stack */
450e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        NFC_Enable (nfa_dm_nfc_response_cback);
451e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
452e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else
453e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
454e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        NFA_TRACE_ERROR0 ("nfa_dm_enable: ERROR ALREADY ENABLED.");
455e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        dm_cback_data.status = NFA_STATUS_ALREADY_STARTED;
456e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        (*(p_data->enable.p_dm_cback)) (NFA_DM_ENABLE_EVT, &dm_cback_data);
457e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
458e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
459e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
460e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
461e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
462e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
463e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
464e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_disable
465e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
466e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Disables the NFC device manager
467e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
468e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
469e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
470e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
471e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_disable (tNFA_DM_MSG *p_data)
472e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
473e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFC_DEACT_TYPE deactivate_type = NFA_DEACTIVATE_TYPE_IDLE;
474e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
475e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG1 ("nfa_dm_disable (): graceful:%d", p_data->disable.graceful);
476e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
477e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (p_data->disable.graceful)
478e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
479e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* if RF discovery is enabled */
480e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_ENABLED)
481e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
482e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.disc_cb.disc_flags &= ~NFA_DM_DISC_FLAGS_ENABLED;
483e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
484e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            if (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_IDLE)
485e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
486e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                /* if waiting RSP in idle state */
487e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                if (nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_W4_RSP)
488e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                {
489e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    nfa_dm_cb.disc_cb.disc_flags |= NFA_DM_DISC_FLAGS_DISABLING;
490e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                }
491e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
492e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            else
493e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
494e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                nfa_dm_cb.disc_cb.disc_flags |= NFA_DM_DISC_FLAGS_DISABLING;
495e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                nfa_dm_disc_sm_execute (NFA_DM_RF_DEACTIVATE_CMD, (tNFA_DM_RF_DISC_DATA *) &deactivate_type);
496e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                if ((nfa_dm_cb.disc_cb.disc_flags & (NFA_DM_DISC_FLAGS_W4_RSP|NFA_DM_DISC_FLAGS_W4_NTF)) == 0)
497e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                {
498e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    /* not waiting to deactivate, clear the flag now */
499e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    nfa_dm_cb.disc_cb.disc_flags &= ~NFA_DM_DISC_FLAGS_DISABLING;
500e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                }
501e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
502e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
503e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* Start timeout for graceful shutdown. If timer expires, then force an ungraceful shutdown */
504e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_sys_start_timer (&nfa_dm_cb.tle, NFA_DM_TIMEOUT_DISABLE_EVT, NFA_DM_DISABLE_TIMEOUT_VAL);
505e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
506e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
507e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* Disable all subsystems other than DM (DM will be disabled after all  */
508e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* the other subsystem have been disabled)                              */
509e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_sys_disable_subsystems (p_data->disable.graceful);
510e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
511e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
512e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
513e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
514e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
515e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
516e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_disable_complete
517e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
518e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Called when all NFA subsytems are disabled.
519e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
520e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**                  NFC core stack can now be disabled.
521e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
522e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          void
523e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
524e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
525e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectvoid nfa_dm_disable_complete (void)
526e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
527e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_disable_complete ()");
528e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
529e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if ((nfa_dm_cb.flags & NFA_DM_FLAGS_DM_DISABLING_NFC) == 0)
530e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
531e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        NFA_TRACE_DEBUG0 ("nfa_dm_disable_complete (): proceeding with nfc core shutdown.");
532e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
533e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.flags |= NFA_DM_FLAGS_DM_DISABLING_NFC;
534e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
535e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_sys_stop_timer (&nfa_dm_cb.tle);
536e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
537e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* Free all buffers for NDEF handlers */
538e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_ndef_dereg_all();
539e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
540e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* Disable nfc core stack */
541e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        NFC_Disable ();
542e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
543e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
544e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
545e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
546e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
547e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_set_config
548e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
549e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Process set config command
550e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
551e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
552e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
553e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
554e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_set_config (tNFA_DM_MSG *p_data)
555e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
556e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFC_STATUS status;
557e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    UINT8       buff[255];
558e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    UINT8      *p = buff;
559e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
560e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_DM_CBACK_DATA dm_cback_data;
561e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
562e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (p_data->setconfig.length + 2 > 255)
563e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
564e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* Total length of TLV must be less than 256 (1 byte) */
565e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        status = NFC_STATUS_FAILED;
566e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
567e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else
568e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
569e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        UINT8_TO_STREAM (p, p_data->setconfig.param_id);
570e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        UINT8_TO_STREAM (p, p_data->setconfig.length);
571e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        ARRAY_TO_STREAM (p, p_data->setconfig.p_data, p_data->setconfig.length)
572e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        status = nfa_dm_check_set_config ((UINT8) (p_data->setconfig.length + 2), buff, TRUE);
573e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
574e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
575e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (status != NFC_STATUS_OK)
576e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
577e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        dm_cback_data.set_config.status = NFA_STATUS_INVALID_PARAM;
578e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        (*nfa_dm_cb.p_dm_cback) (NFA_DM_SET_CONFIG_EVT, &dm_cback_data);
579e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
580e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
581e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
582e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
583e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
584e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
585e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
586e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_get_config
587e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
588e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Process get config command
589e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
590e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
591e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
592e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
593e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_get_config (tNFA_DM_MSG *p_data)
594e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
595e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFC_GetConfig (p_data->getconfig.num_ids, p_data->getconfig.p_pmids);
596e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
597e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
598e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
599e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
600e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
601e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
602e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_conn_cback_event_notify
603e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
604e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Notify application of CONN_CBACK event, using appropriate
605e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**                  callback
606e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
607e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          nothing
608e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
609e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
610e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectvoid nfa_dm_conn_cback_event_notify (UINT8 event, tNFA_CONN_EVT_DATA *p_data)
611e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
612e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE)
613e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
614e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* Use exclusive RF mode callback */
615e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.p_excl_conn_cback)
616e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            (*nfa_dm_cb.p_excl_conn_cback) (event, p_data);
617e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
618e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else
619e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
620e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        (*nfa_dm_cb.p_conn_cback) (event, p_data);
621e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
622e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
623e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
624e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
625e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
626e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_rel_excl_rf_control_and_notify
627e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
628e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Stop exclusive RF control and notify app of
629e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**                  NFA_EXCLUSIVE_RF_CONTROL_STOPPED_EVT
630e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
631e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          void
632e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
633e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
634e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectvoid nfa_dm_rel_excl_rf_control_and_notify (void)
635e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
636e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_CONN_EVT_DATA conn_evt;
637e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
638e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_rel_excl_rf_control_and_notify ()");
639e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
640e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* Exclusive RF control stopped. Notify app */
641e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_cb.flags &= ~NFA_DM_FLAGS_EXCL_RF_ACTIVE;
642e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
643e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* Stop exclusive RF discovery for exclusive RF mode */
644e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_stop_excl_discovery ();
645e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
646e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* Notify app that exclusive RF control has stopped */
647e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    conn_evt.status = NFA_STATUS_OK;
648e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    (*nfa_dm_cb.p_excl_conn_cback) (NFA_EXCLUSIVE_RF_CONTROL_STOPPED_EVT, &conn_evt);
649e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_cb.p_excl_conn_cback = NULL;
650e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_cb.p_excl_ndef_cback = NULL;
651e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
652e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
653e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
654e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
655e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_request_excl_rf_ctrl
656e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
657e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Request exclusive RF control
658e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
659e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
660e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
661e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
662e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_request_excl_rf_ctrl (tNFA_DM_MSG *p_data)
663e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
664e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_CONN_EVT_DATA conn_evt;
665e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
666e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_act_request_excl_rf_ctrl ()");
667e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
668e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (!nfa_dm_cb.p_excl_conn_cback)
669e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
670e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.disc_cb.disc_state != NFA_DM_RFST_IDLE)
671e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
672e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            conn_evt.status = NFA_STATUS_FAILED;
673e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            (*p_data->req_excl_rf_ctrl.p_conn_cback) (NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT, &conn_evt);
674e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            return TRUE;
675e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
676e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
677e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* Store callbacks */
678e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.p_excl_conn_cback = p_data->req_excl_rf_ctrl.p_conn_cback;
679e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.p_excl_ndef_cback = p_data->req_excl_rf_ctrl.p_ndef_cback;
680e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
681e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.flags |= NFA_DM_FLAGS_EXCL_RF_ACTIVE;
682e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
683e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* start exclusive RF discovery */
684e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_start_excl_discovery (p_data->req_excl_rf_ctrl.poll_mask,
685e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                                     &p_data->req_excl_rf_ctrl.listen_cfg,
686e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                                     nfa_dm_excl_disc_cback);
687e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
688e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else
689e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
690e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        NFA_TRACE_ERROR0 ("Exclusive rf control already requested");
691e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
692e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        conn_evt.status = NFA_STATUS_FAILED;
693e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        (*p_data->req_excl_rf_ctrl.p_conn_cback) (NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT, &conn_evt);
694e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
695e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
696e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return TRUE;
697e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
698e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
699e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
700e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
701e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
702e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_release_excl_rf_ctrl
703e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
704e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Release exclusive RF control
705e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
706e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
707e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
708e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
709e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_release_excl_rf_ctrl (tNFA_DM_MSG *p_data)
710e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
711e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_act_release_excl_rf_ctrl ()");
712e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
713e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* nfa_dm_rel_excl_rf_control_and_notify() is called when discovery state goes IDLE */
714e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_cb.disc_cb.disc_flags |= NFA_DM_DISC_FLAGS_STOPPING;
715e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
716e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* if discover command has been sent in IDLE state and waiting for response
717e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    ** then just wait for responose. Otherwise initiate deactivating.
718e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    */
719e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (!(  (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_IDLE)
720e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project          &&(nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_W4_RSP)  ))
721e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
722e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_IDLE);
723e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
724e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
7257c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu    if (nfa_dm_cb.disc_cb.kovio_tle.in_use)
7267c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        nfa_sys_stop_timer (&nfa_dm_cb.disc_cb.kovio_tle);
7277c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu
728e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return TRUE;
729e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
730e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
731e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
732e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
733e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_deactivate
734e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
735e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Process deactivate command
736e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
737e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
738e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
739e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
740e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_deactivate (tNFA_DM_MSG *p_data)
741e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
742e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_CONN_EVT_DATA conn_evt;
743e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_DEACTIVATE_TYPE deact_type;
744e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
745e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_act_deactivate ()");
746e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
747e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (  (p_data->deactivate.sleep_mode == FALSE)                 /* Always allow deactivate to IDLE */
748e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        ||(  (nfa_dm_cb.disc_cb.activated_protocol != NFA_PROTOCOL_T1T)      /* Do not allow deactivate to SLEEP for T1T,NFCDEP, ISO15693 */
749e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project           &&(nfa_dm_cb.disc_cb.activated_protocol != NFA_PROTOCOL_NFC_DEP)
7507c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu           &&(nfa_dm_cb.disc_cb.activated_protocol != NFA_PROTOCOL_ISO15693)
7517c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu           &&(nfa_dm_cb.disc_cb.activated_protocol != NFC_PROTOCOL_KOVIO)  )  )
752e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
75367aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu        deact_type  = NFA_DEACTIVATE_TYPE_DISCOVERY;
75467aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu        if (p_data->deactivate.sleep_mode)
75567aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu        {
75667aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu            if (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_W4_HOST_SELECT)
75767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu            {
75867aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                /* Deactivate to sleep mode not allowed in this state. */
75967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                deact_type = NFA_DEACTIVATE_TYPE_IDLE;
76067aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu            }
76167aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu            else if (nfa_dm_cb.disc_cb.disc_state != NFA_DM_RFST_LISTEN_SLEEP)
76267aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu            {
76367aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                deact_type = NFA_DEACTIVATE_TYPE_SLEEP;
76467aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu            }
76567aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu        }
76667aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu        if (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_W4_ALL_DISCOVERIES)
76767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu        {
76867aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu            /* Only deactivate to IDLE is allowed in this state. */
76967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu            deact_type = NFA_DEACTIVATE_TYPE_IDLE;
77067aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu        }
77167aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
772e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (  (nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_NFC_DEP)
773e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            &&((nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE) == 0x00)  )
774e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
775e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* Exclusive RF control doesn't use NFA P2P */
776e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* NFA P2P will deactivate NFC link after deactivating LLCP link */
77767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu            if (!(nfa_dm_cb.flags & NFA_DM_FLAGS_P2P_PAUSED))
778e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
77967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                nfa_p2p_deactivate_llcp ();
780e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
78167aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu            else
782e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
78367aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                nfa_dm_rf_deactivate (deact_type);
784e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
78567aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu            return (TRUE);
78667aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu        }
78767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu        else
78867aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu        {
78967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
790e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            if (nfa_dm_rf_deactivate (deact_type) == NFA_STATUS_OK)
791e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
7927c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu                if (nfa_dm_cb.disc_cb.kovio_tle.in_use)
7937c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu                    nfa_sys_stop_timer (&nfa_dm_cb.disc_cb.kovio_tle);
794e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                nfa_rw_stop_presence_check_timer ();
795e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                return (TRUE);
796e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
797e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
798e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
799e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
8007c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu    NFA_TRACE_ERROR0 ("nfa_dm_act_deactivate (): invalid protocol, mode or state");
801e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
802e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* Notify error to application */
803e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    conn_evt.status = NFA_STATUS_FAILED;
804e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_conn_cback_event_notify (NFA_DEACTIVATE_FAIL_EVT, &conn_evt);
805e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
806e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
807e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
808e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
809e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
810e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
811e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_power_off_sleep
812e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
813e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Process power off sleep mode request
814e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
815e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
816e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
817e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
818e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_power_off_sleep (tNFA_DM_MSG *p_data)
819e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
820e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_act_power_off_sleep ()");
821e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
822e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFC_SetPowerOffSleep ((BOOLEAN) (p_data->hdr.layer_specific));
823e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
824e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
825e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
826e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
827e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
828e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
829e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_reg_vsc
830e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
831e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Process registers VSC callback
832e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
833e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
834e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
835e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
836e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_reg_vsc(tNFA_DM_MSG *p_data)
837e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
838e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (NFC_RegVSCback(p_data->reg_vsc.is_register, p_data->reg_vsc.p_cback) != NFC_STATUS_OK)
839e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
840e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        NFA_TRACE_ERROR0 ("NFC_RegVSCback failed");
841e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
842e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
843e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
844e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
845e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
846e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
847e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_send_vsc
848e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
849e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Send the NCI Vendor Specific command to the NCI command queue
850e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
851e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          FALSE (message buffer is NOT freed by caller)
852e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
853e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
854e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_send_vsc(tNFA_DM_MSG *p_data)
855e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
856e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    BT_HDR  *p_cmd = (BT_HDR *)p_data;
857e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
858e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    p_cmd->offset   = sizeof (tNFA_DM_API_SEND_VSC) - BT_HDR_SIZE;
859e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    p_cmd->len      = p_data->send_vsc.cmd_params_len;
860e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFC_SendVsCommand (p_data->send_vsc.oid, p_cmd, p_data->send_vsc.p_cback);
861e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
862e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* Most dm action functions return TRUE, so nfa-sys frees the GKI buffer carrying the message,
863e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project     * This action function re-use the GKI buffer to send the VSC, so the GKI buffer can not be freed by nfa-sys */
864e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (FALSE);
865e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
866e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
867e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
868e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
869e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_start_polling
870e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
871e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Start polling
872e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
873e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          tNFA_STATUS
874e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
875e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
876e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjecttNFA_STATUS nfa_dm_start_polling (void)
877e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
878e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_STATUS             status;
879e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_TECHNOLOGY_MASK    poll_tech_mask;
880e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_DM_DISC_TECH_PROTO_MASK poll_disc_mask = 0;
881e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
882e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_start_polling ()");
883e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
884e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    poll_tech_mask = nfa_dm_cb.poll_mask;
885e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
886e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* start RF discovery with discovery callback */
887e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (nfa_dm_cb.poll_disc_handle == NFA_HANDLE_INVALID)
888e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
889e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (poll_tech_mask & NFA_TECHNOLOGY_MASK_A)
890e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
891e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            poll_disc_mask |= NFA_DM_DISC_MASK_PA_T1T;
892e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            poll_disc_mask |= NFA_DM_DISC_MASK_PA_T2T;
893e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            poll_disc_mask |= NFA_DM_DISC_MASK_PA_ISO_DEP;
894e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            poll_disc_mask |= NFA_DM_DISC_MASK_PA_NFC_DEP;
895e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            poll_disc_mask |= NFA_DM_DISC_MASK_P_LEGACY;
896e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
897e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (poll_tech_mask & NFA_TECHNOLOGY_MASK_A_ACTIVE)
898e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
899e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            poll_disc_mask |= NFA_DM_DISC_MASK_PAA_NFC_DEP;
900e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
901e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (poll_tech_mask & NFA_TECHNOLOGY_MASK_B)
902e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
903e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            poll_disc_mask |= NFA_DM_DISC_MASK_PB_ISO_DEP;
904e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
905e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (poll_tech_mask & NFA_TECHNOLOGY_MASK_F)
906e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
907e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            poll_disc_mask |= NFA_DM_DISC_MASK_PF_T3T;
908e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            poll_disc_mask |= NFA_DM_DISC_MASK_PF_NFC_DEP;
909e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
910e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (poll_tech_mask & NFA_TECHNOLOGY_MASK_F_ACTIVE)
911e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
912e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            poll_disc_mask |= NFA_DM_DISC_MASK_PFA_NFC_DEP;
913e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
914e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (poll_tech_mask & NFA_TECHNOLOGY_MASK_ISO15693)
915e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
916e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            poll_disc_mask |= NFA_DM_DISC_MASK_P_ISO15693;
917e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
918e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (poll_tech_mask & NFA_TECHNOLOGY_MASK_B_PRIME)
919e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
920e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            poll_disc_mask |= NFA_DM_DISC_MASK_P_B_PRIME;
921e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
922e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (poll_tech_mask & NFA_TECHNOLOGY_MASK_KOVIO)
923e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
924e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            poll_disc_mask |= NFA_DM_DISC_MASK_P_KOVIO;
925e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
926e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
927e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.poll_disc_handle = nfa_dm_add_rf_discover (poll_disc_mask,
928e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                                                             NFA_DM_DISC_HOST_ID_DH,
929e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                                                             nfa_dm_poll_disc_cback);
930e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
931e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.poll_disc_handle != NFA_HANDLE_INVALID)
932e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            status = NFA_STATUS_OK;
933e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else
934e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            status = NFA_STATUS_FAILED;
935e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
936e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else
937e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
938e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        status = NFA_STATUS_OK;
939e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
940e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
941e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (status);
942e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
943e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
944e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
945e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
946e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_enable_polling
947e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
948e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Process enable polling command
949e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
950e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
951e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
952e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
953e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_enable_polling (tNFA_DM_MSG *p_data)
954e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
955e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_CONN_EVT_DATA evt_data;
956e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
957e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_act_enable_polling ()");
958e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
959e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (  (!(nfa_dm_cb.flags & NFA_DM_FLAGS_POLLING_ENABLED))
960e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        &&(!(nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE)  )  )
961e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
962e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.poll_mask = p_data->enable_poll.poll_mask;
963e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
964e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_start_polling () == NFA_STATUS_OK)
965e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
966e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.flags |= NFA_DM_FLAGS_POLLING_ENABLED;
967e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
968e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            evt_data.status = NFA_STATUS_OK;
969e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_conn_cback_event_notify (NFA_POLL_ENABLED_EVT, &evt_data);
970e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            return (TRUE);
971e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
972e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
973e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else
974e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
975e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        NFA_TRACE_ERROR0 ("nfa_dm_act_enable_polling (): already started");
976e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
977e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
978e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* send NFA_POLL_ENABLED_EVT with NFA_STATUS_FAILED */
979e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    evt_data.status = NFA_STATUS_FAILED;
980e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_conn_cback_event_notify (NFA_POLL_ENABLED_EVT, &evt_data);
981e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
982e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
983e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
984e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
985e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
986e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
987e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_deactivate_polling
988e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
989e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Deactivate any polling state
990e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
991e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE if need to wait for deactivation
992e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
993e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
994e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic BOOLEAN nfa_dm_deactivate_polling (void)
995e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
996e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_deactivate_polling ()");
997e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
998e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (  (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_W4_ALL_DISCOVERIES)
999e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        ||(nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_W4_HOST_SELECT)  )
1000e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1001e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_IDLE);
1002e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return FALSE;
1003e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1004e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else if (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_POLL_ACTIVE)
1005e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1006e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_NFC_DEP)
1007e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1008e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* NFA P2P will deactivate NFC link after deactivating LLCP link */
1009e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_p2p_deactivate_llcp ();
1010e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1011e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else
1012e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1013e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_IDLE);
1014e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1015e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return TRUE;
1016e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1017e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else
1018e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1019e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return FALSE;
1020e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1021e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1022e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1023e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1024e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1025e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_disable_polling
1026e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1027e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Process disable polling command
1028e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1029e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
1030e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1031e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1032e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_disable_polling (tNFA_DM_MSG *p_data)
1033e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1034e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_CONN_EVT_DATA evt_data;
1035e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1036e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_act_disable_polling ()");
1037e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1038e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (nfa_dm_cb.poll_disc_handle != NFA_HANDLE_INVALID)
1039e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1040e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.flags &= ~NFA_DM_FLAGS_POLLING_ENABLED;
1041e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1042e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_deactivate_polling () == FALSE)
1043e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1044e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_delete_rf_discover (nfa_dm_cb.poll_disc_handle);
1045e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.poll_disc_handle = NFA_HANDLE_INVALID;
1046e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1047e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            evt_data.status = NFA_STATUS_OK;
1048e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_conn_cback_event_notify (NFA_POLL_DISABLED_EVT, &evt_data);
1049e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1050e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else
1051e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1052e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.flags |= NFA_DM_FLAGS_SEND_POLL_STOP_EVT;
1053e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1054e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1055e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else
1056e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1057e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        evt_data.status = NFA_STATUS_FAILED;
1058e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_conn_cback_event_notify (NFA_POLL_DISABLED_EVT, &evt_data);
1059e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1060e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1061e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
1062e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1063e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1064e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1065e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
106667aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu** Function         nfa_dm_act_enable_listening
106767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
106867aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu** Description      Process enable listening command
106967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
107067aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu** Returns          TRUE (message buffer to be freed by caller)
107167aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
107267aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu*******************************************************************************/
107367aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan ChuBOOLEAN nfa_dm_act_enable_listening (tNFA_DM_MSG *p_data)
107467aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu{
107567aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    tNFA_CONN_EVT_DATA evt_data;
107667aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
107767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    NFA_TRACE_DEBUG0 ("nfa_dm_act_enable_listening ()");
107867aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
107967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    nfa_dm_cb.flags &= ~NFA_DM_FLAGS_LISTEN_DISABLED;
108067aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    evt_data.status = NFA_STATUS_OK;
108167aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    nfa_dm_conn_cback_event_notify (NFA_LISTEN_ENABLED_EVT, &evt_data);
108267aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
108367aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    return (TRUE);
108467aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu}
108567aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
108667aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu/*******************************************************************************
108767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
108867aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu** Function         nfa_dm_act_disable_listening
108967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
109067aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu** Description      Process disable listening command
109167aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
109267aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu** Returns          TRUE (message buffer to be freed by caller)
109367aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
109467aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu*******************************************************************************/
109567aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan ChuBOOLEAN nfa_dm_act_disable_listening (tNFA_DM_MSG *p_data)
109667aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu{
109767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    tNFA_CONN_EVT_DATA evt_data;
109867aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
109967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    NFA_TRACE_DEBUG0 ("nfa_dm_act_disable_listening ()");
110067aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
110167aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    nfa_dm_cb.flags |= NFA_DM_FLAGS_LISTEN_DISABLED;
110267aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    evt_data.status = NFA_STATUS_OK;
110367aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    nfa_dm_conn_cback_event_notify (NFA_LISTEN_DISABLED_EVT, &evt_data);
110467aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
110567aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    return (TRUE);
110667aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu}
110767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
110867aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu/*******************************************************************************
110967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
111067aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu** Function         nfa_dm_act_pause_p2p
111167aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
111267aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu** Description      Process Pause P2P command
111367aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
111467aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu** Returns          TRUE (message buffer to be freed by caller)
111567aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
111667aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu*******************************************************************************/
111767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan ChuBOOLEAN nfa_dm_act_pause_p2p (tNFA_DM_MSG *p_data)
111867aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu{
111967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    tNFA_CONN_EVT_DATA evt_data;
112067aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
112167aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    NFA_TRACE_DEBUG0 ("nfa_dm_act_pause_p2p ()");
112267aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
112367aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    nfa_dm_cb.flags |= NFA_DM_FLAGS_P2P_PAUSED;
112467aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    evt_data.status = NFA_STATUS_OK;
112567aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    nfa_dm_conn_cback_event_notify (NFA_P2P_PAUSED_EVT, &evt_data);
112667aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
112767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    return (TRUE);
112867aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu}
112967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
113067aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu/*******************************************************************************
113167aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
113267aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu** Function         nfa_dm_act_resume_p2p
113367aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
113467aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu** Description      Process resume P2P command
113567aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
113667aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu** Returns          TRUE (message buffer to be freed by caller)
113767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
113867aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu*******************************************************************************/
113967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan ChuBOOLEAN nfa_dm_act_resume_p2p (tNFA_DM_MSG *p_data)
114067aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu{
114167aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    tNFA_CONN_EVT_DATA evt_data;
114267aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
114367aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    NFA_TRACE_DEBUG0 ("nfa_dm_act_resume_p2p ()");
114467aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
114567aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    nfa_dm_cb.flags &= ~NFA_DM_FLAGS_P2P_PAUSED;
114667aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    evt_data.status = NFA_STATUS_OK;
114767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    nfa_dm_conn_cback_event_notify (NFA_P2P_RESUMED_EVT, &evt_data);
114867aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
114967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu    return (TRUE);
115067aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu}
115167aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu
115267aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu/*******************************************************************************
115367aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu**
1154e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_send_raw_frame
1155e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1156e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Send an raw frame on RF link
1157e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1158e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
1159e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1160e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1161e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_send_raw_frame (tNFA_DM_MSG *p_data)
1162e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1163e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFC_STATUS status = NFC_STATUS_FAILED;
1164e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1165e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_act_send_raw_frame ()");
1166e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1167e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* If NFC link is activated */
1168e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (  (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_POLL_ACTIVE)
1169e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        ||(nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_LISTEN_ACTIVE)  )
1170e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1171e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* If not in exclusive mode, and not activated for LISTEN, then forward raw data to NFA_RW to send */
1172e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (  !(nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE)
1173e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            &&!(nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_LISTEN_ACTIVE)
1174e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            &&(  (nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_T1T)
1175e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project               ||(nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_T2T)
1176e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project               ||(nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_T3T)
11777c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu               ||(nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_ISO_DEP)
1178e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project               ||(nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_ISO15693)  )  )
1179e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1180e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* if RW is checking presence then it will put into pending queue */
1181e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            status = nfa_rw_send_raw_frame ((BT_HDR*)p_data);
1182e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1183e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else
1184e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1185e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            status = NFC_SendData (NFC_RF_CONN_ID, (BT_HDR*) p_data);
11865c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen            /* Already freed or NCI layer will free buffer */
11875c65c3a0f42e174e47fecd4e569606003217ff4eMartijn Coenen            return FALSE;
1188e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1189e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1190e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1191e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (status == NFC_STATUS_FAILED)
1192e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1193e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* free the buffer */
1194e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return TRUE;
1195e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1196e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else
1197e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1198e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* NCI layer will free buffer */
1199e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return FALSE;
1200e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1201e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1202e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1203e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1204e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1205e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_set_p2p_listen_tech
1206e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1207e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Notify change of P2P listen technologies to NFA P2P
1208e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1209e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
1210e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1211e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1212e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_set_p2p_listen_tech (tNFA_DM_MSG *p_data)
1213e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1214e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG1 ("nfa_dm_set_p2p_listen_tech ()  tech_mask = %d",
1215e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                      p_data->set_p2p_listen_tech.tech_mask);
1216e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1217e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_p2p_update_listen_tech (p_data->set_p2p_listen_tech.tech_mask);
1218e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_conn_cback_event_notify (NFA_SET_P2P_LISTEN_TECH_EVT, NULL);
1219e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1220e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
1221e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1222e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1223e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1224e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1225e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_start_rf_discovery
1226e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1227e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Process start RF discovery command
1228e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1229e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
1230e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1231e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1232e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_start_rf_discovery (tNFA_DM_MSG *p_data)
1233e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1234e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_CONN_EVT_DATA evt_data;
1235e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1236e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_act_start_rf_discovery ()");
1237e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1238e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_ENABLED)
1239e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1240e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        evt_data.status = NFA_STATUS_OK;
1241e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_conn_cback_event_notify (NFA_RF_DISCOVERY_STARTED_EVT, &evt_data);
1242e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1243e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else if (nfa_dm_cb.disc_cb.disc_state != NFA_DM_RFST_IDLE)
1244e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1245e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        evt_data.status = NFA_STATUS_SEMANTIC_ERROR;
1246e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_conn_cback_event_notify (NFA_RF_DISCOVERY_STARTED_EVT, &evt_data);
1247e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1248e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else
1249e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1250e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.disc_cb.disc_flags |= (NFA_DM_DISC_FLAGS_ENABLED|NFA_DM_DISC_FLAGS_NOTIFY);
1251e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_start_rf_discover ();
1252e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1253e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1254e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
1255e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1256e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1257e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1258e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1259e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_stop_rf_discovery
1260e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1261e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Process stop RF discovery command
1262e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1263e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
1264e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1265e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1266e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_stop_rf_discovery (tNFA_DM_MSG *p_data)
1267e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1268e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_CONN_EVT_DATA evt_data;
1269e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1270e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_act_stop_rf_discovery ()");
1271e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1272e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (!(nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_ENABLED) ||
1273e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_IDLE) )
1274e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1275e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.disc_cb.disc_flags &= ~NFA_DM_DISC_FLAGS_ENABLED;
1276e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1277e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* if discover command has been sent in IDLE state and waiting for response */
1278e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_W4_RSP)
1279e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1280e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.disc_cb.disc_flags |= NFA_DM_DISC_FLAGS_STOPPING;
1281e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1282e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else
1283e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1284e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            evt_data.status = NFA_STATUS_OK;
1285e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_conn_cback_event_notify (NFA_RF_DISCOVERY_STOPPED_EVT, &evt_data);
1286e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1287e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1288e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else
1289e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1290e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.disc_cb.disc_flags &= ~NFA_DM_DISC_FLAGS_ENABLED;
1291e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.disc_cb.disc_flags |= NFA_DM_DISC_FLAGS_STOPPING;
12927c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu
12937c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        if (nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_IDLE) == NFA_STATUS_OK)
12947c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        {
12957c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu            if (nfa_dm_cb.disc_cb.kovio_tle.in_use)
12967c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu                nfa_sys_stop_timer (&nfa_dm_cb.disc_cb.kovio_tle);
12977c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu            nfa_rw_stop_presence_check_timer ();
12987c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        }
1299e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1300e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
1301e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1302e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1303e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1304e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1305e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_set_rf_disc_duration
1306e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1307e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Set duration for RF discovery
1308e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1309e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
1310e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1311e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1312e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_set_rf_disc_duration (tNFA_DM_MSG *p_data)
1313e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1314e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_cb.disc_cb.disc_duration = p_data->disc_duration.rf_disc_dur_ms;
1315e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
1316e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1317e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1318e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1319e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1320e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_select
1321e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1322e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Process RF select command
1323e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1324e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
1325e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1326e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1327e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_select (tNFA_DM_MSG *p_data)
1328e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1329e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_act_select ()");
1330e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1331e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_rf_discover_select (p_data->select.rf_disc_id,
1332e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                               p_data->select.protocol,
1333e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                               p_data->select.rf_interface);
1334e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
1335e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1336e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1337e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1338e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1339e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_update_rf_params
1340e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1341e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Process update RF communication parameters command
1342e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1343e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
1344e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1345e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1346e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_update_rf_params (tNFA_DM_MSG *p_data)
1347e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1348e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_CONN_EVT_DATA conn_evt;
1349e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1350e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG0 ("nfa_dm_act_update_rf_params ()");
1351e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1352e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (NFC_UpdateRFCommParams (&p_data->update_rf_params.params) != NFC_STATUS_OK)
1353e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1354e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        conn_evt.status = NFA_STATUS_FAILED;
1355e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_conn_cback_event_notify (NFA_UPDATE_RF_PARAM_RESULT_EVT, &conn_evt);
1356e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1357e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1358e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
1359e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1360e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1361e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1362e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1363e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_disable_timeout
1364e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1365e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      timeout on disable process. Shutdown immediately
1366e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1367e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          TRUE (message buffer to be freed by caller)
1368e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1369e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1370e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source ProjectBOOLEAN nfa_dm_act_disable_timeout (tNFA_DM_MSG *p_data)
1371e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1372e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_DM_API_DISABLE disable;
1373e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1374e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    disable.graceful = FALSE;
1375e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_disable ((tNFA_DM_MSG *) &disable);
1376e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    return (TRUE);
1377e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1378e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1379e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1380e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1381e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_conn_cback_notify
1382e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1383e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Notify app of reader/writer/ndef events
1384e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1385e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          nothing
1386e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1387e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1388e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectvoid nfa_dm_act_conn_cback_notify (UINT8 event, tNFA_CONN_EVT_DATA *p_data)
1389e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1390e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG1 ("nfa_dm_act_conn_cback_notify (): event:0x%X", event);
1391e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1392e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* Notify event using appropriate CONN_CBACK */
1393e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_conn_cback_event_notify (event, p_data);
1394e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1395e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    /* If not in exclusive RF mode, then read NDEF message from tag (if automatic reading is enabled) */
1396e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (!(nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE))
1397e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1398e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (  (event == NFA_NDEF_DETECT_EVT)
1399e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            &&(nfa_dm_cb.flags & NFA_DM_FLAGS_AUTO_READING_NDEF)  )
1400e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1401e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* read NDEF message from tag */
1402e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            if (p_data->ndef_detect.status == NFA_STATUS_OK)
1403e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
1404e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                NFA_RwReadNDef ();
1405e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
1406e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            else if (p_data->ndef_detect.status == NFA_STATUS_FAILED)
1407e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
1408e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                nfa_dm_cb.flags &= ~NFA_DM_FLAGS_AUTO_READING_NDEF;
1409e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
1410e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* ignore NFA_STATUS_BUSY */
1411e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1412e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else if (  (event == NFA_READ_CPLT_EVT)
1413e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                 &&(nfa_dm_cb.flags & NFA_DM_FLAGS_AUTO_READING_NDEF))
1414e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1415e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* reading NDEF message is done */
1416e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.flags &= ~NFA_DM_FLAGS_AUTO_READING_NDEF;
1417e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1418e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1419e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1420e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1421e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1422e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1423e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_act_data_cback
1424e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1425e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Processing data from RF link
1426e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1427e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          None
1428e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1429e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1430e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic void nfa_dm_act_data_cback (UINT8 conn_id, tNFC_CONN_EVT event, tNFC_CONN *p_data)
1431e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
14327c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu    BT_HDR             *p_msg;
1433e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_CONN_EVT_DATA evt_data;
1434e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1435e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG1 ("nfa_dm_act_data_cback (): event = 0x%X", event);
1436e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1437e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (event == NFC_DATA_CEVT)
1438e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
14397c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        p_msg = (BT_HDR *) p_data->data.p_data;
14407c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu
1441e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (p_msg)
1442e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1443e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            evt_data.data.p_data = (UINT8 *) (p_msg + 1) + p_msg->offset;
1444e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            evt_data.data.len    = p_msg->len;
1445e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1446e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_conn_cback_event_notify (NFA_DATA_EVT, &evt_data);
1447e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1448e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            GKI_freebuf (p_msg);
1449e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1450e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else
1451e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1452e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            NFA_TRACE_ERROR0 ("nfa_dm_act_data_cback (): received NFC_DATA_CEVT with NULL data pointer");
1453e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1454e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1455e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else if (event == NFC_DEACTIVATE_CEVT)
1456e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1457e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        NFC_SetStaticRfCback (NULL);
1458e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1459e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1460e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1461e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1462e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1463e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_excl_disc_cback
1464e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1465e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Processing event from discovery callback
1466e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1467e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          None
1468e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1469e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1470e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic void nfa_dm_excl_disc_cback (tNFA_DM_RF_DISC_EVT event, tNFC_DISCOVER *p_data)
1471e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1472e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_CONN_EVT_DATA evt_data;
1473e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1474e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG1 ("nfa_dm_excl_disc_cback (): event:0x%02X", event);
1475e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1476e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    switch (event)
1477e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1478e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFA_DM_RF_DISC_START_EVT:
1479e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        evt_data.status = NFA_STATUS_OK;
1480e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_conn_cback_event_notify (NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT, &evt_data);
1481e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
1482e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1483e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFA_DM_RF_DISC_ACTIVATED_EVT:
1484e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.disc_cb.activated_tech_mode == NFC_DISCOVERY_TYPE_POLL_A)
1485e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1486e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* store SEL_RES response */
1487e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.disc_cb.activated_sel_res = p_data->activate.rf_tech_param.param.pa.sel_rsp;
1488e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1489e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1490e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_LISTEN_ACTIVE)
1491e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1492e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* Set data callback to receive raw frame */
1493e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            NFC_SetStaticRfCback (nfa_dm_act_data_cback);
1494e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1495e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            memset (&(evt_data.activated.params), 0x00, sizeof (tNFA_TAG_PARAMS));
1496e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            memcpy (&(evt_data.activated.activate_ntf), &(p_data->activate), sizeof (tNFC_ACTIVATE_DEVT));
1497e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1498e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_conn_cback_event_notify (NFA_ACTIVATED_EVT, &evt_data);
1499e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1500e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else
1501e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1502e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* holding activation notification until sub-module is ready */
1503e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.p_activate_ntf = (UINT8*) GKI_getbuf (sizeof (tNFC_ACTIVATE_DEVT));
1504e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1505e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            if (nfa_dm_cb.p_activate_ntf)
1506e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
1507e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                memcpy (nfa_dm_cb.p_activate_ntf,
1508e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                        &(p_data->activate),
1509e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                        sizeof (tNFC_ACTIVATE_DEVT));
1510e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1511e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                if (  (nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_T1T)
1512e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    ||(nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_T2T)
1513e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    ||(nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_T3T)
15147c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu                    ||(nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_ISO_DEP)
15157c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu                    ||(nfa_dm_cb.disc_cb.activated_protocol  == NFA_PROTOCOL_ISO15693)
15167c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu                    ||(nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_KOVIO)  )
1517e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                {
1518e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    /* Notify NFA tag sub-system */
1519e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    nfa_rw_proc_disc_evt (NFA_DM_RF_DISC_ACTIVATED_EVT, p_data, FALSE);
1520e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                }
1521e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                else /* if NFC-DEP, ISO-DEP with frame interface or others */
1522e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                {
1523e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    /* Set data callback to receive raw frame */
1524e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    NFC_SetStaticRfCback (nfa_dm_act_data_cback);
1525e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    nfa_dm_notify_activation_status (NFA_STATUS_OK, NULL);
1526e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                }
1527e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
1528e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            else
1529e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
1530e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                /* deactivate and restart RF discovery */
1531e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_DISCOVERY);
1532e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
1533e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1534e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
1535e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1536e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFA_DM_RF_DISC_DEACTIVATED_EVT:
1537e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
15387c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        /* if deactivated to idle or discovery */
15397c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        if (  (p_data->deactivate.type == NFC_DEACTIVATE_TYPE_IDLE)
15407c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu            ||(p_data->deactivate.type == NFC_DEACTIVATE_TYPE_DISCOVERY)  )
15417c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        {
15427c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu            /* clear stored NFCID/UID/KOVIO bar code */
15437c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu            nfa_dm_cb.activated_nfcid_len = 0;
15447c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        }
1545e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1546e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.disc_cb.activated_protocol != NFC_PROTOCOL_NFC_DEP)
1547e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1548e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* Notify NFA RW sub-systems */
1549e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_rw_proc_disc_evt (NFA_DM_RF_DISC_DEACTIVATED_EVT, NULL, FALSE);
1550e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1551e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1552e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* if deactivated as sleep mode */
1553e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (  (p_data->deactivate.type == NFC_DEACTIVATE_TYPE_SLEEP)
1554e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            ||(p_data->deactivate.type == NFC_DEACTIVATE_TYPE_SLEEP_AF)  )
1555e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1556e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            evt_data.deactivated.type = NFA_DEACTIVATE_TYPE_SLEEP;
1557e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1558e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else
1559e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1560e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            evt_data.deactivated.type = NFA_DEACTIVATE_TYPE_IDLE;
1561e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1562e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1563e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* notify deactivation to upper layer */
1564e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_conn_cback_event_notify (NFA_DEACTIVATED_EVT, &evt_data);
1565e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1566e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* clean up SEL_RES response */
1567e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.disc_cb.activated_sel_res = 0;
1568e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
1569e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1570e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    default:
1571e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        NFA_TRACE_ERROR0 ("Unexpected event");
1572e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
1573e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1574e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1575e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1576e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1577e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1578e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_poll_disc_cback
1579e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1580e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Processing event from discovery callback
1581e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1582e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          None
1583e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1584e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1585e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectstatic void nfa_dm_poll_disc_cback (tNFA_DM_RF_DISC_EVT event, tNFC_DISCOVER *p_data)
1586e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1587e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_CONN_EVT_DATA evt_data;
1588e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1589e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG1 ("nfa_dm_poll_disc_cback (): event:0x%02X", event);
1590e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1591e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    switch (event)
1592e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1593e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFA_DM_RF_DISC_START_EVT:
1594e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
1595e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1596e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFA_DM_RF_DISC_ACTIVATED_EVT:
1597e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1598e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.disc_cb.activated_tech_mode == NFC_DISCOVERY_TYPE_POLL_A)
1599e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1600e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* store SEL_RES response */
1601e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.disc_cb.activated_sel_res = p_data->activate.rf_tech_param.param.pa.sel_rsp;
1602e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1603e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1604e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* holding activation notification until sub-module is ready */
1605e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.p_activate_ntf = (UINT8*) GKI_getbuf (sizeof (tNFC_ACTIVATE_DEVT));
1606e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1607e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.p_activate_ntf)
1608e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1609e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            memcpy (nfa_dm_cb.p_activate_ntf,
1610e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    &(p_data->activate),
1611e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    sizeof (tNFC_ACTIVATE_DEVT));
1612e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1613e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            if (  (nfa_dm_cb.disc_cb.activated_protocol     == NFC_PROTOCOL_NFC_DEP)
1614e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                &&(nfa_dm_cb.disc_cb.activated_rf_interface == NFC_INTERFACE_NFC_DEP)  )
1615e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
161667aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                if (!(nfa_dm_cb.flags & NFA_DM_FLAGS_P2P_PAUSED))
161767aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                {
161867aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                    /* activate LLCP */
161967aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                    nfa_p2p_activate_llcp (p_data);
162067aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                }
162167aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                else
162267aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                {
162367aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                    NFA_TRACE_DEBUG0 ("P2P is paused");
162467aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                    nfa_dm_notify_activation_status (NFA_STATUS_OK, NULL);
162567aef6c6c6f6bc7b8364b97949e874b9dc7175bcEvan Chu                }
1626e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
1627e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            else if (  (nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_T1T)
1628e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                     ||(nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_T2T)
1629e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                     ||(nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_T3T)
16307c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu                     ||(nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_ISO_DEP)
16317c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu                     ||(nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_15693)
16327c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu                     ||(nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_KOVIO)  )
1633e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
1634e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                /* Notify NFA tag sub-system */
1635e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                nfa_rw_proc_disc_evt (NFA_DM_RF_DISC_ACTIVATED_EVT, p_data, TRUE);
1636e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
1637e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            else /* if NFC-DEP/ISO-DEP with frame interface */
1638e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
1639e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                /* Set data callback to receive raw frame */
1640e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                NFC_SetStaticRfCback (nfa_dm_act_data_cback);
1641e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                nfa_dm_notify_activation_status (NFA_STATUS_OK, NULL);
1642e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
1643e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1644e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else
1645e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1646e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* deactivate and restart RF discovery */
1647e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_DISCOVERY);
1648e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1649e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
1650e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1651e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFA_DM_RF_DISC_DEACTIVATED_EVT:
1652e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
16537c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        /* if deactivated to idle or discovery */
16547c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        if (  (p_data->deactivate.type == NFC_DEACTIVATE_TYPE_IDLE)
16557c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu            ||(p_data->deactivate.type == NFC_DEACTIVATE_TYPE_DISCOVERY)  )
16567c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        {
16577c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu            /* clear stored NFCID/UID/KOVIO bar code */
16587c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu            nfa_dm_cb.activated_nfcid_len = 0;
16597c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        }
1660e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1661e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (  (nfa_dm_cb.disc_cb.activated_protocol     == NFC_PROTOCOL_NFC_DEP)
1662e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            &&(nfa_dm_cb.disc_cb.activated_rf_interface == NFC_INTERFACE_NFC_DEP)  )
1663e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1664e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /*
1665e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            ** If LLCP link is not deactivated yet,
1666e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            ** LLCP will receive deactivation ntf through data callback.
1667e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            ** NFA P2P will receive callback event from LLCP.
1668e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            */
1669e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1670e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else
1671e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1672e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* Notify NFA RW sub-systems */
1673e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_rw_proc_disc_evt (NFA_DM_RF_DISC_DEACTIVATED_EVT, NULL, TRUE);
1674e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1675e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1676e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* if NFA sent NFA_ACTIVATED_EVT earlier */
1677e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.flags & NFA_DM_FLAGS_SEND_DEACTIVATED_EVT)
1678e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1679e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.flags &= ~NFA_DM_FLAGS_SEND_DEACTIVATED_EVT;
1680e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1681e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* if deactivated as sleep mode */
1682e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            if (  (p_data->deactivate.type == NFC_DEACTIVATE_TYPE_SLEEP)
1683e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                ||(p_data->deactivate.type == NFC_DEACTIVATE_TYPE_SLEEP_AF)  )
1684e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
1685e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                evt_data.deactivated.type = NFA_DEACTIVATE_TYPE_SLEEP;
1686e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
1687e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            else
1688e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
1689e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                evt_data.deactivated.type = NFA_DEACTIVATE_TYPE_IDLE;
1690e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
1691e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* notify deactivation to application */
1692e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_conn_cback_event_notify (NFA_DEACTIVATED_EVT, &evt_data);
1693e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1694e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1695e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* clean up SEL_RES response */
1696e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.disc_cb.activated_sel_res = 0;
1697e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1698e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (!(nfa_dm_cb.flags & NFA_DM_FLAGS_POLLING_ENABLED))
1699e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1700e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* deregister discovery callback from NFA DM Discovery */
1701e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_delete_rf_discover (nfa_dm_cb.poll_disc_handle);
1702e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_cb.poll_disc_handle = NFA_HANDLE_INVALID;
1703e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1704e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /* this is for disable polling */
1705e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            if (nfa_dm_cb.flags & NFA_DM_FLAGS_SEND_POLL_STOP_EVT)
1706e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
1707e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                nfa_dm_cb.flags &= ~NFA_DM_FLAGS_SEND_POLL_STOP_EVT;
1708e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1709e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                evt_data.status = NFA_STATUS_OK;
1710e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                nfa_dm_conn_cback_event_notify (NFA_POLL_DISABLED_EVT, &evt_data);
1711e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
1712e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1713e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
1714e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1715e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1716e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1717e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1718e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1719e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_notify_activation_status
1720e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1721e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      Processing activation status from sub-modules
1722e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1723e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Returns          None
1724e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1725e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1726e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectvoid nfa_dm_notify_activation_status (tNFA_STATUS status, tNFA_TAG_PARAMS *p_params)
1727e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1728e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFA_CONN_EVT_DATA  evt_data;
1729e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    tNFC_RF_TECH_PARAMS *p_tech_params;
1730e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    UINT8               *p_nfcid = NULL, nfcid_len;
1731e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1732e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    NFA_TRACE_DEBUG1 ("nfa_dm_notify_activation_status (): status:0x%X", status);
1733e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1734e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (!nfa_dm_cb.p_activate_ntf)
1735e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1736e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* this is for NFA P2P listen */
1737e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return;
1738e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1739e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1740e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    if (status == NFA_STATUS_OK)
1741e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1742e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* notify NFC link activation */
1743e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        memcpy ( &(evt_data.activated.activate_ntf),
1744e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                 nfa_dm_cb.p_activate_ntf,
1745e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                 sizeof (tNFC_ACTIVATE_DEVT));
1746e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1747e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        p_tech_params = &evt_data.activated.activate_ntf.rf_tech_param;
1748e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1749df5080d7feca9827fd0306471c54f52ecf185c22Evan Chu        memset (&(evt_data.activated.params), 0x00, sizeof (tNFA_TAG_PARAMS));
1750e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (p_params)
1751e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1752e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            memcpy (&(evt_data.activated.params),
1753e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    p_params,
1754e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    sizeof (tNFA_TAG_PARAMS));
1755e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1756e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1757e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* get length of NFCID and location */
1758e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (p_tech_params->mode == NFC_DISCOVERY_TYPE_POLL_A)
1759e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1760e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfcid_len = p_tech_params->param.pa.nfcid1_len;
1761e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            p_nfcid   = p_tech_params->param.pa.nfcid1;
1762e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1763e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else if (p_tech_params->mode == NFC_DISCOVERY_TYPE_POLL_B)
1764e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1765e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfcid_len = NFC_NFCID0_MAX_LEN;
1766e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            p_nfcid   = p_tech_params->param.pb.nfcid0;
1767e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1768e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else if (p_tech_params->mode == NFC_DISCOVERY_TYPE_POLL_F)
1769e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1770e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfcid_len = NFC_NFCID2_LEN;
1771e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            p_nfcid   = p_tech_params->param.pf.nfcid2;
1772e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1773e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else if (p_tech_params->mode == NFC_DISCOVERY_TYPE_POLL_ISO15693)
1774e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1775e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfcid_len = NFC_ISO15693_UID_LEN;
1776e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            p_nfcid   = p_tech_params->param.pi93.uid;
1777e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
17787c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        else if (p_tech_params->mode == NFC_DISCOVERY_TYPE_POLL_KOVIO)
17797c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        {
17807c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu            nfcid_len = p_tech_params->param.pk.uid_len;
17817c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu            p_nfcid   = p_tech_params->param.pk.uid;
17827c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        }
1783e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else
1784e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1785e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfcid_len = 0;
1786e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1787e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1788e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /*
1789e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        ** If not in exlusive RF mode, and
1790e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        **      P2P activation, then push default NDEF message through SNEP
1791e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        **      TAG activation, then read NDEF message
1792e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        */
1793e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_NFC_DEP)
1794e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1795e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /*
1796e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            ** Default NDEF message will be put to NFC Forum defualt SNEP server
1797e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            ** after receiving NFA_LLCP_ACTIVATED_EVT.
1798e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            */
1799e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1800e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        else if (!(nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE))
1801e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1802e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            /*
1803e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            ** if the same tag is activated then do not perform auto NDEF detection.
1804e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            ** Application may put a tag into sleep mode and reactivate the same tag.
1805e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            */
1806e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
18077c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu            if (  (p_tech_params->mode != nfa_dm_cb.activated_tech_mode)
1808e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                ||(nfcid_len != nfa_dm_cb.activated_nfcid_len)
1809e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                ||(memcmp (p_nfcid, nfa_dm_cb.activated_nfcid, nfcid_len)))
1810e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            {
1811e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                if (  (nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_T1T)
1812e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    ||(nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_T2T)
1813e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    ||(nfa_dm_cb.disc_cb.activated_protocol  == NFC_PROTOCOL_T3T)
1814e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    ||(  (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_ISO_DEP)
1815e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                       &&(nfa_dm_cb.disc_cb.activated_rf_interface == NFC_INTERFACE_ISO_DEP)  )
1816e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    ||(nfa_dm_cb.disc_cb.activated_protocol  == NFA_PROTOCOL_ISO15693)  )
1817e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                {
1818e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    if (p_nfa_dm_cfg->auto_detect_ndef)
1819e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    {
1820e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                        if (p_nfa_dm_cfg->auto_read_ndef)
1821e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                        {
1822e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                            nfa_dm_cb.flags |= NFA_DM_FLAGS_AUTO_READING_NDEF;
1823e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                        }
1824e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                        NFA_RwDetectNDef ();
1825e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    }
1826e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    else if (p_nfa_dm_cfg->auto_read_ndef)
1827e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    {
1828e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                        NFA_RwReadNDef ();
1829e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                    }
1830e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project                }
1831e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            }
1832e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1833e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1834e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* store activated tag information */
18357c69b2723b60a59df4aaa58b13985b3483b291bfEvan Chu        nfa_dm_cb.activated_tech_mode = p_tech_params->mode;
1836e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.activated_nfcid_len = nfcid_len;
1837e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfcid_len)
1838e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            memcpy (nfa_dm_cb.activated_nfcid, p_nfcid, nfcid_len);
1839e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1840e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_cb.flags |= NFA_DM_FLAGS_SEND_DEACTIVATED_EVT;
1841e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        nfa_dm_conn_cback_event_notify (NFA_ACTIVATED_EVT, &evt_data);
1842e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1843e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    else
1844e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    {
1845e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        /* if NFC_DEP, NFA P2P will deactivate */
1846e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        if (nfa_dm_cb.disc_cb.activated_protocol != NFC_PROTOCOL_NFC_DEP)
1847e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        {
1848e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project            nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_DISCOVERY);
1849e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        }
1850e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1851e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1852e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    GKI_freebuf (nfa_dm_cb.p_activate_ntf);
1853e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    nfa_dm_cb.p_activate_ntf = NULL;
1854e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1855e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1856e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#if (BT_TRACE_VERBOSE == TRUE)
1857e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project/*******************************************************************************
1858e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1859e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Function         nfa_dm_nfc_revt_2_str
1860e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1861e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project** Description      convert nfc revt to string
1862e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project**
1863e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project*******************************************************************************/
1864e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Projectchar *nfa_dm_nfc_revt_2_str (tNFC_RESPONSE_EVT event)
1865e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project{
1866e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    switch (event) {
1867e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_ENABLE_REVT:
1868e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_ENABLE_REVT";
1869e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1870e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_DISABLE_REVT:
1871e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_DISABLE_REVT";
1872e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1873e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_SET_CONFIG_REVT:
1874e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_SET_CONFIG_REVT";
1875e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1876e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_GET_CONFIG_REVT:
1877e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_GET_CONFIG_REVT";
1878e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1879e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCEE_DISCOVER_REVT:
1880e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_NFCEE_DISCOVER_REVT";
1881e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1882e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCEE_INFO_REVT:
1883e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_NFCEE_INFO_REVT";
1884e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1885e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCEE_MODE_SET_REVT:
1886e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_NFCEE_MODE_SET_REVT";
1887e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1888e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_RF_FIELD_REVT:
1889e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_RF_FIELD_REVT";
1890e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1891e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_EE_ACTION_REVT:
1892e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_EE_ACTION_REVT";
1893e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1894e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_EE_DISCOVER_REQ_REVT:
1895e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_EE_DISCOVER_REQ_REVT";
1896e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1897e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_SET_ROUTING_REVT:
1898e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_SET_ROUTING_REVT";
1899e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1900e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_GET_ROUTING_REVT:
1901e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_GET_ROUTING_REVT";
1902e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1903e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_GEN_ERROR_REVT:
1904e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_GEN_ERROR_REVT";
1905e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1906e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCC_RESTART_REVT:
1907e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_NFCC_RESTART_REVT";
1908e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1909e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCC_TIMEOUT_REVT:
1910e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_NFCC_TIMEOUT_REVT";
1911e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1912e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCC_TRANSPORT_ERR_REVT:
1913e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_NFCC_TRANSPORT_ERR_REVT";
1914e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1915e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    case NFC_NFCC_POWER_OFF_REVT:
1916e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "NFC_NFCC_POWER_OFF_REVT";
1917e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project
1918e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    default:
1919e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        return "unknown revt";
1920e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project        break;
1921e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project    }
1922e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project}
1923e9df6ba5a8fcccf306a80b1670b423be8fe7746The Android Open Source Project#endif /* BT_VERBOSE */
1924