summaryrefslogtreecommitdiff
path: root/2.0/default/NxpNfcLegacy.cpp
blob: 1ac5da4d6a23236c4b7552dd48fe2c820cb6a634 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/******************************************************************************
 *
 *  Copyright 2020 NXP
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/
#include <log/log.h>

#include "NxpNfcLegacy.h"
#include "phNxpNciHal.h"
#include <phTmlNfc.h>

extern bool nfc_debug_enabled;

namespace vendor {
namespace nxp {
namespace nxpnfclegacy {
namespace V1_0 {
namespace implementation {


Return<uint8_t>
NxpNfcLegacy::setEseState(NxpNfcHalEseState EseState) {
  NFCSTATUS status = NFCSTATUS_FAILED;
  ALOGD("NxpNfcLegacy::setEseState Entry");

  if(EseState == NxpNfcHalEseState::HAL_NFC_ESE_IDLE_MODE)
  {
    ALOGD("NxpNfcLegacy::setEseState state == HAL_NFC_ESE_IDLE_MODE");
    status = phNxpNciHal_setEseState(phNxpNciHalNfc_e_SetIdleMode);
  }
  if (EseState == NxpNfcHalEseState::HAL_NFC_ESE_WIRED_MODE) {
    ALOGD("NxpNfcLegacy::setEseState state == HAL_NFC_ESE_WIRED_MODE");
    status = phNxpNciHal_setEseState(phNxpNciHalNfc_e_SetWiredMode);
  }

  ALOGD("NxpNfcLegacy::setEseState Exit");
  return status;
}

Return<uint8_t>
NxpNfcLegacy::getchipType() {
  uint8_t chiptype;
  ALOGD("NxpNfcLegacy::getchipType Entry");
  chiptype = phNxpHal_getchipType();
  ALOGD("NxpNfcLegacy::getchipType Exit");
  return chiptype;
}

Return<uint16_t>
NxpNfcLegacy::setNfcServicePid(uint64_t pid) {
  NFCSTATUS status = NFCSTATUS_FAILED;
  ALOGD("NxpNfcLegacy::setNfcServicePid Entry");
  status = phNxpNciHal_setNfcServicePid(pid);
  ALOGD("NxpNfcLegacy::setNfcServicePid Exit");
  return status;
}

Return<uint16_t>
NxpNfcLegacy::getEseState() {
  NFCSTATUS status = NFCSTATUS_FAILED;
  ALOGD("NxpNfcLegacy::getEseState Entry");
  status = phNxpNciHal_getEseState();
  ALOGD("NxpNfcLegacy::getEseState Exit");
  return status;
}

Return<uint16_t>
NxpNfcLegacy::spiDwpSync(uint32_t level) {
  uint16_t status = 0;

  ALOGD("NxpNfcLegacy::spiDwpSync Entry");
  status = phNxpNciHal_ReleaseSVDDWait(level);

  ALOGD("NxpNfcLegacy::spiDwpSync Exit");
  return status;
}

Return<uint16_t>
NxpNfcLegacy::RelForceDwpOnOffWait(uint32_t level) {
  uint16_t status = 0;

  ALOGD("NxpNfcLegacy::RelForceDwpOnOffWait Entry");
  status = phNxpNciHal_ReleaseDWPOnOffWait(level);

  ALOGD("NxpNfcLegacy::RelForceDwpOnOffWait Exit");
  return status;
}

Return<int8_t>
NxpNfcLegacy::getSPMStatus(uint32_t level) {
  int8_t status = -1;

  ALOGD("NxpNfcLegacy::getSPMStatus Entry");
  status = phNxpNciHal_getSPMStatus(level);

  ALOGD("NxpNfcLegacy::getSPMStatus Exit");
  return status;
}

Return<int32_t>
NxpNfcLegacy::hciInitUpdateState(NfcHciInitStatus HciStatus) {
  int32_t status = 0;

  ALOGD("NxpNfcLegacy::hciInitUpdateState Entry");
  if (HciStatus == NfcHciInitStatus::NFC_HCI_INIT_START)
  {
    ALOGD("NxpNfcLegacy::hciInitUpdateState state == NFC_HCI_INIT_START");
    phNxpNciHal_hciInitUpdateState(phNxpNfcHciInitStatus_e_Start);
  }
  else if (HciStatus == NfcHciInitStatus::NFC_HCI_INIT_COMPLETE)
  {
    ALOGD("NxpNfcLegacy::hciInitUpdateState state == NFC_HCI_INIT_COMPLETE");
    phNxpNciHal_hciInitUpdateState(phNxpNfcHciInitStatus_e_Complete);
  }
  ALOGD("NxpNfcLegacy::hciInitUpdateState Exit");
  return status;
}

Return<int32_t>
NxpNfcLegacy::hciInitUpdateStateComplete() {
  int32_t status = 0;

  ALOGD("NxpNfcLegacy::hciInitUpdateStateComplete Entry");

  status = phNxpNciHal_hciInitUpdateStateComplete();

  ALOGD("NxpNfcLegacy::hciInitUpdateStateComplete Exit");

  return status;
}

Return<void> NxpNfcLegacy::getCachedNfccConfig(getCachedNfccConfig_cb _hidl_cb){
  phNxpNci_getCfg_info_t GetCfg_info;
  NxpNciCfgInfo ConfigData;

  ALOGD("NxpNfcLegacy::GetCachedNfccConfig Entry" );

  phNxpNciHal_GetCachedNfccConfig(&GetCfg_info);
  memcpy(&ConfigData,&GetCfg_info,sizeof(NxpNciCfgInfo));
  _hidl_cb(ConfigData);

  ALOGD("NxpNfcLegacy::GetCachedNfccConfig Exit");
  return Void();
}

Return<void> NxpNfcLegacy::getNxpConfig(getNxpConfig_cb _hidl_cb)
{
  phNxpNfcHalConfig localConfigData;
  NxpNfcHalConfig config;
  ALOGD("NxpNfcLegacy::getNxpConfig Entry" );
  phNxpNciHal_getNxpConfig(&localConfigData);
  memcpy(&config, &localConfigData, sizeof(NxpNfcHalConfig));
  _hidl_cb(config);
  ALOGD("NxpNfcLegacy::getNxpConfig Exit");
  return Void();
}

Return<void> NxpNfcLegacy::nciTransceive( const NxpNciExtnCmd &NciCmd,nciTransceive_cb _hidl_cb){
  phNxpNci_Extn_Cmd_t  in;
  phNxpNci_Extn_Resp_t out;

  NxpNciExtnResp nciResp;

  ALOGD("NxpNfcLegacy::NciTransceive Entry" );

  memcpy(&in,&NciCmd,sizeof(NxpNciExtnCmd));

  phNxpNciHal_nciTransceive(&in,&out);

  memcpy(&nciResp,&out,sizeof(NxpNciExtnResp));

  _hidl_cb(nciResp);

  ALOGD("NxpNfcLegacy::NciTransceive Exit");
  return Void();
}


}  // namespace implementation
}  // namespace V1_0
}  // namespace nxpnfclegacy
}  // namespace nxp
}  // namespace vendor