/** ---------------------------------------------------------------------------- * @func tskMessage * * @desc Task for TSK based TSKMESSAGE application. * * @modif None * ---------------------------------------------------------------------------- */ static Int tskMessage() { Int status = SYS_OK; TSKMESSAGE_TransferInfo* info; /* Create Phase */ status = TSKMESSAGE_create(&info); /* Execute Phase */ if (status == SYS_OK) { /* Start the execution phase. */ status = TSKMESSAGE_execute(info); if (status != SYS_OK) { SET_FAILURE_REASON(status); } } /* Delete Phase */ status = TSKMESSAGE_delete(info); if (status != SYS_OK) { SET_FAILURE_REASON(status); } return status; }
/** ---------------------------------------------------------------------------- * @func tskLoop * * @desc Task for TSK based TSKLOOP application. * * @modif None * ---------------------------------------------------------------------------- */ static Int tskLoop() { Int status = SYS_OK; TSKLOOP_TransferInfo *info; #if defined (DSP_BOOTMODE_NOBOOT) { while (DSPLINK_initFlag != 0xC0C0BABA) ; } /* Initialize DSP/BIOS LINK. */ DSPLINK_init () ; #endif /* Create Phase */ status = TSKLOOP_create (&info); /* Execute Phase */ if (status == SYS_OK) { status = TSKLOOP_execute (info); if (status != SYS_OK) { SET_FAILURE_REASON(status); } } /* Delete Phase */ status = TSKLOOP_delete (info); if (status != SYS_OK) { SET_FAILURE_REASON(status); } return status ; }
/** ============================================================================ * @func SWIRGB2YCBCR_DSP_delete * * @desc Delete phase of SWIRGB2YCBCR_DSP application. Deallocates all the * resources that were allocated during create phase. * * @modif None. * ============================================================================ */ Int SWIRGB2YCBCR_DSP_delete (SWIRGB2YCBCR_DSP_TransferInfo * info) { Int status = SYS_OK ; Int iomStatus ; if (info != NULL) { /* Delete SWI */ if (info->swi != NULL) { SWI_delete (info->swi) ; } /* Delete GIO input channel */ if (info->gioInputChan != NULL) { iomStatus = GIO_delete (info->gioInputChan) ; if (iomStatus != IOM_COMPLETED) { status = SYS_EBADIO ; SET_FAILURE_REASON (status) ; } } /* Delete GIO output channel */ if (info->gioOutputChan != NULL) { iomStatus = GIO_delete (info->gioOutputChan) ; if (iomStatus != IOM_COMPLETED) { status = SYS_EBADIO ; SET_FAILURE_REASON (status) ; } } /* Deallocate inputBuffer */ if (info->inputBuffer != NULL) { POOL_free (SAMPLE_POOL_ID, info->inputBuffer, info->bufferSize) ; } /* Deallocate outputBuffer */ if (info->outputBuffer != NULL) { POOL_free (SAMPLE_POOL_ID, info->outputBuffer, info->bufferSize) ; } /* Deallocate info structure */ if (!MEM_free (DSPLINK_SEGID, info, sizeof (SWIRGB2YCBCR_DSP_TransferInfo))) { status = SYS_EALLOC ; SET_FAILURE_REASON (status) ; } } else { status = SYS_EALLOC ; } return status ; }
/** ---------------------------------------------------------------------------- * @func rgb2ycbcr_dspSWI * * @desc SWI entry point. This SWI runs every time both IOM_READ and * IOM_WRITE request get completed. It puts does processing and put * next IOM_READ and IOM_WRITE requests. * * @modif None * ---------------------------------------------------------------------------- */ static Void rgb2ycbcr_dspSWI (Arg arg0, Arg arg1) { Int status = SYS_OK; SWIRGB2YCBCR_DSP_TransferInfo * info = (SWIRGB2YCBCR_DSP_TransferInfo *) arg0; Uns numWordsToWrite = info->readWords; Int iomStatus; Uns i; Uint32 y,cb,cr; (Void) arg1 ; /* To remove compiler warning */ /* Do processing of data here */ for (i = 0 ; (i+3) <= info->readWords ; i = i+3) { y = (((D11 * info->inputBuffer[i]) + (D12 * info->inputBuffer[i+1]) + (D13 * info->inputBuffer[i+2])) / 100) + C1; cb = (((D21 * info->inputBuffer[i]) + (D22 * info->inputBuffer[i+1]) + (D23 * info->inputBuffer[i+2])) / 100) + C2; cr = (((D31 * info->inputBuffer[i]) + (D32 * info->inputBuffer[i+1]) + (D33 * info->inputBuffer[i+2])) / 100) + C3; info->outputBuffer[i] = y; info->outputBuffer[i+1] = cb; info->outputBuffer[i+2] = cr; } /* Submit a Read data request */ iomStatus = GIO_submit (info->gioInputChan, IOM_READ, info->inputBuffer, (size_t *) &(info->bufferSize), &(info->appReadCb)) ; if (iomStatus != IOM_PENDING) { status = SYS_EBADIO ; SET_FAILURE_REASON (status) ; } /* Submit a Write data request */ if (status == SYS_OK) { iomStatus = GIO_submit (info->gioOutputChan, IOM_WRITE, info->outputBuffer, &numWordsToWrite, &(info->appWriteCb)) ; } if (iomStatus != IOM_PENDING) { status = SYS_EBADIO ; SET_FAILURE_REASON (status) ; } }
//For Rev static Int tskRingIo2() { //TSKRING_IO_TransferInfo * info ; Int status = SYS_OK; /* Execute Phase */ if (status == SYS_OK) { status = TSKRING_IO_execute2(info2); if (status != SYS_OK) { SET_FAILURE_REASON(status); } } /* Delete Phase */ status = TSKRING_IO_delete2(info2); if (status != SYS_OK) { SET_FAILURE_REASON(status); } return (status); }
//For Sending static Int tskRingIo1() { Int status = SYS_OK; /* Execute Phase */ if (status == SYS_OK) { status = TSKRING_IO_execute1(info1); if (status != SYS_OK) { SET_FAILURE_REASON(status); } } /* Delete Phase */ status = TSKRING_IO_delete1(info1); if (status != SYS_OK) { SET_FAILURE_REASON(status); } return (status); }
/** ---------------------------------------------------------------------------- * @func loopbackSWI * * @desc SWI entry point. This SWI runs every time both IOM_READ and * IOM_WRITE request get completed. It puts does processing and put * next IOM_READ and IOM_WRITE requests. * * @modif None * ---------------------------------------------------------------------------- */ static Void loopbackSWI (Arg arg0, Arg arg1) { Int status = SYS_OK; SWILOOP_TransferInfo * info = (SWILOOP_TransferInfo *) arg0; Uns numWordsToWrite = info->readWords; Int iomStatus; Uns i; (Void) arg1 ; /* To remove compiler warning */ /* Do processing of data here */ for (i = 0 ; i < info->readWords ; i++) { info->outputBuffer [i] = info->inputBuffer [i] ; } /* Submit a Read data request */ iomStatus = GIO_submit (info->gioInputChan, IOM_READ, info->inputBuffer, (size_t *) &(info->bufferSize), &(info->appReadCb)) ; if (iomStatus != IOM_PENDING) { status = SYS_EBADIO ; SET_FAILURE_REASON (status) ; } /* Submit a Write data request */ if (status == SYS_OK) { iomStatus = GIO_submit (info->gioOutputChan, IOM_WRITE, info->outputBuffer, &numWordsToWrite, &(info->appWriteCb)) ; } if (iomStatus != IOM_PENDING) { status = SYS_EBADIO ; SET_FAILURE_REASON (status) ; } }
/** ---------------------------------------------------------------------------- * @func readFinishCb * * @desc Function to be registered as callback funtion for IOM_READ command * of GIO_submit. * * @modif None * ---------------------------------------------------------------------------- */ static Void readFinishCb (Ptr arg, Int status, Ptr bufp, Uns size) { SWIRGB2YCBCR_DSP_TransferInfo * info = (SWIRGB2YCBCR_DSP_TransferInfo *) arg ; /* Received full buffer from the GPP */ info->inputBuffer = bufp ; info->readWords = size ; if (status != IOM_COMPLETED) { SET_FAILURE_REASON (status) ; } /* Give indication to SWI that READ is over */ SWI_andn (info->swi, READ_MAILBOX_MASK) ; }
/** ---------------------------------------------------------------------------- * @func writeFinishCb * * @desc Function to registered as callback funtion for IOM_WRITE * command of GIO_submit. * * @modif None * ---------------------------------------------------------------------------- */ static Void writeFinishCb (Ptr arg, Int status, Ptr bufp, Uns size) { SWIRGB2YCBCR_DSP_TransferInfo *info = (SWIRGB2YCBCR_DSP_TransferInfo *) arg ; (Void) size ; /* To remove compiler warning */ /* Received empty buffer from the GPP */ info->outputBuffer = bufp ; if (status != IOM_COMPLETED) { SET_FAILURE_REASON(status) ; } /* Give indication to SWI that WRITE is over */ SWI_andn (info->swi, WRITE_MAILBOX_MASK) ; }
/** ============================================================================ * @func main * * @desc Entry function. * * @modif None * ============================================================================ */ Void main(Int argc, Char* argv []) { /* Task handler for TSK_create */ TSK_Handle tskMessageTask; #if !defined (DSP_BOOTMODE_NOBOOT) /* Get the number of transfers to be done by the application */ numTransfers = atoi(argv [0]); /* Initialize DSP/BIOS LINK. */ DSPLINK_init(); #endif /* Creating task for TSKMESSAGE application */ tskMessageTask = TSK_create(tskMessage, NULL, 0); if (tskMessageTask == NULL) { SET_FAILURE_REASON(SYS_EALLOC); LOG_printf(&trace, "Create TSKMESSAGE: Failed.\n"); } }
/** ============================================================================ * @func SWIRGB2YCBCR_DSP_execute * * @desc Execute phase of SWIRGB2YCBCR_DSP application. It get the application * started after that SWIs get posted automatically. * * @modif None. * ============================================================================ */ Int SWIRGB2YCBCR_DSP_execute (SWIRGB2YCBCR_DSP_TransferInfo * info) { Int status = SYS_OK ; Int iomStatus ; /* Submit a read request */ iomStatus = GIO_submit (info->gioInputChan, IOM_READ, info->inputBuffer, (size_t *) &(info->bufferSize), &(info->appReadCb)) ; if (iomStatus != IOM_PENDING) { status = SYS_EBADIO ; SET_FAILURE_REASON (status) ; } /* We don't write for the first time so clearing write bit * from SWI's mailbox */ SWI_andn (info->swi, WRITE_MAILBOX_MASK) ; return status ; }
/** ============================================================================ * @func SWIRGB2YCBCR_DSP_create * * @desc Create phase of SWISWIRGB2YCBCR_DSP application. It allocates * SWISWIRGB2YCBCR_DSP_TransferInfo structure and intializes it with configured * values. * * @modif None. * ============================================================================ */ Int SWIRGB2YCBCR_DSP_create (SWIRGB2YCBCR_DSP_TransferInfo ** infoPtr) { Int status = SYS_OK ; SWI_Attrs swiAttrs = SWI_ATTRS ; SWIRGB2YCBCR_DSP_TransferInfo * info; #if defined (DSP_BOOTMODE_NOBOOT) POOL_Obj poolObj ; { while (DSPLINK_initFlag != 0xC0C0BABA) ; } /* Initialize DSP/BIOS LINK. */ DSPLINK_init () ; smaPoolObj.poolId = 0; smaPoolObj.exactMatchReq = TRUE ; poolObj.initFxn = SMAPOOL_init ; poolObj.fxns = (POOL_Fxns *) &SMAPOOL_FXNS ; poolObj.params = &(smaPoolObj) ; poolObj.object = NULL ; status = POOL_open (0, &poolObj) ; /* Create IOM driver dynamically */ status = DEV_createDevice("/dsplink", &ZCPYDATA_FXNS, (Fxn) &ZCPYDATA_init, &devAttrs) ; /* Create DIO adapter dynamically */ status = DEV_createDevice("/dio_dsplink", &DIO_tskDynamicFxns, NULL, &dioDevAttrs); #endif /* Allocate SWIRGB2YCBCR_DSP_TransferInfo structure */ *infoPtr = MEM_calloc (DSPLINK_SEGID, sizeof (SWIRGB2YCBCR_DSP_TransferInfo), DSPLINK_BUF_ALIGN) ; if (*infoPtr == NULL) { status = SYS_EALLOC ; SET_FAILURE_REASON (status) ; } else { info = *infoPtr ; } /* Initialize SWIRGB2YCBCR_DSP_TransferInfo structure */ if (status == SYS_OK) { info->bufferSize = xferBufSize ; (info->appReadCb).fxn = readFinishCb ; (info->appReadCb).arg = (Ptr) info ; (info->appWriteCb).fxn = writeFinishCb ; (info->appWriteCb).arg = (Ptr) info ; } /* Create channel handles */ if (status == SYS_OK) { GIO_Attrs gioAttrs = GIO_ATTRS ; info->gioInputChan = GIO_create (INPUT_CHANNEL, IOM_INPUT, NULL, NULL, &gioAttrs) ; info->gioOutputChan = GIO_create (OUTPUT_CHANNEL, IOM_OUTPUT, NULL, NULL, &gioAttrs) ; if ( (info->gioInputChan == NULL) || (info->gioOutputChan == NULL)) { status = SYS_EALLOC ; SET_FAILURE_REASON (status) ; } } /* Create SWI for sending and receiving data */ if (status == SYS_OK) { swiAttrs.fxn = rgb2ycbcr_dspSWI ; swiAttrs.arg0 = (Arg) info ; swiAttrs.mailbox = INITIAL_MAILBOX_VAL ; info->swi = SWI_create (&swiAttrs) ; if (info->swi == NULL) { status = SYS_EALLOC ; SET_FAILURE_REASON (status) ; } } /* Allocate input and output buffers */ if (status == SYS_OK) { status = POOL_alloc (SAMPLE_POOL_ID, (Ptr *) &(info->inputBuffer), info->bufferSize) ; if (status == SYS_OK) { status = POOL_alloc (SAMPLE_POOL_ID, (Ptr *) &(info->outputBuffer), info->bufferSize) ; if (status != SYS_OK) { SET_FAILURE_REASON (status) ; } } else { SET_FAILURE_REASON (status) ; } } return status ; }
/** ============================================================================ * @func main * * @desc Entry function. * * @modif None * ============================================================================ */ Void main(Int argc, Char *argv[]) { #if defined (SWI_MODE) /* SWI based loopback */ SWILOOP_TransferInfo * info; #else /* if defined (SWI_MODE) */ /* TSK based loopback */ TSK_Handle tskLoopTask; #endif /* if defined (SWI_MODE) */ #if defined (SWI_MODE) || defined (CHNL_PCPY_LINK) Int status ; #endif /* if defined (SWI_MODE) || defined (CHNL_PCPY_LINK) */ #if defined (DSP_BOOTMODE_NOBOOT) /* register the init ISR */ HAL_intRegister (DSPLINK_INT_ID, DSPLINK_INT_VEC_ID, (Fxn) &HAL_initIsr, 0) ; #endif #if !defined (DSP_BOOTMODE_NOBOOT) /* Initialize DSP/BIOS LINK. */ DSPLINK_init () ; /* Get the number of transfers to be done by the application */ numTransfers = atoi (argv[1]) ; /* Transfer size for loopback given by GPP side */ xferBufSize = DSPLINK_ALIGN ((atoi (argv[0]) / DSP_MAUSIZE), DSPLINK_BUF_ALIGN) ; #else /* Get the number of transfers to be done by the application */ numTransfers = 10000 ; /* Transfer size for loopback given by GPP side */ xferBufSize = 1024 ; #endif #if defined (SWI_MODE) /* Create phase of SWILOOP application */ status = SWILOOP_create(&info); if (status == SYS_OK) { /* Execute phase of SWILOOP application */ status = SWILOOP_execute(info); if (status != SYS_OK) { SET_FAILURE_REASON (status); } } else { SET_FAILURE_REASON (status); } /* Delete phase of SWILOOP application: This is not called right now * because SWI application runs forever */ /* deleteStatus = SWILOOP_delete(info); if (deleteStatus != SYS_OK) { SET_FAILURE_REASON (deleteStatus); } */ #else /* if defined (SWI_MODE) */ /* Creating task for TSKLOOP application */ tskLoopTask = TSK_create(tskLoop, NULL, 0); if (tskLoopTask != NULL) { LOG_printf(&trace, "Create TSKLOOP: Success\n"); } else { LOG_printf(&trace, "Create TSKLOOP: Failed.\n"); return; } #endif /* if defined (SWI_MODE) */ return; }