/*! * ======== VirtQueue_getAvailBuf ======== */ Int16 VirtQueue_getAvailBuf(VirtQueue_Handle vq, Void **buf) { UInt16 head; Log_print5(Diags_USER1, "getAvailBuf vq: 0x%x %d %d %d 0x%x\n", (IArg)vq, vq->last_avail_idx, vq->vring.avail->idx, vq->vring.num, (IArg)&vq->vring.avail); /* There's nothing available? */ if (vq->last_avail_idx == vq->vring.avail->idx) { /* We need to know about added buffers */ vq->vring.used->flags &= ~VRING_USED_F_NO_NOTIFY; return (-1); } /* No need to know be kicked about added buffers anymore */ vq->vring.used->flags |= VRING_USED_F_NO_NOTIFY; /* * Grab the next descriptor number they're advertising, and increment * the index we've seen. */ head = vq->vring.avail->ring[vq->last_avail_idx++ % vq->vring.num]; *buf = mapPAtoVA(vq->vring.desc[head].addr); return (head); }
/* * ======== SPICC26XXDMA_configDMA ======== * This functions configures the transmit and receive DMA channels for a given * SPI_Handle and SPI_Transaction * * @pre Function assumes that the handle and transaction is not NULL */ static void SPICC26XXDMA_configDMA(SPI_Handle handle, SPI_Transaction *transaction) { SPICC26XX_Object *object; SPICC26XX_HWAttrs const *hwAttrs; volatile tDMAControlTable *dmaControlTableEntry; uint16_t numberOfBytes; /* Get the pointer to the object and hwAttrs */ object = handle->object; hwAttrs = handle->hwAttrs; /* Calculate the number of bytes for the transfer */ numberOfBytes = ((uint16_t)(transaction->count) << (object->frameSize)); /* Setup RX side */ /* Set pointer to Rx control table entry */ dmaControlTableEntry = (hwAttrs->baseAddr == SSI0_BASE ? &dmaRxControlTableEntry0 : &dmaRxControlTableEntry1); if (transaction->rxBuf) { dmaControlTableEntry->ui32Control = dmaRxConfig[object->frameSize]; dmaControlTableEntry->pvDstEndAddr = (void *)((uint32_t)(transaction->rxBuf) + numberOfBytes - 1); } else { dmaControlTableEntry->ui32Control = dmaNullConfig[object->frameSize]; dmaControlTableEntry->pvDstEndAddr = (void *) &(object->scratchBuf); } dmaControlTableEntry->pvSrcEndAddr = (void *)(hwAttrs->baseAddr + SSI_O_DR); dmaControlTableEntry->ui32Control |= UDMACC26XX_SET_TRANSFER_SIZE((uint16_t)transaction->count); /* Setup TX side */ /* Set pointer to Tx control table entry */ dmaControlTableEntry = (hwAttrs->baseAddr == SSI0_BASE ? &dmaTxControlTableEntry0 : &dmaTxControlTableEntry1); if (transaction->txBuf) { dmaControlTableEntry->ui32Control = dmaTxConfig[object->frameSize]; dmaControlTableEntry->pvSrcEndAddr = (void *)((uint32_t)(transaction->txBuf) + numberOfBytes - 1); } else { dmaControlTableEntry->ui32Control = dmaNullConfig[object->frameSize]; dmaControlTableEntry->pvSrcEndAddr = (void *) &(hwAttrs->defaultTxBufValue); } dmaControlTableEntry->pvDstEndAddr = (void *)(hwAttrs->baseAddr + SSI_O_DR); dmaControlTableEntry->ui32Control |= UDMACC26XX_SET_TRANSFER_SIZE((uint16_t)transaction->count); /* Enable the channels */ UDMACC26XX_channelEnable(object->udmaHandle, (hwAttrs->rxChannelBitMask) | (hwAttrs->txChannelBitMask)); /* Enable the required DMA channels in the SPI module to start the transaction */ SSIDMAEnable(hwAttrs->baseAddr, SSI_DMA_TX | SSI_DMA_RX); Log_print1(Diags_USER1,"SPI:(%p) DMA transfer enabled", hwAttrs->baseAddr); Log_print5(Diags_USER2,"SPI:(%p) DMA transaction: %p, " "rxBuf: %p; txBuf: %p; Count: %d", hwAttrs->baseAddr, (UArg)transaction, (UArg)transaction->rxBuf, (UArg)transaction->txBuf, (UArg)transaction->count); }
/* * ======== UNIVERSAL_processAsync ======== */ XDAS_Int32 UNIVERSAL_processAsync(UNIVERSAL_Handle handle, XDM1_BufDesc *inBufs, XDM1_BufDesc *outBufs, XDM1_BufDesc *inOutBufs, IUNIVERSAL_InArgs *inArgs, IUNIVERSAL_OutArgs *outArgs) { XDAS_Int32 retVal = UNIVERSAL_EFAIL; /* * Note, we assign "VISA_isChecked()" results to a local variable * rather than repeatedly query it throughout this fxn because * someday we may allow dynamically changing the global * 'VISA_isChecked()' value on the fly. If we allow that, we need * to ensure the value stays consistent in the context of this * call. */ Bool checked = VISA_isChecked(); Log_print5(Diags_ENTRY, "[+E] UNIVERSAL_processAsync> " "Enter (handle=0x%x, inBufs=0x%x, outBufs=0x%x, inArgs=0x%x, " "outArgs=0x%x)", (IArg)handle, (IArg)inBufs, (IArg)outBufs, (IArg)inArgs, (IArg)outArgs); if (handle) { IUNIVERSAL_Handle alg = VISA_getAlgHandle((VISA_Handle)handle); if (alg != NULL) { if (checked) { /* validate inArgs and outArgs */ XdmUtils_validateExtendedStruct(inArgs, sizeof(inArgs), "inArgs"); XdmUtils_validateExtendedStruct(outArgs, sizeof(outArgs), "outArgs"); /* Validate inBufs and outBufs. */ XdmUtils_validateSparseBufDesc1(inBufs, "inBufs"); XdmUtils_validateSparseBufDesc1(outBufs, "outBufs"); /* * Zero out the outArgs struct (except for .size field); * it's write-only to the codec, so the app shouldn't pass * values through it, nor should the codec expect to * receive values through it. */ memset((void *)((XDAS_Int32)(outArgs) + sizeof(outArgs->size)), 0, (sizeof(*outArgs) - sizeof(outArgs->size))); } retVal = processAsync(alg, inBufs, outBufs, inOutBufs, inArgs, outArgs); } } Log_print2(Diags_EXIT, "[+X] UNIVERSAL_processAsync> " "Exit (handle=0x%x, retVal=0x%x)", (IArg)handle, (IArg)retVal); return (retVal); }
/* * ======== VIDDEC2_processWait ======== */ XDAS_Int32 VIDDEC2_processWait(VIDDEC2_Handle handle, XDM1_BufDesc *inBufs, XDM_BufDesc *outBufs, VIDDEC2_InArgs *inArgs, VIDDEC2_OutArgs *outArgs, UInt timeout) { XDAS_Int32 retVal = VIDDEC2_EFAIL; VIDDEC2_InArgs refInArgs; /* * Note, we do this because someday we may allow dynamically changing * the global 'VISA_isChecked()' value on the fly. If we allow that, * we need to ensure the value stays consistent in the context of this call. */ Bool checked = VISA_isChecked(); Log_print5(Diags_ENTRY, "[+E] VIDDEC2_processWait> " "Enter (handle=0x%x, inBufs=0x%x, outBufs=0x%x, inArgs=0x%x, " "outArgs=0x%x)", (IArg)handle, (IArg)inBufs, (IArg)outBufs, (IArg)inArgs, (IArg)outArgs); if (handle) { IVIDDEC2_Handle alg = VISA_getAlgHandle((VISA_Handle)handle); if (alg != NULL) { if (checked) { /* * Make a reference copy of inArgs so we can check that * the codec didn't modify them during process(). */ refInArgs = *inArgs; } retVal = processWait(alg, inBufs, outBufs, inArgs, outArgs, timeout); if (checked) { /* ensure the codec didn't modify the read-only inArgs */ if (memcmp(&refInArgs, inArgs, sizeof(*inArgs)) != 0) { Log_print1(Diags_USER7, "[+7] ERROR> codec (0x%x) modified read-only inArgs " "struct!", (IArg)handle); } } } } Log_print2(Diags_EXIT, "[+X] VIDDEC2_processWait> " "Exit (handle=0x%x, retVal=0x%x)", (IArg)handle, (IArg)retVal); return (retVal); }
/* * ======== AUDDEC1_processAsync ======== */ XDAS_Int32 AUDDEC1_processAsync(AUDDEC1_Handle handle, XDM1_BufDesc *inBufs, XDM1_BufDesc *outBufs, AUDDEC1_InArgs *inArgs, AUDDEC1_OutArgs *outArgs) { XDAS_Int32 retVal = AUDDEC1_EFAIL; /* * Note, we do this because someday we may allow dynamically changing * the global 'VISA_isChecked()' value on the fly. If we allow that, * we need to ensure the value stays consistent in the context of this call. */ Bool checked = VISA_isChecked(); Log_print5(Diags_ENTRY, "[+E] AUDDEC1_processAsync> " "Enter (handle=0x%x, inBufs=0x%x, outBufs=0x%x, inArgs=0x%x, " "outArgs=0x%x)", (IArg)handle, (IArg)inBufs, (IArg)outBufs, (IArg)inArgs, (IArg)outArgs); if (handle) { IAUDDEC1_Handle alg = VISA_getAlgHandle((VISA_Handle)handle); if (alg != NULL) { if (checked) { /* * Validate inBufs and outBufs. */ XdmUtils_validateSparseBufDesc1(inBufs, "inBufs"); XdmUtils_validateSparseBufDesc1(outBufs, "outBufs"); /* * Zero out the outArgs struct (except for .size field); * it's write-only to the codec, so the app shouldn't pass * values through it, nor should the codec expect to * receive values through it. */ memset((void *)((XDAS_Int32)(outArgs) + sizeof(outArgs->size)), 0, (sizeof(*outArgs) - sizeof(outArgs->size))); } retVal = processAsync(alg, inBufs, outBufs, inArgs, outArgs); } } Log_print2(Diags_EXIT, "[+X] AUDDEC1_processAsync> " "Exit (handle=0x%x, retVal=0x%x)", (IArg)handle, (IArg)retVal); return (retVal); }
/* * ======== VIDENC1_processAsync ======== */ XDAS_Int32 VIDENC1_processAsync(VIDENC1_Handle handle, IVIDEO1_BufDescIn *inBufs, XDM_BufDesc *outBufs, IVIDENC1_InArgs *inArgs, IVIDENC1_OutArgs *outArgs) { XDAS_Int32 retVal = VIDENC1_EFAIL; /* * Note, we do this because someday we may allow dynamically changing * the global 'VISA_isChecked()' value on the fly. If we allow that, * we need to ensure the value stays consistent in the context of this call. */ Bool checked = VISA_isChecked(); Log_print5(Diags_ENTRY, "[+E] VIDENC1_processAsync> " "Enter (handle=0x%x, inBufs=0x%x, outBufs=0x%x, inArgs=0x%x, " "outArgs=0x%x)", (IArg)handle, (IArg)inBufs, (IArg)outBufs, (IArg)inArgs, (IArg)outArgs); if (handle) { IVIDENC1_Handle alg = VISA_getAlgHandle((VISA_Handle)handle); if (alg != NULL) { if (checked) { /* validate inArgs with ranges. */ if (inArgs->inputID == 0) { Log_print2(Diags_USER7, "[+7] ERROR> app provided codec (0x%x) with out of range " "inArgs->inputID field (0x%x)", (IArg)alg, (IArg)(inArgs->inputID)); } /* Validate inBufs and outBufs. */ /* TBD XdmUtils_validateVideoBufDesc1(inBufs, "inBufs"); */ XdmUtils_validateSparseBufDesc(outBufs, "outBufs"); } retVal = processAsync(alg, inBufs, outBufs, inArgs, outArgs); } } Log_print2(Diags_EXIT, "[+X] VIDENC1_processAsync> " "Exit (handle=0x%x, retVal=0x%x)", (IArg)handle, (IArg)retVal); return (retVal); }
/* * ======== getPhysicalAddress ======== */ static UInt32 getPhysicalAddress(UInt32 virtualAddress, UInt32 sizeInBytes) { UInt32 physicalAddress = 0; ContigBuf *cb; Log_print2(Diags_USER1, "[+1] Memory__getPhysicalAddress> " "Enter(virtAddr=0x%x, size=0x%x)", (IArg)virtualAddress, (IArg)sizeInBytes); for (cb = contigBufList; cb != NULL; cb = cb->next) { UInt32 startCurrent = cb->virtualAddress; UInt32 endCurrent = startCurrent + cb->sizeInBytes; UInt32 startSubmitted = virtualAddress; UInt32 endSubmitted = virtualAddress + sizeInBytes; /* check if the submitted contigbuf is a subset of (or matches) current * contigbuf. */ if (startCurrent <= startSubmitted && endCurrent >= endSubmitted) { /* case 1: { [ ] } */ Log_print5(Diags_USER1, "[+1] Memory__getPhysicalAddress> " "found in cb(Sc=0x%x, Ec=0x%x, Ss=0x%x, Es=0x%x, PSc=0x%x)", (IArg)startCurrent, (IArg)endCurrent, (IArg)startSubmitted, (IArg)endSubmitted, (IArg)(cb->physicalAddress)); physicalAddress = cb->physicalAddress + (startSubmitted - startCurrent); break; /* result: ^ */ } } Log_print1(Diags_USER1, "[+1] Memory__getPhysicalAddress> " "returning physAddr=0x%x", (IArg)physicalAddress); return physicalAddress; }
/* * ======== Algorithm_create ======== */ Algorithm_Handle Algorithm_create(IALG_Fxns *fxns, Void *idma3FxnsVoid, Void *iresFxnsVoid, IALG_Params *params, Algorithm_Attrs *attrs) { Algorithm_Obj *pObject = NULL; IDMA3_Fxns *idma3Fxns = (IDMA3_Fxns *)idma3FxnsVoid; IRES_Fxns *iresFxns = (IRES_Fxns *)iresFxnsVoid; IRES_Status iresStatus; Log_print5(Diags_ENTRY, "[+E] Algorithm_create> Enter(" "fxns=0x%x, idma3Fxns=0x%x, iresFxns=0x%x, params=0x%x, " "attrs=0x%x)", (IArg)fxns, (IArg)idma3Fxns, (IArg)iresFxns, (IArg)params, (IArg)attrs); assert(attrs != NULL); pObject = Memory_alloc(sizeof(Algorithm_Obj), NULL); if (pObject == NULL) { Log_print0(Diags_USER7, "[+7] Algorithm_create> " "Alloc for a small object FAILED -- out of memory?"); goto Algorithm_create_return; } /* * Note that we don't have to validate groupId as that's done at * config time. */ pObject->idma3Fxns = NULL; pObject->iresFxns = NULL; pObject->groupId = attrs->groupId; /* Call appropriate DSKT2 function, depending on attrs->useExtHeap */ if (attrs->useExtHeap == FALSE) { /* * Create alg normally, attempting to allocate algorithm memory * in the requested memory spaces. */ pObject->alg = DSKT2_createAlg(attrs->groupId, fxns, NULL, params); } else { /* * Create alg with all algorithm memory allocated in external memory. */ pObject->alg = DSKT2_createAlgExt(attrs->groupId, fxns, NULL, params); } if (pObject->alg == NULL) { Log_print0(Diags_USER7, "[+7] Algorithm_create> " "Algorithm creation FAILED; make sure that 1) alg params are " "correct/appropriate, 2) there is enough internal and external " "algorithm memory available -- check DSKT2 settings for heap " "assignments and scratch allocation"); Algorithm_delete(pObject); pObject = NULL; goto Algorithm_create_return; } /* If alg implements IRES, allocate resources */ if (iresFxns != NULL) { iresStatus = RMAN_assignResources(pObject->alg, iresFxns, pObject->groupId); if (iresStatus != IRES_OK) { Log_print1(Diags_USER7, "[+7] Algorithm_create> Assignment of " "alg resources through RMAN FAILED (0x%x)", (IArg)iresStatus); Algorithm_delete(pObject); pObject = NULL; goto Algorithm_create_return; } pObject->iresFxns = iresFxns; } Algorithm_create_return: Log_print1(Diags_EXIT, "[+X] Algorithm_create> return (0x%x)", (IArg)pObject); return (pObject); }
/* * ======== VIDDEC1_process ======== * This method must be the same for both local and remote invocation; * each call site in the client might be calling different implementations * (one that marshalls & sends and one that simply calls). This API * abstracts *all* video decoders (both high and low complexity * decoders are invoked using this method). */ XDAS_Int32 VIDDEC1_process(VIDDEC1_Handle handle, XDM1_BufDesc *inBufs, XDM_BufDesc *outBufs, VIDDEC1_InArgs *inArgs, VIDDEC1_OutArgs *outArgs) { XDAS_Int32 retVal = VIDDEC1_EFAIL; VIDDEC1_InArgs refInArgs; Int32 i; /* * Note, we assign "VISA_isChecked()" results to a local variable * rather than repeatedly query it throughout this fxn because * someday we may allow dynamically changing the global * 'VISA_isChecked()' value on the fly. If we allow that, we need * to ensure the value stays consistent in the context of this * call. */ Bool checked = VISA_isChecked(); if (checked) { /* Ensure inArgs and outArgs are non-NULL, per the XDM spec */ if ((!(XdmUtils_validateExtendedStruct(inArgs, sizeof(*inArgs), "inArgs"))) || (!(XdmUtils_validateExtendedStruct(outArgs, sizeof(*outArgs), "outArgs")))) { /* for safety, return here before dereferencing and crashing */ return (retVal); } } Log_print5(Diags_ENTRY, "[+E] VIDDEC1_process> " "Enter (handle=0x%x, inBufs=0x%x, outBufs=0x%x, inArgs=0x%x, " "outArgs=0x%x)", (IArg)handle, (IArg)inBufs, (IArg)outBufs, (IArg)inArgs, (IArg)outArgs); if (handle) { IVIDDEC1_Fxns *fxns = (IVIDDEC1_Fxns *)VISA_getAlgFxns((VISA_Handle)handle); IVIDDEC1_Handle alg = VISA_getAlgHandle((VISA_Handle)handle); if ((fxns != NULL) && (alg != NULL)) { if (checked) { /* validate inArgs with ranges. */ if (inArgs->inputID == 0) { Log_print2(Diags_USER7, "[+7] ERROR> app provided codec (0x%x) with out of range " "inArgs->inputID field (0x%x)", (IArg)alg, (IArg)(inArgs->inputID)); } /* * Validate inBufs and outBufs. */ XdmUtils_validateSparseBufDesc1(inBufs, "inBufs"); XdmUtils_validateSparseBufDesc(outBufs, "outBufs"); /* * Make a reference copy of inArgs so we can check that * the codec didn't modify them during process(). */ refInArgs = *inArgs; } //Log_printf(ti_sdo_ce_dvtLog, "%s", (Arg)"VIDDEC1:process", // (Arg)handle, (Arg)0); VISA_enter((VISA_Handle)handle); retVal = fxns->process(alg, inBufs, outBufs, inArgs, outArgs); VISA_exit((VISA_Handle)handle); if (checked) { /* ensure the codec didn't modify the read-only inArgs */ if (memcmp(&refInArgs, inArgs, sizeof(*inArgs)) != 0) { Log_print1(Diags_USER7, "[+7] ERROR> codec (0x%x) modified read-only inArgs " "struct!", (IArg)handle); } /* only check these on successful return */ if ((retVal == IVIDDEC1_EOK) || (!(XDM_ISFATALERROR( outArgs->decodedBufs.extendedError)))) { /* Validate outArgs->decodedBufs */ XdmUtils_validateVideo1BufDesc(&(outArgs->decodedBufs), "decodedBufs"); } /* Validate outArgs->displayBufs */ for (i = 0; ((outArgs->outputID[i] != 0) && (i < XDM_MAX_IO_BUFFERS)); i++) { if ((retVal == IVIDDEC1_EOK) || (!(XDM_ISFATALERROR(outArgs-> displayBufs[i].extendedError)))) { XdmUtils_validateVideo1BufDesc(&(outArgs->displayBufs[i]), "displayBufs"); } } } } } Log_print2(Diags_EXIT, "[+X] VIDDEC1_process> " "Exit (handle=0x%x, retVal=0x%x)", (IArg)handle, (IArg)retVal); return (retVal); }
/* * ======== VIDDEC_process ======== * This method must be the same for both local and remote invocation; * each call site in the client might be calling different implementations * (one that marshalls & sends and one that simply calls). This API * abstracts *all* video decoders (both high and low complexity * decoders are invoked using this method). */ XDAS_Int32 VIDDEC_process(VIDDEC_Handle handle, XDM_BufDesc *inBufs, XDM_BufDesc *outBufs, VIDDEC_InArgs *inArgs, VIDDEC_OutArgs *outArgs) { XDAS_Int32 retVal = VIDDEC_EFAIL; VIDDEC_InArgs refInArgs; /* * Note, we assign "VISA_isChecked()" results to a local variable * rather than repeatedly query it throughout this fxn because * someday we may allow dynamically changing the global * 'VISA_isChecked()' value on the fly. If we allow that, we need * to ensure the value stays consistent in the context of this * call. */ Bool checked = VISA_isChecked(); if (checked) { /* Ensure inArgs and outArgs are non-NULL, per the XDM spec */ if ((!(XdmUtils_validateExtendedStruct(inArgs, sizeof(*inArgs), "inArgs"))) || (!(XdmUtils_validateExtendedStruct(outArgs, sizeof(*outArgs), "outArgs")))) { /* for safety, return here before dereferencing and crashing */ return (retVal); } } Log_print5(Diags_ENTRY, "[+E] VIDDEC_process> " "Enter (handle=0x%x, inBufs=0x%x, outBufs=0x%x, inArgs=0x%x, " "outArgs=0x%x)", (IArg)handle, (IArg)inBufs, (IArg)outBufs, (IArg)inArgs, (IArg)outArgs); if (handle) { IVIDDEC_Fxns *fxns = (IVIDDEC_Fxns *)VISA_getAlgFxns((VISA_Handle)handle); IVIDDEC_Handle alg = VISA_getAlgHandle((VISA_Handle)handle); if (fxns && (alg != NULL)) { if (checked) { /* * Zero out the outArgs struct (except for .size field); * it's write-only to the codec, so the app shouldn't pass * values through it, nor should the codec expect to * receive values through it. */ memset((void *)((XDAS_Int32)(outArgs) + sizeof(outArgs->size)), 0, (sizeof(*outArgs) - sizeof(outArgs->size))); /* * Make a reference copy of inArgs so we can check that * the codec didn't modify them during process(). */ refInArgs = *inArgs; } //Log_printf(ti_sdo_ce_dvtLog, "%s", (Arg)"VIDDEC:process", // (Arg)handle, (Arg)0); VISA_enter((VISA_Handle)handle); retVal = fxns->process(alg, inBufs, outBufs, inArgs, outArgs); VISA_exit((VISA_Handle)handle); if (checked) { /* ensure the codec didn't modify the read-only inArgs */ if (memcmp(&refInArgs, inArgs, sizeof(*inArgs)) != 0) { Log_print1(Diags_USER7, "[+7] ERROR> codec (0x%x) modified read-only inArgs " "struct!", (IArg)handle); } /* Validate outArgs->displayBufs */ XdmUtils_validateVideoBufDesc(&(outArgs->displayBufs), "displayBufs"); } } } Log_print2(Diags_EXIT, "[+X] VIDDEC_process> " "Exit (handle=0x%x, retVal=0x%x)", (IArg)handle, (IArg)retVal); return (retVal); }
/* * ======== VIDENCCOPY_TI_process ======== */ XDAS_Int32 VIDENCCOPY_TI_process(IVIDENC_Handle h, XDM_BufDesc *inBufs,XDM_BufDesc *outBufs, IVIDENC_InArgs *inArgs, IVIDENC_OutArgs *outArgs) { XDAS_Int32 curBuf; XDAS_UInt32 minSamples; #ifdef USE_ACPY3 const Uint32 maxTransferChunkSize = 0xffff; Uint32 thisTransferChunkSize = 0x0; Uint32 remainingTransferChunkSize; Uint32 thisTransferSrcAddr, thisTransferDstAddr; ACPY3_Params params; VIDENCCOPY_TI_Obj *videncObj = (VIDENCCOPY_TI_Obj *)h; #endif Log_print5(Diags_ENTRY, "[+E] VIDENCCOPY_TI_process(0x%x, 0x%x, 0x%x, " "0x%x, 0x%x)", (IArg)h, (IArg)inBufs, (IArg)outBufs, (IArg)inArgs, (IArg)outArgs); /* validate arguments - this codec only supports "base" xDM. */ if ((inArgs->size != sizeof(*inArgs)) || (outArgs->size != sizeof(*outArgs))) { Log_print2(Diags_ENTRY, "[+E] VIDENCCOPY_TI_process, unsupported size (0x%x, 0x%x)", (IArg)(inArgs->size), (IArg)(outArgs->size)); return (IVIDENC_EFAIL); } #ifdef USE_ACPY3 /* * Activate Channel scratch DMA channels. */ //ACPY3_activate(videncObj->dmaHandle1D1D8B); #endif /* outArgs->bytesGenerated reports the total number of bytes generated */ outArgs->bytesGenerated = 0; /* * A couple constraints for this simple "copy" codec: * - Video encoding presumes a single input buffer, so only one input * buffer will be encoded, regardless of inBufs->numBufs. * - Given a different size of an input and output buffers, only * encode (i.e., copy) the lesser of the sizes. */ for (curBuf = 0; (curBuf < inBufs->numBufs) && (curBuf < outBufs->numBufs); curBuf++) { /* there's an available in and out buffer, how many samples? */ minSamples = inBufs->bufSizes[curBuf] < outBufs->bufSizes[curBuf] ? inBufs->bufSizes[curBuf] : outBufs->bufSizes[curBuf]; #ifdef USE_ACPY3 #if 0 thisTransferSrcAddr = (Uint32)inBufs->bufs[curBuf]; thisTransferDstAddr = (Uint32)outBufs->bufs[curBuf]; remainingTransferChunkSize = minSamples; while (remainingTransferChunkSize > 0) { if (remainingTransferChunkSize > maxTransferChunkSize) { thisTransferChunkSize = maxTransferChunkSize; } else { thisTransferChunkSize = remainingTransferChunkSize; } /* Configure the logical channel */ params.transferType = ACPY3_1D1D; params.srcAddr = (void *)thisTransferSrcAddr; params.dstAddr = (void *)thisTransferDstAddr; params.elementSize = thisTransferChunkSize; params.numElements = 1; params.waitId = 0; params.numFrames = 1; remainingTransferChunkSize -= thisTransferChunkSize; thisTransferSrcAddr += thisTransferChunkSize; thisTransferDstAddr += thisTransferChunkSize; /* Configure logical dma channel */ ACPY3_configure(videncObj->dmaHandle1D1D8B, ¶ms, 0); /* Use DMA to copy data */ ACPY3_start(videncObj->dmaHandle1D1D8B); /* wait for transfer to finish */ ACPY3_wait(videncObj->dmaHandle1D1D8B); } Log_print1(Diags_USER2, "[+2] VIDENCCOPY_TI_process> " "ACPY3 Processed %d bytes.", (IArg)minSamples); #endif #else Log_print3(Diags_USER2, "[+2] VIDENCCOPY_TI_process> " "memcpy (0x%x, 0x%x, %d)", (IArg)(outBufs->bufs[curBuf]), (IArg)(inBufs->bufs[curBuf]), (IArg)minSamples); /* process the data: read input, produce output */ memcpy(outBufs->bufs[curBuf], inBufs->bufs[curBuf], minSamples); #endif outArgs->bytesGenerated += minSamples; } #ifdef USE_ACPY3 /* * Deactivate Channel scratch DMA channels. */ //ACPY3_deactivate(videncObj->dmaHandle1D1D8B); //videncObj->p_data //avi mem runOnce(videncObj->p_data, videncObj->p_ddr_data, videncObj->p_DARAM0, videncObj->dmaHandle1D1D8B); DspModule(inBufs->bufs[0], outBufs->bufs[0]); //memcpy(outBufs->bufs[0] + 8,&(videncObj->p_DARAM0),4); runOver(); #endif /* Fill out the rest of the outArgs struct */ outArgs->extendedError = 0; outArgs->encodedFrameType = 0; /* TODO */ outArgs->inputFrameSkip = IVIDEO_FRAME_ENCODED; outArgs->reconBufs.numBufs = 0; /* important: indicate no reconBufs */ return (IVIDENC_EOK); }
/** * @name DomxTunnelMgr_mapTunnelComponentPeerHandles * @brief Map component handle to peer handles to be used in tunnel request * @param hTunneledOutput : Handle to output port component * @param hTunneledInput : Handle to input port component * @param hTunneledOutputPeerMap : Handle to mapped output port component * @param hTunneledOutputPeerMap : Handle to mapped input port component * @return none */ Void DomxTunnelMgr_mapTunnelComponentPeerHandles (OmxTypes_OMX_HANDLETYPE hTunneledOutput, OmxTypes_OMX_HANDLETYPE hTunneledInput, OmxTypes_OMX_HANDLETYPE *hTunneledOutputPeerMap, OmxTypes_OMX_HANDLETYPE *hTunneledInputPeerMap) { OMX_CONFIG_DOMXPROXYCOMPINFO sDomxProxyInfohOut, sDomxProxyInfohIn; DomxTypes_coreType eOutCompCoreId, eInCompCoreId; Int32 nCompIdxhOut, nCompIdxhIn; Error_Block ebObj; Error_Block *eb = &ebObj; IArg key; Bool bDisconnecthOut = FALSE; Bool bDisconnecthIn = FALSE; DOMX_UTL_TRACE_FUNCTION_ENTRY_LEVEL1 (); Log_print5 (Diags_USER1, "Entered: %s (0x%x, 0x%x, 0x%x, 0x%x)", (xdc_IArg) __FUNCTION__, (xdc_IArg) hTunneledOutput, (xdc_IArg) hTunneledInput, (xdc_IArg) hTunneledOutputPeerMap, (xdc_IArg) hTunneledInputPeerMap); Error_init (eb); if (FALSE == DomxTunnelMgr_module->initDone) { domxtmgr_module_init (); } key = Gate_enterModule (); *hTunneledOutputPeerMap = NULL; *hTunneledInputPeerMap = NULL; sDomxProxyInfohOut.pRpcStubHandle = NULL; sDomxProxyInfohIn.pRpcStubHandle = NULL; if (NULL != hTunneledOutput) { domxtmgr_get_component_connection_info (hTunneledOutput, &sDomxProxyInfohOut, &nCompIdxhOut, &eOutCompCoreId, eb); } else { bDisconnecthOut = TRUE; } if (FALSE == Error_check (eb)) { if (NULL != hTunneledInput) { Log_print1 (Diags_USER1, "eOutCompCoreId: %d\n", eOutCompCoreId); domxtmgr_get_component_connection_info (hTunneledInput, &sDomxProxyInfohIn, &nCompIdxhIn, &eInCompCoreId, eb); } else { bDisconnecthIn = TRUE; } } if (FALSE == Error_check (eb)) { if (NULL != hTunneledOutput) { if (FALSE == bDisconnecthIn) { Log_print1 (Diags_USER1, "eInCompCoreId: %d\n", eInCompCoreId); domxtmgr_map_connection_handle (nCompIdxhOut, eInCompCoreId, sDomxProxyInfohIn.pRpcStubHandle, hTunneledInputPeerMap, eb); } else { /* Do nothing for now */ } } } if (FALSE == Error_check (eb)) { if (NULL != hTunneledInput) { if (FALSE == bDisconnecthOut) { domxtmgr_map_connection_handle (nCompIdxhIn, eOutCompCoreId, sDomxProxyInfohOut.pRpcStubHandle, hTunneledOutputPeerMap, eb); } else { /* Do nothing for now */ } } } Gate_leaveModule (key); /* TODO: Component should return error code */ DOMX_UTL_TRACE_FUNCTION_ASSERT ((FALSE == Error_check (eb)), " in mapTunnelComponentPeerHandles"); DOMX_UTL_TRACE_FUNCTION_EXIT_LEVEL1 (OMX_ErrorNone); }
/** * @name domxtmgr_create_rpcskel * @brief Create the RPCSkeleton for a component * @param nCompIdx : Component index in connection table * @param pRpcStubHandle : Pointer to rpc stub handle * @param eb : Error block to raise errors * @return none */ static Int domxtmgr_create_rpcskel (Int32 nCompIdx, DomxTypes_coreType eConnectCoreId, OmxRpc_Handle pRpcStubHandle, Error_Block *eb) { OmxRpc_Params omxRpcParams; OmxRpc_Handle rpcSkelHandle = NULL; DomxCore_componentCoreInfoEntry *entry; Int status = 0; DOMX_UTL_TRACE_FUNCTION_ENTRY_LEVEL1 (); Log_print5 (Diags_USER1, "Entered %s (%d, %d, 0x%x, 0x%x)", (xdc_IArg) __FUNCTION__, nCompIdx, eConnectCoreId, (xdc_IArg) pRpcStubHandle, (xdc_IArg) eb); OmxRpc_Params_init (&omxRpcParams); omxRpcParams.componentName = (xdc_String) DomxTunnelMgr_module->connectionInfoTbl.elem[nCompIdx][0]. cComponentName; domxtmgr_map_component_name2info (omxRpcParams.componentName, &entry, eb); if (NULL != entry) { omxRpcParams.remoteCoreId = eConnectCoreId; /* Create an OmxRpc Skel instance */ omxRpcParams.layerId = OmxRpc_layerTypeSkel; rpcSkelHandle = OmxRpc_create (&omxRpcParams, eb); } if (NULL == rpcSkelHandle) { DOMX_UTL_TRACE_FUNCTION_ERROR ((NULL != entry), "OmxRpc Skel create failed"); status = -1; } else { OmxRpc_errorType eRpcError; OmxRpc_skelComponentConfigInfo skelCfg; DomxTunnelMgr_module->connectionInfoTbl.elem[nCompIdx][0].sRpcSkelInfo. pRpcSkelHandle = rpcSkelHandle; OmxRpc_skelGetCompRcmServerName (rpcSkelHandle, (OmxTypes_OMX_S8 *) DomxTunnelMgr_module->connectionInfoTbl. elem[nCompIdx][0].sRpcSkelInfo. cComponentRcmSvrName, sizeof (DomxTunnelMgr_module-> connectionInfoTbl. elem[nCompIdx][0].sRpcSkelInfo. cComponentRcmSvrName)); skelCfg.stubHandle = NULL; skelCfg.pComponentHandle = DomxTunnelMgr_module->connectionInfoTbl.elem[nCompIdx][0]. hComponentRealHandle; eRpcError = OmxRpc_skelConfigCompInfo (rpcSkelHandle, &skelCfg); DOMX_UTL_TRACE_FUNCTION_ASSERT ((OmxRpc_errorNone == eRpcError), "OmxRpc_skelConfigCompInfo failed"); } DOMX_UTL_TRACE_FUNCTION_EXIT_LEVEL1 (OmxRpc_errorNone); return status; }
/* * ======== Algorithm_create ======== */ Algorithm_Handle Algorithm_create(IALG_Fxns *fxns, Void *idma3FxnsVoid, Void *iresFxnsVoid, IALG_Params *params, Algorithm_Attrs *attrs) { Algorithm_Obj *pObject = NULL; Int groupId; IDMA3_Fxns *idma3Fxns = (IDMA3_Fxns *)idma3FxnsVoid; IRES_Fxns *iresFxns = (IRES_Fxns *)iresFxnsVoid; IRES_Status iresStatus; UInt32 useCachedMem; Log_print5(Diags_ENTRY, "[+E] Algorithm_create> Enter(" "fxns=0x%x, idma3Fxns=0x%x, iresFxns=0x%x, params=0x%x, " "attrs=0x%x)", (IArg)fxns, (IArg)idma3Fxns, (IArg)iresFxns, (IArg)params, (IArg)attrs); groupId = (attrs != NULL) ? attrs->groupId : -1; useCachedMem = (attrs != NULL) ? attrs->useCachedMem : Algorithm_USECACHEDMEM_DEFAULT; Log_print1(Diags_USER2, "Algorithm_create> useCachedMem = %d", (IArg)useCachedMem); /* if (attrs == NULL) use default groupId */ if ((pObject = (Algorithm_Obj *)Memory_alloc(sizeof(Algorithm_Obj), NULL)) == NULL) { Log_print0(Diags_USER7, "[+7] Algorithm_create> " "Alloc for a small object FAILED -- out of memory?"); goto Algorithm_create_return; } pObject->alg = ALG_create(groupId, fxns, NULL, params, useCachedMem); pObject->idma3Fxns = NULL; pObject->iresFxns = NULL; pObject->groupId = groupId; if (pObject->alg == NULL) { Log_print0(Diags_USER7, "[+7] Algorithm_create> " "Algorithm creation FAILED; make sure that 1) alg params are " "correct/appropriate, 2) there is enough internal and external " "algorithm memory available -- check DSKT2 settings for heap " "assignments and scratch allocation"); Algorithm_delete(pObject); pObject = NULL; goto Algorithm_create_return; } /* if the alg implements IDMA3, we need to negotiate DMA resources */ if (idma3Fxns != NULL) { Int status; status = DMAN3_grantDmaChannels(pObject->groupId, &pObject->alg, &idma3Fxns, 1); if (status != DMAN3_SOK) { Log_print1(Diags_USER7, "[+7] Algorithm_create> " "Granting DMA channels to algorithm through DMAN3 FAILED" " (0x%x)", (IArg)status); Algorithm_delete(pObject); pObject = NULL; goto Algorithm_create_return; } pObject->idma3Fxns = idma3Fxns; /* tell Algorithm_delete to release */ } /* If alg implements IRES, allocate resources */ if (iresFxns != NULL) { iresStatus = RMAN_assignResources(pObject->alg, iresFxns, pObject->groupId); if (iresStatus != IRES_OK) { Log_print1(Diags_USER7, "[+7] Algorithm_create> Assignment of " "alg resources through RMAN FAILED (0x%x)", (IArg)iresStatus); /* Free DMAN3 channels, if allocated */ if (idma3Fxns != NULL) { DMAN3_releaseDmaChannels(&(pObject->alg), &(pObject->idma3Fxns), 1); } Algorithm_delete(pObject); pObject = NULL; goto Algorithm_create_return; } pObject->iresFxns = iresFxns; } Algorithm_create_return: Log_print1(Diags_EXIT, "[+X] Algorithm_create> return (0x%x)", (IArg)pObject); return (pObject); }
Int SystemCfg_createLocalResources(Void) { Error_Block eb; SemThread_Params semThreadP; HeapBufMP_Params heapBufMPP; Int count; Char heapName[32]; Int status = 0; struct SystemCfg *stateObj = &SystemCfg_State; static Int heapId = 1; Log_print1(Diags_ENTRY, "--> %s: ()", (IArg)FXNN); Error_init(&eb); /* create sync object used to wait on remote core startup */ SemThread_Params_init(&semThreadP); semThreadP.mode = SemThread_Mode_COUNTING; SemThread_construct(&stateObj->semObj, 0, &semThreadP, &eb); if (Error_check(&eb)) { /* Log_error() */ Log_print3(Diags_USER8, "Error: %s, line %d: %s: SemThread_construct() failed", (IArg)__FILE__, (IArg)__LINE__, (IArg)FXNN); status = -1; goto leave; } stateObj->semH = SemThread_handle(&stateObj->semObj); /* register notify callback for ready event from remote core */ status = Notify_registerEvent(stateObj->hostProcId, Global_NotifyLineId, Global_HostDspEvtNum, SystemCfg_notifyCB__P, (UArg)stateObj); if (status < 0) { /* Log_error() */ Log_print4(Diags_USER8, "Error: %s, line %d: %s: " "Notify_registerEventSingle() returned error %d", (IArg)__FILE__, (IArg)__LINE__, (IArg)FXNN, (IArg)status); goto leave; } /* create a heap for tiler usage */ Log_print0(Diags_USER2, FXNN": HeapBufMP_create for tiler"); HeapBufMP_Params_init(&heapBufMPP); heapBufMPP.regionId = 0; heapBufMPP.blockSize = 0x200; /* 512 B */ heapBufMPP.numBlocks = 8; /* hack: make a unique heap name */ System_sprintf(heapName, "rcmHeap-%d", heapId); heapBufMPP.name = heapName; stateObj->heapH = HeapBufMP_create(&heapBufMPP); if (stateObj->heapH == NULL) { /* Log_error() */ Log_print3(Diags_USER8, "Error: %s, line %d: %s: HeapBuf_create() failed", (IArg)FXNN, (IArg)__FILE__, (IArg)__LINE__); status = -1; goto leave; } /* register this heap with MessageQ */ Log_print2(Diags_USER2, FXNN": MessageQ_registerHeap: (heapH: 0x%x, heapId: %d)", (IArg)(stateObj->heapH), (IArg)Global_TilerHeapId); MessageQ_registerHeap((Ptr)(stateObj->heapH), Global_TilerHeapId); /* Send create done event to remote core. Need to loop in case * the remote core has not yet registered with notify to receive * this event. */ Log_print0(Diags_USER1, FXNN": send EvtCreateDone to remote core"); count = 0; do { status = Notify_sendEvent(stateObj->hostProcId, Global_NotifyLineId, Global_HostDspEvtNum, Global_EvtCreateDone, TRUE); if (status == Notify_E_EVTNOTREGISTERED) { Thread_sleep(500, &eb); /* 0.5 ms */ } } while ((++count < 10) && (status == Notify_E_EVTNOTREGISTERED)); if (status < 0) { /* Log_error() */ Log_print5(Diags_USER8, "Error: %s, line %d: %s: Notify_sendEvent() returned error %d," "giving up after %d tries", (IArg)__FILE__, (IArg)__LINE__, (IArg)FXNN, (IArg)status, (IArg)count); goto leave; } /* wait for create done event from remote core */ Log_print0(Diags_USER1, FXNN": waiting for EvtCreateDone event..."); SemThread_pend(stateObj->semH, SemThread_FOREVER, &eb); if (Error_check(&eb)) { /* Log_error() */ Log_print3(Diags_USER8, "Error: %s, line %d: %s: SemThread_pend() returned with error", (IArg)__FILE__, (IArg)__LINE__, (IArg)FXNN); status = -1; goto leave; } Log_print0(Diags_USER1, FXNN": ...received EvtCreatDone event"); leave: Log_print2(Diags_EXIT, "<-- %s: %d", (IArg)FXNN, (IArg)status); return(status); }