summaryrefslogtreecommitdiff
path: root/halimpl/src
diff options
context:
space:
mode:
authorYerriswamy <yerriswamy.kurubathayanna@nxp.com>2020-04-22 02:36:57 +0530
committerSangeetha Agarwal <sangeetha.agarwal@nxp.com>2020-04-22 20:42:08 +0530
commitf8ca22078c945ece40dc262be09b5b14bf6cb64c (patch)
treeb20b3a8fe50345adef943f63b32ea8ce16d4be49 /halimpl/src
parentf926f30adefe5d411357a7652e7ec0ac7917911d (diff)
Code cleanup on HAL 2.0 implementation
hal_nxpnfc.h file and correspondinig dependencies are removed.
Diffstat (limited to 'halimpl/src')
-rwxr-xr-xhalimpl/src/halLibnfc/src/Android.bp2
-rwxr-xr-xhalimpl/src/halLibnfc/src/adaptation/HalNfcAdaptation.cc52
-rwxr-xr-xhalimpl/src/halLibnfc/src/include/HalNfcAdaptation.h5
-rwxr-xr-xhalimpl/src/halLibnfc/src/include/nfc_hal_api.h3
-rwxr-xr-xhalimpl/src/halLibnfc/src/nfa/dm/nfa_dm_act.cc1
-rwxr-xr-xhalimpl/src/halLibnfc/src/nfc/include/nfc_api.h39
-rwxr-xr-xhalimpl/src/halLibnfc/src/nfc/nfc/nfc_main.cc94
-rwxr-xr-xhalimpl/src/halLibnfc/src/nfc/nfc/nfc_ncif.cc60
8 files changed, 45 insertions, 211 deletions
diff --git a/halimpl/src/halLibnfc/src/Android.bp b/halimpl/src/halLibnfc/src/Android.bp
index b06bda8..a11a2c5 100755
--- a/halimpl/src/halLibnfc/src/Android.bp
+++ b/halimpl/src/halLibnfc/src/Android.bp
@@ -23,6 +23,7 @@ cc_library_shared {
"android.hardware.nfc@1.0",
"android.hardware.nfc@1.1",
"vendor.nxp.nxpnfc@2.0",
+ "vendor.nxp.nxpnfclegacy@1.0"
],
cflags: [
"-DBUILDCFG=1",
@@ -42,7 +43,6 @@ cc_library_shared {
"gki/common",
],
include_dirs: [
- "hardware/nxp/nfc/extns/impl/",
"hardware/nxp/nfc/extns/impl/nxpnfc/2.0",
"hardware/nxp/secure_element/extns/impl/",
],
diff --git a/halimpl/src/halLibnfc/src/adaptation/HalNfcAdaptation.cc b/halimpl/src/halLibnfc/src/adaptation/HalNfcAdaptation.cc
index af55d00..da5919a 100755
--- a/halimpl/src/halLibnfc/src/adaptation/HalNfcAdaptation.cc
+++ b/halimpl/src/halLibnfc/src/adaptation/HalNfcAdaptation.cc
@@ -35,7 +35,6 @@
*
******************************************************************************/
#include "HalNfcAdaptation.h"
-#include "hal_nxpnfc.h"
#include "nfa_api.h"
#include "nfc_int.h"
#include "nfc_target.h"
@@ -68,6 +67,7 @@ using android::hardware::hidl_vec;
using android::hardware::nfc::V1_1::INfcClientCallback;
using ::android::hidl::base::V1_0::IBase;
using vendor::nxp::nxpnfc::V2_0::INxpNfc;
+using vendor::nxp::nxpnfclegacy::V1_0::INxpNfcLegacy;
extern bool nfc_debug_enabled;
@@ -77,6 +77,7 @@ HalNfcAdaptation *HalNfcAdaptation::mpInstance = NULL;
HalAdaptationThreadMutex HalNfcAdaptation::sLock;
HalAdaptationThreadMutex HalNfcAdaptation::sIoctlLock;
sp<INxpNfc> HalNfcAdaptation::mHalNxpNfc;
+sp<INxpNfcLegacy> HalNfcAdaptation::mHalNxpNfcLegacy;
sp<INfc> HalNfcAdaptation::mHal;
sp<INfcV1_1> HalNfcAdaptation::mHal_1_1;
INfcClientCallback *HalNfcAdaptation::mCallback;
@@ -173,7 +174,6 @@ public:
**
*******************************************************************************/
HalNfcAdaptation::HalNfcAdaptation() {
- mCurrentIoctlData = NULL;
mNfcHalDeathRecipient = new NfcDeathRecipient(mHal);
memset(&mHalEntryFuncs, 0, sizeof(mHalEntryFuncs));
}
@@ -385,6 +385,21 @@ uint32_t HalNfcAdaptation::Thread(__attribute__((unused)) uint32_t arg) {
tHAL_NFC_ENTRY *HalNfcAdaptation::GetHalEntryFuncs() { return &mHalEntryFuncs; }
/*******************************************************************************
+ **
+ ** Function phNxpNciHal_getchipType
+ **
+ ** Description Gets the chipType from hal which is already configured
+ ** during init time.
+ **
+ ** Returns chipType
+ *******************************************************************************/
+uint8_t HalNfcAdaptation::HalgetchipType() {
+ const char* func = "NfcAdaptation::HalgetchipType";
+ DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s : Enter", func);
+ return mHalNxpNfcLegacy->getchipType();
+}
+
+/*******************************************************************************
**
** Function: HalNfcAdaptation::InitializeHalDeviceContext
**
@@ -402,6 +417,7 @@ void HalNfcAdaptation::InitializeHalDeviceContext() {
mHalEntryFuncs.close = HalClose;
mHalEntryFuncs.core_initialized = HalCoreInitialized;
mHalEntryFuncs.write = HalWrite;
+ mHalEntryFuncs.getchipType = HalgetchipType;
mHalEntryFuncs.prediscover = HalPrediscover;
mHalEntryFuncs.control_granted = HalControlGranted;
LOG(INFO) << StringPrintf("%s: Try INfcV1_1::getService()", func);
@@ -428,6 +444,15 @@ void HalNfcAdaptation::InitializeHalDeviceContext() {
func, mHalNxpNfc.get(),
(mHalNxpNfc->isRemote() ? "remote" : "local"));
}
+
+ LOG(INFO) << StringPrintf("%s: INxpNfcLegacy::getService()", func);
+ mHalNxpNfcLegacy = INxpNfcLegacy::tryGetService();
+ if(mHalNxpNfcLegacy == nullptr) {
+ LOG(INFO) << StringPrintf ( "Failed to retrieve the NXPNFC Legacy HAL!");
+ } else {
+ LOG(INFO) << StringPrintf("%s: INxpNfcLegacy::getService() returned %p (%s)", func, mHalNxpNfcLegacy.get(),
+ (mHalNxpNfcLegacy->isRemote() ? "remote" : "local"));
+ }
}
/*******************************************************************************
@@ -553,29 +578,6 @@ void HalNfcAdaptation::HalWrite(uint16_t data_len, uint8_t *p_data) {
#if (NXP_EXTNS == TRUE)
/*******************************************************************************
**
-** Function: IoctlCallback
-**
-** Description: Callback from HAL stub for IOCTL api invoked.
-** Output data for IOCTL is sent as argument
-**
-** Returns: None.
-**
-*******************************************************************************/
-void IoctlCallback(::android::hardware::nfc::V1_0::NfcData outputData) {
- const char *func = "IoctlCallback";
- nfc_nci_ExtnOutputData_t *pOutData =
- (nfc_nci_ExtnOutputData_t *)&outputData[0];
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "%s Ioctl Type=%llu", func, (unsigned long long)pOutData->ioctlType);
- HalNfcAdaptation *pAdaptation = (HalNfcAdaptation *)pOutData->context;
- /*Output Data from stub->Proxy is copied back to output data
- * This data will be sent back to libnfc*/
- memcpy(&pAdaptation->mCurrentIoctlData->out, &outputData[0],
- sizeof(nfc_nci_ExtnOutputData_t));
-}
-
-/*******************************************************************************
-**
** Function: HalNfcAdaptation::HalGetFwDwnldFlag
**
** Description: Get FW Download Flag.
diff --git a/halimpl/src/halLibnfc/src/include/HalNfcAdaptation.h b/halimpl/src/halLibnfc/src/include/HalNfcAdaptation.h
index 9a6ffa5..22318b8 100755
--- a/halimpl/src/halLibnfc/src/include/HalNfcAdaptation.h
+++ b/halimpl/src/halLibnfc/src/include/HalNfcAdaptation.h
@@ -44,6 +44,8 @@
#include <android/hardware/nfc/1.0/types.h>
#include <hardware/nfc.h>
#include <utils/RefBase.h>
+#include <vendor/nxp/nxpnfclegacy/1.0/INxpNfcLegacy.h>
+#include <vendor/nxp/nxpnfclegacy/1.0/types.h>
#include <vendor/nxp/nxpnfc/2.0/INxpNfc.h>
using ::android::sp;
@@ -111,6 +113,7 @@ public:
void Finalize();
void FactoryReset();
void DeviceShutdown();
+ static uint8_t HalgetchipType();
static HalNfcAdaptation &GetInstance();
tHAL_NFC_ENTRY *GetHalEntryFuncs();
void DownloadFirmware();
@@ -118,7 +121,6 @@ public:
#if (NXP_EXTNS == TRUE)
void MinInitialize();
int HalGetFwDwnldFlag(uint8_t *fwDnldRequest);
- nfc_nci_IoctlInOutData_t *mCurrentIoctlData;
#endif
private:
@@ -138,6 +140,7 @@ private:
static android::sp<android::hardware::nfc::V1_1::INfc> mHal_1_1;
static android::sp<vendor::nxp::nxpnfc::V2_0::INxpNfc> mHalNxpNfc;
static android::hardware::nfc::V1_1::INfcClientCallback *mCallback;
+ static android::sp<vendor::nxp::nxpnfclegacy::V1_0::INxpNfcLegacy> mHalNxpNfcLegacy;
sp<NfcDeathRecipient> mNfcHalDeathRecipient;
#if (NXP_EXTNS == TRUE)
static HalAdaptationThreadCondVar mHalCoreResetCompletedEvent;
diff --git a/halimpl/src/halLibnfc/src/include/nfc_hal_api.h b/halimpl/src/halLibnfc/src/include/nfc_hal_api.h
index 140f93b..508417f 100755
--- a/halimpl/src/halLibnfc/src/include/nfc_hal_api.h
+++ b/halimpl/src/halLibnfc/src/include/nfc_hal_api.h
@@ -43,7 +43,6 @@
#ifndef NFC_HAL_API_H
#define NFC_HAL_API_H
#include "data_types.h"
-#include "hal_nxpnfc.h"
#include "nfc_hal_target.h"
#include <hardware/nfc.h>
@@ -71,6 +70,7 @@ typedef uint8_t(tHAL_API_GET_MAX_NFCEE)(void);
#if (NXP_EXTNS == TRUE)
typedef int(tHAL_API_IOCTL)(long arg, void *p_data);
typedef int(tHAL_API_GET_FW_DWNLD_FLAG)(uint8_t *fwDnldRequest);
+typedef uint8_t(tHAL_API_getchipType)(void);
#endif
typedef struct {
@@ -87,6 +87,7 @@ typedef struct {
#if (NXP_EXTNS == TRUE)
tHAL_API_IOCTL *ioctl;
tHAL_API_GET_FW_DWNLD_FLAG *check_fw_dwnld_flag;
+ tHAL_API_getchipType* getchipType;
#endif
} tHAL_NFC_ENTRY;
diff --git a/halimpl/src/halLibnfc/src/nfa/dm/nfa_dm_act.cc b/halimpl/src/halLibnfc/src/nfa/dm/nfa_dm_act.cc
index 0c8671d..cbd1e49 100755
--- a/halimpl/src/halLibnfc/src/nfa/dm/nfa_dm_act.cc
+++ b/halimpl/src/halLibnfc/src/nfa/dm/nfa_dm_act.cc
@@ -50,7 +50,6 @@
#include "nfc_api.h"
#include "nfa_ee_int.h"
#if (NFC_NFCEE_INCLUDED == true)
-#include "hal_nxpnfc.h"
#include "nfc_int.h"
#endif
diff --git a/halimpl/src/halLibnfc/src/nfc/include/nfc_api.h b/halimpl/src/halLibnfc/src/nfc/include/nfc_api.h
index cc62bed..ea068a5 100755
--- a/halimpl/src/halLibnfc/src/nfc/include/nfc_api.h
+++ b/halimpl/src/halLibnfc/src/nfc/include/nfc_api.h
@@ -363,6 +363,12 @@ enum {
};
typedef uint16_t tNFC_CONN_EVT;
+enum {
+ HAL_NFC_ENABLE_I2C_FRAGMENTATION_EVT = 0x08,
+ HAL_NFC_POST_MIN_INIT_CPLT_EVT = 0x09,
+ HAL_NFC_WRITE_COMPLETE = 0x0A
+};
+
#define NFC_NFCC_INFO_LEN 4
#ifndef NFC_NFCC_MAX_NUM_VS_INTERFACE
#define NFC_NFCC_MAX_NUM_VS_INTERFACE 5
@@ -1537,39 +1543,6 @@ extern tNFC_STATUS NFC_Nfcee_PwrLinkCtrl(uint8_t nfcee_id, uint8_t cfg_value);
**
*******************************************************************************/
int32_t NFC_ReqWiredAccess(void *pdata);
-/*******************************************************************************
-**
-** Function NFC_GetWiredAccess
-**
-** Description This function gets the current access state
-** of P61. Current state would be updated to pdata
-**
-** Returns 0 if api call success, else -1
-**
-*******************************************************************************/
-int32_t NFC_GetP61Status(void *pdata);
-/*******************************************************************************
-**
-** Function NFC_SetNfcServicePid
-**
-** Description This function request to pn54x driver to
-** update NFC service process ID for signalling.
-**
-** Returns 0 if api call success, else -1
-**
-*******************************************************************************/
-int32_t NFC_SetNfcServicePid();
-/*******************************************************************************
-**
-** Function NFC_ResetNfcServicePid
-**
-** Description This function request to pn54x driver to
-** reset NFC service process ID for signalling.
-**
-** Returns 0 if api call success, else -1
-**
-*******************************************************************************/
-int32_t NFC_ResetNfcServicePid();
/*******************************************************************************
**
diff --git a/halimpl/src/halLibnfc/src/nfc/nfc/nfc_main.cc b/halimpl/src/halLibnfc/src/nfc/nfc/nfc_main.cc
index 44d83b7..4d12d6c 100755
--- a/halimpl/src/halLibnfc/src/nfc/nfc/nfc_main.cc
+++ b/halimpl/src/halLibnfc/src/nfc/nfc/nfc_main.cc
@@ -52,7 +52,6 @@
#include "bt_types.h"
#include "gki.h"
-#include "hal_nxpnfc.h"
#include "nci_hmsgs.h"
#include "nfa_sys.h"
#include "nfc_int.h"
@@ -1525,24 +1524,6 @@ int get_i2c_fragmentation_enabled() { return i2c_fragmentation_enabled; }
*******************************************************************************/
uint8_t NFC_GetNCIVersion() { return nfc_cb.nci_version; }
-/*******************************************************************************
-**
-** Function NFC_GetP61Status
-**
-** Description This function gets the current access state
-** of P61. Current state would be updated to pdata
-**
-** Returns 0 if api call success, else -1
-**
-*******************************************************************************/
-int32_t NFC_GetP61Status(void *pdata) {
- nfc_nci_IoctlInOutData_t inpOutData;
- int32_t status;
- status = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_P61_PWR_MODE, &inpOutData);
- *(uint32_t *)pdata = inpOutData.out.data.p61CurrentState;
- return status;
-}
-
#if (NXP_EXTNS == TRUE)
/*******************************************************************************
**
@@ -1573,67 +1554,6 @@ void check_nfcee_session_and_reset()
/*******************************************************************************
**
-** Function NFC_SetNfcServicePid
-**
-** Description This function request to pn54x driver to
-** update NFC service process ID for signalling.
-**
-** Returns 0 if api call success, else -1
-**
-*******************************************************************************/
-int32_t NFC_SetNfcServicePid() {
- tNFC_STATUS setPidStatus = NFC_STATUS_OK;
- nfc_nci_IoctlInOutData_t inpOutData;
- if (NFC_IsLowRamDevice()) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NFC_SetNfcServicePid: Not valid for low RAM device");
- return setPidStatus;
- }
- inpOutData.inp.data.nfcServicePid = getpid();
- setPidStatus = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_SET_NFC_SERVICE_PID,
- (void *)&inpOutData);
- if (setPidStatus == NFC_STATUS_OK) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("nfc service set pid done");
- } else {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("nfc service set pid failed");
- }
- return setPidStatus;
-}
-/*******************************************************************************
-**
-** Function NFC_ResetNfcServicePid
-**
-** Description This function request to pn54x driver to
-** update NFC service process ID for signalling.
-**
-** Returns 0 if api call success, else -1
-**
-*******************************************************************************/
-int32_t NFC_ResetNfcServicePid() {
- tNFC_STATUS setPidStatus = NFC_STATUS_OK;
- nfc_nci_IoctlInOutData_t inpOutData;
- inpOutData.inp.data.nfcServicePid = 0;
- if (NFC_IsLowRamDevice()) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NFC_ResetNfcServicePid: Not valid for low RAM device");
- return setPidStatus;
- }
- setPidStatus = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_SET_NFC_SERVICE_PID,
- (void *)&inpOutData);
- if (setPidStatus == NFC_STATUS_OK) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("nfc service set pid done");
- } else {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("nfc service set pid failed");
- }
- return setPidStatus;
-}
-
-/*******************************************************************************
-**
** Function NFC_IsLowRamDevice
**
** Description This function provides low_ram is enabled or not
@@ -1693,16 +1613,10 @@ void NFC_SetStaticHciCback(tNFC_CONN_CBACK *p_cback) {
void NFC_GetFeatureList() {
DLOG_IF(INFO, nfc_debug_enabled)
<< StringPrintf("NFC_GetFeatureList() Enter");
- tNFC_STATUS status = NFC_STATUS_FAILED;
- nfc_nci_IoctlInOutData_t inpOutData;
- status =
- nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_GET_FEATURE_LIST, (void *)&inpOutData);
- if (status == NFC_STATUS_OK) {
- chipType = (tNFC_chipType)inpOutData.out.data.chipType;
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NFC_GetFeatureList ()chipType = %d", chipType);
-
- } else {
+ chipType = (tNFC_chipType)nfc_cb.p_hal->getchipType();
+ if(chipType != 0x00) {
+ DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("NFC_GetFeatureList ()chipType = %d", chipType);
+ } else{
chipType = pn553;
}
CONFIGURE_FEATURELIST(chipType);
diff --git a/halimpl/src/halLibnfc/src/nfc/nfc/nfc_ncif.cc b/halimpl/src/halLibnfc/src/nfc/nfc/nfc_ncif.cc
index d41ca93..2ac5695 100755
--- a/halimpl/src/halLibnfc/src/nfc/nfc/nfc_ncif.cc
+++ b/halimpl/src/halLibnfc/src/nfc/nfc/nfc_ncif.cc
@@ -47,7 +47,6 @@
#include "nfc_target.h"
-#include "hal_nxpnfc.h"
#include "nci_defs.h"
#include "nci_hmsgs.h"
#include "nfc_api.h"
@@ -88,63 +87,6 @@ void disc_deact_ntf_timeout_handler(tNFC_RESPONSE_EVT event);
/*******************************************************************************
**
-** Function nfc_hal_nfcc_get_reset_info
-**
-** Description Register dump when CORE_RESET_NTF happens
-**
-** Returns status of command transceive
-**
-*******************************************************************************/
-uint8_t nfc_hal_nfcc_get_reset_info(void) {
- nfc_nci_IoctlInOutData_t inpOutData;
- /*NCI_RESET_CMD*/
- uint8_t nfc_hal_nfcc_get_reset_info[6][6] = {
- {
- 0x20,
- 0x00,
- 0x01,
- 0x00,
- },
- {
- 0x20,
- 0x01,
- 0x00,
- },
- {0x20, 0x03, 0x03, 0x01, 0xA0, 0x1A},
- {0x20, 0x03, 0x03, 0x01, 0xA0, 0x1B},
- {0x20, 0x03, 0x03, 0x01, 0xA0, 0x1C},
- {0x20, 0x03, 0x03, 0x01, 0xA0, 0x27}};
- uint8_t core_status = NCI_STATUS_FAILED;
- uint8_t retry_count = 0;
- uint8_t i = 0, j = 0;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s Enter", __func__);
-
- for (i = 0; i < 6; i++) {
- memset(&inpOutData, 0x00, sizeof(nfc_nci_IoctlInOutData_t));
- inpOutData.inp.data.nciCmd.cmd_len = nfc_hal_nfcc_get_reset_info[i][2] + 3;
- memcpy(inpOutData.inp.data.nciCmd.p_cmd,
- (uint8_t *)&nfc_hal_nfcc_get_reset_info[i],
- nfc_hal_nfcc_get_reset_info[i][2] + 3);
- do {
- core_status =
- nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_NCI_TRANSCEIVE, &inpOutData);
- retry_count++;
- } while (NCI_STATUS_OK != core_status &&
- retry_count < (NFC_NFCC_INIT_MAX_RETRY + 1));
- if (core_status == NCI_STATUS_OK) {
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "%s No.%d response for nfc_hal_nfcc_get_reset_info", __func__, i);
- for (j = 0; j < inpOutData.out.data.nciRsp.rsp_len; j++) {
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- " %s 0x%02x", __func__, inpOutData.out.data.nciRsp.p_rsp[j]);
- }
- }
- }
- return core_status;
-}
-
-/*******************************************************************************
-**
** Function nfc_ncif_update_window
**
** Description Update tx cmd window to indicate that NFCC can received
@@ -2342,4 +2284,4 @@ bool nfc_ncif_proc_proprietary_rsp(uint8_t mt, uint8_t gid, uint8_t oid) {
return stat;
}
-#endif \ No newline at end of file
+#endif