535.104.05

This commit is contained in:
Bernhard Stoeckner
2023-08-22 15:09:37 +02:00
parent 12c0739352
commit a8e01be6b2
122 changed files with 41595 additions and 34601 deletions

View File

@@ -181,24 +181,6 @@ static const NVHDMIPKT_CLASS_HIERARCHY hierarchy[] =
},
};
#if defined(DSC_CALLBACK_MODIFIED)
// Callbacks for DSC PPS library
void *hdmipktMallocCb(const void *clientHandle, NvLength size);
void hdmipktFreeCb(const void *clientHandle, void *pMemPtr);
void *hdmipktMallocCb(const void *clientHandle, NvLength size)
{
const NVHDMIPKT_CLASS *pClass = (const NVHDMIPKT_CLASS*)(clientHandle);
return pClass->callback.malloc(pClass->cbHandle, size);
}
void hdmipktFreeCb(const void *clientHandle, void *pMemPtr)
{
const NVHDMIPKT_CLASS *pClass = (const NVHDMIPKT_CLASS*)(clientHandle);
pClass->callback.free(pClass->cbHandle, pMemPtr);
}
#endif // DSC_CALLBACK_MODIFIED
/********************************** HDMI Library interfaces *************************************/
/*
* NvHdmiPkt_PacketCtrl
@@ -581,15 +563,6 @@ NvHdmiPkt_InitializeLibrary(NvU32 const hwClass,
// 2. Constructor calls
result = NvHdmiPkt_CallConstructors(thisClassId, pClass);
#if defined(DSC_CALLBACK_MODIFIED)
DSC_CALLBACK callbacks;
NVMISC_MEMSET(&callbacks, 0, sizeof(DSC_CALLBACK));
callbacks.clientHandle = pClass;
callbacks.dscMalloc = hdmipktMallocCb;
callbacks.dscFree = hdmipktFreeCb;
DSC_InitializeCallback(callbacks);
#endif // DSC_CALLBACK_MODIFIED
NvHdmiPkt_InitializeLibrary_exit:
if (result)
{

View File

@@ -1168,18 +1168,29 @@ frlQuery_Success:
NvU64 availableLinkBw = (NvU64)(frlBitRateGbps) * (NvU64)(numLanes) * MULTIPLIER_1G;
warData.connectorType = DSC_HDMI;
DSC_GENERATE_PPS_OPAQUE_WORKAREA *pDscScratchBuffer = NULL;
pDscScratchBuffer = (DSC_GENERATE_PPS_OPAQUE_WORKAREA*)pThis->callback.malloc(pThis->cbHandle,
sizeof(DSC_GENERATE_PPS_OPAQUE_WORKAREA));
if ((DSC_GeneratePPS(&dscInfo,
&dscModesetInfo,
&warData,
availableLinkBw,
pFRLConfig->dscInfo.pps,
&bitsPerPixelX16)) != NVT_STATUS_SUCCESS)
&bitsPerPixelX16,
pDscScratchBuffer)) != NVT_STATUS_SUCCESS)
{
NvHdmiPkt_Print(pThis, "ERROR - DSC PPS calculation failed.");
NvHdmiPkt_Assert(0);
result = NVHDMIPKT_FAIL;
}
if (pDscScratchBuffer != NULL)
{
pThis->callback.free(pThis->cbHandle, pDscScratchBuffer);
pDscScratchBuffer = NULL;
}
// DSC lib should honor the bpp setting passed from client, assert here just in case
NvHdmiPkt_Assert(bitsPerPixelX16 == pFRLConfig->dscInfo.bitsPerPixelX16);
}

View File

@@ -33,20 +33,19 @@
#include "nvt_dsc_pps.h"
#include "nvmisc.h"
#include "displayport/displayport.h"
#include "nvctassert.h"
#include <stddef.h>
/* ------------------------ Macros ----------------------------------------- */
#if defined (DEBUG)
#define DSC_Print(...) \
do { \
if (callbacks.dscPrint) { \
callbacks.dscPrint("DSC: " __VA_ARGS__); \
} \
} while(0)
#else
//
// DSC_Print macro was for debugging purposes in early development of
// DSC PPS library. The print statements no longer get logged
// inside any client logger. But the lines of print in this file are useful
// for browsing code, hence this DSC_Print is left as a stub
// definition intentionally to help reader understand the PPS code.
//
#define DSC_Print(...) do { } while(0)
#endif
#define MIN_CHECK(s,a,b) { if((a)<(b)) { DSC_Print("%s (=%u) needs to be larger than %u",s,a,b); return (NVT_STATUS_ERR);} }
#define RANGE_CHECK(s,a,b,c) { if((((NvS32)(a))<(NvS32)(b))||(((NvS32)(a))>(NvS32)(c))) { DSC_Print("%s (=%u) needs to be between %u and %u",s,a,b,c); return (NVT_STATUS_ERR);} }
@@ -171,9 +170,21 @@ typedef struct
NvU32 flatness_det_thresh;
} DSC_OUTPUT_PARAMS;
/* ------------------------ Global Variables ------------------------------- */
//
// Opaque scratch space is passed by client for DSC calculation usage.
// Use an internal struct to cast the input buffer
// into in/out params for DSC PPS calculation functions to work with
//
typedef struct _DSC_GENERATE_PPS_WORKAREA
{
DSC_INPUT_PARAMS in;
DSC_OUTPUT_PARAMS out;
} DSC_GENERATE_PPS_WORKAREA;
DSC_CALLBACK callbacks;
// Compile time check to ensure Opaque workarea buffer size always covers required work area.
ct_assert(sizeof(DSC_GENERATE_PPS_OPAQUE_WORKAREA) >= sizeof(DSC_GENERATE_PPS_WORKAREA));
/* ------------------------ Global Variables ------------------------------- */
static const NvU8 minqp444_8b[15][37]={
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
@@ -396,8 +407,6 @@ static const NvU32 rcBufThresh[] = { 896, 1792, 2688, 3584, 4480, 5376, 6272, 67
/* ------------------------ Static Variables ------------------------------- */
/* ------------------------ Private Functions Prototype--------------------- */
static void * DSC_Malloc(NvLength size);
static void DSC_Free(void * ptr);
static NvU32
DSC_GetHigherSliceCount
(
@@ -1586,19 +1595,11 @@ static NVT_STATUS
DSC_PpsDataGen
(
const DSC_INPUT_PARAMS *in,
NvU32 out[DSC_MAX_PPS_SIZE_DWORD]
DSC_OUTPUT_PARAMS *pPpsOut,
NvU32 out[DSC_MAX_PPS_SIZE_DWORD]
)
{
NVT_STATUS ret;
DSC_OUTPUT_PARAMS *pPpsOut;
pPpsOut = (DSC_OUTPUT_PARAMS *)DSC_Malloc(sizeof(DSC_OUTPUT_PARAMS));
if (pPpsOut == NULL)
{
DSC_Print("ERROR - Memory allocation error.");
ret = NVT_STATUS_NO_MEMORY;
goto done;
}
NVMISC_MEMSET(pPpsOut, 0, sizeof(DSC_OUTPUT_PARAMS));
ret = DSC_PpsCalc(in, pPpsOut);
@@ -1612,44 +1613,9 @@ DSC_PpsDataGen
/* fall through */
done:
DSC_Free(pPpsOut);
return ret;
}
/*
* @brief Allocates memory for requested size
*
* @param[in] size Size to be allocated
*
* @returns Pointer to allocated memory
*/
static void *
DSC_Malloc(NvLength size)
{
#if defined(DSC_CALLBACK_MODIFIED)
return (callbacks.dscMalloc)(callbacks.clientHandle, size);
#else
return (callbacks.dscMalloc)(size);
#endif // DSC_CALLBACK_MODIFIED
}
/*
* @brief Frees dynamically allocated memory
*
* @param[in] ptr Pointer to a memory to be deallocated
*
*/
static void
DSC_Free(void * ptr)
{
#if defined(DSC_CALLBACK_MODIFIED)
(callbacks.dscFree)(callbacks.clientHandle, ptr);
#else
(callbacks.dscFree)(ptr);
#endif // DSC_CALLBACK_MODIFIED
}
/*
* @brief Validate input parameter we got from caller of this function
*
@@ -1992,19 +1958,26 @@ DSC_GeneratePPS
const WAR_DATA *pWARData,
NvU64 availableBandwidthBitsPerSecond,
NvU32 pps[DSC_MAX_PPS_SIZE_DWORD],
NvU32 *pBitsPerPixelX16
NvU32 *pBitsPerPixelX16,
DSC_GENERATE_PPS_OPAQUE_WORKAREA *pOpaqueWorkarea
)
{
DSC_INPUT_PARAMS *in = NULL;
DSC_INPUT_PARAMS *in = NULL;
DSC_OUTPUT_PARAMS *out = NULL;
DSC_GENERATE_PPS_WORKAREA *pWorkarea = NULL;
NVT_STATUS ret = NVT_STATUS_ERR;
if ((!pDscInfo) || (!pModesetInfo) || (!pBitsPerPixelX16))
if ((!pDscInfo) || (!pModesetInfo) || (!pBitsPerPixelX16) || (!pOpaqueWorkarea))
{
DSC_Print("ERROR - Invalid parameter.");
ret = NVT_STATUS_INVALID_PARAMETER;
goto done;
}
pWorkarea = (DSC_GENERATE_PPS_WORKAREA*)(pOpaqueWorkarea);
in = &pWorkarea->in;
out = &pWorkarea->out;
ret = _validateInput(pDscInfo, pModesetInfo, pWARData, availableBandwidthBitsPerSecond);
if (ret != NVT_STATUS_SUCCESS)
{
@@ -2013,14 +1986,6 @@ DSC_GeneratePPS
goto done;
}
in = (DSC_INPUT_PARAMS *)DSC_Malloc(sizeof(DSC_INPUT_PARAMS));
if (in == NULL)
{
DSC_Print("ERROR - Memory allocation error.");
ret = NVT_STATUS_NO_MEMORY;
goto done;
}
NVMISC_MEMSET(in, 0, sizeof(DSC_INPUT_PARAMS));
in->bits_per_component = pModesetInfo->bitsPerComponent;
@@ -2277,42 +2242,11 @@ DSC_GeneratePPS
}
}
ret = DSC_PpsDataGen(in, pps);
ret = DSC_PpsDataGen(in, out, pps);
*pBitsPerPixelX16 = in->bits_per_pixel;
/* fall through */
done:
DSC_Free(in);
return ret;
}
/*
* @brief Initializes callbacks for print and assert
*
* @param[in] callback DSC callbacks
*
* @returns NVT_STATUS_SUCCESS if successful;
* NVT_STATUS_ERR if unsuccessful;
*/
NVT_STATUS DSC_InitializeCallback(DSC_CALLBACK callback)
{
// if callbacks are initialized already, return nothing to do
if (callbacks.dscMalloc && callbacks.dscFree)
{
return NVT_STATUS_SUCCESS;
}
#if defined(DSC_CALLBACK_MODIFIED)
callbacks.clientHandle = callback.clientHandle;
#endif // DSC_CALLBACK_MODIFIED
callbacks.dscPrint = NULL;
callbacks.dscMalloc = callback.dscMalloc;
callbacks.dscFree = callback.dscFree;
#if defined (DEBUG)
callbacks.dscPrint = callback.dscPrint;
#endif
return NVT_STATUS_SUCCESS;
}

View File

@@ -43,27 +43,6 @@
/* ------------------------ Datatypes -------------------------------------- */
#define DSC_CALLBACK_MODIFIED 1
#if defined(DSC_CALLBACK_MODIFIED)
typedef struct
{
// DSC - Callbacks
const void* clientHandle; // ClientHandle is only used when calling into HDMI lib's mallocCb/freeCb
void (*dscPrint) (const char* fmtstring, ...);
void *(*dscMalloc)(const void *clientHandle, NvLength size);
void (*dscFree) (const void *clientHandle, void * ptr);
} DSC_CALLBACK;
#else
typedef struct
{
// DSC - Callbacks
void (*dscPrint) (const char* fmtstring, ...);
void *(*dscMalloc)(NvLength size);
void (*dscFree) (void * ptr);
} DSC_CALLBACK;
#endif // DSC_CALLBACK_MODIFIED
typedef struct
{
NvU32 versionMajor;
@@ -278,6 +257,16 @@ typedef struct
}dpData;
} WAR_DATA;
//
// DSC PPS calculations need large scratch buffer to work with, which can be too
// big for some platforms. These buffers need to be allocated on heap rather
// than local stack variable. Clients are expected to pre-allocate
// this buffer and pass it in to DSC PPS interface
//
typedef struct {
NvU8 data[512U]; // an upper bound of total size of DSC_IN/OUTPUT_PARAMS
} DSC_GENERATE_PPS_OPAQUE_WORKAREA;
/*
* Windows testbed compiles are done with warnings as errors
* with the maximum warning level. Here we turn off some
@@ -292,16 +281,6 @@ typedef struct
#ifdef __cplusplus
extern "C" {
#endif
/*
* @brief Initializes callbacks for print and assert
*
* @param[in] callback DSC callbacks
*
* @returns NVT_STATUS_SUCCESS if successful;
* NVT_STATUS_ERR if unsuccessful;
*/
NVT_STATUS DSC_InitializeCallback(DSC_CALLBACK callback);
/*
* @brief Calculate PPS parameters based on passed down Sink,
* GPU capability and modeset info
@@ -323,7 +302,8 @@ NVT_STATUS DSC_GeneratePPS(const DSC_INFO *pDscInfo,
const WAR_DATA *pWARData,
NvU64 availableBandwidthBitsPerSecond,
NvU32 pps[DSC_MAX_PPS_SIZE_DWORD],
NvU32 *pBitsPerPixelX16);
NvU32 *pBitsPerPixelX16,
DSC_GENERATE_PPS_OPAQUE_WORKAREA *pOpaqueWorkarea);
#ifdef __cplusplus
}