unsigned int dmaRxCompletion(unsigned short usbDevInst, unsigned int ulEndpoint ) { unsigned int bufferAdd; unsigned int length; usbInstance *usbInstance; hostPacketDesc *rx_bd =0;; usbInstance = &(cppiInfo.usbInst[usbDevInst]); ulEndpoint = USB_EP_TO_INDEX(ulEndpoint); /*read the compltetion queue */ rx_bd = (hostPacketDesc *)Cppi41DmaReadCompletionQueue(usbDevInst, usbInstance ->rxEndPoint[ulEndpoint].complettionq); /*Fush the cache to update the BD */ CacheInv((unsigned int)rx_bd, sizeof(hostPacketDesc)); bufferAdd = rx_bd->buffAdd; length = rx_bd->buffLength; /*Flush the cache to update the buffer */ CacheInv(bufferAdd, length); putFreeBd(rx_bd); return bufferAdd; }
/* ** VPIF Interrupt service routine. */ static void VPIFIsr(void) { #ifdef _TMS320C6X IntEventClear(SYS_INT_VPIF_INT); #else IntSystemStatusClear(SYS_INT_VPIF); #endif /* If previously captured frame not processed, clear this interrupt and return */ if (!processed) { VPIFInterruptStatusClear(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0); return; } /* buffcount represents buffer to be given to capture driver and * buffcount2 represents the newly captured buffer to be processed */ processed = 0; captured = 0; buffcount++; buffcount2 = buffcount - 1; /* Currently only two buffers are being used for capture */ if (buffcount == 2) buffcount = 0; /* Invalidate the buffers before giving to capture driver*/ #ifdef _TMS320C6X CacheInv((unsigned int) buff_luma[buffcount], CAPTURE_IMAGE_WIDTH * CAPTURE_IMAGE_HEIGHT * 2); CacheInv((unsigned int) buff_chroma[buffcount], CAPTURE_IMAGE_WIDTH * CAPTURE_IMAGE_HEIGHT * 2); #else CP15ICacheFlushBuff((unsigned int) buff_luma[buffcount], CAPTURE_IMAGE_WIDTH * CAPTURE_IMAGE_HEIGHT * 2); CP15ICacheFlushBuff((unsigned int) buff_chroma[buffcount], CAPTURE_IMAGE_WIDTH * CAPTURE_IMAGE_HEIGHT * 2); #endif /* Initialize buffer addresses for a new frame*/ VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD, VPIF_LUMA, (unsigned int) buff_luma[buffcount], CAPTURE_IMAGE_WIDTH*2); VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD, VPIF_CHROMA, (unsigned int) buff_chroma[buffcount], CAPTURE_IMAGE_WIDTH*2); VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD, VPIF_LUMA, (unsigned int) (buff_luma[buffcount] + CAPTURE_IMAGE_WIDTH), CAPTURE_IMAGE_WIDTH*2); VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD, VPIF_CHROMA, (unsigned int) (buff_chroma[buffcount] + CAPTURE_IMAGE_WIDTH), CAPTURE_IMAGE_WIDTH*2); /* Initialize buffer addresses with the captured frame ready to be processed */ videoTopC = buff_chroma[buffcount2]; videoTopY = buff_luma[buffcount2]; captured = 1; /* clear interrupt */ VPIFInterruptStatusClear(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0); }
unsigned int dmaTxCompletion(unsigned short usbDevInst, unsigned int ulEndpoint ) { hostPacketDesc *completed_bd; unsigned int ulRegister; unsigned int state; unsigned int packetid; usbInstance *usbInstance; usbInstance = &(cppiInfo.usbInst[usbDevInst]); ulRegister = USB_O_TXCSRL1 + EP_OFFSET( ulEndpoint); ulEndpoint = USB_EP_TO_INDEX(ulEndpoint); /*read the compltetion queue */ completed_bd = (hostPacketDesc *)Cppi41DmaReadCompletionQueue(usbDevInst, usbInstance ->txEndPoint[ulEndpoint].complettionq); /*Get the packet ID to update the DMA status */ packetid = completed_bd->packetId; if(packetid == EOP) state = DMA_TX_COMPLETED; else state = DMA_TX_IN_PROGRESS; /*wait till Tx completion */ if(state == DMA_TX_COMPLETED) while ((HWREGH(usbInstance->usbBaseAddress + ulRegister) & 0x2) == 0x02); CacheInv((unsigned int)completed_bd->buffAdd, sizeof(completed_bd->buffAdd)); cppiDmaFreenBuffer((unsigned int *)completed_bd->buffAdd); completed_bd->buffAdd = 0; /*put the free buffer */ putFreeBd(completed_bd); return state; }