VHWA Driver API Guide
msc_cfg.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2019
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the
15  * distribution.
16  *
17  * Neither the name of Texas Instruments Incorporated nor the names of
18  * its contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
49 #ifndef CFG_MSC_H_
50 #define CFG_MSC_H_
51 
52 /* ========================================================================== */
53 /* Include Files */
54 /* ========================================================================== */
55 #include <vhwa_vpac_abstraction_layer.h>
56 
57 #include <include/vhwa_common.h>
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 /* ========================================================================== */
64 /* Macros & Typedefs */
65 /* ========================================================================== */
67 #define MSC_MAX_OUTPUT (10U)
68 
70 #define MSC_MAX_TAP (5U)
71 
73 #define MSC_MAX_SP_COEFF_SET (2U)
74 
76 #define MSC_MAX_MP_COEFF_SET (4U)
77 
92 #define MSC_COEFF_SHIFT_5 (5U)
94 #define MSC_COEFF_SHIFT_6 (6U)
96 #define MSC_COEFF_SHIFT_7 (7U)
98 #define MSC_COEFF_SHIFT_8 (8U)
100 #define MSC_COEFF_SHIFT_9 (9U)
116 #define MSC_MULTI_32PHASE_COEFF_SET_0 (0U)
118 #define MSC_MULTI_32PHASE_COEFF_SET_1 (1U)
120 #define MSC_MULTI_32PHASE_COEFF_SET_2 (2U)
122 #define MSC_MULTI_32PHASE_COEFF_SET_3 (3U)
124 #define MSC_MULTI_64PHASE_COEFF_SET_0 (0U)
126 #define MSC_MULTI_64PHASE_COEFF_SET_2 (2U)
141 #define MSC_TAP_SEL_3TAPS (0U)
143 #define MSC_TAP_SEL_4TAPS (1U)
145 #define MSC_TAP_SEL_5TAPS (2U)
159 #define MSC_SINGLE_PHASE_SP_COEFF_0 (0U)
161 #define MSC_SINGLE_PHASE_SP_COEFF_1 (1U)
163 #define MSC_SINGLE_PHASE_MP_COEFF0_0 (2U)
165 #define MSC_SINGLE_PHASE_MP_COEFF0_1 (3U)
167 #define MSC_SINGLE_PHASE_MP_COEFF0_2 (4U)
169 #define MSC_SINGLE_PHASE_MP_COEFF0_3 (5U)
171 #define MSC_SINGLE_PHASE_MP_COEFF0_4 (6U)
173 #define MSC_SINGLE_PHASE_MP_COEFF0_5 (7U)
175 #define MSC_SINGLE_PHASE_MP_COEFF0_6 (8U)
177 #define MSC_SINGLE_PHASE_MP_COEFF0_7 (9U)
179 #define MSC_SINGLE_PHASE_MP_COEFF0_8 (10U)
181 #define MSC_SINGLE_PHASE_MP_COEFF0_9 (11U)
183 #define MSC_SINGLE_PHASE_MP_COEFF0_10 (12U)
185 #define MSC_SINGLE_PHASE_MP_COEFF0_11 (13U)
187 #define MSC_SINGLE_PHASE_MP_COEFF0_12 (14U)
189 #define MSC_SINGLE_PHASE_MP_COEFF0_13 (15U)
191 #define MSC_SINGLE_PHASE_MP_COEFF0_14 (16U)
193 #define MSC_SINGLE_PHASE_MP_COEFF0_15 (17U)
205 #define MSC_PHASE_MODE_64PHASE (0U)
206 
207 #define MSC_PHASE_MODE_32PHASE (1U)
217 #define MSC_FILTER_MODE_SINGLE_PHASE (0U)
218 
219 #define MSC_FILTER_MODE_MULTI_PHASE (1U)
233 #define VHWA_MSC_VBUSM_RD_ERR (0x4U)
235 #define VHWA_MSC_SL2_WR_ERR (0x8U)
237 #define VHWA_MSC0_WDTIMER_ERR (0x1000000U)
239 #define VHWA_MSC1_WDTIMER_ERR (0x2000000U)
240 
242 #define VHWA_MSC_ALL_ERR_EVENTS (VHWA_MSC_VBUSM_RD_ERR | VHWA_MSC_SL2_WR_ERR)
245 /* ========================================================================== */
246 /* Structure Declarations */
247 /* ========================================================================== */
248 
262 typedef void (*Msc_ErrEventCbFxn)(Fvid2_Handle handle, uint32_t errEvents,
263  void *appData);
264 
278 typedef void (*Msc_WdTimerErrEventCbFxn)(Fvid2_Handle handle, uint32_t errEvents,
279  void *appData);
280 
290 typedef int32_t (*Msc_ConfigRegCompareCbFxn)(Fvid2_Handle handle, void *configRegPrms);
291 
296 typedef struct
297 {
298  uint32_t enable;
301  Fvid2_CropConfig inRoi;
311  uint32_t outWidth;
313  uint32_t outHeight;
315  uint32_t horzAccInit;
317  uint32_t vertAccInit;
320  uint32_t filtMode;
323  uint32_t phaseMode;
325  uint32_t hsSpCoeffSel;
329  uint32_t vsSpCoeffSel;
333  uint32_t hsMpCoeffSel;
337  uint32_t vsMpCoeffSel;
342  uint32_t coeffShift;
345  uint32_t isSignedData;
355 } Msc_ScConfig;
356 
361 typedef struct
362 {
363  uint32_t tapSel;
367 } Msc_Config;
368 
374 typedef struct
375 {
376  uint32_t errEvents;
383  void *appData;
386 
394 typedef struct
395 {
396  uint32_t wdTimeoutCycles;
407  void *appData;
410 
415 typedef struct
416 {
417  int32_t *spCoeffSet[MSC_MAX_SP_COEFF_SET];
421  int32_t *mpCoeffSet[MSC_MAX_MP_COEFF_SET];
429 } Msc_Coeff;
430 
431 /* ========================================================================== */
432 /* Function Declarations */
433 /* ========================================================================== */
434 
443 static inline void Msc_configInit(Msc_Config *mscCfg);
444 
453 static inline void Msc_coeffInit(Msc_Coeff *coeffCfg);
454 
455 /* ========================================================================== */
456 /* Function Definitions */
457 /* ========================================================================== */
458 
459 static inline void Msc_coeffInit(Msc_Coeff *coeffCfg)
460 { /* LDRA_JUSTIFY_START
461  <metric start> branch <metric end>
462  <justification start> Rationale:
463 
464  The negative test framework and test applications are unable to reach this portion of the code. The coeffCfg is passed using control commands from the application; if these control commands are not called, this API will not be invoked.
465  Effect on this unit: If the control reaches here, the code base is expected to accumulate and return the error.
466  However, due to the stated rationale, this is not tested.
467  <justification end> */
468  if (NULL != coeffCfg)
469  /* LDRA_JUSTIFY_END */
470 
471  {
472  Fvid2Utils_memset(coeffCfg, 0, sizeof(Msc_Coeff));
473  }
474  /* LDRA_JUSTIFY_START
475  <metric start> statement branch <metric end>
476  <justification start> Rationale:
477 
478  The negative test framework and test applications are unable to reach this portion of the code. The coeffCfg is passed using control commands from the application; if these control commands are not called, this API will not be invoked.
479  Effect on this unit: If the control reaches here, the code base is expected to accumulate and return the error.
480  However, due to the stated rationale, this is not tested.
481  <justification end> */
482  else
483 
484  {
485  GT_0trace(VhwaMscTrace, GT_ERR,"Msc_coeffInit: Error - coeffCfg is null\n");
486  }
487  /* LDRA_JUSTIFY_END */
488 
489 }
490 
491 static inline void Msc_ConfigInit(Msc_Config *mscCfg)
492 {
493  uint32_t cnt;
494  /* LDRA_JUSTIFY_START
495  <metric start> branch <metric end>
496  <justification start> Rationale:
497  The negative test framework and test apps cannot reach this portion.
498 
499  mscCfg is passed using hObj which is passed from Imaging kernel layer
500  Effect on this unit: If the control reaches here, the code base is expected to accumulate and return the error.
501  However, due to the stated rationale, this is not tested.
502  <justification end> */
503  if (NULL != mscCfg)
504  /* LDRA_JUSTIFY_END */
505 
506  {
507  mscCfg->tapSel = MSC_TAP_SEL_5TAPS;
508  for (cnt = 0; cnt < MSC_MAX_OUTPUT; cnt++)
509  {
510  mscCfg->scCfg[cnt].enable = UFALSE;
511  mscCfg->scCfg[cnt].outWidth = 0U;
512  mscCfg->scCfg[cnt].outHeight = 0U;
513  mscCfg->scCfg[cnt].horzAccInit = 0U;
514  mscCfg->scCfg[cnt].vertAccInit = 0U;
516  mscCfg->scCfg[cnt].phaseMode = MSC_PHASE_MODE_64PHASE;
521  mscCfg->scCfg[cnt].coeffShift = MSC_COEFF_SHIFT_8;
522  mscCfg->scCfg[cnt].isSignedData = UFALSE;
523  mscCfg->scCfg[cnt].isEnableFiltSatMode = UFALSE;
524  mscCfg->scCfg[cnt].inRoi.cropStartX = 0U;
525  mscCfg->scCfg[cnt].inRoi.cropStartY = 0U;
526  mscCfg->scCfg[cnt].inRoi.cropWidth = 0U;
527  mscCfg->scCfg[cnt].inRoi.cropHeight = 0U;
528  }
529  }
530  /* LDRA_JUSTIFY_START
531  <metric start> statement branch <metric end>
532  <justification start>
533  Rationale: The component level negative test framework and test applications cannot reach this portion.
534  This failure case is out of scope for the imaging test framework.
535  Effect on this unit: If the control reaches here, our code base is expected to accumulate the error status and return the same to the application.
536  However, due to the stated rationale, this is not tested.
537  <justification end> */
538  else
539  {
540  GT_0trace(VhwaMscTrace, GT_ERR, "Msc_ConfigInit: Error - mscCfg is null\n");
541  }
542 /* LDRA_JUSTIFY_END */
543 }
544 
545 #ifdef __cplusplus
546 }
547 #endif
548 
549 #endif
#define VhwaMscTrace
Log enable for MSC module.
Definition: vhwa_common.h:318
#define MSC_MAX_OUTPUT
Maximum number of scalar output supported in MSC.
Definition: msc_cfg.h:67
#define MSC_FILTER_MODE_SINGLE_PHASE
Definition: msc_cfg.h:217
void(* Msc_WdTimerErrEventCbFxn)(Fvid2_Handle handle, uint32_t errEvents, void *appData)
Prototype for the Watchdog Timeout Error Event for MSC. The callback for the MSC Watchdog Timeout err...
Definition: msc_cfg.h:278
static void Msc_configInit(Msc_Config *mscCfg)
This function should be used to initialize variable of type Msc_Config.
#define MSC_MAX_MP_COEFF_SET
Maximum number of Multi phase coefficients set.
Definition: msc_cfg.h:76
#define MSC_SINGLE_PHASE_SP_COEFF_0
Use Dedicated Single phase coef-0.
Definition: msc_cfg.h:159
int32_t(* Msc_ConfigRegCompareCbFxn)(Fvid2_Handle handle, void *configRegPrms)
Prototype for the config Register Memory Compare Event for MSC. Following DOF pattern for configurati...
Definition: msc_cfg.h:290
void(* Msc_ErrEventCbFxn)(Fvid2_Handle handle, uint32_t errEvents, void *appData)
Prototype for the Error Event for MSC. The callback for the MSC error events can be registered using ...
Definition: msc_cfg.h:262
#define MSC_TAP_SEL_5TAPS
Selects the 5 tap filter.
Definition: msc_cfg.h:145
static void Msc_coeffInit(Msc_Coeff *coeffCfg)
This function should be used to initialize variable of type Msc_Coeff.
Definition: msc_cfg.h:459
#define MSC_COEFF_SHIFT_8
Coefficient shift by 8bits, 8bit fraction.
Definition: msc_cfg.h:98
#define MSC_MAX_SP_COEFF_SET
Maximum number of single phase coefficients set.
Definition: msc_cfg.h:73
static void Msc_ConfigInit(Msc_Config *mscCfg)
Definition: msc_cfg.h:491
#define MSC_MULTI_64PHASE_COEFF_SET_0
Coefficient Set 0 for 64phase coefficients.
Definition: msc_cfg.h:124
#define MSC_PHASE_MODE_64PHASE
Definition: msc_cfg.h:205
Structure used for setting scalar coefficients.
Definition: msc_cfg.h:416
Structure for complete MSC Configuration.
Definition: msc_cfg.h:362
Msc_ScConfig scCfg[MSC_MAX_OUTPUT]
Definition: msc_cfg.h:365
uint32_t tapSel
Definition: msc_cfg.h:363
Structure for error event parameters Used to register callback for the given set of events.
Definition: msc_cfg.h:375
void * appData
Definition: msc_cfg.h:383
uint32_t errEvents
Definition: msc_cfg.h:376
Msc_ErrEventCbFxn cbFxn
Definition: msc_cfg.h:381
Individual Scalar configuration.
Definition: msc_cfg.h:297
uint32_t vsMpCoeffSel
Definition: msc_cfg.h:337
Fvid2_CropConfig inRoi
Definition: msc_cfg.h:301
uint32_t vsSpCoeffSel
Definition: msc_cfg.h:329
uint32_t filtMode
Definition: msc_cfg.h:320
uint32_t hsSpCoeffSel
Definition: msc_cfg.h:325
uint32_t horzAccInit
Definition: msc_cfg.h:315
uint32_t isInterleaveFormat
Definition: msc_cfg.h:352
uint32_t outWidth
Definition: msc_cfg.h:311
uint32_t isEnableFiltSatMode
Definition: msc_cfg.h:348
uint32_t phaseMode
Definition: msc_cfg.h:323
uint32_t coeffShift
Definition: msc_cfg.h:342
uint32_t vertAccInit
Definition: msc_cfg.h:317
uint32_t isSignedData
Definition: msc_cfg.h:345
uint32_t hsMpCoeffSel
Definition: msc_cfg.h:333
uint32_t enable
Definition: msc_cfg.h:298
uint32_t outHeight
Definition: msc_cfg.h:313
WD Timer parameters Used to configure WD Timer parameters Must be called after SET_PARAMS ioctl Used ...
Definition: msc_cfg.h:395
uint32_t wdTimerErrEvents
Definition: msc_cfg.h:399
Msc_WdTimerErrEventCbFxn cbFxn
Definition: msc_cfg.h:405
uint32_t wdTimeoutCycles
Definition: msc_cfg.h:396
void * appData
Definition: msc_cfg.h:407
File containning defination for common configuration/API used across all VHWA modules.