pva_apl_types.h#

Fully qualified name: src/device/fixed_function_library/include/pva_apl/pva_apl_types.h

File members: src/device/fixed_function_library/include/pva_apl/pva_apl_types.h

/*
 * SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
 *
 * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
 * property and proprietary rights in and to this material, related
 * documentation and any modifications thereto. Any use, reproduction,
 * disclosure or distribution of this material and related documentation
 * without an express license agreement from NVIDIA CORPORATION or
 * its affiliates is strictly prohibited.
 */

#ifndef PVA_APL_TYPES_H
#define PVA_APL_TYPES_H

#ifdef CUPVA_DEVICE_VPU
#    include <cupva_device.h>
#endif
#include <stdint.h>

#define PPE_FIXED_SEPCONV_5x5_S16_INIT_ID 0
#define PPE_FIXED_SEPCONV_5x5_S16_EXEC_ID 1
#define PPE_FIXED_HARRIS_CORNER_S16_INIT_ID 2
#define PPE_FIXED_HARRIS_CORNER_S16_EXEC_ID 3
#define PPE_FIXED_NMS_3x3_S32_INIT_ID 4
#define PPE_FIXED_NMS_3x3_S32_EXEC_ID 5
#define PPE_FIXED_NMS_5x5_S32_INIT_ID 6
#define PPE_FIXED_NMS_5x5_S32_EXEC_ID 7

struct SepConv5x5S16AlgorithmParams
{
    int16_t *input;
    int16_t *coeff_h;
    int16_t *coeff_v;
    int32_t width;
    int32_t height;
    int32_t inputLinePitch;
    int32_t outputLinePitch;
    int32_t roundNBits;
    int16_t *output;
    int16_t *cbStart;
    int32_t cbSize;
    int16_t *scratch;
};

struct HarrisCornerS16AlgorithmParams
{
    int16_t *input;
    int16_t *coeff;
    int32_t roundNBits;
    int32_t lambda;
    int32_t width;
    int32_t height;
    int32_t inputLinePitch;
    int32_t outputLinePitch;
    int32_t *output;
    int16_t *cbStart;
    int32_t cbSize;
};

struct NmsS32AlgorithmParams
{
    int32_t *input;
    int32_t width;
    int32_t height;
    int32_t inputLinePitch;
    int32_t outputLinePitch;
    int32_t *output;
    int32_t *cbStart;
    int32_t cbSize;
};

struct AgenConfigStruct
{
    void *a;
    uint8_t vmem_transaction_type;
    uint16_t lane_ofst;
    uint16_t n1;
    uint16_t n2;
    uint16_t n3;
    uint16_t n4;
    uint16_t n5;
    uint16_t n6;
    intptr_t mod1;
    intptr_t mod2;
    intptr_t mod3;
    intptr_t mod4;
    intptr_t mod5;
    intptr_t mod6;
    void *cb_start;
    uint16_t cb_size;
};

// Define struct for skip words for a single block
typedef struct
{
    uint32_t tall0; // Skip word for first vector (east) in TALL0
    uint32_t tall1; // Skip word for second vector (south) in TALL1
} skip_words_t;

// Struct containing all unique skip word configurations
typedef struct
{
    // Non-last row configurations
    skip_words_t non_last_row_regular_columns;    // [0]: Non-last row, regular columns
    skip_words_t non_last_row_second_last_column; // [1]: Non-last row, second-last column
    skip_words_t non_last_row_last_column;        // [2]: Non-last row, last column

    // Last row configurations
    skip_words_t last_row_regular_columns;    // [3]: Last row, regular columns
    skip_words_t last_row_second_last_column; // [4]: Last row, second-last column
    skip_words_t last_row_last_column;        // [5]: Last row, last column
} unique_skip_words_t;

#ifdef CUPVA_DEVICE_VPU
struct NmsS32VpuPriv
{
    AgenCFG cfgs[5];
    int32_t niter;
    int32_t niterFirstPass;
    int32_t verScratchOffset;
};

struct HarrisCornerS16VpuPriv
{
    AgenCFG input;
    AgenCFG gradHoriz;
    AgenCFG inGradVert;
    AgenCFG outGradVert;
    AgenCFG inGradMult;
    AgenCFG outGradMult;
    AgenCFG rollingSumVertHead;
    AgenCFG rollingSumVertTail;
    AgenCFG rollingSumHorizHead;
    AgenCFG rollingSumHorizTail;
    AgenCFG harrisResponseIn;
    AgenCFG harrisResponseOut;

    void *scratch0;
    void *scratch1;
    void *scratch2;
    uint32_t niterGradHoriz;
    uint32_t niterGradVert;
    uint32_t niterGradMult;
    uint32_t gradBufOffset;
    uint32_t rollingSumVertNiter1;
    uint32_t rollingSumVertNiter2;
    uint32_t rollingSumHorizNiter1;
    uint32_t rollingSumHorizNiter2;
    uint32_t harrisNiter;
    int32_t scratchIntLp;
    uint32_t lambda;
    int16_t sobelCoefficients[32];
};
#endif

struct NmsS32PpePriv
{
    NmsS32AlgorithmParams algorithmParams;
    AgenConfigStruct loadAgen;
    AgenConfigStruct storeAgen;
    AgenConfigStruct storeAgenLastRow;
    unique_skip_words_t skipWords;
};

struct HarrisCornerS16PpePriv
{
    HarrisCornerS16AlgorithmParams algorithmParams;
    AgenConfigStruct loadAgen;
    AgenConfigStruct storeAgen;
    AgenConfigStruct storeAgenLastRow;
    unique_skip_words_t skipWords;
};

struct AlgorithmHandleCommon
{
    int32_t execFuncId;
};

struct PvaAplSepConv5x5S16
{
    AlgorithmHandleCommon commonParams;
    SepConv5x5S16AlgorithmParams algorithmParams;
    AgenConfigStruct loadAgen;
    AgenConfigStruct storeAgen;
    AgenConfigStruct storeAgenLastRow;
    unique_skip_words_t skipWords;
};

struct PvaAplHarrisCornerS16
{
    AlgorithmHandleCommon commonParams;
    union
    {
#ifdef CUPVA_DEVICE_VPU
        HarrisCornerS16VpuPriv vpu;
#endif
        HarrisCornerS16PpePriv ppe;
    } priv;
};

struct PvaAplNms3x3S32
{
    AlgorithmHandleCommon commonParams;
    union
    {
#ifdef CUPVA_DEVICE_VPU
        NmsS32VpuPriv vpu;
#endif
        NmsS32PpePriv ppe;
    } priv;
};

struct PvaAplNms5x5S32
{
    AlgorithmHandleCommon commonParams;
    union
    {
#ifdef CUPVA_DEVICE_VPU
        NmsS32VpuPriv vpu;
#endif
        NmsS32PpePriv ppe;
    } priv;
};

#endif // PVA_APL_TYPES_H