515.43.04

This commit is contained in:
Andy Ritger
2022-05-09 13:18:59 -07:00
commit 1739a20efc
2519 changed files with 1060036 additions and 0 deletions

View File

@@ -0,0 +1,268 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/** @file nvhdmi_frlInterface.h
* @brief This file provides FRL related interfaces between client and HDMI lib
*/
#ifndef _NVHDMI_FRLINTERFACE_H_
#define _NVHDMI_FRLINTERFACE_H_
#include "nvhdmipkt.h"
#include "nvHdmiFrlCommon.h"
#include "../timing/nvtiming.h"
#ifdef __cplusplus
extern "C" {
#endif
// DSC encoder color format bitmasks (these match DSC lib & RM ctrl 0073 fields)
typedef enum tagHDMI_DSC_ENCODER_COLOR_FORMAT
{
HDMI_DSC_ENCODER_COLOR_FORMAT_RGB = 1,
HDMI_DSC_ENCODER_COLOR_FORMAT_YCBCR444 = 2,
HDMI_DSC_ENCODER_COLOR_FORMAT_YCBCRNATIVE422 = 4,
HDMI_DSC_ENCODER_COLOR_FORMAT_YCBCRNATIVE420 = 8
} HDMI_DSC_ENCODER_COLOR_FORMAT;
// Options for QueryFRLConfig interface
typedef enum tagHDMI_QUERY_FRL_OPTION
{
HDMI_QUERY_FRL_ANY_CONFIG = 0, // any FRL config that supports mode
HDMI_QUERY_FRL_OPTIMUM_CONFIG, // find best fit config for this mode
HDMI_QUERY_FRL_LOWEST_BANDWIDTH, // min bw
HDMI_QUERY_FRL_HIGHEST_PIXEL_QUALITY, // trade off bandwidth for pixel quality
HDMI_QUERY_FRL_HIGHEST_BANDWIDTH
} HDMI_QUERY_FRL_OPTION;
/*************************************************************************************************
* HDMI_VIDEO_TRANSPORT_INFO: *
* Video transport format - a combination of timing, bpc, packing represents what goes on the link*
* client passes this in, lib uses this for bandwidth calculations to decide required FRL rate *
**************************************************************************************************/
typedef struct tagHDMI_VIDEO_TRANSPORT_INFO
{
const NVT_TIMING *pTiming; // backend timing
HDMI_BPC bpc;
HDMI_PIXEL_PACKING packing;
NvBool bDualHeadMode; // 2H1OR
} HDMI_VIDEO_TRANSPORT_INFO;
/************************************************************************************************
* HDMI_QUERY_FRL_CLIENT_CONTROL: *
* Allow client to force request DSC/FRL configurations. For testing purpose or otherwise *
* eg, client could query for any fitting FRL config instead of most optimum. It could trade off *
* bandwidth for pixel quality. *
*************************************************************************************************/
typedef struct tagHDMI_QUERY_FRL_CLIENT_CONTROL
{
HDMI_QUERY_FRL_OPTION option;
NvU32 forceFRLRate : 1;
NvU32 forceAudio2Ch48KHz : 1;
NvU32 enableDSC : 1;
NvU32 forceSliceCount : 1;
NvU32 forceSliceWidth : 1;
NvU32 forceBppx16 : 1;
NvU32 skipGeneratePPS : 1;
NvU32 reserved : 25;
// client can set below params if respective force flag is set
NvU32 sliceCount;
NvU32 sliceWidth;
NvU32 bitsPerPixelX16;
HDMI_FRL_DATA_RATE frlRate;
} HDMI_QUERY_FRL_CLIENT_CONTROL;
/************************************************************************************************
* HDMI_SRC_CAPS: *
* Input to HDMI lib. *
* *
* Client gives info about GPU capabilities - DSC related caps *
*************************************************************************************************/
typedef struct tagHDMI_SRC_CAPS
{
struct
{
NvU32 dscCapable : 1;
NvU32 bppPrecision : 8;
NvU32 encoderColorFormatMask : 8;
NvU32 lineBufferSizeKB : 8;
NvU32 rateBufferSizeKB : 8;
NvU32 maxNumHztSlices : 8;
NvU32 lineBufferBitDepth : 8;
NvU32 dualHeadBppTargetMaxX16 : 16;
NvU32 maxWidthPerSlice;
} dscCaps;
HDMI_FRL_DATA_RATE linkMaxFRLRate;
} HDMI_SRC_CAPS;
/************************************************************************************************
* HDMI_SINK_CAPS: *
* Input to HDMI lib. *
* *
* Client gives info from EDID, HDMI lib uses DSC related info to call DSC lib to generate PPS *
* Audio information from CEA861 block is used for bandwidth calculations *
* linkMaxFRLRate and linkMaxFRLRateDSC are max link rates determined from physical link *
* training. *
*************************************************************************************************/
typedef struct tagHDMI_SINK_CAPS
{
const NVT_HDMI_FORUM_INFO *pHdmiForumInfo;
NvU32 audioType;
NvU32 maxAudioChannels;
NvU32 maxAudioFreqKHz;
NvBool bHBRAudio;
HDMI_FRL_DATA_RATE linkMaxFRLRate;
HDMI_FRL_DATA_RATE linkMaxFRLRateDSC;
} HDMI_SINK_CAPS;
/************************************************************************************************
* HDMI_FRL_CONFIG: *
* Output from HDMI lib. Client uses this info for modeset *
* *
* maxSupportedAudioCh, maxSupportedAudioFreqKHz - max possible audio settings at the chosen *
* FRL rate, though the sink caps may have reported higher caps *
* *
* dscInfo - if current timing requires DSC, lib returns PPS information here *
* *
* bitsPerPixelx16 - optimum bpp value calculated per spec *
* dscHActiveBytes - in compressed video transport mode, number of bytes in 1 line *
* dscHActiveTriBytes - in compressed video transport mode, number of tri-bytes in 1 line *
* dscHBlankTriBytes - in compressed video transport mode, number of tri-bytes to be sent *
* to represent horizontal blanking *
* *
* pps[32] - PPS data. HDMI lib calls DSC lib to fill it in *
*************************************************************************************************/
#define HDMI_DSC_MAX_PPS_SIZE_DWORD 32
typedef struct tagHDMI_FRL_CONFIG
{
HDMI_FRL_DATA_RATE frlRate;
NvU32 maxSupportedAudioCh;
NvU32 maxSupportedAudioFreqKHz;
// DSC info client will use for core channel modeset
struct
{
NvU32 bEnableDSC : 1;
NvU32 reserved : 31;
NvU32 bitsPerPixelX16;
NvU32 sliceCount;
NvU32 sliceWidth;
NvU32 pps[HDMI_DSC_MAX_PPS_SIZE_DWORD];
NvU32 dscHActiveBytes;
NvU32 dscHActiveTriBytes;
NvU32 dscHBlankTriBytes;
NvU32 dscTBlankToTTotalRatioX1k;
} dscInfo;
} HDMI_FRL_CONFIG;
/************************************************************************************************
* NvHdmi_AssessLinkCapabilities: *
* *
* Input parameters: *
* subDevice - Sub Device ID. *
* displayId - Display ID. *
* pSinkEdid - EDID of sink *
* *
* Output parameters: *
* pSrcCaps - src capabilities - DSC caps *
* pSinkCaps - sink capabilities - actual caps calculated from link training *
* *
* Calls RM to get DSC related src side caps. Performs physical link training to determine if *
* sink reported max FRL rate can actually be supported on the physical link *
*************************************************************************************************/
NVHDMIPKT_RESULT
NvHdmi_AssessLinkCapabilities(NvHdmiPkt_Handle libHandle,
NvU32 subDevice,
NvU32 displayId,
NVT_EDID_INFO const * const pSinkEdid,
HDMI_SRC_CAPS *pSrcCaps,
HDMI_SINK_CAPS *pSinkCaps);
/************************************************************************************************
* NvHdmi_QueryFRLConfig: *
* *
* Input parameters: *
* libHandle - Hdmi library handle, provided on initializing the library. *
* pVidTransInfo - information about timing, bpc and packing *
* pClientCtrl - settings client wants to see set. HDMI lib tries to honor these *
* pSinkCaps - sink capabilities *
* *
* Output parameters: *
* pFRLConfig - chosen FRL rate and DSC configuration *
* *
*************************************************************************************************/
NVHDMIPKT_RESULT
NvHdmi_QueryFRLConfig(NvHdmiPkt_Handle libHandle,
HDMI_VIDEO_TRANSPORT_INFO const * const pVidTransInfo,
HDMI_QUERY_FRL_CLIENT_CONTROL const * const pClientCtrl,
HDMI_SRC_CAPS const * const pSrcCaps,
HDMI_SINK_CAPS const * const pSinkCaps,
HDMI_FRL_CONFIG *pFRLConfig);
/************************************************************************************************
* NvHdmi_SetFRLConfig: *
* *
* Input parameters: *
* libHandle - Hdmi library handle, provided on initializing the library. *
* subDevice - Sub Device ID. *
* displayId - Display ID. *
* bFakeLt - Indicates that the GPU's link configuration should be forced and that *
* configuration of the sink device should be skipped. *
* pFRLConfig - Link configuration to set. *
* *
************************************************************************************************/
NVHDMIPKT_RESULT
NvHdmi_SetFRLConfig(NvHdmiPkt_Handle libHandle,
NvU32 subDevice,
NvU32 displayId,
NvBool bFakeLt,
HDMI_FRL_CONFIG *pFRLConfig);
/************************************************************************************************
* NvHdmi_ClearFRLConfig: *
* *
* Input parameters: *
* libHandle - Hdmi library handle, provided on initializing the library. *
* subDevice - Sub Device ID. *
* displayId - Display ID to change the settings on. *
* *
************************************************************************************************/
NVHDMIPKT_RESULT
NvHdmi_ClearFRLConfig(NvHdmiPkt_Handle libHandle,
NvU32 subDevice,
NvU32 displayId);
#ifdef __cplusplus
}
#endif
#endif // _NVHDMI_FRLINTERFACE_H_

View File

@@ -0,0 +1,616 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* File: nvhdmipkt.c
*
* Purpose: Provide initialization functions for HDMI library
*/
#include "nvlimits.h"
#include "nvhdmipkt_common.h"
#include "nvhdmipkt_class.h"
#include "nvhdmipkt_internal.h"
#include "../timing/nvt_dsc_pps.h"
#include "class/cl9170.h"
#include "class/cl917d.h"
#include "class/cl9270.h"
#include "class/cl927d.h"
#include "class/cl9470.h"
#include "class/cl947d.h"
#include "class/cl9570.h"
#include "class/cl957d.h"
#include "class/clc370.h"
#include "class/clc37d.h"
#include "class/clc570.h"
#include "class/clc57d.h"
#include "class/clc670.h"
#include "class/clc67d.h"
// Class hierarchy structure
typedef struct tagNVHDMIPKT_CLASS_HIERARCHY
{
NVHDMIPKT_CLASS_ID classId;
NVHDMIPKT_CLASS_ID parentClassId;
NvBool isRootClass;
void (*initInterface)(NVHDMIPKT_CLASS*);
NvBool (*constructor) (NVHDMIPKT_CLASS*);
void (*destructor) (NVHDMIPKT_CLASS*);
NvU32 displayClass;
NvU32 coreDmaClass;
} NVHDMIPKT_CLASS_HIERARCHY;
/*************************************************************************************************
* hierarchy structure establishes the relationship between classes. *
* If isRootClass=NV_TRUE, it is a root class, else it is a child of a class. classId *
* also acts as an index, and hence the order of the structure below should be maintanied. *
* *
* ASSUMPTION: There are two huge assumptions while creating the class relationship and *
* while traversing it. 1. That of the Class ID definitaion (NVHDMIPKT_CLASS_ID), which has *
* to be strictly indexed, that is 0, 1, 2... and so on. And 2. that the structure *
* CLASS_HIERARCHY (above) follow that indexing. That is NVHDMIPKT_0073_CLASS is value 0 and *
* the first entry in CLASS_HIERARCHY, NVHDMIPKT_9171_CLASS is value 1 and hence the second *
* entry in CLASS_HIERARCHY, so on and so forth. *
* *
* HOW TO ADD A NEW CLASS? *
* 1. Add an ID in NVHDMIPKT_CLASS_ID. *
* 2. Add a source file nvhdmipkt_XXXX.c, and include it into makefiles. Makefiles of *
* Mods, Windows, and Linux. *
* 3. Provide initializeHdmiPktInterfaceXXXX, hdmiConstructorXXXX, and, hdmiDestructorXXXX. *
* 4. Add functions that needs to be overridden in NVHDMIPKT_CLASS. *
* 5. Add a relationship in hierarchy[] array. The new class can be a subclass or a root. In *
* case of a root all the interfaces needs to be overridden in NVHDMIPKT_CLASS. *
************************************************************************************************/
static const NVHDMIPKT_CLASS_HIERARCHY hierarchy[] =
{
{// Index 0==NVHDMIPKT_0073_CLASS
NVHDMIPKT_0073_CLASS, // classId
NVHDMIPKT_0073_CLASS, // parentClassId
NV_TRUE, // isRootClass
initializeHdmiPktInterface0073, // initInterface
hdmiConstructor0073, // constructor
hdmiDestructor0073, // destructor
0, // displayClass
0 // coreDmaClass
},
{// Index 1==NVHDMIPKT_9171_CLASS
NVHDMIPKT_9171_CLASS, // classId
NVHDMIPKT_9171_CLASS, // parentClassId
NV_TRUE, // isRootClass
initializeHdmiPktInterface9171, // initInterface
hdmiConstructor9171, // constructor
hdmiDestructor9171, // destructor
NV9170_DISPLAY, // displayClass
NV917D_CORE_CHANNEL_DMA // coreDmaClass
},
{// Index 2==NVHDMIPKT_9271_CLASS
NVHDMIPKT_9271_CLASS, // classId
NVHDMIPKT_9171_CLASS, // parentClassId
NV_FALSE, // isRootClass
initializeHdmiPktInterface9271, // initInterface
hdmiConstructor9271, // constructor
hdmiDestructor9271, // destructor
NV9270_DISPLAY, // displayClass
NV927D_CORE_CHANNEL_DMA // coreDmaClass
},
{// Index 3==NVHDMIPKT_9471_CLASS
NVHDMIPKT_9471_CLASS, // classId
NVHDMIPKT_9171_CLASS, // parentClassId
NV_FALSE, // isRootClass
initializeHdmiPktInterface9471, // initInterface
hdmiConstructor9471, // constructor
hdmiDestructor9471, // destructor
NV9470_DISPLAY, // displayClass
NV947D_CORE_CHANNEL_DMA // coreDmaClass
},
{// Index 4==NVHDMIPKT_9571_CLASS
NVHDMIPKT_9571_CLASS, // classId
NVHDMIPKT_9171_CLASS, // parentClassId
NV_FALSE, // isRootClass
initializeHdmiPktInterface9571, // initInterface
hdmiConstructor9571, // constructor
hdmiDestructor9571, // destructor
NV9570_DISPLAY, // displayClass
NV957D_CORE_CHANNEL_DMA // coreDmaClass
},
{// Index 5==NVHDMIPKT_C371_CLASS
NVHDMIPKT_C371_CLASS, // classId
NVHDMIPKT_9171_CLASS, // parentClassId
NV_FALSE, // isRootClass
initializeHdmiPktInterfaceC371, // initInterface
hdmiConstructorC371, // constructor
hdmiDestructorC371, // destructor
NVC370_DISPLAY, // displayClass
NVC37D_CORE_CHANNEL_DMA // coreDmaClass
},
{// Index 6==NVHDMIPKT_C571_CLASS
// Note that Turing (C57x) has a distinct displayClass and coreDmaClass,
// but it inherits the _DISP_SF_USER class from Volta (C37x). We call this
// NVHDMIPKT_C571_CLASS, but reuse initInterface()/constructor()/destructor()
// from C371.
NVHDMIPKT_C571_CLASS,
NVHDMIPKT_9171_CLASS, // parentClassId
NV_FALSE, // isRootClass
initializeHdmiPktInterfaceC371, // initInterface
hdmiConstructorC371, // constructor
hdmiDestructorC371, // destructor
NVC570_DISPLAY, // displayClass
NVC57D_CORE_CHANNEL_DMA // coreDmaClass
},
{// Index 7==NVHDMIPKT_C671_CLASS
NVHDMIPKT_C671_CLASS, // classId
NVHDMIPKT_9171_CLASS, // parentClassId
NV_FALSE, // isRootClass
initializeHdmiPktInterfaceC671, // initInterface
hdmiConstructorC671, // constructor
hdmiDestructorC671, // destructor
NVC670_DISPLAY, // displayClass
NVC67D_CORE_CHANNEL_DMA // coreDmaClass
},
};
#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
*/
NVHDMIPKT_RESULT
NvHdmiPkt_PacketCtrl(NvHdmiPkt_Handle libHandle,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl)
{
NVHDMIPKT_CLASS* pClass = fromHdmiPktHandle(libHandle);
if (libHandle == NVHDMIPKT_INVALID_HANDLE)
{
return NVHDMIPKT_LIBRARY_INIT_FAIL;
}
return pClass->hdmiPacketCtrl(pClass,
subDevice,
displayId,
head,
packetType,
transmitControl);
}
/*
* NvHdmiPkt_PacketWrite
*/
NVHDMIPKT_RESULT
NvHdmiPkt_PacketWrite(NvHdmiPkt_Handle libHandle,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl,
NvU32 packetLen,
NvU8 const *const pPacket)
{
NVHDMIPKT_CLASS* pClass = fromHdmiPktHandle(libHandle);
if (libHandle == NVHDMIPKT_INVALID_HANDLE)
{
return NVHDMIPKT_LIBRARY_INIT_FAIL;
}
return pClass->hdmiPacketWrite(pClass,
subDevice,
displayId,
head,
packetType,
transmitControl,
packetLen,
pPacket);
}
NVHDMIPKT_RESULT
NvHdmi_AssessLinkCapabilities(NvHdmiPkt_Handle libHandle,
NvU32 subDevice,
NvU32 displayId,
NVT_EDID_INFO const * const pSinkEdid,
HDMI_SRC_CAPS *pSrcCaps,
HDMI_SINK_CAPS *pSinkCaps)
{
if (libHandle == NVHDMIPKT_INVALID_HANDLE)
{
return NVHDMIPKT_LIBRARY_INIT_FAIL;
}
if (!pSinkEdid ||
!pSrcCaps ||
!pSinkCaps)
{
return NVHDMIPKT_INVALID_ARG;
}
NVHDMIPKT_CLASS* pClass = fromHdmiPktHandle(libHandle);
return pClass->hdmiAssessLinkCapabilities(pClass,
subDevice,
displayId,
pSinkEdid,
pSrcCaps,
pSinkCaps);
}
/*
* NvHdmi_QueryFRLConfig
*/
NVHDMIPKT_RESULT
NvHdmi_QueryFRLConfig(NvHdmiPkt_Handle libHandle,
HDMI_VIDEO_TRANSPORT_INFO const * const pVidTransInfo,
HDMI_QUERY_FRL_CLIENT_CONTROL const * const pClientCtrl,
HDMI_SRC_CAPS const * const pSrcCaps,
HDMI_SINK_CAPS const * const pSinkCaps,
HDMI_FRL_CONFIG *pFRLConfig)
{
if (libHandle == NVHDMIPKT_INVALID_HANDLE)
{
return NVHDMIPKT_LIBRARY_INIT_FAIL;
}
if (!pVidTransInfo ||
!pClientCtrl ||
!pSrcCaps ||
!pSinkCaps ||
!pFRLConfig)
{
return NVHDMIPKT_INVALID_ARG;
}
// if there is no FRL capability reported fail this call
if (pSinkCaps->linkMaxFRLRate == HDMI_FRL_DATA_RATE_NONE)
{
return NVHDMIPKT_FAIL;
}
NVHDMIPKT_CLASS* pClass = fromHdmiPktHandle(libHandle);
return pClass->hdmiQueryFRLConfig(pClass,
pVidTransInfo,
pClientCtrl,
pSrcCaps,
pSinkCaps,
pFRLConfig);
}
/*
* NvHdmi_SetFRLConfig
*/
NVHDMIPKT_RESULT
NvHdmi_SetFRLConfig(NvHdmiPkt_Handle libHandle,
NvU32 subDevice,
NvU32 displayId,
NvBool bFakeLt,
HDMI_FRL_CONFIG *pFRLConfig)
{
if (libHandle == NVHDMIPKT_INVALID_HANDLE)
{
return NVHDMIPKT_LIBRARY_INIT_FAIL;
}
if (!pFRLConfig)
{
return NVHDMIPKT_INVALID_ARG;
}
NVHDMIPKT_CLASS* pClass = fromHdmiPktHandle(libHandle);
return pClass->hdmiSetFRLConfig(pClass,
subDevice,
displayId,
bFakeLt,
pFRLConfig);
}
/*
* NvHdmi_ClearFRLConfig
*/
NVHDMIPKT_RESULT
NvHdmi_ClearFRLConfig(NvHdmiPkt_Handle libHandle,
NvU32 subDevice,
NvU32 displayId)
{
if (libHandle == NVHDMIPKT_INVALID_HANDLE)
{
return NVHDMIPKT_LIBRARY_INIT_FAIL;
}
NVHDMIPKT_CLASS* pClass = fromHdmiPktHandle(libHandle);
return pClass->hdmiClearFRLConfig(pClass,
subDevice,
displayId);
}
/*************************** HDMI Library internal helper functions *****************************/
/*
* NvHdmiPkt_HwClass2HdmiClass
* internal function; translates display/display-dma class to hdmi class
*/
static NVHDMIPKT_CLASS_ID
NvHdmiPkt_HwClass2HdmiClass(NvU32 const hwClass)
{
NVHDMIPKT_CLASS_ID hdmiClassId = NVHDMIPKT_9571_CLASS;
NvU32 i = 0;
for (i = 0; i < NVHDMIPKT_INVALID_CLASS; i++)
{
if ((hierarchy[i].displayClass == hwClass) ||
(hierarchy[i].coreDmaClass == hwClass))
{
hdmiClassId = hierarchy[i].classId;
break;
}
}
// Assign default class 73 to pre-Kepler families
if (hwClass < NV9170_DISPLAY)
{
hdmiClassId = NVHDMIPKT_0073_CLASS;
}
return hdmiClassId;
}
/*
* NvHdmiPkt_InitInterfaces
* internal function; calls class init interface functions
*/
static void
NvHdmiPkt_InitInterfaces(NVHDMIPKT_CLASS_ID const thisClassId,
NVHDMIPKT_CLASS* const pClass)
{
// Recurse to the root first, and then call each initInterface() method
// from root to child.
if (!hierarchy[thisClassId].isRootClass)
{
NvHdmiPkt_InitInterfaces(hierarchy[thisClassId].parentClassId, pClass);
}
hierarchy[thisClassId].initInterface(pClass);
}
static void
NvHdmiPkt_CallDestructors(NVHDMIPKT_CLASS_ID const thisClassId,
NVHDMIPKT_CLASS* const pClass)
{
// Destructor calls are made from this to root class.
hierarchy[thisClassId].destructor(pClass);
if (!hierarchy[thisClassId].isRootClass)
{
NvHdmiPkt_CallDestructors(hierarchy[thisClassId].parentClassId, pClass);
}
}
/*
* NvHdmiPkt_CallConstructors
* internal function; calls class constructors and returns boolean success/failure
*/
static NvBool
NvHdmiPkt_CallConstructors(NVHDMIPKT_CLASS_ID const thisClassId,
NVHDMIPKT_CLASS* const pClass)
{
// Recurse to the root first, and then call each constructor
// from root to child.
if (!hierarchy[thisClassId].isRootClass)
{
if (!NvHdmiPkt_CallConstructors(hierarchy[thisClassId].parentClassId, pClass))
{
return NV_FALSE;
}
}
if (!hierarchy[thisClassId].constructor(pClass))
{
if (!hierarchy[thisClassId].isRootClass)
{
// Backtrack on constructor failure
NvHdmiPkt_CallDestructors(hierarchy[thisClassId].parentClassId, pClass);
}
return NV_FALSE;
}
return NV_TRUE;
}
/******************************** HDMI Library Init functions ***********************************/
/*
* NvHdmiPkt_InitializeLibrary
*/
NvHdmiPkt_Handle
NvHdmiPkt_InitializeLibrary(NvU32 const hwClass,
NvU32 const numSubDevices,
NvHdmiPkt_CBHandle const cbHandle,
const NVHDMIPKT_CALLBACK* const pCallbacks,
NvU32 const sfUserHandle,
const NVHDMIPKT_RM_CLIENT_HANDLES* const pClientHandles)
{
NVHDMIPKT_CLASS* pClass = 0;
NvU32 i = 0;
NvBool result = NV_FALSE;
NVHDMIPKT_CLASS_ID thisClassId = NVHDMIPKT_INVALID_CLASS;
// Argument validations
if (pCallbacks == 0 || numSubDevices == 0)
{
goto NvHdmiPkt_InitializeLibrary_exit;
}
// Validating RM handles/callbacks
#if NVHDMIPKT_RM_CALLS_INTERNAL
if (sfUserHandle == 0 || pClientHandles == 0)
{
goto NvHdmiPkt_InitializeLibrary_exit;
}
#else // !NVHDMIPKT_RM_CALLS_INTERNAL
if (pCallbacks->rmGetMemoryMap == 0 ||
pCallbacks->rmFreeMemoryMap == 0 ||
pCallbacks->rmDispControl2 == 0)
{
goto NvHdmiPkt_InitializeLibrary_exit;
}
#endif // NVHDMIPKT_RM_CALLS_INTERNAL
// Mandatory mutex callbacks.
if (pCallbacks->acquireMutex == 0 || pCallbacks->releaseMutex == 0)
{
goto NvHdmiPkt_InitializeLibrary_exit;
}
// Mandatory memory allocation callbacks.
if (pCallbacks->malloc == 0 || pCallbacks->free == 0)
{
goto NvHdmiPkt_InitializeLibrary_exit;
}
pClass = pCallbacks->malloc(cbHandle, sizeof(NVHDMIPKT_CLASS));
if (!pClass)
{
goto NvHdmiPkt_InitializeLibrary_exit;
}
// 0. Get the hdmi class ID
thisClassId = NvHdmiPkt_HwClass2HdmiClass(hwClass);
// Init data
NVMISC_MEMSET(pClass, 0, sizeof(NVHDMIPKT_CLASS));
for (i = 0; i < NV_MAX_SUBDEVICES; i++)
{
pClass->memMap[i].subDevice = NVHDMIPKT_INVALID_SUBDEV;
}
pClass->numSubDevices = numSubDevices;
pClass->cbHandle = cbHandle;
pClass->thisId = thisClassId;
// RM handles/callbacks
#if NVHDMIPKT_RM_CALLS_INTERNAL
pClass->isRMCallInternal = NV_TRUE;
pClass->sfUserHandle = sfUserHandle;
pClass->clientHandles.hClient = pClientHandles->hClient;
pClass->clientHandles.hDevice = pClientHandles->hDevice;
pClass->clientHandles.hDisplay = pClientHandles->hDisplay;
for (i = 0; i < NV_MAX_SUBDEVICES; i++)
{
pClass->clientHandles.hSubDevices[i] = pClientHandles->hSubDevices[i];
}
#else // !NVHDMIPKT_RM_CALLS_INTERNAL
pClass->isRMCallInternal = NV_FALSE;
pClass->callback.rmGetMemoryMap = pCallbacks->rmGetMemoryMap;
pClass->callback.rmFreeMemoryMap = pCallbacks->rmFreeMemoryMap;
pClass->callback.rmDispControl2 = pCallbacks->rmDispControl2;
#endif // NVHDMIPKT_RM_CALLS_INTERNAL
pClass->callback.acquireMutex = pCallbacks->acquireMutex;
pClass->callback.releaseMutex = pCallbacks->releaseMutex;
pClass->callback.malloc = pCallbacks->malloc;
pClass->callback.free = pCallbacks->free;
#if !defined (NVHDMIPKT_DONT_USE_TIMER)
pClass->callback.setTimeout = pCallbacks->setTimeout;
pClass->callback.checkTimeout = pCallbacks->checkTimeout;
#endif
#if defined (DEBUG)
pClass->callback.print = pCallbacks->print;
pClass->callback.assert = pCallbacks->assert;
#endif
// 1. Init interfaces
NvHdmiPkt_InitInterfaces(thisClassId, pClass);
// 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)
{
NvHdmiPkt_Print(pClass, "Initialize Success.");
}
else
{
if (pClass)
{
NvHdmiPkt_Print(pClass, "Initialize Failed.");
}
if (pCallbacks && pCallbacks->free)
{
pCallbacks->free(cbHandle, pClass);
}
}
return (result == NV_TRUE) ? toHdmiPktHandle(pClass) : NVHDMIPKT_INVALID_HANDLE;
}
/*
* NvHdmiPkt_DestroyLibrary
*/
void
NvHdmiPkt_DestroyLibrary(NvHdmiPkt_Handle libHandle)
{
NVHDMIPKT_CLASS* pClass = fromHdmiPktHandle(libHandle);
NVHDMIPKT_CLASS_ID currClassId = NVHDMIPKT_0073_CLASS;
if (pClass != 0)
{
NvHdmiPkt_Print(pClass, "Destroy.");
NvHdmiPkt_CBHandle cbHandle = pClass->cbHandle;
void (*freeCb) (NvHdmiPkt_CBHandle handle,
void *pMem) = pClass->callback.free;
currClassId = pClass->thisId;
NvHdmiPkt_CallDestructors(currClassId, pClass);
freeCb(cbHandle, pClass);
}
}

View File

@@ -0,0 +1,317 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* File: nvhdmipkt.h
*
* Purpose: This file is a common header for all HDMI Library Clients
*/
#ifndef _NVHDMIPKT_H_
#define _NVHDMIPKT_H_
#include <nvlimits.h>
#include "nvmisc.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************** HDMI Library defines, enums and structs ***************************/
/************************************************************************************************
* NOTE: NVHDMIPKT_RM_CALLS_INTERNAL define tells this library to make RM calls (allocate, free *
* control, etc.) internally and not through callbacks into the client. *
************************************************************************************************/
#if !defined(NVHDMIPKT_RM_CALLS_INTERNAL)
# define NVHDMIPKT_RM_CALLS_INTERNAL 1
#endif
// NVHDMIPKT_RESULT: HDMI library return result enums
typedef enum
{
NVHDMIPKT_SUCCESS = 0,
NVHDMIPKT_FAIL = 1,
NVHDMIPKT_LIBRARY_INIT_FAIL = 2,
NVHDMIPKT_INVALID_ARG = 3,
NVHDMIPKT_TIMEOUT = 4,
NVHDMIPKT_ERR_GENERAL = 5,
NVHDMIPKT_INSUFFICIENT_BANDWIDTH = 6,
NVHDMIPKT_RETRY = 7
} NVHDMIPKT_RESULT;
// NVHDMIPKT_TYPE: HDMI Packet Enums
typedef enum _NVHDMIPKT_TYPE
{
NVHDMIPKT_TYPE_UNDEFINED = 0, // Undefined Packet Type
NVHDMIPKT_TYPE_GENERIC = 1, // Generic packet, any Generic Packet
// (e.g Gamut Metadata packet)
NVHDMIPKT_TYPE_AVI_INFOFRAME = 2, // Avi infoframe
NVHDMIPKT_TYPE_GENERAL_CONTROL = 3, // GCP
NVHDMIPKT_TYPE_VENDOR_SPECIFIC_INFOFRAME = 4, // VSI
NVHDMIPKT_TYPE_AUDIO_INFOFRAME = 5, // Audio InfoFrame
NVHDMIPKT_TYPE_EXTENDED_METADATA_PACKET = 6, // Extended Metadata Packet (HDMI 2.1)
NVHDMIPKT_INVALID_PKT_TYPE = 13
} NVHDMIPKT_TYPE;
// Hdmi packet TransmitControl defines. These definitions reflect the
// defines from ctrl and class defines for info frames.
#define NV_HDMI_PKT_TRANSMIT_CTRL_ENABLE 0:0
#define NV_HDMI_PKT_TRANSMIT_CTRL_ENABLE_DIS 0x00000000
#define NV_HDMI_PKT_TRANSMIT_CTRL_ENABLE_EN 0x00000001
#define NV_HDMI_PKT_TRANSMIT_CTRL_OTHER 1:1
#define NV_HDMI_PKT_TRANSMIT_CTRL_OTHER_DIS 0x00000000
#define NV_HDMI_PKT_TRANSMIT_CTRL_OTHER_EN 0x00000001
#define NV_HDMI_PKT_TRANSMIT_CTRL_SINGLE 2:2
#define NV_HDMI_PKT_TRANSMIT_CTRL_SINGLE_DIS 0x00000000
#define NV_HDMI_PKT_TRANSMIT_CTRL_SINGLE_EN 0x00000001
#define NV_HDMI_PKT_TRANSMIT_CTRL_CHKSUM_HW 3:3
#define NV_HDMI_PKT_TRANSMIT_CTRL_CHKSUM_HW_DIS 0x00000000
#define NV_HDMI_PKT_TRANSMIT_CTRL_CHKSUM_HW_EN 0x00000001
#define NV_HDMI_PKT_TRANSMIT_CTRL_HBLANK 4:4
#define NV_HDMI_PKT_TRANSMIT_CTRL_HBLANK_DIS 0x00000000
#define NV_HDMI_PKT_TRANSMIT_CTRL_HBLANK_EN 0x00000001
#define NV_HDMI_PKT_TRANSMIT_CTRL_VIDEO_FMT 5:5
#define NV_HDMI_PKT_TRANSMIT_CTRL_VIDEO_FMT_SW_CTRL 0x00000000
#define NV_HDMI_PKT_TRANSMIT_CTRL_VIDEO_FMT_HW_CTRL 0x00000001
// NVHDMIPKT_TC: HDMI Packet Transmit Control
// NOTE: Client should use these defines below for transmit control, and avoid using the ones
// above. Use only if client knows and wants fine control. And in that case the value
// passed has to be explicitly typecasted to NVHDMIPKT_TC by the client.
typedef enum _NVHDMIPKT_TC
{
NVHDMIPKT_TRANSMIT_CONTROL_DISABLE =
(DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _ENABLE, _DIS) |
DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _OTHER, _DIS) |
DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _SINGLE, _DIS) |
DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _CHKSUM_HW, _DIS)),
NVHDMIPKT_TRANSMIT_CONTROL_ENABLE_EVERY_FRAME =
(DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _ENABLE, _EN) |
DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _OTHER, _DIS) |
DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _SINGLE, _DIS) |
DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _CHKSUM_HW, _EN)),
NVHDMIPKT_TRANSMIT_CONTROL_ENABLE_SINGLE_FRAME =
(DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _ENABLE, _EN) |
DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _OTHER, _DIS) |
DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _SINGLE, _EN) |
DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _CHKSUM_HW, _EN)),
NVHDMIPKT_TRANSMIT_CONTROL_ENABLE_EVERY_OTHER_FRAME =
(DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _ENABLE, _EN) |
DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _OTHER, _EN) |
DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _SINGLE, _DIS) |
DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _CHKSUM_HW, _EN)),
NVHDMIPKT_TRANSMIT_CONTROL_VIDEO_FMT_HW_CTRL =
(DRF_DEF(_HDMI_PKT, _TRANSMIT_CTRL, _VIDEO_FMT, _HW_CTRL)),
} NVHDMIPKT_TC;
// RM client handles. Used when client chooses that hdmi library make RM calls.
// NOTE: NVHDMIPKT_RM_CALLS_INTERNAL macro should be define to use it.
typedef struct tagNVHDMIPKT_RM_CLIENT_HANDLES
{
NvU32 hClient;
NvU32 hDevice;
NvU32 hSubDevices[NV_MAX_SUBDEVICES];
NvU32 hDisplay;
} NVHDMIPKT_RM_CLIENT_HANDLES;
/****************************** HDMI Library callbacks into client ******************************/
typedef void* NvHdmiPkt_CBHandle;
/************************************************************************************************
* [rmGetMemoryMap, rmFreeMemoryMap, rmDispControl,] acquireMutex and releaseMutex are mandatory*
* callbacks, to be implemented by the client. Callbacks in [] above are mandatory only for *
* Windows. *
* Linux need not implement those, if they plan to use NVHDMIPKT_RM_CALLS_INTERNAL define. *
* *
* rmGetMemoryMap and rmFreeMemoryMap are RM calls to allocate the DISP_SF_USER class. *
* And mutex callbacks keep hemi packet operations atomic. *
************************************************************************************************/
typedef struct _tagNVHDMIPKT_CALLBACK
{
// MANDATORY callbacks.
NvBool
(*rmGetMemoryMap) (NvHdmiPkt_CBHandle handle,
NvU32 dispSfUserClassId,
NvU32 dispSfUserSize,
NvU32 subDevice,
NvU32* pMemHandle,
void** ppBaseMem);
void
(*rmFreeMemoryMap) (NvHdmiPkt_CBHandle handle,
NvU32 subDevice,
NvU32 memHandle,
void* pMem);
NvBool
(*rmDispControl2) (NvHdmiPkt_CBHandle handle,
NvU32 subDevice,
NvU32 cmd,
void* pParams,
NvU32 paramSize);
void
(*acquireMutex) (NvHdmiPkt_CBHandle handle);
void
(*releaseMutex) (NvHdmiPkt_CBHandle handle);
// OPTIONAL callbacks
/* time in microseconds (us) */
NvBool
(*setTimeout) (NvHdmiPkt_CBHandle handle,
NvU32 us_timeout);
/* ChecTimeout returns true when timer times out */
NvBool
(*checkTimeout) (NvHdmiPkt_CBHandle handle);
// callbacks to allocate memory on heap to reduce stack usage
void*
(*malloc) (NvHdmiPkt_CBHandle handle,
NvLength numBytes);
void
(*free) (NvHdmiPkt_CBHandle handle,
void *pMem);
void
(*print) (NvHdmiPkt_CBHandle handle,
const char* fmtstring,
...)
#if defined(__GNUC__)
__attribute__ ((format (printf, 2, 3)))
#endif
;
void
(*assert) (NvHdmiPkt_CBHandle handle,
NvBool expression);
} NVHDMIPKT_CALLBACK;
/*********************** HDMI Library interface to write hdmi ctrl/packet ***********************/
typedef void* NvHdmiPkt_Handle;
#define NVHDMIPKT_INVALID_HANDLE ((NvHdmiPkt_Handle)0)
/************************************************************************************************
* NvHdmiPkt_PacketCtrl - Returns HDMI NVHDMIPKT_RESULT. *
* *
* Parameters: *
* libHandle - Hdmi library handle, provided on initializing the library. *
* subDevice - Sub Device ID. *
* displayId - Display ID. *
* head - Head number. *
* packetType - One of the NVHDMIPKT_TYPE types. *
* transmitControl - Packet transmit control setting. *
************************************************************************************************/
NVHDMIPKT_RESULT
NvHdmiPkt_PacketCtrl (NvHdmiPkt_Handle libHandle,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl);
/************************************************************************************************
* NvHdmiPkt_PacketWrite - Returns HDMI NVHDMIPKT_RESULT. *
* *
* Parameters: *
* libHandle - Hdmi library handle, provided on initializing the library. *
* subDevice - Sub Device ID. *
* displayId - Display ID. *
* head - Head number. *
* packetType - One of the NVHDMIPKT_TYPE types. *
* transmitControl - Packet transmit control setting. *
* packetLen - Length of the packet in bytes to be transmitted. *
* pPacket - Pointer to packet data. *
************************************************************************************************/
NVHDMIPKT_RESULT
NvHdmiPkt_PacketWrite(NvHdmiPkt_Handle libHandle,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl,
NvU32 packetLen,
NvU8 const *const pPacket);
/***************************** Interface to initialize HDMI Library *****************************/
/************************************************************************************************
* NvHdmiPkt_InitializeLibrary - Returns NvHdmiPkt_Handle. This handle is used to call *
* library interfaces. If handle returned is invalid - *
* NVHDMIPKT_INVALID_HANDLE -, there was a problem in *
* initialization and the library won't work. *
* *
* Parameters: *
* hwClass - Depending on HW, apply display class or display dma class. Either will do.*
* Eg. for GK104- NV9170_DISPLAY or NV917D_CORE_CHANNEL_DMA. *
* numSubDevices - Number of sub devices. *
* *
* cbHandle - Callback handle. Client cookie for callbacks made to client. *
* pCallback - Callbacks. Struct NVHDMIPKT_CALLBACK. *
* *
* Below mentioned sfUserHandle and clientHandles parameters are used only when not providing *
* rmGetMemoryMap, rmFreeMemoryMap and rmDispControl callbacks. This is meant for Linux. *
* And is controlled by NVHDMIPKT_RM_CALLS_INTERNAL macro. *
* NOTE: And Clients not using NVHDMIPKT_RM_CALLS_INTERNAL, need to set both sfUserHandle and *
* clientHandles to 0. *
* *
* sfUserHandle - SF_USER handle; this is the base handle. Subsequent subdevice handles are *
* derived incrementally from this handle. *
* pClientHandles - RM handles for client, device, subdevices and displayCommon. *
* *
************************************************************************************************/
NvHdmiPkt_Handle
NvHdmiPkt_InitializeLibrary(NvU32 const hwClass,
NvU32 const numSubDevices,
NvHdmiPkt_CBHandle const cbHandle,
const NVHDMIPKT_CALLBACK* const pCallback,
NvU32 const sfUserHandle,
const NVHDMIPKT_RM_CLIENT_HANDLES* const pClientHandles);
/************************************************************************************************
* NvHdmiPkt_DestroyLibrary *
* *
* When done with the HDMI Library call NvHdmiPkt_DestroyLibrary. It is like a destructor. *
* This destructor frees up resources acquired during initialize. *
* *
************************************************************************************************/
void
NvHdmiPkt_DestroyLibrary(NvHdmiPkt_Handle libHandle);
#ifdef __cplusplus
}
#endif
#endif // _NVHDMIPKT_H_

View File

@@ -0,0 +1,385 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* File: nvhdmipkt_0073.c
*
* Purpose: Provides infoframe write functions for HDMI library for Pre-KEPLER chips
*/
#include "nvhdmipkt_common.h"
#include "nvhdmipkt_class.h"
#include "nvhdmipkt_internal.h"
#include "hdmi_spec.h"
#include "ctrl/ctrl0073/ctrl0073specific.h"
NVHDMIPKT_RESULT
hdmiPacketCtrl0073(NVHDMIPKT_CLASS* pThis,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl);
NVHDMIPKT_RESULT
hdmiPacketWrite0073(NVHDMIPKT_CLASS* pThis,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl,
NvU32 packetLen,
NvU8 const *const pPacket);
/*
* hdmiPacketCtrl0073
*/
NVHDMIPKT_RESULT
hdmiPacketCtrl0073(NVHDMIPKT_CLASS* pThis,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl)
{
NVHDMIPKT_RESULT result = NVHDMIPKT_SUCCESS;
NV0073_CTRL_SPECIFIC_SET_OD_PACKET_CTRL_PARAMS params = {0};
NVMISC_MEMSET(&params, 0, sizeof(params));
params.subDeviceInstance = subDevice;
params.displayId = displayId;
params.type = pThis->translatePacketType(pThis, packetType);
params.transmitControl = pThis->translateTransmitControl(pThis, transmitControl);
#if NVHDMIPKT_RM_CALLS_INTERNAL
if (NvRmControl(pThis->clientHandles.hClient,
pThis->clientHandles.hDisplay,
NV0073_CTRL_CMD_SPECIFIC_SET_OD_PACKET_CTRL,
&params,
sizeof(params)) != NVOS_STATUS_SUCCESS)
#else // !NVHDMIPKT_RM_CALLS_INTERNAL
NvBool bSuccess = pThis->callback.rmDispControl2(pThis->cbHandle,
params.subDeviceInstance,
NV0073_CTRL_CMD_SPECIFIC_SET_OD_PACKET_CTRL,
&params, sizeof(params));
if (bSuccess == NV_FALSE)
#endif // NVHDMIPKT_RM_CALLS_INTERNAL
{
NvHdmiPkt_Print(pThis, "ERROR - RM call to hdmiPacketCtrl failed.");
NvHdmiPkt_Assert(0);
result = NVHDMIPKT_FAIL;
}
return result;
}
/*
* hdmiPacketWrite0073
*/
NVHDMIPKT_RESULT
hdmiPacketWrite0073(NVHDMIPKT_CLASS* pThis,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl,
NvU32 packetLen,
NvU8 const *const pPacket)
{
NVHDMIPKT_RESULT result = NVHDMIPKT_SUCCESS;
NV0073_CTRL_SPECIFIC_SET_OD_PACKET_PARAMS params = {0};
NVMISC_MEMSET(&params, 0, sizeof(params));
params.subDeviceInstance = subDevice;
params.displayId = displayId;
params.packetSize = packetLen;
params.transmitControl = pThis->translateTransmitControl(pThis, transmitControl);
// init the infoframe packet
NVMISC_MEMSET(params.aPacket, 0, NV0073_CTRL_SET_OD_MAX_PACKET_SIZE);
// copy the payload
NVMISC_MEMCPY(params.aPacket, pPacket, packetLen);
#if NVHDMIPKT_RM_CALLS_INTERNAL
if (NvRmControl(pThis->clientHandles.hClient,
pThis->clientHandles.hDisplay,
NV0073_CTRL_CMD_SPECIFIC_SET_OD_PACKET,
&params,
sizeof(params)) != NVOS_STATUS_SUCCESS)
#else // !NVHDMIPKT_RM_CALLS_INTERNAL
NvBool bSuccess = pThis->callback.rmDispControl2(pThis->cbHandle,
params.subDeviceInstance,
NV0073_CTRL_CMD_SPECIFIC_SET_OD_PACKET,
&params,
sizeof(params));
if (bSuccess == NV_FALSE)
#endif // NVHDMIPKT_RM_CALLS_INTERNAL
{
NvHdmiPkt_Print(pThis, "ERROR - RM call to hdmiPacketWrite failed.");
NvHdmiPkt_Assert(0);
result = NVHDMIPKT_FAIL;
}
return result;
}
/*
* translatePacketType0073
*/
static NvU32
translatePacketType0073(NVHDMIPKT_CLASS* pThis,
NVHDMIPKT_TYPE packetType)
{
NvU32 type0073 = 0;
switch (packetType)
{
case NVHDMIPKT_TYPE_AVI_INFOFRAME:
type0073 = pktType_AviInfoFrame;
break;
case NVHDMIPKT_TYPE_GENERIC:
type0073 = pktType_GamutMetadata;
break;
case NVHDMIPKT_TYPE_GENERAL_CONTROL:
type0073 = pktType_GeneralControl;
break;
case NVHDMIPKT_TYPE_VENDOR_SPECIFIC_INFOFRAME:
type0073 = pktType_VendorSpecInfoFrame;
break;
case NVHDMIPKT_TYPE_AUDIO_INFOFRAME:
type0073 = pktType_AudioInfoFrame;
break;
default:
NvHdmiPkt_Print(pThis, "ERROR - translatePacketType wrong packet type: %0x",
packetType);
NvHdmiPkt_Assert(0);
break;
}
return type0073;
}
/*
* translateTransmitControl0073
*/
static NvU32
translateTransmitControl0073(NVHDMIPKT_CLASS* pThis,
NVHDMIPKT_TC transmitControl)
{
NvU32 tc = 0;
// TODO: tc validation
if (FLD_TEST_DRF(_HDMI_PKT, _TRANSMIT_CTRL, _ENABLE, _EN, transmitControl))
{
tc = FLD_SET_DRF(0073, _CTRL_SPECIFIC_SET_OD_PACKET_CTRL_TRANSMIT_CONTROL,
_ENABLE, _YES, tc);
}
if (FLD_TEST_DRF(_HDMI_PKT, _TRANSMIT_CTRL, _OTHER, _EN, transmitControl))
{
tc = FLD_SET_DRF(0073, _CTRL_SPECIFIC_SET_OD_PACKET_CTRL_TRANSMIT_CONTROL,
_OTHER_FRAME, _ENABLE, tc);
}
if (FLD_TEST_DRF(_HDMI_PKT, _TRANSMIT_CTRL, _SINGLE, _EN, transmitControl))
{
tc = FLD_SET_DRF(0073, _CTRL_SPECIFIC_SET_OD_PACKET_CTRL_TRANSMIT_CONTROL,
_SINGLE_FRAME, _ENABLE, tc);
}
if (FLD_TEST_DRF(_HDMI_PKT, _TRANSMIT_CTRL, _HBLANK, _EN, transmitControl))
{
tc = FLD_SET_DRF(0073, _CTRL_SPECIFIC_SET_OD_PACKET_CTRL_TRANSMIT_CONTROL,
_ON_HBLANK, _ENABLE, tc);
}
if (FLD_TEST_DRF(_HDMI_PKT, _TRANSMIT_CTRL, _VIDEO_FMT, _HW_CTRL, transmitControl))
{
tc = FLD_SET_DRF(0073, _CTRL_SPECIFIC_SET_OD_PACKET_CTRL_TRANSMIT_CONTROL,
_VIDEO_FMT, _HW_CONTROLLED, tc);
}
return tc;
}
// non-HW - class utility/maintenance functions
/*
* hdmiConstructor0073
*/
NvBool
hdmiConstructor0073(NVHDMIPKT_CLASS* pThis)
{
return NV_TRUE;
}
/*
* hdmiUnDestructor0073
*/
void
hdmiDestructor0073(NVHDMIPKT_CLASS* pThis)
{
return;
}
// Below are dummy functions for the HW functions not needed for a display class
/*
* hdmiWriteDummyPacket
*/
void
hdmiWriteDummyPacket(NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 packetLen,
NvU8 const *const pPacket)
{
NvHdmiPkt_Print(pThis, "ERROR - Dummy function hdmiWriteDummyPacket called. "
"Should never be called.");
NvHdmiPkt_Assert(0);
return;
}
/*
* hdmiReadDummyPacketStatus
*/
static NvBool
hdmiReadDummyPacketStatus(NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 pktType0073)
{
NvHdmiPkt_Print(pThis, "ERROR - Dummy function hdmiReadDummyPacketStatus called. "
"Should never be called.");
NvHdmiPkt_Assert(0);
return NV_TRUE;
}
/*
* hdmiWriteDummyPacketCtrl
*/
static NVHDMIPKT_RESULT
hdmiWriteDummyPacketCtrl(NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 pktType0073,
NvU32 transmitControl,
NvBool bDisable)
{
NvHdmiPkt_Print(pThis, "ERROR - Dummy function hdmiWriteDummyPacketCtrl called. "
"Should never be called.");
NvHdmiPkt_Assert(0);
return NVHDMIPKT_SUCCESS;
}
NVHDMIPKT_RESULT
hdmiAssessLinkCapabilitiesDummy(NVHDMIPKT_CLASS *pThis,
NvU32 subDevice,
NvU32 displayId,
NVT_EDID_INFO const * const pSinkEdid,
HDMI_SRC_CAPS *pSrcCaps,
HDMI_SINK_CAPS *pSinkCaps)
{
NvHdmiPkt_Print(pThis, "ERROR - Dummy function hdmiAssessLinkCapabilitiesDummy called. "
"Should never be called.");
NvHdmiPkt_Assert(0);
return NVHDMIPKT_SUCCESS;
}
NVHDMIPKT_RESULT
hdmiQueryFRLConfigDummy(NVHDMIPKT_CLASS *pThis,
HDMI_VIDEO_TRANSPORT_INFO const * const pVidTransInfo,
HDMI_QUERY_FRL_CLIENT_CONTROL const * const pClientCtrl,
HDMI_SRC_CAPS const * const pSrcCaps,
HDMI_SINK_CAPS const * const pSinkCaps,
HDMI_FRL_CONFIG *pFRLConfig)
{
NvHdmiPkt_Print(pThis, "ERROR - Dummy function hdmiQueryFRLConfigDummy called. "
"Should never be called.");
NvHdmiPkt_Assert(0);
return NVHDMIPKT_SUCCESS;
}
NVHDMIPKT_RESULT
hdmiSetFRLConfigDummy(NVHDMIPKT_CLASS *pThis,
NvU32 subDevice,
NvU32 displayId,
NvBool bFakeLt,
HDMI_FRL_CONFIG *pFRLConfig)
{
NvHdmiPkt_Print(pThis, "ERROR - Dummy function hdmiSetFRLConfigDummy called. "
"Should never be called.");
NvHdmiPkt_Assert(0);
return NVHDMIPKT_SUCCESS;
}
NVHDMIPKT_RESULT
hdmiClearFRLConfigDummy(NVHDMIPKT_CLASS *pThis,
NvU32 subDevice,
NvU32 displayId)
{
NvHdmiPkt_Print(pThis, "ERROR - Dummy function hdmiClearFRLConfigDummy called. "
"Should never be called.");
NvHdmiPkt_Assert(0);
return NVHDMIPKT_SUCCESS;
}
/*
* initializeHdmiPktInterface0073
*/
void
initializeHdmiPktInterface0073(NVHDMIPKT_CLASS* pClass)
{
pClass->hdmiPacketCtrl = hdmiPacketCtrl0073;
pClass->hdmiPacketWrite = hdmiPacketWrite0073;
pClass->translatePacketType = translatePacketType0073;
pClass->translateTransmitControl = translateTransmitControl0073;
// Functions below are mapped to dummy functions, as not needed for HW before GK104
pClass->hdmiReadPacketStatus = hdmiReadDummyPacketStatus;
pClass->hdmiWritePacketCtrl = hdmiWriteDummyPacketCtrl;
pClass->hdmiWriteAviPacket = hdmiWriteDummyPacket;
pClass->hdmiWriteAudioPacket = hdmiWriteDummyPacket;
pClass->hdmiWriteGenericPacket = hdmiWriteDummyPacket;
pClass->hdmiWriteGeneralCtrlPacket = hdmiWriteDummyPacket;
pClass->hdmiWriteVendorPacket = hdmiWriteDummyPacket;
// Update SF_USER data
pClass->dispSfUserClassId = 0;
pClass->dispSfUserSize = 0;
// Functions below are used by HDMI FRL and will be available for Ampere+.
pClass->hdmiAssessLinkCapabilities = hdmiAssessLinkCapabilitiesDummy;
pClass->hdmiQueryFRLConfig = hdmiQueryFRLConfigDummy;
pClass->hdmiSetFRLConfig = hdmiSetFRLConfigDummy;
pClass->hdmiClearFRLConfig = hdmiClearFRLConfigDummy;
}

View File

@@ -0,0 +1,804 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* File: nvhdmipkt_9171.c
*
* Purpose: Provides packet write functions for HDMI library for KEPLER + chips
*/
#include "nvlimits.h"
#include "nvhdmipkt_common.h"
#include "nvhdmipkt_class.h"
#include "nvhdmipkt_internal.h"
#include "hdmi_spec.h"
#include "class/cl9171.h"
#include "ctrl/ctrl0073/ctrl0073specific.h"
#define NVHDMIPKT_9171_INVALID_PKT_TYPE ((NV9171_SF_HDMI_INFO_IDX_VSI) + 1)
NVHDMIPKT_RESULT
hdmiPacketWrite9171(NVHDMIPKT_CLASS* pThis,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl,
NvU32 packetLen,
NvU8 const *const pPacket);
NVHDMIPKT_RESULT
hdmiPacketCtrl9171(NVHDMIPKT_CLASS* pThis,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl);
/*
* hdmiReadPacketStatus9171
*/
static NvBool
hdmiReadPacketStatus9171(NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 pktType9171)
{
NvBool bResult = NV_FALSE;
NvU32 regOffset = 0;
NvU32 status = 0;
if (pBaseReg == 0 || head >= NV9171_SF_HDMI_INFO_STATUS__SIZE_1)
{
return bResult;
}
switch (pktType9171)
{
case NV9171_SF_HDMI_INFO_IDX_AVI_INFOFRAME:
case NV9171_SF_HDMI_INFO_IDX_GENERIC_INFOFRAME:
case NV9171_SF_HDMI_INFO_IDX_GCP:
case NV9171_SF_HDMI_INFO_IDX_VSI:
regOffset = NV9171_SF_HDMI_INFO_STATUS(head, pktType9171);
status = REG_RD32(pBaseReg, regOffset);
bResult = FLD_TEST_DRF(9171, _SF_HDMI_INFO_STATUS, _SENT, _DONE, status);
break;
default:
break;
}
return bResult;
}
/*
* hdmiWritePacketCtrl9171
*/
static NVHDMIPKT_RESULT
hdmiWritePacketCtrl9171(NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 pktType9171,
NvU32 transmitControl,
NvBool bDisable)
{
NVHDMIPKT_RESULT result = NVHDMIPKT_INVALID_ARG;
NvU32 regOffset = 0;
NvU32 hdmiCtrl = 0;
if (pBaseReg == 0 || head >= NV9171_SF_HDMI_INFO_CTRL__SIZE_1)
{
return result;
}
switch (pktType9171)
{
case NV9171_SF_HDMI_INFO_IDX_AVI_INFOFRAME:
case NV9171_SF_HDMI_INFO_IDX_GENERIC_INFOFRAME:
case NV9171_SF_HDMI_INFO_IDX_GCP:
case NV9171_SF_HDMI_INFO_IDX_VSI:
regOffset = NV9171_SF_HDMI_INFO_CTRL(head, pktType9171);
hdmiCtrl = REG_RD32(pBaseReg, regOffset);
hdmiCtrl = (bDisable == NV_TRUE) ?
(FLD_SET_DRF(9171, _SF_HDMI_INFO_CTRL, _ENABLE, _DIS, hdmiCtrl)) :
(transmitControl);
REG_WR32(pBaseReg, regOffset, hdmiCtrl);
result = NVHDMIPKT_SUCCESS;
break;
default:
break;
}
return result;
}
/*
* hdmiWriteAviPacket9171
*/
static void
hdmiWriteAviPacket9171(NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 packetLen,
NvU8 const *const pPacket)
{
NvU32 data = 0;
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_AVI_INFOFRAME_HEADER(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_HEADER, _HB0, pPacket[0], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_HEADER, _HB1, pPacket[1], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_HEADER, _HB2, pPacket[2], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_AVI_INFOFRAME_HEADER(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_AVI_INFOFRAME_SUBPACK0_LOW(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK0_LOW, _PB0, pPacket[3], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK0_LOW, _PB1, pPacket[4], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK0_LOW, _PB2, pPacket[5], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK0_LOW, _PB3, pPacket[6], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_AVI_INFOFRAME_SUBPACK0_LOW(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_AVI_INFOFRAME_SUBPACK0_HIGH(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK0_HIGH, _PB4, pPacket[7], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK0_HIGH, _PB5, pPacket[8], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK0_HIGH, _PB6, pPacket[9], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_AVI_INFOFRAME_SUBPACK0_HIGH(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_AVI_INFOFRAME_SUBPACK1_LOW(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK1_LOW, _PB7, pPacket[10], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK1_LOW, _PB8, pPacket[11], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK1_LOW, _PB9, pPacket[12], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK1_LOW, _PB10, pPacket[13], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_AVI_INFOFRAME_SUBPACK1_LOW(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_AVI_INFOFRAME_SUBPACK1_HIGH(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK1_HIGH, _PB11, pPacket[14], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK1_HIGH, _PB12, pPacket[15], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_AVI_INFOFRAME_SUBPACK1_HIGH, _PB13, pPacket[16], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_AVI_INFOFRAME_SUBPACK1_HIGH(head), data);
return;
}
/*
* hdmiWriteGenericPacket9171
*/
static void
hdmiWriteGenericPacket9171(NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 packetLen,
NvU8 const *const pPacket)
{
NvU32 data = 0;
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_GENERIC_HEADER(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_HEADER, _HB0, pPacket[0], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_HEADER, _HB1, pPacket[1], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_HEADER, _HB2, pPacket[2], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_GENERIC_HEADER(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK0_LOW(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK0_LOW, _PB0, pPacket[3], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK0_LOW, _PB1, pPacket[4], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK0_LOW, _PB2, pPacket[5], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK0_LOW, _PB3, pPacket[6], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK0_LOW(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK0_HIGH(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK0_HIGH, _PB4, pPacket[7], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK0_HIGH, _PB5, pPacket[8], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK0_HIGH, _PB6, pPacket[9], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK0_HIGH(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK1_LOW(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK1_LOW, _PB7, pPacket[10], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK1_LOW, _PB8, pPacket[11], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK1_LOW, _PB9, pPacket[12], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK1_LOW, _PB10, pPacket[13], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK1_LOW(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK1_HIGH(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK1_HIGH, _PB11, pPacket[14], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK1_HIGH, _PB12, pPacket[15], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK1_HIGH, _PB13, pPacket[16], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK1_HIGH(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK2_LOW(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK2_LOW, _PB14, pPacket[17], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK2_LOW, _PB15, pPacket[18], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK2_LOW, _PB16, pPacket[19], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK2_LOW, _PB17, pPacket[20], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK2_LOW(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK2_HIGH(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK2_HIGH, _PB18, pPacket[21], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK2_HIGH, _PB19, pPacket[22], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK2_HIGH, _PB20, pPacket[23], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK2_HIGH(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK3_LOW(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK3_LOW, _PB21, pPacket[24], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK3_LOW, _PB22, pPacket[25], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK3_LOW, _PB23, pPacket[26], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK3_LOW, _PB24, pPacket[27], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK3_LOW(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK3_HIGH(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK3_HIGH, _PB25, pPacket[28], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK3_HIGH, _PB26, pPacket[29], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GENERIC_SUBPACK3_HIGH, _PB27, pPacket[30], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK3_HIGH(head), data);
return;
}
/*
* hdmiWriteGeneralCtrlPacket9171
*/
static void
hdmiWriteGeneralCtrlPacket9171(NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 packetLen,
NvU8 const *const pPacket)
{
NvU32 data = 0;
// orIndexer info is ignored.
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_GCP_SUBPACK(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GCP_SUBPACK, _SB0, pPacket[3], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GCP_SUBPACK, _SB1, pPacket[4], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_GCP_SUBPACK, _SB2, pPacket[5], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_GCP_SUBPACK(head), data);
return;
}
/*
* hdmiWriteVendorPacket9171
*/
static void
hdmiWriteVendorPacket9171(NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 packetLen,
NvU8 const *const pPacketIn)
{
NvU32 data = 0;
NvU8 pPacket[31] = {0};
NVMISC_MEMCPY(pPacket, pPacketIn, packetLen);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_VSI_HEADER(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_HEADER, _HB0, pPacket[0], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_HEADER, _HB1, pPacket[1], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_HEADER, _HB2, pPacket[2], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_VSI_HEADER(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK0_LOW(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK0_LOW, _PB0, pPacket[3], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK0_LOW, _PB1, pPacket[4], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK0_LOW, _PB2, pPacket[5], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK0_LOW, _PB3, pPacket[6], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK0_LOW(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK0_HIGH(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK0_HIGH, _PB4, pPacket[7], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK0_HIGH, _PB5, pPacket[8], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK0_HIGH, _PB6, pPacket[9], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK0_HIGH(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK1_LOW(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK1_LOW, _PB7, pPacket[10], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK1_LOW, _PB8, pPacket[11], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK1_LOW, _PB9, pPacket[12], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK1_LOW, _PB10, pPacket[13], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK1_LOW(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK1_HIGH(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK1_HIGH, _PB11, pPacket[14], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK1_HIGH, _PB12, pPacket[15], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK1_HIGH, _PB13, pPacket[16], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK1_HIGH(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK2_LOW(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK2_LOW, _PB14, pPacket[17], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK2_LOW, _PB15, pPacket[18], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK2_LOW, _PB16, pPacket[19], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK2_LOW, _PB17, pPacket[20], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK2_LOW(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK2_HIGH(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK2_HIGH, _PB18, pPacket[21], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK2_HIGH, _PB19, pPacket[22], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK2_HIGH, _PB20, pPacket[23], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK2_HIGH(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_GENERIC_SUBPACK3_LOW(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK3_LOW, _PB21, pPacket[24], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK3_LOW, _PB22, pPacket[25], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK3_LOW, _PB23, pPacket[26], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK3_LOW, _PB24, pPacket[27], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK3_LOW(head), data);
data = REG_RD32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK3_HIGH(head));
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK3_HIGH, _PB25, pPacket[28], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK3_HIGH, _PB26, pPacket[29], data);
data = FLD_SET_DRF_NUM(9171, _SF_HDMI_VSI_SUBPACK3_HIGH, _PB27, pPacket[30], data);
REG_WR32(pBaseReg, NV9171_SF_HDMI_VSI_SUBPACK3_HIGH(head), data);
return;
}
/*
* translatePacketType9171
*/
static NvU32
translatePacketType9171(NVHDMIPKT_CLASS* pThis,
NVHDMIPKT_TYPE packetType)
{
NvU32 type9171 = NVHDMIPKT_9171_INVALID_PKT_TYPE;
switch (packetType)
{
case NVHDMIPKT_TYPE_AVI_INFOFRAME:
type9171 = NV9171_SF_HDMI_INFO_IDX_AVI_INFOFRAME;
break;
case NVHDMIPKT_TYPE_GENERIC:
type9171 = NV9171_SF_HDMI_INFO_IDX_GENERIC_INFOFRAME;
break;
case NVHDMIPKT_TYPE_GENERAL_CONTROL:
type9171 = NV9171_SF_HDMI_INFO_IDX_GCP;
break;
case NVHDMIPKT_TYPE_VENDOR_SPECIFIC_INFOFRAME:
type9171 = NV9171_SF_HDMI_INFO_IDX_VSI;
break;
case NVHDMIPKT_TYPE_AUDIO_INFOFRAME:
default:
NvHdmiPkt_Print(pThis, "ERROR - translatePacketType wrong packet type: %0x.",
packetType);
NvHdmiPkt_Assert(0);
break;
}
return type9171;
}
/*
* translateTransmitControl9171
*/
static NvU32
translateTransmitControl9171(NVHDMIPKT_CLASS* pThis,
NVHDMIPKT_TC transmitControl)
{
NvU32 tc = 0;
// TODO: tc validation
if (FLD_TEST_DRF(_HDMI_PKT, _TRANSMIT_CTRL, _ENABLE, _EN, transmitControl))
{
tc = FLD_SET_DRF(9171, _SF_HDMI_INFO_CTRL, _ENABLE, _EN, tc);
}
if (FLD_TEST_DRF(_HDMI_PKT, _TRANSMIT_CTRL, _OTHER, _EN, transmitControl))
{
tc = FLD_SET_DRF(9171, _SF_HDMI_INFO_CTRL, _OTHER, _EN, tc);
}
if (FLD_TEST_DRF(_HDMI_PKT, _TRANSMIT_CTRL, _SINGLE, _EN, transmitControl))
{
tc = FLD_SET_DRF(9171, _SF_HDMI_INFO_CTRL, _SINGLE, _EN, tc);
}
if (FLD_TEST_DRF(_HDMI_PKT, _TRANSMIT_CTRL, _CHKSUM_HW, _EN, transmitControl))
{
tc = FLD_SET_DRF(9171, _SF_HDMI_INFO_CTRL, _CHKSUM_HW, _EN, tc);
}
if (FLD_TEST_DRF(_HDMI_PKT, _TRANSMIT_CTRL, _HBLANK, _EN, transmitControl))
{
tc = FLD_SET_DRF(9171, _SF_HDMI_INFO_CTRL, _HBLANK, _EN, tc);
}
if (FLD_TEST_DRF(_HDMI_PKT, _TRANSMIT_CTRL, _VIDEO_FMT, _HW_CTRL, transmitControl))
{
tc = FLD_SET_DRF(9171, _SF_HDMI_INFO_CTRL, _VIDEO_FMT, _HW_CONTROLLED, tc);
}
return tc;
}
/*
* hdmiPacketCtrl9171
*/
NVHDMIPKT_RESULT
hdmiPacketCtrl9171(NVHDMIPKT_CLASS* pThis,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl)
{
NvU32* pBaseReg = (NvU32*)pThis->memMap[subDevice].pMemBase;
NvU32 pktType9171 = pThis->translatePacketType(pThis, packetType);
NvU32 tc = pThis->translateTransmitControl(pThis, transmitControl);
if (pBaseReg == 0 || head >= NV9171_SF_HDMI_AVI_INFOFRAME_CTRL__SIZE_1 ||
pktType9171 == NVHDMIPKT_9171_INVALID_PKT_TYPE)
{
return NVHDMIPKT_INVALID_ARG;
}
return pThis->hdmiWritePacketCtrl(pThis, pBaseReg, head, pktType9171, tc, NV_FALSE);
}
/*
* internal utility function
* checkPacketStatus
*/
static NVHDMIPKT_RESULT
checkPacketStatus(NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 pktType9171)
{
NVHDMIPKT_RESULT result = NVHDMIPKT_SUCCESS;
NvBool bCheckPacketStatus = NV_TRUE;
NvU32 regOffset = 0;
NvU32 status = 0;
// check to see if timer callbacks are provided
if (pThis->callback.setTimeout == 0 || pThis->callback.checkTimeout == 0)
{
goto checkPacketStatus_exit;
}
// Mark packets that don't need status check
switch (pktType9171)
{
case NV9171_SF_HDMI_INFO_IDX_AVI_INFOFRAME:
case NV9171_SF_HDMI_INFO_IDX_GCP:
regOffset = NV9171_SF_HDMI_INFO_STATUS(head, pktType9171);
status = REG_RD32(pBaseReg, regOffset);
bCheckPacketStatus = FLD_TEST_DRF(9171, _SF_HDMI_INFO_CTRL, _SINGLE, _EN, status);
break;
default:
bCheckPacketStatus = NV_FALSE;
break;
}
if (bCheckPacketStatus == NV_TRUE)
{
if (pThis->callback.setTimeout(pThis->cbHandle, NVHDMIPKT_STATUS_READ_TIMEOUT_IN_us)
== NV_FALSE)
{
// Timer set failed
goto checkPacketStatus_exit;
}
while(pThis->hdmiReadPacketStatus(pThis, pBaseReg, head, pktType9171) == NV_FALSE)
{
if (pThis->callback.checkTimeout(pThis->cbHandle) == NV_TRUE)
{
// status check operation timed out
result = NVHDMIPKT_TIMEOUT;
goto checkPacketStatus_exit;
}
}
}
checkPacketStatus_exit:
return result;
}
/*
* hdmiPacketWrite9171
*/
NVHDMIPKT_RESULT
hdmiPacketWrite9171(NVHDMIPKT_CLASS* pThis,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl,
NvU32 packetLen,
NvU8 const *const pPacket)
{
NVHDMIPKT_RESULT result = NVHDMIPKT_SUCCESS;
NvU32* pBaseReg = (NvU32*)pThis->memMap[subDevice].pMemBase;
NvU32 pktType9171 = pThis->translatePacketType(pThis, packetType);
NvU32 tc = pThis->translateTransmitControl(pThis, transmitControl);
NV0073_CTRL_SPECIFIC_CTRL_HDMI_PARAMS params = {0};
if (pBaseReg == 0 || head >= NV9171_SF_HDMI_AVI_INFOFRAME_CTRL__SIZE_1 ||
packetLen == 0 || pPacket == 0 || pktType9171 == NVHDMIPKT_9171_INVALID_PKT_TYPE)
{
result = NVHDMIPKT_INVALID_ARG;
goto hdmiPacketWrite9171_exit;
}
// acquire mutex
pThis->callback.acquireMutex(pThis->cbHandle);
// Check status if last infoframe was sent out or not
if ((result = checkPacketStatus(pThis, pBaseReg, head, pktType9171)) ==
NVHDMIPKT_TIMEOUT)
{
NvHdmiPkt_Print(pThis, "ERROR - Packet status check timed out.");
NvHdmiPkt_Assert(0);
goto hdmiPacketWrite9171_release_mutex_exit;
}
// Disable this packet type.
pThis->hdmiWritePacketCtrl(pThis, pBaseReg, head, pktType9171, tc, NV_TRUE);
// write the packet
switch (pktType9171)
{
case NV9171_SF_HDMI_INFO_IDX_AVI_INFOFRAME:
pThis->hdmiWriteAviPacket(pThis, pBaseReg, head, packetLen, pPacket);
break;
case NV9171_SF_HDMI_INFO_IDX_GENERIC_INFOFRAME:
pThis->hdmiWriteGenericPacket(pThis, pBaseReg, head, packetLen, pPacket);
break;
case NV9171_SF_HDMI_INFO_IDX_GCP:
// Check whether the GCP packet is AVMute DISABLE or AvMute ENABLE
// Enable HDMI only on GCP unmute i.e. AVMUTE DISABLE
if (pPacket[HDMI_PKT_HDR_SIZE] == HDMI_GENCTRL_PACKET_MUTE_DISABLE)
{
// Enable HDMI.
NVMISC_MEMSET(&params, 0, sizeof(params));
params.subDeviceInstance = (NvU8)subDevice;
params.displayId = displayId;
params.bEnable = NV0073_CTRL_SPECIFIC_CTRL_HDMI_ENABLE;
#if NVHDMIPKT_RM_CALLS_INTERNAL
if (CALL_DISP_RM(NvRmControl)(pThis->clientHandles.hClient,
pThis->clientHandles.hDisplay,
NV0073_CTRL_CMD_SPECIFIC_CTRL_HDMI,
&params,
sizeof(params)) != NVOS_STATUS_SUCCESS)
#else // !NVHDMIPKT_RM_CALLS_INTERNAL
NvBool bSuccess = pThis->callback.rmDispControl2(pThis->cbHandle,
params.subDeviceInstance,
NV0073_CTRL_CMD_SPECIFIC_CTRL_HDMI,
&params,
sizeof(params));
if (bSuccess == NV_FALSE)
#endif // NVHDMIPKT_RM_CALLS_INTERNAL
{
NvHdmiPkt_Print(pThis, "ERROR - RM call to enable hdmi ctrl failed.");
NvHdmiPkt_Assert(0);
result = NVHDMIPKT_FAIL;
}
}
pThis->hdmiWriteGeneralCtrlPacket(pThis, pBaseReg, head, packetLen, pPacket);
break;
case NV9171_SF_HDMI_INFO_IDX_VSI:
pThis->hdmiWriteVendorPacket(pThis, pBaseReg, head, packetLen, pPacket);
break;
default:
result = NVHDMIPKT_INVALID_ARG;
break;
}
// Enable this infoframe.
pThis->hdmiWritePacketCtrl(pThis, pBaseReg, head, pktType9171, tc, NV_FALSE);
hdmiPacketWrite9171_release_mutex_exit:
// release mutex
pThis->callback.releaseMutex(pThis->cbHandle);
hdmiPacketWrite9171_exit:
return result;
}
// non-HW - class utility/maintenance functions
/*
* hdmiConstructor9171
*/
NvBool
hdmiConstructor9171(NVHDMIPKT_CLASS* pThis)
{
NvU32 i = 0;
NvBool result = NV_TRUE;
#if NVHDMIPKT_RM_CALLS_INTERNAL
for (i = 0; i < pThis->numSubDevices; i++)
{
if (CALL_DISP_RM(NvRmAlloc)(pThis->clientHandles.hClient,
pThis->clientHandles.hSubDevices[i],
pThis->sfUserHandle + i,
pThis->dispSfUserClassId,
(void*)0) != NVOS_STATUS_SUCCESS)
{
NvHdmiPkt_Print(pThis, "ERROR - Init failed. "
"Failed to alloc SF_USER handle");
NvHdmiPkt_Assert(0);
break;
}
pThis->memMap[i].memHandle = pThis->sfUserHandle + i;
if (CALL_DISP_RM(NvRmMapMemory)(pThis->clientHandles.hClient,
pThis->clientHandles.hSubDevices[i],
pThis->memMap[i].memHandle,
0,
pThis->dispSfUserSize,
&pThis->memMap[i].pMemBase,
0) != NVOS_STATUS_SUCCESS)
{
NvHdmiPkt_Print(pThis, "ERROR - Init failed. "
"Failed to map SF_USER memory.");
NvHdmiPkt_Assert(0);
break;
}
if (pThis->memMap[i].pMemBase == 0)
{
NvHdmiPkt_Print(pThis, "ERROR - Init failed. "
"SF_USER memory returned is NULL.");
NvHdmiPkt_Assert(0);
break;
}
pThis->memMap[i].subDevice = i;
}
// coudln't complete the loop above
if (i < pThis->numSubDevices)
{
result = NV_FALSE;
goto hdmiConstructor9171_exit;
}
#else // !NVHDMIPKT_RM_CALLS_INTERNAL
for (i = 0; i < pThis->numSubDevices; i++)
{
result = pThis->callback.rmGetMemoryMap(pThis->cbHandle,
pThis->dispSfUserClassId,
pThis->dispSfUserSize,
i,
&pThis->memMap[i].memHandle,
&pThis->memMap[i].pMemBase);
if (result == NV_TRUE)
{
pThis->memMap[i].subDevice = i;
}
else
{
NvHdmiPkt_Print(pThis, "ERROR - Init failed. "
"Failed to map SF_USER memory.");
NvHdmiPkt_Assert(0);
result = NV_FALSE;
goto hdmiConstructor9171_exit;
}
}
#endif // NVHDMIPKT_RM_CALLS_INTERNAL
hdmiConstructor9171_exit:
return result;
}
/*
* hdmiDestructor9171
*/
void
hdmiDestructor9171(NVHDMIPKT_CLASS* pThis)
{
NvU32 i = 0;
#if NVHDMIPKT_RM_CALLS_INTERNAL
for (i = 0; i < NV_MAX_SUBDEVICES; i++)
{
// free memory
if (pThis->memMap[i].pMemBase)
{
if (CALL_DISP_RM(NvRmUnmapMemory)(pThis->clientHandles.hClient,
pThis->clientHandles.hSubDevices[i],
pThis->memMap[i].memHandle,
pThis->memMap[i].pMemBase,
0) != NVOS_STATUS_SUCCESS)
{
NvHdmiPkt_Print(pThis, "ERROR - unInit failed. "
"SF_USER memory unMap failed.");
NvHdmiPkt_Assert(0);
}
}
// free handle
if (pThis->memMap[i].memHandle)
{
if (CALL_DISP_RM(NvRmFree)(pThis->clientHandles.hClient,
pThis->clientHandles.hSubDevices[i],
pThis->memMap[i].memHandle) != NVOS_STATUS_SUCCESS)
{
NvHdmiPkt_Print(pThis, "ERROR - unInit failed. "
"Freeing SF_USER memory handle failed.");
NvHdmiPkt_Assert(0);
}
}
pThis->memMap[i].subDevice = NVHDMIPKT_INVALID_SUBDEV;
pThis->memMap[i].memHandle = 0;
pThis->memMap[i].pMemBase = 0;
}
#else // !NVHDMIPKT_RM_CALLS_INTERNAL
for (i = 0; i < NV_MAX_SUBDEVICES; i++)
{
if (pThis->memMap[i].memHandle)
{
pThis->callback.rmFreeMemoryMap(pThis->cbHandle,
i,
pThis->memMap[i].memHandle,
pThis->memMap[i].pMemBase);
pThis->memMap[i].subDevice = NVHDMIPKT_INVALID_SUBDEV;
pThis->memMap[i].memHandle = 0;
pThis->memMap[i].pMemBase = 0;
}
}
#endif // NVHDMIPKT_RM_CALLS_INTERNAL
return;
}
/*
* initializeHdmiPktInterface9171
*/
void
initializeHdmiPktInterface9171(NVHDMIPKT_CLASS* pClass)
{
pClass->hdmiPacketCtrl = hdmiPacketCtrl9171;
pClass->hdmiPacketWrite = hdmiPacketWrite9171;
pClass->translatePacketType = translatePacketType9171;
pClass->translateTransmitControl = translateTransmitControl9171;
// HW register write functions
pClass->hdmiReadPacketStatus = hdmiReadPacketStatus9171;
pClass->hdmiWritePacketCtrl = hdmiWritePacketCtrl9171;
pClass->hdmiWriteAviPacket = hdmiWriteAviPacket9171;
pClass->hdmiWriteAudioPacket = hdmiWriteDummyPacket;
pClass->hdmiWriteGenericPacket = hdmiWriteGenericPacket9171;
pClass->hdmiWriteGeneralCtrlPacket = hdmiWriteGeneralCtrlPacket9171;
pClass->hdmiWriteVendorPacket = hdmiWriteVendorPacket9171;
// Update SF_USER data
pClass->dispSfUserClassId = NV9171_DISP_SF_USER;
pClass->dispSfUserSize = sizeof(Nv9171DispSfUserMap);
// Functions below are used by HDMI FRL and will be available for Ampere+.
pClass->hdmiAssessLinkCapabilities = hdmiAssessLinkCapabilitiesDummy;
pClass->hdmiQueryFRLConfig = hdmiQueryFRLConfigDummy;
pClass->hdmiSetFRLConfig = hdmiSetFRLConfigDummy;
pClass->hdmiClearFRLConfig = hdmiClearFRLConfigDummy;
}

View File

@@ -0,0 +1,71 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* File: nvhdmipkt_9271.c
*
* Purpose: Provides packet write functions for HDMI library for KEPLER + chips
*/
#include "nvhdmipkt_common.h"
#include "nvhdmipkt_class.h"
#include "nvhdmipkt_internal.h"
#include "class/cl9271.h"
/******************************************** NOTE ***********************************************
* This file serves as an example on how to add a new HW SF USER CLASS. Notice that this *
* Class didn't override any functions, as 9171 is identical to 9271. *
*************************************************************************************************/
// non-HW - class utility/maintenance functions
/*
* hdmiConstructor9271
*/
NvBool
hdmiConstructor9271(NVHDMIPKT_CLASS* pThis)
{
NvBool result = NV_TRUE;
return result;
}
/*
* hdmiDestructor9271
*/
void
hdmiDestructor9271(NVHDMIPKT_CLASS* pThis)
{
return;
}
/*
* initializeHdmiPktInterface9271
*/
void
initializeHdmiPktInterface9271(NVHDMIPKT_CLASS* pClass)
{
// Update SF_USER data
pClass->dispSfUserClassId = NV9271_DISP_SF_USER;
pClass->dispSfUserSize = sizeof(Nv9271DispSfUserMap);
}

View File

@@ -0,0 +1,71 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* File: nvhdmipkt_9471.c
*
* Purpose: Provides packet write functions for HDMI library for Maxwell + chips
*/
#include "nvhdmipkt_common.h"
#include "nvhdmipkt_class.h"
#include "nvhdmipkt_internal.h"
#include "class/cl9471.h"
/******************************************** NOTE ***********************************************
* This file serves as an example on how to add a new HW SF USER CLASS. Notice that this *
* Class didn't override any functions, as 9171 is identical to 9471. *
*************************************************************************************************/
// non-HW - class utility/maintenance functions
/*
* hdmiConstructor9471
*/
NvBool
hdmiConstructor9471(NVHDMIPKT_CLASS* pThis)
{
NvBool result = NV_TRUE;
return result;
}
/*
* hdmiDestructor9471
*/
void
hdmiDestructor9471(NVHDMIPKT_CLASS* pThis)
{
return;
}
/*
* initializeHdmiPktInterface9471
*/
void
initializeHdmiPktInterface9471(NVHDMIPKT_CLASS* pClass)
{
// Update SF_USER data
pClass->dispSfUserClassId = NV9471_DISP_SF_USER;
pClass->dispSfUserSize = sizeof(Nv9471DispSfUserMap);
}

View File

@@ -0,0 +1,71 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* File: nvhdmipkt_9571.c
*
* Purpose: Provides packet write functions for HDMI library for Maxwell + chips
*/
#include "nvhdmipkt_common.h"
#include "nvhdmipkt_class.h"
#include "nvhdmipkt_internal.h"
#include "class/cl9571.h"
/******************************************** NOTE ***********************************************
* This file serves as an example on how to add a new HW SF USER CLASS. Notice that this *
* Class didn't override any functions, as 9171 is identical to 9571. *
*************************************************************************************************/
// non-HW - class utility/maintenance functions
/*
* hdmiConstructor9571
*/
NvBool
hdmiConstructor9571(NVHDMIPKT_CLASS* pThis)
{
NvBool result = NV_TRUE;
return result;
}
/*
* hdmiDestructor9571
*/
void
hdmiDestructor9571(NVHDMIPKT_CLASS* pThis)
{
return;
}
/*
* initializeHdmiPktInterface9571
*/
void
initializeHdmiPktInterface9571(NVHDMIPKT_CLASS* pClass)
{
// Update SF_USER data
pClass->dispSfUserClassId = NV9571_DISP_SF_USER;
pClass->dispSfUserSize = sizeof(Nv9571DispSfUserMap);
}

View File

@@ -0,0 +1,71 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* File: nvhdmipkt_C371.c
*
* Purpose: Provides packet write functions for HDMI library for Volta+ chips
*/
#include "nvhdmipkt_common.h"
#include "nvhdmipkt_class.h"
#include "nvhdmipkt_internal.h"
#include "class/clc371.h"
/******************************************** NOTE ***********************************************
* This file serves as an example on how to add a new HW SF USER CLASS. Notice that this *
* Class didn't override any functions, as 9171 is identical to C371. *
*************************************************************************************************/
// non-HW - class utility/maintenance functions
/*
* hdmiConstructorC371
*/
NvBool
hdmiConstructorC371(NVHDMIPKT_CLASS* pThis)
{
NvBool result = NV_TRUE;
return result;
}
/*
* hdmiDestructorC371
*/
void
hdmiDestructorC371(NVHDMIPKT_CLASS* pThis)
{
return;
}
/*
* initializeHdmiPktInterfaceC371
*/
void
initializeHdmiPktInterfaceC371(NVHDMIPKT_CLASS* pClass)
{
// Update SF_USER data
pClass->dispSfUserClassId = NVC371_DISP_SF_USER;
pClass->dispSfUserSize = sizeof(NvC371DispSfUserMap);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,179 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* File: nvhdmipkt_class.h
*
* Purpose: This file contains hdmipkt class definition. Which defines class interfaces.
*/
#ifndef _NVHDMIPKT_CLASS_H_
#define _NVHDMIPKT_CLASS_H_
#include "nvlimits.h"
#include "nvhdmi_frlInterface.h"
/*************************************************************************************************
* NOTE * This header file to be used only inside this (Hdmi Packet) library. *
************************************************************************************************/
// NVHDMIPKT_CLASS_ID: HDMI packet class version
// NOTE: Anytime a new class comes with upgrades, it needs to be added here.
// Consult resman\kernel\inc\classhal.h, before adding a class.
typedef enum
{
NVHDMIPKT_0073_CLASS = 0, // pre GK104
NVHDMIPKT_9171_CLASS = 1, // GK104
NVHDMIPKT_9271_CLASS = 2, // GK110
NVHDMIPKT_9471_CLASS = 3, // GM10X
NVHDMIPKT_9571_CLASS = 4, // GM20X
NVHDMIPKT_C371_CLASS = 5, // GV100
NVHDMIPKT_C571_CLASS = 6, // TU102
NVHDMIPKT_C671_CLASS = 7, // GA102, T234D
NVHDMIPKT_INVALID_CLASS // Not to be used by client, and always the last entry here.
} NVHDMIPKT_CLASS_ID;
// Hdmi packet class
struct tagNVHDMIPKT_CLASS
{
// data
NvU32 dispSfUserClassId; // Id from nvidia/class definition
NvU32 dispSfUserSize;
NvU32 numSubDevices;
NvU32 sfUserHandle;
NVHDMIPKT_RM_CLIENT_HANDLES clientHandles;
NVHDMIPKT_MEM_MAP memMap[NV_MAX_SUBDEVICES];
NvHdmiPkt_CBHandle cbHandle;
NVHDMIPKT_CALLBACK callback;
NVHDMIPKT_CLASS_ID thisId;
NvBool isRMCallInternal;
// functions
NVHDMIPKT_RESULT
(*hdmiPacketCtrl) (NVHDMIPKT_CLASS* pThis,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl);
NVHDMIPKT_RESULT
(*hdmiPacketWrite) (NVHDMIPKT_CLASS* pThis,
NvU32 subDevice,
NvU32 displayId,
NvU32 head,
NVHDMIPKT_TYPE packetType,
NVHDMIPKT_TC transmitControl,
NvU32 packetLen,
NvU8 const *const pPacket);
// HW functions - that read/write registers
NvBool
(*hdmiReadPacketStatus) (NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 pktTypeNative);
NVHDMIPKT_RESULT
(*hdmiWritePacketCtrl) (NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 pktTypeNative,
NvU32 transmitControl,
NvBool bDisable);
void
(*hdmiWriteAviPacket) (NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 packetLen,
NvU8 const *const pPacket);
void
(*hdmiWriteAudioPacket) (NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 packetLen,
NvU8 const *const pPacket);
void
(*hdmiWriteGenericPacket) (NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 packetLen,
NvU8 const *const pPacket);
void
(*hdmiWriteGeneralCtrlPacket)(NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 packetLen,
NvU8 const *const pPacket);
void
(*hdmiWriteVendorPacket) (NVHDMIPKT_CLASS* pThis,
NvU32* pBaseReg,
NvU32 head,
NvU32 packetLen,
NvU8 const *const pPacket);
// utility functions to translate the generic packet type and transmit control
// to corresponding rm ctrl or hw define types.
NvU32
(*translatePacketType) (NVHDMIPKT_CLASS* pThis,
NVHDMIPKT_TYPE packetType);
NvU32
(*translateTransmitControl) (NVHDMIPKT_CLASS* pThis,
NVHDMIPKT_TC transmitControl);
//
// HDMI FRL functions to enable/disable HDMI FRL and calculate the bandwidth
// capacity required for target timing.
//
NVHDMIPKT_RESULT
(*hdmiAssessLinkCapabilities) (NVHDMIPKT_CLASS *pThis,
NvU32 subDevice,
NvU32 displayId,
NVT_EDID_INFO const * const pSinkEdid,
HDMI_SRC_CAPS *pSrcCaps,
HDMI_SINK_CAPS *pSinkCaps);
NVHDMIPKT_RESULT
(*hdmiQueryFRLConfig) (NVHDMIPKT_CLASS *pThis,
HDMI_VIDEO_TRANSPORT_INFO const * const pVidTransInfo,
HDMI_QUERY_FRL_CLIENT_CONTROL const * const pClientCtrl,
HDMI_SRC_CAPS const * const pSrcCaps,
HDMI_SINK_CAPS const * const pSinkCaps,
HDMI_FRL_CONFIG *pFRLConfig);
NVHDMIPKT_RESULT
(*hdmiSetFRLConfig) (NVHDMIPKT_CLASS *pThis,
NvU32 subDevice,
NvU32 displayId,
NvBool bFakeLt,
HDMI_FRL_CONFIG *pFRLConfig);
NVHDMIPKT_RESULT
(*hdmiClearFRLConfig) (NVHDMIPKT_CLASS* pThis,
NvU32 subDevice,
NvU32 displayId);
};
#endif //_NVHDMIPKT_CLASS_H_

View File

@@ -0,0 +1,114 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* File: nvhdmipkt_common.h
*
* Purpose: This file contains defines and structures used across hdmipkt library. All the
* common stuff goes here.
*/
#ifndef _NVHDMIPKT_COMMON_H_
#define _NVHDMIPKT_COMMON_H_
/*************************************************************************************************
* NOTE * This header file to be used only inside this (Hdmi Packet) library. *
************************************************************************************************/
#include "nvhdmipkt.h"
#include "nvhdmi_frlInterface.h"
#if NVHDMIPKT_RM_CALLS_INTERNAL
#include "nvRmApi.h"
#define CALL_DISP_RM(x) x
#endif
/**************************** HDMI Library defines, enums and structs ***************************/
// typedefs
typedef struct tagNVHDMIPKT_CLASS NVHDMIPKT_CLASS;
typedef struct tagNVHDMIPKT_MEM_MAP NVHDMIPKT_MEM_MAP;
// Register read/write defines
#define REG_RD32(reg, offset) (*(((volatile NvU32*)(reg)) + ((offset)/4)))
#define REG_WR32(reg, offset, data) ((*(((volatile NvU32*)(reg)) + ((offset)/4))) = (data))
#define NVHDMIPKT_INVALID_SUBDEV (0xFFFFFFFF)
#define NVHDMIPKT_DONT_USE_TIMER
#define NVHDMIPKT_STATUS_READ_TIMEOUT_IN_us (1*1000*1000) /* us - micro second */
// Disp SF User memory map and handle structure
struct tagNVHDMIPKT_MEM_MAP
{
NvU32 subDevice;
NvU32 memHandle;
void* pMemBase;
};
// HDMIPKT print define
#if defined (DEBUG)
#define NvHdmiPkt_Print(_p, ...) \
do { \
if ((_p)->callback.print) \
{ \
(_p)->callback.print((_p)->cbHandle, "HdmiPacketLibrary: " __VA_ARGS__); \
} \
} while(0)
#else
#define NvHdmiPkt_Print(_p, ...) /* nothing */
#endif
// HDMIPKT assert define
#if defined (DEBUG)
#define NvHdmiPkt_AssertP(p, expr) ((p)->callback.assert ? \
(p)->callback.assert((p)->cbHandle, !!(expr)) : 0)
#define NvHdmiPkt_Assert(expr) NvHdmiPkt_AssertP(pThis, expr)
#else
#define NvHdmiPkt_AssertP(p, expr)
#define NvHdmiPkt_Assert(expr)
#endif
// Prototypes for common functions shared across implementations.
extern void hdmiWriteDummyPacket(NVHDMIPKT_CLASS*, NvU32*, NvU32, NvU32, NvU8 const *const);
extern NVHDMIPKT_RESULT hdmiAssessLinkCapabilitiesDummy(NVHDMIPKT_CLASS *pThis,
NvU32 subDevice,
NvU32 displayId,
NVT_EDID_INFO const * const pSinkEdid,
HDMI_SRC_CAPS *pSrcCaps,
HDMI_SINK_CAPS *pSinkCaps);
extern NVHDMIPKT_RESULT hdmiQueryFRLConfigDummy(NVHDMIPKT_CLASS *pThis,
HDMI_VIDEO_TRANSPORT_INFO const * const pVidTransInfo,
HDMI_QUERY_FRL_CLIENT_CONTROL const * const pClientCtrl,
HDMI_SRC_CAPS const * const pSrcCaps,
HDMI_SINK_CAPS const * const pSinkCaps,
HDMI_FRL_CONFIG *pFRLConfig);
extern NVHDMIPKT_RESULT hdmiSetFRLConfigDummy(NVHDMIPKT_CLASS *pThis,
NvU32 subDevice,
NvU32 displayId,
NvBool bFakeLt,
HDMI_FRL_CONFIG *pFRLConfig);
extern NVHDMIPKT_RESULT hdmiClearFRLConfigDummy(NVHDMIPKT_CLASS *pThis,
NvU32 subDevice,
NvU32 displayId);
#endif //_NVHDMIPKT_COMMON_H_

View File

@@ -0,0 +1,60 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* File: nvhdmipkt_internal.h
*
* Purpose: This files contains defines to be used by nvhdmipkt.c
*/
#ifndef _NVHDMIPKT_INTERNAL_H_
#define _NVHDMIPKT_INTERNAL_H_
/*************************************************************************************************
* NOTE * This header file to be used only inside this (Hdmi Packet) library. *
************************************************************************************************/
#define toHdmiPktHandle(p) ((NvHdmiPkt_Handle)(p))
#define fromHdmiPktHandle(h) ((NVHDMIPKT_CLASS*)(h))
extern void initializeHdmiPktInterface0073(NVHDMIPKT_CLASS*);
extern void initializeHdmiPktInterface9171(NVHDMIPKT_CLASS*);
extern void initializeHdmiPktInterface9271(NVHDMIPKT_CLASS*);
extern void initializeHdmiPktInterface9471(NVHDMIPKT_CLASS*);
extern void initializeHdmiPktInterface9571(NVHDMIPKT_CLASS*);
extern void initializeHdmiPktInterfaceC371(NVHDMIPKT_CLASS*);
extern void initializeHdmiPktInterfaceC671(NVHDMIPKT_CLASS*);
extern NvBool hdmiConstructor0073(NVHDMIPKT_CLASS*);
extern void hdmiDestructor0073 (NVHDMIPKT_CLASS*);
extern NvBool hdmiConstructor9171(NVHDMIPKT_CLASS*);
extern void hdmiDestructor9171 (NVHDMIPKT_CLASS*);
extern NvBool hdmiConstructor9271(NVHDMIPKT_CLASS*);
extern void hdmiDestructor9271 (NVHDMIPKT_CLASS*);
extern NvBool hdmiConstructor9471(NVHDMIPKT_CLASS*);
extern void hdmiDestructor9471 (NVHDMIPKT_CLASS*);
extern NvBool hdmiConstructor9571(NVHDMIPKT_CLASS*);
extern void hdmiDestructor9571 (NVHDMIPKT_CLASS*);
extern NvBool hdmiConstructorC371(NVHDMIPKT_CLASS*);
extern void hdmiDestructorC371 (NVHDMIPKT_CLASS*);
extern NvBool hdmiConstructorC671(NVHDMIPKT_CLASS*);
extern void hdmiDestructorC671 (NVHDMIPKT_CLASS*);
#endif //_NVHDMIPKT_INTERNAL_H_