Lines Matching refs:gpphTmlNfc_Context

49 phTmlNfc_Context_t* gpphTmlNfc_Context = NULL;  variable
89 if (NULL != gpphTmlNfc_Context) { in phTmlNfc_Init()
100 gpphTmlNfc_Context = in phTmlNfc_Init()
103 if (NULL == gpphTmlNfc_Context) { in phTmlNfc_Init()
110 memset(gpphTmlNfc_Context, PH_TMLNFC_RESET_VALUE, in phTmlNfc_Init()
113 gpphTmlNfc_Context->bThreadDone = 1; in phTmlNfc_Init()
116 pConfig, &(gpphTmlNfc_Context->pDevHandle)); in phTmlNfc_Init()
120 gpphTmlNfc_Context->pDevHandle = NULL; in phTmlNfc_Init()
122 gpphTmlNfc_Context->platform_type = in phTmlNfc_Init()
123 gpTransportObj->GetPlatform(gpphTmlNfc_Context->pDevHandle); in phTmlNfc_Init()
124 gpphTmlNfc_Context->nfc_state = NFC_STATE_UNKNOWN; in phTmlNfc_Init()
125 gpphTmlNfc_Context->tReadInfo.bEnable = 0; in phTmlNfc_Init()
126 gpphTmlNfc_Context->tWriteInfo.bEnable = 0; in phTmlNfc_Init()
127 gpphTmlNfc_Context->tReadInfo.bThreadBusy = false; in phTmlNfc_Init()
128 gpphTmlNfc_Context->tWriteInfo.bThreadBusy = false; in phTmlNfc_Init()
130 if (0 != sem_init(&gpphTmlNfc_Context->rxSemaphore, 0, 0)) { in phTmlNfc_Init()
134 } else if (0 != sem_init(&gpphTmlNfc_Context->txSemaphore, 0, 0)) { in phTmlNfc_Init()
136 } else if (0 != sem_init(&gpphTmlNfc_Context->postMsgSemaphore, 0, 0)) { in phTmlNfc_Init()
139 sem_post(&gpphTmlNfc_Context->postMsgSemaphore); in phTmlNfc_Init()
145 gpphTmlNfc_Context->dwTimerId = phOsalNfc_Timer_Create(); in phTmlNfc_Init()
146 if (PH_OSALNFC_TIMER_ID_INVALID != gpphTmlNfc_Context->dwTimerId) { in phTmlNfc_Init()
148 gpphTmlNfc_Context->dwCallbackThreadId = in phTmlNfc_Init()
152 gpphTmlNfc_Context->eConfig = phTmlNfc_e_DisableRetrans; in phTmlNfc_Init()
155 gpphTmlNfc_Context->bRetryCount = in phTmlNfc_Init()
157 gpphTmlNfc_Context->bWriteCbInvoked = false; in phTmlNfc_Init()
220 gpphTmlNfc_Context->eConfig = eConfiguration; in phTmlNfc_ConfigNciPktReTx()
224 gpphTmlNfc_Context->bRetryCount = bRetryCounter; in phTmlNfc_ConfigNciPktReTx()
230 gpphTmlNfc_Context->bRetryCount = in phTmlNfc_ConfigNciPktReTx()
258 pthread_create(&gpphTmlNfc_Context->readerThread, NULL, in phTmlNfc_StartThread()
265 pthread_create(&gpphTmlNfc_Context->writerThread, NULL, in phTmlNfc_StartThread()
288 if ((gpphTmlNfc_Context->dwTimerId == dwTimerId) && (NULL == pContext)) { in phTmlNfc_ReTxTimerCb()
296 gpphTmlNfc_Context->tWriteInfo.bThreadBusy = true; in phTmlNfc_ReTxTimerCb()
297 gpphTmlNfc_Context->tWriteInfo.bEnable = 1; in phTmlNfc_ReTxTimerCb()
299 sem_post(&gpphTmlNfc_Context->txSemaphore); in phTmlNfc_ReTxTimerCb()
320 wStatus = phOsalNfc_Timer_Start(gpphTmlNfc_Context->dwTimerId, in phTmlNfc_InitiateTimer()
354 while (gpphTmlNfc_Context->bThreadDone) { in phTmlNfc_TmlThread()
358 if (-1 == sem_wait(&gpphTmlNfc_Context->rxSemaphore)) { in phTmlNfc_TmlThread()
363 if (1 == gpphTmlNfc_Context->tReadInfo.bEnable) { in phTmlNfc_TmlThread()
372 if (NULL != gpphTmlNfc_Context->pDevHandle) { in phTmlNfc_TmlThread()
375 gpTransportObj->Read(gpphTmlNfc_Context->pDevHandle, temp, 260); in phTmlNfc_TmlThread()
385 sem_post(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_TmlThread()
389 sem_post(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_TmlThread()
391 memcpy(gpphTmlNfc_Context->tReadInfo.pBuffer, temp, dwNoBytesWrRd); in phTmlNfc_TmlThread()
396 gpphTmlNfc_Context->tReadInfo.bEnable = 0; in phTmlNfc_TmlThread()
397 if ((phTmlNfc_e_EnableRetrans == gpphTmlNfc_Context->eConfig) && in phTmlNfc_TmlThread()
398 (0x00 != (gpphTmlNfc_Context->tReadInfo.pBuffer[0] & 0xE0))) { in phTmlNfc_TmlThread()
402 phOsalNfc_Timer_Stop(gpphTmlNfc_Context->dwTimerId); in phTmlNfc_TmlThread()
406 gpphTmlNfc_Context->bWriteCbInvoked = false; in phTmlNfc_TmlThread()
409 if (gpphTmlNfc_Context->tWriteInfo.bThreadBusy) { in phTmlNfc_TmlThread()
414 gpphTmlNfc_Context->tReadInfo.wLength = (uint16_t)(dwNoBytesWrRd); in phTmlNfc_TmlThread()
416 gpphTmlNfc_Context->tReadInfo.pBuffer, in phTmlNfc_TmlThread()
417 gpphTmlNfc_Context->tReadInfo.wLength); in phTmlNfc_TmlThread()
424 tTransactionInfo.pBuff = gpphTmlNfc_Context->tReadInfo.pBuffer; in phTmlNfc_TmlThread()
426 tTransactionInfo.wLength = gpphTmlNfc_Context->tReadInfo.wLength; in phTmlNfc_TmlThread()
439 pthread_mutex_lock(&gpphTmlNfc_Context->wait_busy_lock); in phTmlNfc_TmlThread()
440 if ((gpphTmlNfc_Context->gWriterCbflag == false) && in phTmlNfc_TmlThread()
441 ((gpphTmlNfc_Context->tReadInfo.pBuffer[0] & 0x60) != 0x60)) { in phTmlNfc_TmlThread()
445 pthread_mutex_unlock(&gpphTmlNfc_Context->wait_busy_lock); in phTmlNfc_TmlThread()
447 phTmlNfc_DeferredCall(gpphTmlNfc_Context->dwCallbackThreadId, &tMsg); in phTmlNfc_TmlThread()
488 while (gpphTmlNfc_Context->bThreadDone) { in phTmlNfc_TmlWriterThread()
490 if (-1 == sem_wait(&gpphTmlNfc_Context->txSemaphore)) { in phTmlNfc_TmlWriterThread()
494 if (1 == gpphTmlNfc_Context->tWriteInfo.bEnable) { in phTmlNfc_TmlWriterThread()
498 if (NULL != gpphTmlNfc_Context->pDevHandle) { in phTmlNfc_TmlWriterThread()
500 gpphTmlNfc_Context->tWriteInfo.bEnable = 0; in phTmlNfc_TmlWriterThread()
506 pthread_mutex_lock(&gpphTmlNfc_Context->wait_busy_lock); in phTmlNfc_TmlWriterThread()
507 gpphTmlNfc_Context->gWriterCbflag = false; in phTmlNfc_TmlWriterThread()
509 gpTransportObj->Write(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_TmlWriterThread()
510 gpphTmlNfc_Context->tWriteInfo.pBuffer, in phTmlNfc_TmlWriterThread()
511 gpphTmlNfc_Context->tWriteInfo.wLength); in phTmlNfc_TmlWriterThread()
513 pthread_mutex_unlock(&gpphTmlNfc_Context->wait_busy_lock); in phTmlNfc_TmlWriterThread()
530 gpphTmlNfc_Context->tWriteInfo.pBuffer, in phTmlNfc_TmlWriterThread()
531 gpphTmlNfc_Context->tWriteInfo.wLength); in phTmlNfc_TmlWriterThread()
541 tTransactionInfo.pBuff = gpphTmlNfc_Context->tWriteInfo.pBuffer; in phTmlNfc_TmlWriterThread()
560 if ((phTmlNfc_e_EnableRetrans == gpphTmlNfc_Context->eConfig) && in phTmlNfc_TmlWriterThread()
561 (0x00 != (gpphTmlNfc_Context->tWriteInfo.pBuffer[0] & 0xE0))) { in phTmlNfc_TmlWriterThread()
562 if (gpphTmlNfc_Context->bWriteCbInvoked == false) { in phTmlNfc_TmlWriterThread()
565 phTmlNfc_DeferredCall(gpphTmlNfc_Context->dwCallbackThreadId, in phTmlNfc_TmlWriterThread()
567 gpphTmlNfc_Context->bWriteCbInvoked = true; in phTmlNfc_TmlWriterThread()
572 phTmlNfc_DeferredCall(gpphTmlNfc_Context->dwCallbackThreadId, &tMsg); in phTmlNfc_TmlWriterThread()
575 pthread_mutex_lock(&gpphTmlNfc_Context->wait_busy_lock); in phTmlNfc_TmlWriterThread()
576 gpphTmlNfc_Context->gWriterCbflag = true; in phTmlNfc_TmlWriterThread()
579 pthread_mutex_unlock(&gpphTmlNfc_Context->wait_busy_lock); in phTmlNfc_TmlWriterThread()
587 if ((phTmlNfc_e_EnableRetrans == gpphTmlNfc_Context->eConfig) && in phTmlNfc_TmlWriterThread()
588 (0x00 != (gpphTmlNfc_Context->tWriteInfo.pBuffer[0] & 0xE0))) { in phTmlNfc_TmlWriterThread()
594 gpphTmlNfc_Context->tWriteInfo.bEnable = 0; in phTmlNfc_TmlWriterThread()
620 if (NULL == gpphTmlNfc_Context) { in phTmlNfc_CleanUp()
623 if (NULL != gpphTmlNfc_Context->pDevHandle) { in phTmlNfc_CleanUp()
627 (void)gpTransportObj->NfccReset(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_CleanUp()
632 gpphTmlNfc_Context->bThreadDone = 0; in phTmlNfc_CleanUp()
634 sem_destroy(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_CleanUp()
635 sem_destroy(&gpphTmlNfc_Context->txSemaphore); in phTmlNfc_CleanUp()
636 sem_destroy(&gpphTmlNfc_Context->postMsgSemaphore); in phTmlNfc_CleanUp()
637 pthread_mutex_destroy(&gpphTmlNfc_Context->wait_busy_lock); in phTmlNfc_CleanUp()
638 pthread_cond_destroy(&gpphTmlNfc_Context->wait_busy_condition); in phTmlNfc_CleanUp()
639 gpTransportObj->Close(gpphTmlNfc_Context->pDevHandle); in phTmlNfc_CleanUp()
641 gpphTmlNfc_Context->pDevHandle = NULL; in phTmlNfc_CleanUp()
643 free((void*)gpphTmlNfc_Context); in phTmlNfc_CleanUp()
645 gpphTmlNfc_Context = NULL; in phTmlNfc_CleanUp()
670 if (NULL != gpphTmlNfc_Context) { in phTmlNfc_Shutdown()
672 gpphTmlNfc_Context->bThreadDone = 0; in phTmlNfc_Shutdown()
675 sem_post(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_Shutdown()
677 sem_post(&gpphTmlNfc_Context->txSemaphore); in phTmlNfc_Shutdown()
679 sem_post(&gpphTmlNfc_Context->postMsgSemaphore); in phTmlNfc_Shutdown()
681 sem_post(&gpphTmlNfc_Context->postMsgSemaphore); in phTmlNfc_Shutdown()
683 if (0 != pthread_join(gpphTmlNfc_Context->readerThread, (void**)NULL)) { in phTmlNfc_Shutdown()
686 if (0 != pthread_join(gpphTmlNfc_Context->writerThread, (void**)NULL)) { in phTmlNfc_Shutdown()
736 if (NULL != gpphTmlNfc_Context) { in phTmlNfc_Write()
737 if ((NULL != gpphTmlNfc_Context->pDevHandle) && (NULL != pBuffer) && in phTmlNfc_Write()
739 if (!gpphTmlNfc_Context->tWriteInfo.bThreadBusy) { in phTmlNfc_Write()
741 gpphTmlNfc_Context->tWriteInfo.bThreadBusy = true; in phTmlNfc_Write()
745 gpphTmlNfc_Context->tWriteInfo.pBuffer = pBuffer; in phTmlNfc_Write()
746 gpphTmlNfc_Context->tWriteInfo.wLength = wLength; in phTmlNfc_Write()
747 gpphTmlNfc_Context->tWriteInfo.pThread_Callback = pTmlWriteComplete; in phTmlNfc_Write()
748 gpphTmlNfc_Context->tWriteInfo.pContext = pContext; in phTmlNfc_Write()
752 if (phTmlNfc_e_EnableRetrans == gpphTmlNfc_Context->eConfig) { in phTmlNfc_Write()
757 bCurrentRetryCount = gpphTmlNfc_Context->bRetryCount; in phTmlNfc_Write()
758 gpphTmlNfc_Context->bWriteCbInvoked = false; in phTmlNfc_Write()
761 gpphTmlNfc_Context->tWriteInfo.bEnable = 1; in phTmlNfc_Write()
762 sem_post(&gpphTmlNfc_Context->txSemaphore); in phTmlNfc_Write()
808 if (NULL != gpphTmlNfc_Context) { in phTmlNfc_Read()
809 if ((gpphTmlNfc_Context->pDevHandle != NULL) && (NULL != pBuffer) && in phTmlNfc_Read()
811 if (!gpphTmlNfc_Context->tReadInfo.bThreadBusy) { in phTmlNfc_Read()
813 gpphTmlNfc_Context->tReadInfo.bThreadBusy = true; in phTmlNfc_Read()
817 gpphTmlNfc_Context->tReadInfo.pBuffer = pBuffer; in phTmlNfc_Read()
818 gpphTmlNfc_Context->tReadInfo.wLength = wLength; in phTmlNfc_Read()
819 gpphTmlNfc_Context->tReadInfo.pThread_Callback = pTmlReadComplete; in phTmlNfc_Read()
820 gpphTmlNfc_Context->tReadInfo.pContext = pContext; in phTmlNfc_Read()
824 gpphTmlNfc_Context->tReadInfo.bEnable = 1; in phTmlNfc_Read()
825 ret = sem_getvalue(&gpphTmlNfc_Context->rxSemaphore, &rxSemVal); in phTmlNfc_Read()
829 sem_post(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_Read()
867 gpphTmlNfc_Context->tReadInfo.bEnable = 0; in phTmlNfc_ReadAbort()
870 gpphTmlNfc_Context->tReadInfo.bThreadBusy = false; in phTmlNfc_ReadAbort()
896 gpphTmlNfc_Context->tWriteInfo.bEnable = 0; in phTmlNfc_WriteAbort()
901 gpphTmlNfc_Context->tWriteInfo.bThreadBusy = false; in phTmlNfc_WriteAbort()
928 if (NULL == gpphTmlNfc_Context) { in phTmlNfc_IoCtl()
934 gpTransportObj->NfccReset(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_IoCtl()
942 if (PLATFORM_IF_I3C == gpphTmlNfc_Context->platform_type) { in phTmlNfc_IoCtl()
949 gpTransportObj->NfccReset(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_IoCtl()
952 gpTransportObj->NfccReset(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_IoCtl()
955 gpTransportObj->NfccReset(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_IoCtl()
965 if (gpphTmlNfc_Context->tReadInfo.bEnable) { in phTmlNfc_IoCtl()
966 gpphTmlNfc_Context->tReadInfo.bEnable = 0; in phTmlNfc_IoCtl()
969 gpphTmlNfc_Context->tReadInfo.bEnable = 0; in phTmlNfc_IoCtl()
970 if (PLATFORM_IF_I3C == gpphTmlNfc_Context->platform_type) { in phTmlNfc_IoCtl()
978 gpTransportObj->NfccReset(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_IoCtl()
981 gpTransportObj->NfccReset(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_IoCtl()
984 gpTransportObj->NfccReset(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_IoCtl()
991 gpTransportObj->NfccReset(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_IoCtl()
994 gpTransportObj->NfccReset(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_IoCtl()
999 gpphTmlNfc_Context->tReadInfo.bEnable = 1; in phTmlNfc_IoCtl()
1000 sem_post(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_IoCtl()
1006 gpphTmlNfc_Context->tReadInfo.bEnable = 0; in phTmlNfc_IoCtl()
1007 gpphTmlNfc_Context->nfc_state = in phTmlNfc_IoCtl()
1008 gpTransportObj->GetNfcState(gpphTmlNfc_Context->pDevHandle); in phTmlNfc_IoCtl()
1009 if (PLATFORM_IF_I3C == gpphTmlNfc_Context->platform_type && in phTmlNfc_IoCtl()
1010 gpphTmlNfc_Context->nfc_state == NFC_STATE_FW_DWL) { in phTmlNfc_IoCtl()
1019 wStatus = gpTransportObj->NfccReset(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_IoCtl()
1023 wStatus = gpTransportObj->NfccReset(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_IoCtl()
1027 gpphTmlNfc_Context->tReadInfo.bEnable = 1; in phTmlNfc_IoCtl()
1028 sem_post(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_IoCtl()
1033 gpphTmlNfc_Context->tReadInfo.bEnable = 0; in phTmlNfc_IoCtl()
1037 wStatus = gpTransportObj->NfccReset(gpphTmlNfc_Context->pDevHandle, in phTmlNfc_IoCtl()
1040 gpphTmlNfc_Context->tReadInfo.bEnable = 1; in phTmlNfc_IoCtl()
1041 sem_post(&gpphTmlNfc_Context->rxSemaphore); in phTmlNfc_IoCtl()
1072 if (-1 == sem_wait(&gpphTmlNfc_Context->postMsgSemaphore)) { in phTmlNfc_DeferredCall()
1076 phDal4Nfc_msgsnd(gpphTmlNfc_Context->dwCallbackThreadId, ptWorkerMsg, 0); in phTmlNfc_DeferredCall()
1077 sem_post(&gpphTmlNfc_Context->postMsgSemaphore); in phTmlNfc_DeferredCall()
1096 gpphTmlNfc_Context->tReadInfo.bThreadBusy = false; in phTmlNfc_ReadDeferredCb()
1097 gpphTmlNfc_Context->tReadInfo.pThread_Callback( in phTmlNfc_ReadDeferredCb()
1098 gpphTmlNfc_Context->tReadInfo.pContext, pTransactionInfo); in phTmlNfc_ReadDeferredCb()
1119 gpphTmlNfc_Context->tWriteInfo.bThreadBusy = false; in phTmlNfc_WriteDeferredCb()
1120 gpphTmlNfc_Context->tWriteInfo.pThread_Callback( in phTmlNfc_WriteDeferredCb()
1121 gpphTmlNfc_Context->tWriteInfo.pContext, pTransactionInfo); in phTmlNfc_WriteDeferredCb()
1152 gpphTmlNfc_Context->wait_busy_flag = true; in phTmlNfc_WaitWriteComplete()
1154 ret = pthread_cond_timedwait(&gpphTmlNfc_Context->wait_busy_condition, in phTmlNfc_WaitWriteComplete()
1155 &gpphTmlNfc_Context->wait_busy_lock, in phTmlNfc_WaitWriteComplete()
1177 if (gpphTmlNfc_Context->wait_busy_flag == true) { in phTmlNfc_SignalWriteComplete()
1179 gpphTmlNfc_Context->wait_busy_flag = false; in phTmlNfc_SignalWriteComplete()
1181 ret = pthread_cond_signal(&gpphTmlNfc_Context->wait_busy_condition); in phTmlNfc_SignalWriteComplete()
1205 memset(&gpphTmlNfc_Context->wait_busy_condition, 0, in phTmlNfc_WaitReadInit()
1206 sizeof(gpphTmlNfc_Context->wait_busy_condition)); in phTmlNfc_WaitReadInit()
1207 pthread_mutex_init(&gpphTmlNfc_Context->wait_busy_lock, NULL); in phTmlNfc_WaitReadInit()
1208 ret = pthread_cond_init(&gpphTmlNfc_Context->wait_busy_condition, &attr); in phTmlNfc_WaitReadInit()
1281 if (NULL != gpphTmlNfc_Context) { in phTmlNfc_WaitForIRQLow()
1283 irq_state = gpTransportObj->GetIrqState(gpphTmlNfc_Context->pDevHandle); in phTmlNfc_WaitForIRQLow()