gsdf_impl_hwseq.h#
Fully qualified name: src/device/vpu_runtime/include/cupva_device/impl/gsdf_impl_hwseq.h
File members: src/device/vpu_runtime/include/cupva_device/impl/gsdf_impl_hwseq.h
/*
* Copyright (c) 2023 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA Corporation is strictly prohibited.
*/
#ifndef GSDF_IMPL_HWSEQ_H
#define GSDF_IMPL_HWSEQ_H
#include "dma_common.h"
#include "gsdf_impl_common.h"
#include <cupva_types.h>
struct GSDFVPUConfigPreamble
{
GSDFVPUConfigPair frameHeader1;
GSDFVPUConfigPair srcPt1Cntl;
GSDFVPUConfigPair dstPt1Cntl;
GSDFVPUConfigPair vpucAddr;
};
struct GSDFHwseqVPUConfigTable
{
uint32_t count;
uint32_t magic;
GSDFVPUConfigPreamble preamble;
GSDFVPUConfigPair payload[];
};
// Data which exists on a per config buffer basis
struct GSDFHwseqConfigBuffer
{
ExtMemPointer extPointer;
GSDFBufferMetadata bufferMetadata;
GSDFHwseqVPUConfigTable *vpucTbl;
};
// Private GSDF struct
struct GSDFHwseqPriv
{
GSDFHwseqConfigBuffer configBuffers[GSDF_NUM_VPUC_BUFFERS];
/* Variable for storing VPUC table index */
uint32_t vpucTblIdx;
/* Variable for storing a flag to indicate that trigger has started. */
uint8_t triggered;
uint8_t padding[3];
};
inline GSDFHwseqVPUConfigTable *cupvaGSDFHwseqGetVPUCTblPongImpl(GSDFParams const *params,
GSDFHwseqVPUConfigTable const *vpucTable,
bool const isUniform)
{
uint32_t const tblSize = GSDF_HWSEQ_VPUC_TBL_SIZE(params->numTilesPerTrigger, isUniform);
uint8_t const *vpucTblPong = (uint8_t *)vpucTable + tblSize;
return POINTER_CAST(GSDFHwseqVPUConfigTable, vpucTblPong);
}
inline void cupvaGSDFHwseqInitPongBufferImpl(GSDFParams *params, GSDFHwseqPriv *priv, bool const isUniform)
{
dvuint *vpucTblPing = POINTER_CAST(dvuint, priv->configBuffers[0].vpucTbl);
dvuint *vpucTblPong = POINTER_CAST(dvuint, priv->configBuffers[1].vpucTbl);
uint32_t const vpucTblEntries =
GSDF_HWSEQ_VPUC_TBL_SIZE(params->numTilesPerTrigger, isUniform) / (sizeof(GSDFVPUConfigPair) * 8);
for (uint32_t i = 0; i < vpucTblEntries; i++)
{
*vpucTblPong = *vpucTblPing;
vpucTblPing++;
vpucTblPong++;
}
}
inline dvintx cupvaGetDescAttrAddrImpl(dvintx did, uint32_t fieldOfst)
{
uint32_t const base = cupvaGetDmaDescBase();
uint32_t const offset = base + fieldOfst;
dvintx size;
size.lo = replicatew((uint32_t)sizeof(PvaDmaDescriptor));
size.hi = replicatew((uint32_t)sizeof(PvaDmaDescriptor));
dvintx v0;
v0.lo = replicatew(offset);
v0.hi = replicatew(offset);
v0 = dvmaddwhw(did, size, v0, 0, 1);
return v0;
}
// Implementation of flipping GSDF vpu config table.
inline void cupvaGSDFHwseqCycleBuffersImpl(GSDFHwseqPriv *priv)
{
uint32_t vpucTblIdxN = mod_inc(priv->vpucTblIdx, GSDF_NUM_VPUC_BUFFERS - 1);
GSDFHwseqVPUConfigTable *oldBuffer = priv->configBuffers[priv->vpucTblIdx].vpucTbl;
GSDFHwseqVPUConfigTable *newBuffer = priv->configBuffers[vpucTblIdxN].vpucTbl;
oldBuffer->preamble.vpucAddr.value = cupvaGetVmemAddress(newBuffer);
priv->vpucTblIdx = vpucTblIdxN;
}
// Implementation of GSDF trigger.
inline void cupvaGSDFHwseqTrigImpl(GSDFParams *params, GSDFHwseqPriv *priv)
{
cupvaGSDFHwseqCycleBuffersImpl(priv);
priv->triggered = 1U;
cupvaDataFlowTrig(params->trigger);
}
// Implementation of GSDF sync.
inline void cupvaGSDFHwseqSyncImpl(GSDFParams *params, GSDFHwseqPriv *priv)
{
uint32_t trigger = (priv->triggered == 1U) ? params->trigger : 0U;
cupvaDataFlowSync(trigger);
}
// GSDF HWSEQ private functions.
// Implementation of GSDF trig private function.
inline void cupvaGSDFHwseqTrigPriv(GSDFHandler const *handler, GSDFParams *params, void *priv)
{
chess_dont_warn_dead(handler);
cupvaGSDFHwseqTrigImpl(params, POINTER_CAST(GSDFHwseqPriv, priv));
}
// Implementation of GSDF sync private function.
inline void cupvaGSDFHwseqSyncPriv(GSDFHandler const *handler, GSDFParams *params, void *priv)
{
chess_dont_warn_dead(handler);
cupvaGSDFHwseqSyncImpl(params, POINTER_CAST(GSDFHwseqPriv, priv));
}
// Implementation of GSDF CycleBuffers private function.
inline void cupvaGSDFHwseqCycleBuffersPriv(GSDFHandler const *handler, void *priv)
{
chess_dont_warn_dead(handler);
cupvaGSDFHwseqCycleBuffersImpl(POINTER_CAST(GSDFHwseqPriv, priv));
}
// Implementation of GSDF trig private function.
inline void cupvaGSDFHwseqTrigPriv(GSDFHandlerUniform const *handler, GSDFParams *params, void *priv)
{
chess_dont_warn_dead(handler);
cupvaGSDFHwseqTrigImpl(params, POINTER_CAST(GSDFHwseqPriv, priv));
}
// Implementation of GSDF sync private function.
inline void cupvaGSDFHwseqSyncPriv(GSDFHandlerUniform const *handler, GSDFParams *params, void *priv)
{
chess_dont_warn_dead(handler);
cupvaGSDFHwseqSyncImpl(params, POINTER_CAST(GSDFHwseqPriv, priv));
}
// Implementation of GSDF CycleBuffers private function.
inline void cupvaGSDFHwseqCycleBuffersPriv(GSDFHandlerUniform const *handler, void *priv)
{
chess_dont_warn_dead(handler);
cupvaGSDFHwseqCycleBuffersImpl(POINTER_CAST(GSDFHwseqPriv, priv));
}
bool cupvaGSDFHwseqOpenPriv(GSDFHandler *handler, void *addr, uint16_t linePitch, uint32_t stride);
void cupvaGSDFHwseqClosePriv(GSDFHandler *handler);
bool cupvaGSDFHwseqResetExtBasePriv(GSDFHandler *handler, ExtMemPointer const *addr, uint16_t width, uint16_t height,
uint16_t linePitch);
bool cupvaGSDFHwseqResetExtBasePriv(GSDFHandler *handler, VPUSurfaceData const *surfObj);
bool cupvaGSDFHwseqResetExtBasePriv(GSDFHandler *handler, VPUSurfaceData const *surfObj, PlanarGeometry const *geom);
bool cupvaGSDFHwseqResetExtBasePriv(GSDFHandler *handler, ExtMemPointer const *addr, PlanarGeometry const *geom);
void cupvaGSDFHwseqUpdateVmemAddrPriv(GSDFHandler *handler, void *addr, uint16_t linePitch, uint32_t stride);
void cupvaGSDFHwseqUpdateOffsets1DPriv(GSDFHandler *handler, int32_t const *offsets);
void cupvaGSDFHwseqUpdateOffsets2DPriv(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords);
void cupvaGSDFHwseqUpdateSize1DPriv(GSDFHandler *handler, uint16_t const *transferSizes, int32_t size);
void cupvaGSDFHwseqUpdateSize1DPriv(GSDFHandler *handler, uint16_t transferSize, int32_t size);
void cupvaGSDFHwseqUpdateSize2DPriv(GSDFHandler *handler, uint16_t const *tx, uint16_t const *ty, int32_t size);
void cupvaGSDFHwseqUpdateSize2DPriv(GSDFHandler *handler, uint16_t tx, uint16_t ty, int32_t size);
void cupvaGSDFHwseqUpdateTilesPriv(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords,
uint16_t const *tx, uint16_t const *ty, int32_t size);
void cupvaGSDFHwseqUpdateTilesPriv(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords,
uint16_t const tx, uint16_t const ty, int32_t size);
void cupvaGSDFHwseqUpdateTilesPriv(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords, int32_t size);
void cupvaGSDFHwseqUpdateTilesWithOffsetsPriv(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords,
int32_t const *offsets, uint16_t const *tx, uint16_t const *ty,
int32_t size);
void cupvaGSDFHwseqUpdateTilesWithOffsetsPriv(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords,
int32_t const *offsets, uint16_t const tx, uint16_t const ty,
int32_t size);
void cupvaGSDFHwseqUpdateTilesWithOffsetsPriv(GSDFHandler *handler, int32_t const *xCoords, int32_t const *yCoords,
int32_t const *offsets, int32_t size);
void cupvaGSDFHwseqUpdatePlaneIndicesPriv(GSDFHandler *handler, uint8_t const *planeIndices, int32_t const size);
bool cupvaGSDFHwseqOpenPriv(GSDFHandlerUniform *handler, void *addr, uint16_t linePitch, uint32_t stride);
void cupvaGSDFHwseqClosePriv(GSDFHandlerUniform *handler);
bool cupvaGSDFHwseqResetExtBasePriv(GSDFHandlerUniform *handler, ExtMemPointer const *addr, uint16_t width,
uint16_t height, uint16_t linePitch);
bool cupvaGSDFHwseqResetExtBasePriv(GSDFHandlerUniform *handler, ExtMemPointer const *addr, PlanarGeometry const *geom);
void cupvaGSDFHwseqUpdateVmemAddrPriv(GSDFHandlerUniform *handler, void *addr, uint16_t linePitch, uint32_t stride);
void cupvaGSDFHwseqUpdateOffsets1DPriv(GSDFHandlerUniform *handler, int32_t const *offsets);
void cupvaGSDFHwseqUpdateOffsets2DPriv(GSDFHandlerUniform *handler, int32_t const *xCoords, int32_t const *yCoords);
void cupvaGSDFHwseqUpdateSize1DPriv(GSDFHandlerUniform *handler, uint16_t transferSize);
void cupvaGSDFHwseqUpdateSize2DPriv(GSDFHandlerUniform *handler, uint16_t tx, uint16_t ty);
void cupvaGSDFHwseqUpdatePlaneIndicesPriv(GSDFHandlerUniform *handler, uint8_t const *planeIndices);
#endif // CUPVA_GSDF_IMPL_H