1 /* 2 * SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 * SPDX-License-Identifier: MIT 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24 /** @file nvhdmi_frlInterface.h 25 * @brief This file provides FRL related interfaces between client and HDMI lib 26 */ 27 28 29 #ifndef _NVHDMI_FRLINTERFACE_H_ 30 #define _NVHDMI_FRLINTERFACE_H_ 31 32 #include "nvhdmipkt.h" 33 #include "nvHdmiFrlCommon.h" 34 35 #include "../timing/nvtiming.h" 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 42 // DSC encoder color format bitmasks (these match DSC lib & RM ctrl 0073 fields) 43 typedef enum tagHDMI_DSC_ENCODER_COLOR_FORMAT 44 { 45 HDMI_DSC_ENCODER_COLOR_FORMAT_RGB = 1, 46 HDMI_DSC_ENCODER_COLOR_FORMAT_YCBCR444 = 2, 47 HDMI_DSC_ENCODER_COLOR_FORMAT_YCBCRNATIVE422 = 4, 48 HDMI_DSC_ENCODER_COLOR_FORMAT_YCBCRNATIVE420 = 8 49 } HDMI_DSC_ENCODER_COLOR_FORMAT; 50 51 // Options for QueryFRLConfig interface 52 typedef enum tagHDMI_QUERY_FRL_OPTION 53 { 54 HDMI_QUERY_FRL_ANY_CONFIG = 0, // any FRL config that supports mode 55 HDMI_QUERY_FRL_OPTIMUM_CONFIG, // find best fit config for this mode 56 HDMI_QUERY_FRL_LOWEST_BANDWIDTH, // min bw 57 HDMI_QUERY_FRL_HIGHEST_PIXEL_QUALITY, // trade off bandwidth for pixel quality 58 HDMI_QUERY_FRL_HIGHEST_BANDWIDTH 59 } HDMI_QUERY_FRL_OPTION; 60 61 /************************************************************************************************* 62 * HDMI_VIDEO_TRANSPORT_INFO: * 63 * Video transport format - a combination of timing, bpc, packing represents what goes on the link* 64 * client passes this in, lib uses this for bandwidth calculations to decide required FRL rate * 65 **************************************************************************************************/ 66 typedef struct tagHDMI_VIDEO_TRANSPORT_INFO 67 { 68 const NVT_TIMING *pTiming; // backend timing 69 HDMI_BPC bpc; 70 HDMI_PIXEL_PACKING packing; 71 NvBool bDualHeadMode; // 2H1OR 72 } HDMI_VIDEO_TRANSPORT_INFO; 73 74 /************************************************************************************************ 75 * HDMI_QUERY_FRL_CLIENT_CONTROL: * 76 * Allow client to force request DSC/FRL configurations. For testing purpose or otherwise * 77 * eg, client could query for any fitting FRL config instead of most optimum. It could trade off * 78 * bandwidth for pixel quality. * 79 *************************************************************************************************/ 80 typedef struct tagHDMI_QUERY_FRL_CLIENT_CONTROL 81 { 82 HDMI_QUERY_FRL_OPTION option; 83 84 NvU32 forceFRLRate : 1; 85 NvU32 forceAudio2Ch48KHz : 1; 86 NvU32 enableDSC : 1; 87 NvU32 forceSliceCount : 1; 88 NvU32 forceSliceWidth : 1; 89 NvU32 forceBppx16 : 1; 90 NvU32 skipGeneratePPS : 1; 91 NvU32 reserved : 25; 92 93 // client can set below params if respective force flag is set 94 NvU32 sliceCount; 95 NvU32 sliceWidth; 96 NvU32 bitsPerPixelX16; 97 HDMI_FRL_DATA_RATE frlRate; 98 99 } HDMI_QUERY_FRL_CLIENT_CONTROL; 100 101 /************************************************************************************************ 102 * HDMI_SRC_CAPS: * 103 * Input to HDMI lib. * 104 * * 105 * Client gives info about GPU capabilities - DSC related caps * 106 *************************************************************************************************/ 107 typedef struct tagHDMI_SRC_CAPS 108 { 109 struct 110 { 111 NvU32 dscCapable : 1; 112 NvU32 bppPrecision : 8; 113 NvU32 encoderColorFormatMask : 8; 114 NvU32 lineBufferSizeKB : 8; 115 NvU32 rateBufferSizeKB : 8; 116 NvU32 maxNumHztSlices : 8; 117 NvU32 lineBufferBitDepth : 8; 118 NvU32 dualHeadBppTargetMaxX16 : 16; 119 NvU32 maxWidthPerSlice; 120 } dscCaps; 121 122 HDMI_FRL_DATA_RATE linkMaxFRLRate; 123 } HDMI_SRC_CAPS; 124 125 /************************************************************************************************ 126 * HDMI_SINK_CAPS: * 127 * Input to HDMI lib. * 128 * * 129 * Client gives info from EDID, HDMI lib uses DSC related info to call DSC lib to generate PPS * 130 * Audio information from CEA861 block is used for bandwidth calculations * 131 * linkMaxFRLRate and linkMaxFRLRateDSC are max link rates determined from physical link * 132 * training. * 133 *************************************************************************************************/ 134 typedef struct tagHDMI_SINK_CAPS 135 { 136 const NVT_HDMI_FORUM_INFO *pHdmiForumInfo; 137 NvU32 audioType; 138 NvU32 maxAudioChannels; 139 NvU32 maxAudioFreqKHz; 140 NvBool bHBRAudio; 141 HDMI_FRL_DATA_RATE linkMaxFRLRate; 142 HDMI_FRL_DATA_RATE linkMaxFRLRateDSC; 143 } HDMI_SINK_CAPS; 144 145 /************************************************************************************************ 146 * HDMI_FRL_CONFIG: * 147 * Output from HDMI lib. Client uses this info for modeset * 148 * * 149 * maxSupportedAudioCh, maxSupportedAudioFreqKHz - max possible audio settings at the chosen * 150 * FRL rate, though the sink caps may have reported higher caps * 151 * * 152 * dscInfo - if current timing requires DSC, lib returns PPS information here * 153 * * 154 * bitsPerPixelx16 - optimum bpp value calculated per spec * 155 * dscHActiveBytes - in compressed video transport mode, number of bytes in 1 line * 156 * dscHActiveTriBytes - in compressed video transport mode, number of tri-bytes in 1 line * 157 * dscHBlankTriBytes - in compressed video transport mode, number of tri-bytes to be sent * 158 * to represent horizontal blanking * 159 * * 160 * pps[32] - PPS data. HDMI lib calls DSC lib to fill it in * 161 *************************************************************************************************/ 162 #define HDMI_DSC_MAX_PPS_SIZE_DWORD 32 163 typedef struct tagHDMI_FRL_CONFIG 164 { 165 HDMI_FRL_DATA_RATE frlRate; 166 NvU32 maxSupportedAudioCh; 167 NvU32 maxSupportedAudioFreqKHz; 168 169 // DSC info client will use for core channel modeset 170 struct 171 { 172 NvU32 bEnableDSC : 1; 173 NvU32 reserved : 31; 174 175 NvU32 bitsPerPixelX16; 176 NvU32 sliceCount; 177 NvU32 sliceWidth; 178 NvU32 pps[HDMI_DSC_MAX_PPS_SIZE_DWORD]; 179 NvU32 dscHActiveBytes; 180 NvU32 dscHActiveTriBytes; 181 NvU32 dscHBlankTriBytes; 182 NvU32 dscTBlankToTTotalRatioX1k; 183 } dscInfo; 184 185 } HDMI_FRL_CONFIG; 186 187 /************************************************************************************************ 188 * NvHdmi_AssessLinkCapabilities: * 189 * * 190 * Input parameters: * 191 * subDevice - Sub Device ID. * 192 * displayId - Display ID. * 193 * pSinkEdid - EDID of sink * 194 * * 195 * Output parameters: * 196 * pSrcCaps - src capabilities - DSC caps * 197 * pSinkCaps - sink capabilities - actual caps calculated from link training * 198 * * 199 * Calls RM to get DSC related src side caps. Performs physical link training to determine if * 200 * sink reported max FRL rate can actually be supported on the physical link * 201 *************************************************************************************************/ 202 NVHDMIPKT_RESULT 203 NvHdmi_AssessLinkCapabilities(NvHdmiPkt_Handle libHandle, 204 NvU32 subDevice, 205 NvU32 displayId, 206 NVT_EDID_INFO const * const pSinkEdid, 207 HDMI_SRC_CAPS *pSrcCaps, 208 HDMI_SINK_CAPS *pSinkCaps); 209 210 /************************************************************************************************ 211 * NvHdmi_QueryFRLConfig: * 212 * * 213 * Input parameters: * 214 * libHandle - Hdmi library handle, provided on initializing the library. * 215 * pVidTransInfo - information about timing, bpc and packing * 216 * pClientCtrl - settings client wants to see set. HDMI lib tries to honor these * 217 * pSinkCaps - sink capabilities * 218 * * 219 * Output parameters: * 220 * pFRLConfig - chosen FRL rate and DSC configuration * 221 * * 222 *************************************************************************************************/ 223 NVHDMIPKT_RESULT 224 NvHdmi_QueryFRLConfig(NvHdmiPkt_Handle libHandle, 225 HDMI_VIDEO_TRANSPORT_INFO const * const pVidTransInfo, 226 HDMI_QUERY_FRL_CLIENT_CONTROL const * const pClientCtrl, 227 HDMI_SRC_CAPS const * const pSrcCaps, 228 HDMI_SINK_CAPS const * const pSinkCaps, 229 HDMI_FRL_CONFIG *pFRLConfig); 230 231 /************************************************************************************************ 232 * NvHdmi_SetFRLConfig: * 233 * * 234 * Input parameters: * 235 * libHandle - Hdmi library handle, provided on initializing the library. * 236 * subDevice - Sub Device ID. * 237 * displayId - Display ID. * 238 * bFakeLt - Indicates that the GPU's link configuration should be forced and that * 239 * configuration of the sink device should be skipped. * 240 * pFRLConfig - Link configuration to set. * 241 * * 242 ************************************************************************************************/ 243 NVHDMIPKT_RESULT 244 NvHdmi_SetFRLConfig(NvHdmiPkt_Handle libHandle, 245 NvU32 subDevice, 246 NvU32 displayId, 247 NvBool bFakeLt, 248 HDMI_FRL_CONFIG *pFRLConfig); 249 250 /************************************************************************************************ 251 * NvHdmi_ClearFRLConfig: * 252 * * 253 * Input parameters: * 254 * libHandle - Hdmi library handle, provided on initializing the library. * 255 * subDevice - Sub Device ID. * 256 * displayId - Display ID to change the settings on. * 257 * * 258 ************************************************************************************************/ 259 NVHDMIPKT_RESULT 260 NvHdmi_ClearFRLConfig(NvHdmiPkt_Handle libHandle, 261 NvU32 subDevice, 262 NvU32 displayId); 263 264 #ifdef __cplusplus 265 } 266 #endif 267 268 #endif // _NVHDMI_FRLINTERFACE_H_ 269