DSPLIB User Guide
DSPLIB_blk_eswap.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * *
3  * module name :DSPLIB *
4  * *
5  * module descripton :Digital Signal Processing Library module for C7x+MMA *
6  * *
7  * Copyright (C) 2017-2018 Texas Instruments Incorporated - https://www.ti.com/ *
8  * ALL RIGHTS RESERVED *
9  * *
10  ******************************************************************************/
11 
23 #include "DSPLIB_blk_eswap_priv.h"
24 
26 {
27  int32_t privBufSize = sizeof(DSPLIB_blk_eswap_PrivArgs);
28 
29  DSPLIB_DEBUGPRINTFN(0, "privBufSize: %d\n", privBufSize);
30 
31  return privBufSize;
32 }
33 
35  const DSPLIB_bufParams1D_t *bufParamsIn,
36  const DSPLIB_bufParams1D_t *bufParamsOut,
37  const DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
38 {
39  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering Function");
40 
42 
43  if (handle == NULL) {
44  status = DSPLIB_ERR_NULL_POINTER;
45  }
46 
47  if (status == DSPLIB_SUCCESS) {
48  if ((bufParamsIn->data_type != DSPLIB_UINT16) && (bufParamsIn->data_type != DSPLIB_UINT32) &&
49  (bufParamsIn->data_type != DSPLIB_UINT64) && (bufParamsIn->data_type != DSPLIB_INT16) &&
50  (bufParamsIn->data_type != DSPLIB_INT32) && (bufParamsIn->data_type != DSPLIB_INT64) &&
51  (bufParamsIn->data_type != DSPLIB_FLOAT64) && (bufParamsIn->data_type != DSPLIB_FLOAT32)) {
52 
53  status = DSPLIB_ERR_INVALID_TYPE;
54  }
55  else if (bufParamsIn->data_type != bufParamsOut->data_type) {
56  status = DSPLIB_ERR_INVALID_TYPE;
57  }
58  else {
59  /* Nothing to do here */
60  }
61  }
62 
63  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
64 
65  return status;
66 }
67 
69 DSPLIB_blk_eswap_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pIn, const void *restrict pOut)
70 {
71  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
72 
73  DSPLIB_STATUS status;
74 
75  if ((pIn == NULL) || (pOut == NULL)) {
76  status = DSPLIB_ERR_NULL_POINTER;
77  }
78  else {
79  status = DSPLIB_SUCCESS;
80  }
81  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
82 
83  return status;
84 }
85 
87  DSPLIB_bufParams1D_t *bufParamsIn,
88  DSPLIB_bufParams1D_t *bufParamsOut,
89  const DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
90 {
91  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
92 
94  DSPLIB_blk_eswap_PrivArgs *pKerPrivArgs = (DSPLIB_blk_eswap_PrivArgs *) handle;
95 
96  pKerPrivArgs->blockSize = pKerInitArgs->dataSize;
97 
98  DSPLIB_DEBUGPRINTFN(0, "pKerInitArgs->funcStyle: %d bufParamsOut->data_type: %d\n", pKerInitArgs->funcStyle,
99  bufParamsOut->data_type);
100 
101  if (pKerInitArgs->funcStyle == DSPLIB_FUNCTION_NATC) {
102 
103  if (bufParamsIn->data_type == DSPLIB_UINT16) {
105  status = DSPLIB_blk_eswap_init_cn(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
106  }
107  else if (bufParamsIn->data_type == DSPLIB_UINT32) {
109  status = DSPLIB_blk_eswap_init_cn(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
110  }
111  else if (bufParamsIn->data_type == DSPLIB_UINT64) {
113  status = DSPLIB_blk_eswap_init_cn(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
114  }
115  else if (bufParamsIn->data_type == DSPLIB_INT16) {
117  status = DSPLIB_blk_eswap_init_cn(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
118  }
119  else if (bufParamsIn->data_type == DSPLIB_INT32) {
121  status = DSPLIB_blk_eswap_init_cn(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
122  }
123  else if (bufParamsIn->data_type == DSPLIB_INT64) {
125  status = DSPLIB_blk_eswap_init_cn(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
126  }
127  else if (bufParamsIn->data_type == DSPLIB_FLOAT32) {
129  status = DSPLIB_blk_eswap_init_cn(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
130  }
131  else if (bufParamsIn->data_type == DSPLIB_FLOAT64) {
133  status = DSPLIB_blk_eswap_init_cn(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
134  }
135  else {
136  status = DSPLIB_ERR_INVALID_TYPE;
137  }
138  }
139  else {
140  if (bufParamsIn->data_type == DSPLIB_UINT16) {
142  status = DSPLIB_blk_eswap_init_ci<uint16_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
143  }
144  else if (bufParamsIn->data_type == DSPLIB_UINT32) {
146  status = DSPLIB_blk_eswap_init_ci<uint32_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
147  }
148  else if (bufParamsIn->data_type == DSPLIB_UINT64) {
150  status = DSPLIB_blk_eswap_init_ci<uint64_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
151  }
152  else if (bufParamsIn->data_type == DSPLIB_INT16) {
154  status = DSPLIB_blk_eswap_init_ci<int16_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
155  }
156  else if (bufParamsIn->data_type == DSPLIB_INT32) {
158  status = DSPLIB_blk_eswap_init_ci<int32_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
159  }
160  else if (bufParamsIn->data_type == DSPLIB_INT64) {
162  status = DSPLIB_blk_eswap_init_ci<int64_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
163  }
164  else if (bufParamsIn->data_type == DSPLIB_FLOAT32) {
166  status = DSPLIB_blk_eswap_init_ci<float>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
167  }
168  else if (bufParamsIn->data_type == DSPLIB_FLOAT64) {
170  status = DSPLIB_blk_eswap_init_ci<double>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
171  }
172  else {
173  status = DSPLIB_ERR_INVALID_TYPE;
174  }
175  }
176  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
177 
178  return status;
179 }
180 
181 DSPLIB_STATUS DSPLIB_blk_eswap_exec(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
182 {
183  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
184 
185  DSPLIB_STATUS status;
186 
187  DSPLIB_blk_eswap_PrivArgs *pKerPrivArgs = (DSPLIB_blk_eswap_PrivArgs *) handle;
188 
189  DSPLIB_DEBUGPRINTFN(0, "pKerPrivArgs->blockSize %d\n", pKerPrivArgs->blockSize);
190 
191  status = pKerPrivArgs->execute(handle, pIn, pOut);
192 
193  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
194 
195  return status;
196 }
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_ci< int64_t, DSPLIB_UINT64 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_init_ci< int16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_ci< uint16_t, DSPLIB_UINT16 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_init_ci< uint32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_ci< double, DSPLIB_UINT64 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_init_ci< uint16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_eswap_init_ci< double >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_eswap_init_ci< uint64_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_ci< int32_t, DSPLIB_UINT32 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_ci< uint32_t, DSPLIB_UINT32 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_ci< int16_t, DSPLIB_UINT16 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_init_ci< int32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_ci< float, DSPLIB_UINT32 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_init_ci< float >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_ci< uint64_t, DSPLIB_UINT64 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_init_ci< int64_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_cn< float, DSPLIB_UINT32 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
DSPLIB_STATUS DSPLIB_blk_eswap_init_cn(DSPLIB_kernelHandle handle, DSPLIB_bufParams1D_t *bufParamsIn, DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
This function is the initialization function for the natural C implementation of the kernel....
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_cn< int32_t, DSPLIB_UINT32 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_cn< uint32_t, DSPLIB_UINT32 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_cn< uint16_t, DSPLIB_UINT16 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_cn< uint64_t, DSPLIB_UINT64 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_cn< int64_t, DSPLIB_UINT64 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_cn< int16_t, DSPLIB_UINT16 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_eswap_exec_cn< double, DSPLIB_UINT64 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_blk_eswap.
#define DSPLIB_DEBUGPRINTFN(N, fmt,...)
Definition: DSPLIB_types.h:83
DSPLIB_STATUS_NAME
The enumeration of all status codes.
Definition: DSPLIB_types.h:151
void * DSPLIB_kernelHandle
Handle type for DSPLIB operations.
Definition: DSPLIB_types.h:172
@ DSPLIB_FUNCTION_NATC
Definition: DSPLIB_types.h:176
@ DSPLIB_UINT64
@ DSPLIB_UINT16
@ DSPLIB_INT32
@ DSPLIB_INT16
@ DSPLIB_FLOAT32
@ DSPLIB_INT64
@ DSPLIB_FLOAT64
@ DSPLIB_UINT32
@ DSPLIB_SUCCESS
Definition: DSPLIB_types.h:152
@ DSPLIB_ERR_NULL_POINTER
Definition: DSPLIB_types.h:157
@ DSPLIB_ERR_INVALID_TYPE
Definition: DSPLIB_types.h:155
DSPLIB_STATUS DSPLIB_blk_eswap_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pIn, const void *restrict pOut)
This function checks the validity of the parameters passed to DSPLIB_blk_eswap_exec function....
DSPLIB_STATUS DSPLIB_blk_eswap_init(DSPLIB_kernelHandle handle, DSPLIB_bufParams1D_t *bufParamsIn, DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
This function should be called before the DSPLIB_blk_eswap_exec function is called....
DSPLIB_STATUS DSPLIB_blk_eswap_exec(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
This function is the main kernel swapping function.
int32_t DSPLIB_blk_eswap_getHandleSize(DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
This is a query function to calculate the size of internal handle.
DSPLIB_STATUS DSPLIB_blk_eswap_init_checkParams(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_eswap_InitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to DSPLIB_blk_eswap_init function....
Structure containing the parameters to initialize the kernel.
int8_t funcStyle
Variant of the function refer to DSPLIB_FUNCTION_STYLE
uint32_t dataSize
Size of input data
Structure that is reserved for internal use by the kernel.
pFxnDSPLIB_blk_eswap_exec execute
Function pointer to point to the right execution variant between DSPLIB_blk_eswap_exec_cn and DSPLIB_...
int32_t blockSize
Size of input buffer for different batches DSPLIB_blk_eswap_init that will be retrieved and used by D...
A structure for a 1 dimensional buffer descriptor.
uint32_t data_type
Values are of type DSPLIB_data_type_e.