diff options
author | Yerriswamy <yerriswamy.kurubathayanna@nxp.com> | 2020-04-22 02:36:57 +0530 |
---|---|---|
committer | Sangeetha Agarwal <sangeetha.agarwal@nxp.com> | 2020-04-22 20:42:08 +0530 |
commit | f8ca22078c945ece40dc262be09b5b14bf6cb64c (patch) | |
tree | b20b3a8fe50345adef943f63b32ea8ce16d4be49 | |
parent | f926f30adefe5d411357a7652e7ec0ac7917911d (diff) |
Code cleanup on HAL 2.0 implementation
hal_nxpnfc.h file and correspondinig dependencies are removed.
-rw-r--r-- | extns/impl/hal_nxpnfc.h | 232 | ||||
-rwxr-xr-x | halimpl/ese-clients/src/DwpEseUpdater.cc | 22 | ||||
-rw-r--r-- | halimpl/hal/phNxpNciHal.cc | 70 | ||||
-rw-r--r-- | halimpl/hal/phNxpNciHal.h | 9 | ||||
-rw-r--r-- | halimpl/hal/phNxpNciHal_ext.cc | 17 | ||||
-rwxr-xr-x | halimpl/src/halLibnfc/src/Android.bp | 2 | ||||
-rwxr-xr-x | halimpl/src/halLibnfc/src/adaptation/HalNfcAdaptation.cc | 52 | ||||
-rwxr-xr-x | halimpl/src/halLibnfc/src/include/HalNfcAdaptation.h | 5 | ||||
-rwxr-xr-x | halimpl/src/halLibnfc/src/include/nfc_hal_api.h | 3 | ||||
-rwxr-xr-x | halimpl/src/halLibnfc/src/nfa/dm/nfa_dm_act.cc | 1 | ||||
-rwxr-xr-x | halimpl/src/halLibnfc/src/nfc/include/nfc_api.h | 39 | ||||
-rwxr-xr-x | halimpl/src/halLibnfc/src/nfc/nfc/nfc_main.cc | 94 | ||||
-rwxr-xr-x | halimpl/src/halLibnfc/src/nfc/nfc/nfc_ncif.cc | 60 |
13 files changed, 101 insertions, 505 deletions
diff --git a/extns/impl/hal_nxpnfc.h b/extns/impl/hal_nxpnfc.h deleted file mode 100644 index d1ab289..0000000 --- a/extns/impl/hal_nxpnfc.h +++ /dev/null @@ -1,232 +0,0 @@ -/****************************************************************************** - * - * Copyright 2018-2019 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. - * - ******************************************************************************/ -#ifndef ANDROID_HARDWARE_HAL_NXPNFC_V1_0_H -#define ANDROID_HARDWARE_HAL_NXPNFC_V1_0_H -#include <vector> -#include <string> - -#define NFC_NCI_NXP_PN54X_HARDWARE_MODULE_ID "nfc_nci.pn54x" -#define MAX_IOCTL_TRANSCEIVE_CMD_LEN 256 -#define MAX_IOCTL_TRANSCEIVE_RESP_LEN 256 -#define MAX_ATR_INFO_LEN 128 - -enum { - HAL_NFC_ENABLE_I2C_FRAGMENTATION_EVT = 0x08, - HAL_NFC_POST_MIN_INIT_CPLT_EVT = 0x09, - HAL_NFC_WRITE_COMPLETE = 0x0A -}; - -enum { - HAL_NFC_IOCTL_P61_IDLE_MODE = 0, - HAL_NFC_IOCTL_P61_WIRED_MODE, - HAL_NFC_IOCTL_P61_PWR_MODE, - HAL_NFC_IOCTL_GET_CONFIG_INFO, - HAL_NFC_IOCTL_NCI_TRANSCEIVE, - HAL_NFC_SET_SPM_PWR, - HAL_NFC_IOCTL_REL_SVDD_WAIT, - HAL_NFC_IOCTL_SPI_DWP_SYNC, - HAL_NFC_IOCTL_SET_NFC_SERVICE_PID, - HAL_NFC_IOCTL_REL_DWP_WAIT, - HAL_NFC_IOCTL_GET_FEATURE_LIST, - HAL_NFC_SET_POWER_SCHEME, - HAL_NFC_GET_SPM_STATUS, - HAL_NFC_GET_NXP_CONFIG, - HAL_NFC_IOCTL_RF_ACTION_NTF, - HAL_NFC_IOCTL_SET_TRANSIT_CONFIG, - HAL_NFC_IOCTL_ESE_JCOP_DWNLD, - HAL_NFC_IOCTL_ESE_UPDATE_COMPLETE, - HAL_NFC_IOCTL_HCI_INIT_STATUS_UPDATE, - HAL_NFC_IOCTL_HCI_INIT_STATUS_UPDATE_COMPLETE /* 28 */ -}; - -/* - * Data structures provided below are used of Hal Ioctl calls - */ -/* - * nfc_nci_ExtnCmd_t shall contain data for commands used for transceive command - * in ioctl - */ -typedef struct { - uint16_t cmd_len; - uint8_t p_cmd[MAX_IOCTL_TRANSCEIVE_CMD_LEN]; -} nfc_nci_ExtnCmd_t; - -/* - * nxp_nfc_scrResetEmvcoCmd_t shall contain core set conf command to reset EMVCO - * mode and the length of the command - */ -typedef struct { - long len; - uint8_t cmd[10]; -} nxp_nfc_scrResetEmvcoCmd_t; - -/* - * nfc_nci_ExtnRsp_t shall contain response for command sent in transceive - * command - */ -typedef struct { - uint8_t ese_listen_tech_mask; - uint8_t default_nfcee_disc_timeout; - uint8_t default_nfcee_timeout; - uint8_t ese_wired_prt_mask; - uint8_t uicc_wired_prt_mask; - uint8_t wired_mode_rf_field_enable; - uint8_t aid_block_route; - - uint8_t esePowerDhControl; - uint8_t tagOpTimeout; - uint8_t loaderServiceVersion; - uint8_t defaultNfceeDiscTimeout; - uint8_t dualUiccEnable; - uint8_t ceRouteStrictDisable; - uint32_t osDownloadTimeoutValue; - uint8_t defaultAidRoute; - uint8_t defaultAidPwrState; - uint8_t defaultRoutePwrState; - uint8_t defaultOffHostPwrState; - uint8_t jcopDlAtBootEnable; - uint8_t defaultNfceeTimeout; - uint8_t nxpNfcChip; - uint8_t coreScrnOffAutonomousEnable; - uint8_t p61LsDefaultInterface; - uint8_t p61JcopDefaultInterface; - uint8_t agcDebugEnable; - uint8_t felicaCltPowerState; - uint32_t cmdRspTimeoutValue; - uint8_t checkDefaultProtoSeId; - uint8_t nfccPassiveListenTimeout; - uint32_t nfccStandbyTimeout; - uint32_t wmMaxWtxCount; - uint32_t nfccRfFieldEventTimeout; - uint8_t allowWiredInMifareDesfireClt; - uint8_t dwpIntfResetEnable; - uint8_t nxpLogHalLoglevel; - uint8_t nxpLogExtnsLogLevel; - uint8_t nxpLogTmlLogLevel; - uint8_t nxpLogFwDnldLogLevel; - uint8_t nxpLogNcixLogLevel; - uint8_t nxpLogNcirLogLevel; - uint8_t scrCfgFormat; - uint8_t etsiReaderEnable; - uint8_t techAbfRoute; - uint8_t techAbfPwrState; - uint8_t wTagSupport; - uint8_t t4tNfceePwrState; - nxp_nfc_scrResetEmvcoCmd_t scrResetEmvco; -} nxp_nfc_config_t; -/* - * nfc_nci_ExtnRsp_t shall contain response for command sent in transceive - * command - */ -typedef struct { - uint16_t rsp_len; - uint8_t p_rsp[MAX_IOCTL_TRANSCEIVE_RESP_LEN]; -} nfc_nci_ExtnRsp_t; -/* - * TransitConfig_t shall contain transit config value and transit - * Configuration length - */ -typedef struct { - long len; - char *val; -} TransitConfig_t; -/* - * InputData_t :ioctl has multiple subcommands - * Each command has corresponding input data which needs to be populated in this - */ -typedef union { - uint16_t bootMode; - uint8_t halType; - nfc_nci_ExtnCmd_t nciCmd; - uint32_t timeoutMilliSec; - long nfcServicePid; - TransitConfig_t transitConfig; -} InputData_t; -/* - * nfc_nci_ExtnInputData_t :Apart from InputData_t, there are context data - * which is required during callback from stub to proxy. - * To avoid additional copy of data while propagating from libnfc to Adaptation - * and Nfcstub to ncihal, common structure is used. As a sideeffect, context - * data - * is exposed to libnfc (Not encapsulated). - */ -typedef struct { - /*context to be used/updated only by users of proxy & stub of Nfc.hal - * i.e, NfcAdaptation & hardware/interface/Nfc. - */ - void* context; - InputData_t data; - uint8_t data_source; - long level; -} nfc_nci_ExtnInputData_t; - -/* - * outputData_t :ioctl has multiple commands/responses - * This contains the output types for each ioctl. - */ -typedef union { - uint32_t status; - nfc_nci_ExtnRsp_t nciRsp; - uint8_t nxpNciAtrInfo[MAX_ATR_INFO_LEN]; - uint32_t p61CurrentState; - uint16_t fwUpdateInf; - uint16_t fwDwnldStatus; - uint16_t fwMwVerStatus; - uint8_t chipType; - nxp_nfc_config_t nxpConfigs; -} outputData_t; - -/* - * nfc_nci_ExtnOutputData_t :Apart from outputData_t, there are other - * information - * which is required during callback from stub to proxy. - * For ex (context, result of the operation , type of ioctl which was - * completed). - * To avoid additional copy of data while propagating from libnfc to Adaptation - * and Nfcstub to ncihal, common structure is used. As a sideeffect, these data - * is exposed(Not encapsulated). - */ -typedef struct { - /*ioctlType, result & context to be used/updated only by users of - * proxy & stub of Nfc.hal. - * i.e, NfcAdaptation & hardware/interface/Nfc - * These fields shall not be used by libnfc or halimplementation*/ - uint64_t ioctlType; - uint32_t result; - void* context; - outputData_t data; -} nfc_nci_ExtnOutputData_t; - -/* - * nfc_nci_IoctlInOutData_t :data structure for input & output - * to be sent for ioctl command. input is populated by client/proxy side - * output is provided from server/stub to client/proxy - */ -typedef struct { - nfc_nci_ExtnInputData_t inp; - nfc_nci_ExtnOutputData_t out; -} nfc_nci_IoctlInOutData_t; - -enum NxpNfcHalStatus { - /** In case of an error, HCI network needs to be re-initialized */ - HAL_NFC_STATUS_RESTART = 0x30, - HAL_NFC_HCI_NV_RESET = 0x40, - HAL_NFC_CONFIG_ESE_LINK_COMPLETE = 0x50 -}; - -#endif // ANDROID_HARDWARE_HAL_NXPNFC_V1_0_H diff --git a/halimpl/ese-clients/src/DwpEseUpdater.cc b/halimpl/ese-clients/src/DwpEseUpdater.cc index b629b01..2a8d130 100755 --- a/halimpl/ese-clients/src/DwpEseUpdater.cc +++ b/halimpl/ese-clients/src/DwpEseUpdater.cc @@ -21,7 +21,6 @@ #include "DwpSeEvtCallback.h" #include "EseAdaptation.h" #include "EseUpdateChecker.h" -#include "hal_nxpnfc.h" #include <JcDnld.h> #include <cutils/log.h> #include <dirent.h> @@ -35,6 +34,7 @@ #include <unistd.h> #include <vendor/nxp/nxpese/1.0/INxpEse.h> +extern bool phNxpNciHal_Abort(); #define HAL_ESE_IOCTL_NFC_JCOP_DWNLD 176 using vendor::nxp::nxpese::V1_0::INxpEse; @@ -75,15 +75,15 @@ void DwpEseUpdater::checkIfEseClientUpdateReqd() void IoctlCallback_DwpClient(hidl_vec<uint8_t> outputData) { const char* func = "IoctlCallback_DwpClient"; - nfc_nci_ExtnOutputData_t *pOutData = - (nfc_nci_ExtnOutputData_t *)&outputData[0]; + ese_nxp_ExtnOutputData_t *pOutData = + (ese_nxp_ExtnOutputData_t *)&outputData[0]; ALOGD_IF(nfc_debug_enabled, "%s Ioctl Type=%lu", func, (unsigned long)pOutData->ioctlType); EseAdaptation* pAdaptation = (EseAdaptation*)pOutData->context; /*Output Data from stub->Proxy is copied back to output data * This data will be sent back to libese*/ memcpy(&pAdaptation->mCurrentIoctlData->out, &outputData[0], - sizeof(nfc_nci_ExtnOutputData_t)); + sizeof(ese_nxp_ExtnOutputData_t)); } SESTATUS DwpEseUpdater::doEseUpdateIfReqd() { @@ -168,13 +168,13 @@ void DwpEseUpdater::setDwpEseClientState(uint8_t state) } void DwpEseUpdater::sendeSEUpdateState(uint8_t state) { - nfc_nci_IoctlInOutData_t inpOutData; + ese_nxp_IoctlInOutData_t inpOutData; gpEseAdapt = &EseAdaptation::GetInstance(); gpEseAdapt->Initialize(); ALOGE("%s: State = %d", __FUNCTION__, state); - memset(&inpOutData, 0x00, sizeof(nfc_nci_IoctlInOutData_t)); - inpOutData.inp.data.nciCmd.cmd_len = sizeof(state); - memcpy(inpOutData.inp.data.nciCmd.p_cmd, &state, sizeof(state)); + memset(&inpOutData, 0x00, sizeof(ese_nxp_IoctlInOutData_t)); + inpOutData.inp.data.nxpCmd.cmd_len = sizeof(state); + memcpy(inpOutData.inp.data.nxpCmd.p_cmd, &state, sizeof(state)); inpOutData.inp.data_source = 2; phNxpNciHal_ioctl(HAL_ESE_IOCTL_NFC_JCOP_DWNLD, &inpOutData); } @@ -203,13 +203,13 @@ SESTATUS DwpEseUpdater::eSEUpdate_SeqHandler() { case ESE_LS_UPDATE_COMPLETED: case ESE_UPDATE_COMPLETED: { - nfc_nci_IoctlInOutData_t inpOutData; + ese_nxp_IoctlInOutData_t inpOutData; DwpEseUpdater::setDwpEseClientState(ESE_UPDATE_COMPLETED); ALOGD("LSUpdate Thread not required inform NFC to restart"); - memset(&inpOutData, 0x00, sizeof(nfc_nci_IoctlInOutData_t)); + memset(&inpOutData, 0x00, sizeof(ese_nxp_IoctlInOutData_t)); inpOutData.inp.data_source = 2; usleep(50 * 1000); - phNxpNciHal_ioctl(HAL_NFC_IOCTL_ESE_UPDATE_COMPLETE, &inpOutData); + phNxpNciHal_Abort(); } break; } diff --git a/halimpl/hal/phNxpNciHal.cc b/halimpl/hal/phNxpNciHal.cc index b7dcfef..5c4a0c9 100644 --- a/halimpl/hal/phNxpNciHal.cc +++ b/halimpl/hal/phNxpNciHal.cc @@ -30,7 +30,6 @@ #include <phTmlNfc_i2c.h> #include "phNxpNciHal_nciParser.h" #include <EseAdaptation.h> -#include "hal_nxpnfc.h" #include "spi_spm.h" #include <vendor/nxp/nxpnfc/2.0/types.h> #include "Nxp_Features.h" @@ -3671,13 +3670,10 @@ int phNxpNciHal_check_ncicmd_write_window(uint16_t cmd_len, uint8_t* p_cmd) { ******************************************************************************/ int phNxpNciHal_ioctl(long arg, void* p_data) { NXPLOG_NCIHAL_D("%s : enter - arg = %ld", __func__, arg); - nfc_nci_IoctlInOutData_t* pInpOutData = (nfc_nci_IoctlInOutData_t*)p_data; + ese_nxp_IoctlInOutData_t* pInpOutData = (ese_nxp_IoctlInOutData_t*)p_data; int ret = -1; - NFCSTATUS status = NFCSTATUS_FAILED; - long level; if (nxpncihal_ctrl.halStatus == HAL_STATUS_CLOSE && - (arg != HAL_NFC_IOCTL_ESE_JCOP_DWNLD && arg - != HAL_NFC_IOCTL_ESE_UPDATE_COMPLETE && arg != HAL_ESE_IOCTL_NFC_JCOP_DWNLD)) { + (arg != HAL_ESE_IOCTL_NFC_JCOP_DWNLD)) { NFCSTATUS status = NFCSTATUS_FAILED; status = phNxpNciHal_MinOpen(); if (status != NFCSTATUS_SUCCESS) { @@ -3685,44 +3681,11 @@ int phNxpNciHal_ioctl(long arg, void* p_data) { } } switch (arg) { - case HAL_NFC_IOCTL_P61_PWR_MODE: - if(nfcFL.nfcNxpEse) { - status = phTmlNfc_IoCtl(phTmlNfc_e_GetP61PwrMode); - if (NFCSTATUS_FAILED != status) { - if (NULL != p_data) - pInpOutData->out.data.p61CurrentState = (uint16_t)status; - ret = 0; - } - } - break; case HAL_ESE_IOCTL_NFC_JCOP_DWNLD : - NXPLOG_NCIHAL_D("HAL_ESE_IOCTL_NFC_JCOP_DWNLD Enter value is %d: \n",pInpOutData->inp.data.nciCmd.p_cmd[0]); + NXPLOG_NCIHAL_D("HAL_ESE_IOCTL_NFC_JCOP_DWNLD Enter value is %d: \n",pInpOutData->inp.data.nxpCmd.p_cmd[0]); if(gpEseAdapt != NULL) ret = gpEseAdapt->HalIoctl(HAL_ESE_IOCTL_NFC_JCOP_DWNLD,pInpOutData); [[fallthrough]]; - case HAL_NFC_IOCTL_ESE_UPDATE_COMPLETE : - NXPLOG_NCIHAL_D("HAL_NFC_IOCTL_ESE_UPDATE_COMPLETE \n"); - if(p_nfc_stack_cback_backup != NULL) - { - (*p_nfc_stack_cback_backup)((uint32_t)HAL_NFC_STATUS_RESTART, - HAL_NFC_STATUS_OK); - } - else - { - NXPLOG_NCIHAL_D("p_nfc_stack_cback_backup cback NULL \n"); - } - ret = 0; - break; - case HAL_NFC_SET_POWER_SCHEME: - level = pInpOutData->inp.level; - ret = phPalEse_spi_ioctl(phPalEse_e_SetPowerScheme, - gpphTmlNfc_Context->pDevHandle, level); - break; - case HAL_NFC_IOCTL_SET_TRANSIT_CONFIG: - phNxpNciHal_setNxpTransitConfig( - pInpOutData->inp.data.transitConfig.val); - ret = 0; - break; default: NXPLOG_NCIHAL_E("%s : Wrong arg = %ld", __func__, arg); break; @@ -4923,7 +4886,32 @@ void seteSEClientState(uint8_t state) { DwpEseUpdater::setSpiEseClientState(state); } -bool phNxpNciHal_Abort() { return false; } +/****************************************************************************** +** Function phNxpNciHal_Abort +** +** Description This function shall be used to trigger the abort +** +** Parameters None +** +** Returns bool. +** +*******************************************************************************/ +bool phNxpNciHal_Abort() { + bool ret = true; + + NXPLOG_NCIHAL_D("phNxpNciHal_Abort aborting. \n"); + /* When JCOP download is triggered phNxpNciHal_open is blocked, in this case only + we need to abort the libnfc , this can be done only by check the p_nfc_stack_cback_backup + pointer which is assigned before the JCOP download.*/ + if (p_nfc_stack_cback_backup != NULL){ + abort(); + } + else { + ret = false; + NXPLOG_NCIHAL_D("phNxpNciHal_Abort not triggered\n"); + } + return ret; +} bool getJcopUpdateRequired() { return false; } diff --git a/halimpl/hal/phNxpNciHal.h b/halimpl/hal/phNxpNciHal.h index f42ffd3..dc5468f 100644 --- a/halimpl/hal/phNxpNciHal.h +++ b/halimpl/hal/phNxpNciHal.h @@ -22,7 +22,6 @@ #include "NxpNfcCapability.h" #include <vendor/nxp/nxpnfc/2.0/types.h> #include "DwpEseUpdater.h" -#include "hal_nxpnfc.h" #include "EseUpdateChecker.h" using namespace std; @@ -32,6 +31,7 @@ using namespace std; #define NCI_MAX_DATA_LEN 300 #define NCI_POLL_DURATION 500 #define HAL_NFC_ENABLE_I2C_FRAGMENTATION_EVT 0x07 +#define HAL_NFC_POST_MIN_INIT_CPLT_EVT 0x09 #define NXP_STAG_TIMEOUT_BUF_LEN 0x04 /*FIXME:TODO:remove*/ #define NXP_WIREDMODE_RESUME_TIMEOUT_LEN 0x04 #define NFCC_DECIDES 00 @@ -97,6 +97,13 @@ typedef enum { GPIO_CLEAR = 0xFF } phNxpNciHal_GpioInfoState; +enum NxpNfcHalStatus { + /** In case of an error, HCI network needs to be re-initialized */ + HAL_NFC_STATUS_RESTART = 0x30, + HAL_NFC_HCI_NV_RESET = 0x40, + HAL_NFC_CONFIG_ESE_LINK_COMPLETE = 0x50 +}; + typedef struct phNxpNciGpioInfo { phNxpNciHal_GpioInfoState state; uint8_t values[2]; diff --git a/halimpl/hal/phNxpNciHal_ext.cc b/halimpl/hal/phNxpNciHal_ext.cc index 2e92a7b..92cfa65 100644 --- a/halimpl/hal/phNxpNciHal_ext.cc +++ b/halimpl/hal/phNxpNciHal_ext.cc @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "hal_nxpnfc.h" #include "phNxpNciHal_nciParser.h" #include <cutils/properties.h> #include <log/log.h> @@ -109,14 +108,14 @@ void phNxpNciHal_ext_init(void) { ** *******************************************************************************/ void phNxpNciHal_sendRfEvtToEseHal(uint8_t rfEvtType) { - nfc_nci_IoctlInOutData_t inpOutData; + ese_nxp_IoctlInOutData_t inpOutData; gpEseAdapt = &EseAdaptation::GetInstance(); gpEseAdapt->Initialize(); uint8_t rf_state_update[] = {0x00}; - memset(&inpOutData, 0x00, sizeof(nfc_nci_IoctlInOutData_t)); - inpOutData.inp.data.nciCmd.cmd_len = sizeof(rf_state_update); + memset(&inpOutData, 0x00, sizeof(ese_nxp_IoctlInOutData_t)); + inpOutData.inp.data.nxpCmd.cmd_len = sizeof(rf_state_update); rf_state_update[0] = rfEvtType; - memcpy(inpOutData.inp.data.nciCmd.p_cmd, rf_state_update, + memcpy(inpOutData.inp.data.nxpCmd.p_cmd, rf_state_update, sizeof(rf_state_update)); inpOutData.inp.data_source = 2; if (gpEseAdapt != NULL) @@ -364,10 +363,10 @@ NFCSTATUS phNxpNciHal_process_ext_rsp(uint8_t* p_ntf, uint16_t* p_len) { NXPLOG_NCIHAL_D("RF_STATUS_UPDATE_ENABLE : %lu", rf_update_enable); } if (rf_update_enable == 0x01) { - nfc_nci_IoctlInOutData_t inpOutData; - memset(&inpOutData, 0x00, sizeof(nfc_nci_IoctlInOutData_t)); - inpOutData.inp.data.nciCmd.cmd_len = p_ntf[2]; - memcpy(inpOutData.inp.data.nciCmd.p_cmd, p_ntf + 3, p_ntf[2]); + ese_nxp_IoctlInOutData_t inpOutData; + memset(&inpOutData, 0x00, sizeof(ese_nxp_IoctlInOutData_t)); + inpOutData.inp.data.nxpCmd.cmd_len = p_ntf[2]; + memcpy(inpOutData.inp.data.nxpCmd.p_cmd, p_ntf + 3, p_ntf[2]); inpOutData.inp.data_source = 2; if (gpEseAdapt != NULL) gpEseAdapt->HalNfccNtf(HAL_ESE_IOCTL_RF_ACTION_NTF, &inpOutData); 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 |