Hi,
I want to creat a new kernel function following the steps to create a one (http://processors.wiki.ti.com/index.php/C6Accel_Advanced_Users_Guide) like the complextorreal function. I defined all the IDs and all the required files. The new function defined has one input buffer, two output buffers and one output variable like the complxtoreal function, but in my case the kind of variable is an integer (short) instead of float.
I notice that when I call my function from the main code, the input buffer is well received but the output buffer is not modified inside the function. I just though that was an error on my function. By this reason I modify the complextoreal function, invoking from it my function. The results were satisfactory and the output buffer were the expected one. I attach the c6accelw.c or c6accel_dsplib.h:
/********** c6accelw.c **************************************************/
case (F_TEST_FUNCTION_FXN_ID):{
DSPF_TEST_FUNCTION_Params *test_function_paramPtr;
test_function_paramPtr = pFnArray;
if( (test_function_paramPtr->in_InArrID1>INBUF15)|
(test_function_paramPtr->out1_OutArrID1>OUTBUF15)|
(test_function_paramPtr->out2_OutArrID2>OUTBUF15) )
return(IUNIVERSAL_EPARAMFAIL);
else
return( USER_test_function((unsigned short *)inBufs->descs[test_function_paramPtr->in_InArrID1].buf,
(short *)outBufs->descs[test_function_paramPtr->out1_OutArrID1].buf,
(short *)outBufs->descs[test_function_paramPtr->out2_OutArrID2].buf,
test_function_paramPtr->q) );
}
break;
/********** c6accelw.c **************************************************/
Int C6accel_DSPF_test_function(C6accel_Handle hC6accel,
unsigned short *ptr_in,
short *ptr_out1,
short *ptr_out2,
short ptr_q
)
{
XDM1_BufDesc inBufDesc;
XDM1_BufDesc outBufDesc;
XDAS_Int32 InArg_Buf_size;
IC6Accel_InArgs *CInArgs;
UNIVERSAL_OutArgs uniOutArgs;
Int status;
/* Define pointer to function parameter structure */
DSPF_test_function_Params *fp0;
XDAS_Int8 *pAlloc;
ACQUIRE_CODEC_ENGINE;
/* Allocate the InArgs structure as it varies in size
(Needs to be changed everytime we make a API call)*/
InArg_Buf_size= sizeof(Fxn_struct)+
sizeof(DSPF_test_function_Params)+
sizeof(CInArgs->size)+
sizeof(CInArgs->Num_fxns);
pAlloc=(XDAS_Int8 *)Memory_alloc(InArg_Buf_size, &wrapperMemParams);
CInArgs= (IC6Accel_InArgs *)pAlloc;
/* Initialize .size fields for dummy input and output arguments */
uniOutArgs.size = sizeof(uniOutArgs);
/* Set up buffers to pass buffers in and out to alg */
inBufDesc.numBufs = 1;
outBufDesc.numBufs = 2;
/* Fill in input/output buffer descriptor parameters */
CACHE_WB_INV_INPUT_BUFFERS_AND_SETUP_FOR_C6ACCEL(ptr_in,0,p*o*sizeof(unsigned short));
CACHE_INV_OUTPUT_BUFFERS_AND_SETUP_FOR_C6ACCEL(ptr_out1,0,p_int*o_del*sizeof(short));
CACHE_INV_OUTPUT_BUFFERS_AND_SETUP_FOR_C6ACCEL(ptr_out2,1,p_int*o*sizeof(short));
//CACHE_INV_OUTPUT_BUFFERS_AND_SETUP_FOR_C6ACCEL(pBuffer,outputBufferId,size)
/* Initialize the extended InArgs structure */
CInArgs->Num_fxns = 1;
CInArgs->size = InArg_Buf_size;
/* Set function Id and parameter pointers for first function call */
CInArgs->fxn[0].FxnID = USER_test_function_FXN_ID;
CInArgs->fxn[0].Param_ptr_offset = sizeof(CInArgs->size)+sizeof(CInArgs->Num_fxns)+sizeof(Fxn_struct);
/* Initialize pointers to function parameters */
fp0 = (DSPF_test_function_Params*)((XDAS_Int8*)CInArgs + CInArgs->fxn[0].Param_ptr_offset);
/* Fill in the fields in the parameter structure */
fp0->in_InArrID1 = INBUF0;
fp0->out1_OutArrID1 = OUTBUF0;
fp0->out2_OutArrID2 = OUTBUF1;
fp0->q=ptr_q;
/* Call the actual algorithm */
if (hC6accel->callType == ASYNC)
{
/* Update async structure */
if (c6accelAsyncParams.asyncCallCount!=0){
status = UNIVERSAL_EFAIL;
printf("Async call failed as %d are still pending\n",c6accelAsyncParams.asyncCallCount);
}
else{
/* Context Saving */
c6accelAsyncParams.asyncCallCount++;
memcpy(&(c6accelAsyncParams.inBufs),&inBufDesc, sizeof (XDM1_BufDesc));
memcpy(&(c6accelAsyncParams.outBufs), &outBufDesc,sizeof(XDM1_BufDesc));
memcpy(&(c6accelAsyncParams.inArgs), CInArgs,sizeof(UNIVERSAL_InArgs));
memcpy(&(c6accelAsyncParams.outArgs),&uniOutArgs,sizeof(UNIVERSAL_OutArgs));
c6accelAsyncParams.pBuf = pAlloc;
c6accelAsyncParams.pBufSize = InArg_Buf_size;
/* Asynchronous Call to the actual algorithm */
status = UNIVERSAL_processAsync(hC6accel->hUni, &inBufDesc, &outBufDesc, NULL,(UNIVERSAL_InArgs *)CInArgs, &uniOutArgs);
}
}
else{
/* Synchronous Call to the actual algorithm */
status = UNIVERSAL_process(hC6accel->hUni, &inBufDesc, &outBufDesc, NULL,(UNIVERSAL_InArgs *)CInArgs, &uniOutArgs);
/* Free the InArgs structure */
Memory_free(pAlloc, InArg_Buf_size, &wrapperMemParams);
}
RELEASE_CODEC_ENGINE;
return status;
}
/**********************************************************************/
I included the new function to the dsplib64plus.h and also compile all the modules with "make clean" and then "make all". Do I need to make an special compilation?
Regards,
John