pva_apl_impl.h#

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

File members: src/device/fixed_function_library/include/pva_apl/pva_apl_impl.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_IMPL_H
#define PVA_APL_IMPL_H

#include "pva_apl_types.h"

#include <CupvaPpeIpcVpu.h>
#include <stdint.h>

#if CUPVA_PVA_GEN_NUMBER > 2
#    define PVAAPL_IMPL_FUNC(_a, _b, ...) pvaApl##_b##_a##Ppe(__VA_ARGS__)
#else
#    define PVAAPL_IMPL_FUNC(_a, _b, ...) pvaApl##_b##_a##Vpu(__VA_ARGS__)
#endif

#if CUPVA_PVA_GEN_NUMBER > 2
inline void pvaAplInitSepConv5x5S16Ppe(PvaAplSepConv5x5S16 *handle, 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)
{
    handle->commonParams.execFuncId               = PPE_FIXED_SEPCONV_5x5_S16_EXEC_ID;
    SepConv5x5S16AlgorithmParams *algorithmParams = &handle->algorithmParams;
    algorithmParams->input                        = input;
    algorithmParams->coeff_h                      = coeff_h;
    algorithmParams->coeff_v                      = coeff_v;
    algorithmParams->width                        = width;
    algorithmParams->height                       = height;
    algorithmParams->inputLinePitch               = inputLinePitch;
    algorithmParams->outputLinePitch              = outputLinePitch;
    algorithmParams->roundNBits                   = roundNBits;
    algorithmParams->output                       = output;
    algorithmParams->scratch                      = scratch;
    algorithmParams->cbStart                      = cbStart;
    algorithmParams->cbSize                       = cbSize;

    PvaAplSepConv5x5S16 **handleInteropPtr = (PvaAplSepConv5x5S16 **)cupvaPPEGetParamPointer();
    cupvaPPEWait();
    *handleInteropPtr = handle;

    cupvaPPEStart(PPE_FIXED_SEPCONV_5x5_S16_INIT_ID);
}

inline void pvaAplUpdateSepConv5x5S16Ppe(PvaAplSepConv5x5S16 *handle, int16_t *input, int16_t *output)
{
    SepConv5x5S16AlgorithmParams *algorithmParams = &handle->algorithmParams;
    algorithmParams->input                        = input;
    algorithmParams->output                       = output;
}

inline void pvaAplExecSepConv5x5S16Ppe(PvaAplSepConv5x5S16 *handle)
{
    PvaAplSepConv5x5S16 **handleInteropPtr = (PvaAplSepConv5x5S16 **)cupvaPPEGetParamPointer();
    cupvaPPEWait();
    *handleInteropPtr = (PvaAplSepConv5x5S16 *)handle;
    cupvaPPEStart(handle->commonParams.execFuncId);
}

inline void pvaAplInitHarrisCornerS16Ppe(PvaAplHarrisCornerS16 *handle, 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, void *scratch0, void *scratch1,
                                         void *scratch2)
{
    (void)scratch0;
    (void)scratch1;
    (void)scratch2;
    handle->commonParams.execFuncId                 = PPE_FIXED_HARRIS_CORNER_S16_EXEC_ID;
    HarrisCornerS16AlgorithmParams *algorithmParams = &handle->priv.ppe.algorithmParams;
    algorithmParams->input                          = input;
    algorithmParams->coeff                          = coeff;
    algorithmParams->roundNBits                     = roundNBits;
    algorithmParams->lambda                         = lambda;
    algorithmParams->width                          = width;
    algorithmParams->height                         = height;
    algorithmParams->inputLinePitch                 = inputLinePitch;
    algorithmParams->outputLinePitch                = outputLinePitch;
    algorithmParams->output                         = output;
    algorithmParams->cbStart                        = cbStart;
    algorithmParams->cbSize                         = cbSize;

    PvaAplHarrisCornerS16 **handleInteropPtr = (PvaAplHarrisCornerS16 **)cupvaPPEGetParamPointer();
    cupvaPPEWait();
    *handleInteropPtr = handle;

    cupvaPPEStart(PPE_FIXED_HARRIS_CORNER_S16_INIT_ID);
}

inline void pvaAplUpdateHarrisCornerS16Ppe(PvaAplHarrisCornerS16 *handle, int16_t *input, int32_t *output)
{
    HarrisCornerS16AlgorithmParams *algorithmParams = &handle->priv.ppe.algorithmParams;
    algorithmParams->input                          = input;
    algorithmParams->output                         = output;
}

inline void pvaAplExecHarrisCornerS16Ppe(PvaAplHarrisCornerS16 *handle)
{
    PvaAplHarrisCornerS16 **handleInteropPtr = (PvaAplHarrisCornerS16 **)cupvaPPEGetParamPointer();
    cupvaPPEWait();
    *handleInteropPtr = (PvaAplHarrisCornerS16 *)handle;
    cupvaPPEStart(handle->commonParams.execFuncId);
}

inline void pvaAplInitNms5x5S32Ppe(PvaAplNms5x5S32 *handle, int32_t *input, int32_t width, int32_t height,
                                   int32_t inputLinePitch, int32_t outputLinePitch, int32_t *output, int32_t *cbStart,
                                   int32_t cbSize, void *scratch)
{
    (void)scratch;
    handle->commonParams.execFuncId        = PPE_FIXED_NMS_5x5_S32_EXEC_ID;
    NmsS32AlgorithmParams *algorithmParams = &handle->priv.ppe.algorithmParams;
    algorithmParams->input                 = input;
    algorithmParams->width                 = width;
    algorithmParams->height                = height;
    algorithmParams->inputLinePitch        = inputLinePitch;
    algorithmParams->outputLinePitch       = outputLinePitch;
    algorithmParams->output                = output;
    algorithmParams->cbStart               = cbStart;
    algorithmParams->cbSize                = cbSize;

    PvaAplNms5x5S32 **handleInteropPtr = (PvaAplNms5x5S32 **)cupvaPPEGetParamPointer();
    cupvaPPEWait();
    *handleInteropPtr = handle;

    cupvaPPEStart(PPE_FIXED_NMS_5x5_S32_INIT_ID);
}

inline void pvaAplUpdateNms5x5S32Ppe(PvaAplNms5x5S32 *handle, int32_t *input, int32_t *output)
{
    NmsS32AlgorithmParams *algorithmParams = &handle->priv.ppe.algorithmParams;
    algorithmParams->input                 = input;
    algorithmParams->output                = output;
}

inline void pvaAplExecNms5x5S32Ppe(PvaAplNms5x5S32 *handle)
{
    PvaAplNms5x5S32 **handleInteropPtr = (PvaAplNms5x5S32 **)cupvaPPEGetParamPointer();
    cupvaPPEWait();
    *handleInteropPtr = (PvaAplNms5x5S32 *)handle;
    cupvaPPEStart(handle->commonParams.execFuncId);
}

inline void pvaAplInitNms3x3S32Ppe(PvaAplNms3x3S32 *handle, int32_t *input, int32_t width, int32_t height,
                                   int32_t inputLinePitch, int32_t outputLinePitch, int32_t *output, int32_t *cbStart,
                                   int32_t cbSize, void *scratch)
{
    handle->commonParams.execFuncId        = PPE_FIXED_NMS_3x3_S32_EXEC_ID;
    NmsS32AlgorithmParams *algorithmParams = &handle->priv.ppe.algorithmParams;
    algorithmParams->input                 = input;
    algorithmParams->width                 = width;
    algorithmParams->height                = height;
    algorithmParams->inputLinePitch        = inputLinePitch;
    algorithmParams->outputLinePitch       = outputLinePitch;
    algorithmParams->output                = output;
    algorithmParams->cbStart               = cbStart;
    algorithmParams->cbSize                = cbSize;

    PvaAplNms3x3S32 **handleInteropPtr = (PvaAplNms3x3S32 **)cupvaPPEGetParamPointer();
    cupvaPPEWait();
    *handleInteropPtr = handle;

    cupvaPPEStart(PPE_FIXED_NMS_3x3_S32_INIT_ID);
}

inline void pvaAplUpdateNms3x3S32Ppe(PvaAplNms3x3S32 *handle, int32_t *input, int32_t *output)
{
    NmsS32AlgorithmParams *algorithmParams = &handle->priv.ppe.algorithmParams;
    algorithmParams->input                 = input;
    algorithmParams->output                = output;
}

inline void pvaAplExecNms3x3S32Ppe(PvaAplNms3x3S32 *handle)
{
    PvaAplNms3x3S32 **handleInteropPtr = (PvaAplNms3x3S32 **)cupvaPPEGetParamPointer();
    cupvaPPEWait();
    *handleInteropPtr = handle;
    cupvaPPEStart(handle->commonParams.execFuncId);
}

#endif

#endif // PVA_APL_IMPL_H