1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2004-2017 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 #pragma once
25 
26 #include <nvtypes.h>
27 
28 //
29 // This file was generated with FINN, an NVIDIA coding tool.
30 // Source file:      ctrl/ctrl0080/ctrl0080fb.finn
31 //
32 
33 #include "ctrl/ctrl0080/ctrl0080base.h"
34 
35 /* NV01_DEVICE_XX/NV03_DEVICE fb control commands and parameters */
36 
37 /**
38  * NV0080_CTRL_CMD_FB_GET_CAPS
39  *
40  * This command returns the set of framebuffer capabilities for the device
41  * in the form of an array of unsigned bytes.  Framebuffer capabilities
42  * include supported features and required workarounds for the framebuffer
43  * engine(s) within the device, each represented by a byte offset into the
44  * table and a bit position within that byte.
45  *
46  *   capsTblSize
47  *     This parameter specifies the size in bytes of the caps table.
48  *     This value should be set to NV0080_CTRL_FB_CAPS_TBL_SIZE.
49  *   capsTbl
50  *     This parameter specifies a pointer to the client's caps table buffer
51  *     into which the framebuffer caps bits will be transferred by the RM.
52  *     The caps table is an array of unsigned bytes.
53  *
54  * Possible status values returned are:
55  *   NV_OK
56  *   NV_ERR_INVALID_PARAM_STRUCT
57  *   NV_ERR_INVALID_ARGUMENT
58  *   NV_ERR_INVALID_POINTER
59  */
60 #define NV0080_CTRL_CMD_FB_GET_CAPS (0x801301) /* finn: Evaluated from "(FINN_NV01_DEVICE_0_FB_INTERFACE_ID << 8) | NV0080_CTRL_FB_GET_CAPS_PARAMS_MESSAGE_ID" */
61 
62 #define NV0080_CTRL_FB_GET_CAPS_PARAMS_MESSAGE_ID (0x1U)
63 
64 typedef struct NV0080_CTRL_FB_GET_CAPS_PARAMS {
65     NvU32 capsTblSize;
66     NV_DECLARE_ALIGNED(NvP64 capsTbl, 8);
67 } NV0080_CTRL_FB_GET_CAPS_PARAMS;
68 
69 /* extract cap bit setting from tbl */
70 #define NV0080_CTRL_FB_GET_CAP(tbl,c)              (((NvU8)tbl[(1?c)]) & (0?c))
71 
72 /* caps format is byte_index:bit_mask */
73 #define NV0080_CTRL_FB_CAPS_SUPPORT_RENDER_TO_SYSMEM                                0:0x01
74 #define NV0080_CTRL_FB_CAPS_BLOCKLINEAR                                             0:0x02
75 #define NV0080_CTRL_FB_CAPS_SUPPORT_SCANOUT_FROM_SYSMEM                             0:0x04
76 #define NV0080_CTRL_FB_CAPS_SUPPORT_CACHED_SYSMEM                                   0:0x08
77 #define NV0080_CTRL_FB_CAPS_SUPPORT_C24_COMPRESSION                                 0:0x10 // Deprecated
78 #define NV0080_CTRL_FB_CAPS_SUPPORT_SYSMEM_COMPRESSION                              0:0x20
79 #define NV0080_CTRL_FB_CAPS_NISO_CFG0_BUG_534680                                    0:0x40 // Deprecated
80 #define NV0080_CTRL_FB_CAPS_ISO_FETCH_ALIGN_BUG_561630                              0:0x80 // Deprecated
81 
82 #define NV0080_CTRL_FB_CAPS_BLOCKLINEAR_GOBS_512                                    1:0x01
83 #define NV0080_CTRL_FB_CAPS_L2_TAG_BUG_632241                                       1:0x02
84 #define NV0080_CTRL_FB_CAPS_SINGLE_FB_UNIT                                          1:0x04 // Deprecated
85 #define NV0080_CTRL_FB_CAPS_CE_RMW_DISABLE_BUG_897745                               1:0x08 // Deprecated
86 #define NV0080_CTRL_FB_CAPS_OS_OWNS_HEAP_NEED_ECC_SCRUB                             1:0x10
87 #define NV0080_CTRL_FB_CAPS_ASYNC_CE_L2_BYPASS_SET                                  1:0x20 // Deprecated
88 #define NV0080_CTRL_FB_CAPS_DISABLE_TILED_CACHING_INVALIDATES_WITH_ECC_BUG_1521641  1:0x40
89 #define NV0080_CTRL_FB_CAPS_GENERIC_PAGE_KIND                                       1:0x80
90 
91 #define NV0080_CTRL_FB_CAPS_DISABLE_MSCG_WITH_VR_BUG_1681803                        2:0x01
92 #define NV0080_CTRL_FB_CAPS_VIDMEM_ALLOCS_ARE_CLEARED                               2:0x02
93 #define NV0080_CTRL_FB_CAPS_DISABLE_PLC_GLOBALLY                                    2:0x04
94 #define NV0080_CTRL_FB_CAPS_PLC_BUG_3046774                                         2:0x08
95 
96 
97 /* size in bytes of fb caps table */
98 #define NV0080_CTRL_FB_CAPS_TBL_SIZE         3
99 
100 
101 
102 /*!
103  * NV0080_CTRL_CMD_FB_COMPBIT_STORE_GET_INFO
104  *
105  * This command returns compbit backing store-related information.
106  *
107  *   size
108  *     [out] Size of compbit store, in bytes
109  *   address
110  *     [out] Address of compbit store
111  *   addressSpace
112  *     [out] Address space of compbit store (corresponds to type NV_ADDRESS_SPACE in nvrm.h)
113  *   maxCompbitLine
114  *     [out] Maximum compbitline possible, determined based on size
115  *   comptagsPerCacheLine
116  *     [out] Number of compression tags per compression cache line, across all
117  *           L2 slices.
118  *   cacheLineSize
119  *     [out] Size of compression cache line, across all L2 slices. (bytes)
120  *   cacheLineSizePerSlice
121  *     [out] Size of the compression cache line per slice (bytes)
122  *   cacheLineFetchAlignment
123  *     [out] Alignment used while fetching the compression cacheline range in FB.
124  *           If start offset of compcacheline in FB is S and end offset is E, then
125  *           the range to fetch to ensure entire compcacheline data is extracted is:
126  *           (align_down(S) , align_up(E))
127  *           This is needed in GM20X+ because of interleaving of data in Linear FB space.
128  *           Example - In GM204 every other 1K FB chunk of data is offset by 16K.
129  *   backingStoreBase
130  *     [out] Address of start of Backing Store in linear FB Physical Addr space.
131  *           This is the actual offset in FB which HW starts using as the Backing Store and
132  *           in general will be different from the start of the region that driver allocates
133  *           as the backing store. This address is expected to be 2K aligned.
134  *   gobsPerComptagPerSlice
135  *     [out] (Only on Pascal) Number of GOBS(512 bytes of surface PA) that correspond to one 64KB comptgaline, per slice.
136  *           One GOB stores 1 byte of compression bits.
137  *           0 value means this field is not applicable for the current architecture.
138  *   backingStoreCbcBase
139  *     [out] 2KB aligned base address of CBC (post divide address)
140  *   comptaglineAllocationPolicy
141  *     [out] Policy used to allocate comptagline from CBC for the device
142  *   privRegionStartOffset
143  *     [out] Starting offset for any priv region allocated by clients. only used by MODS
144  *   Possible status values returned are:
145  *   NV_OK
146  */
147 #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO (0x801306) /* finn: Evaluated from "(FINN_NV01_DEVICE_0_FB_INTERFACE_ID << 8) | NV0080_CTRL_FB_GET_COMPBIT_STORE_INFO_PARAMS_MESSAGE_ID" */
148 
149 #define NV0080_CTRL_FB_GET_COMPBIT_STORE_INFO_PARAMS_MESSAGE_ID (0x6U)
150 
151 typedef struct NV0080_CTRL_FB_GET_COMPBIT_STORE_INFO_PARAMS {
152     NV_DECLARE_ALIGNED(NvU64 Size, 8);
153     NV_DECLARE_ALIGNED(NvU64 Address, 8);
154     NvU32 AddressSpace;
155     NvU32 MaxCompbitLine;
156     NvU32 comptagsPerCacheLine;
157     NvU32 cacheLineSize;
158     NvU32 cacheLineSizePerSlice;
159     NvU32 cacheLineFetchAlignment;
160     NV_DECLARE_ALIGNED(NvU64 backingStoreBase, 8);
161     NvU32 gobsPerComptagPerSlice;
162     NvU32 backingStoreCbcBase;
163     NvU32 comptaglineAllocationPolicy;
164     NV_DECLARE_ALIGNED(NvU64 privRegionStartOffset, 8);
165     NvU32 cbcCoveragePerSlice;
166 } NV0080_CTRL_FB_GET_COMPBIT_STORE_INFO_PARAMS;
167 
168 #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO_ADDRESS_SPACE_UNKNOWN 0 // ADDR_UNKNOWN
169 #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO_ADDRESS_SPACE_SYSMEM  1 // ADDR_SYSMEM
170 #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO_ADDRESS_SPACE_FBMEM   2 // ADDR_FBMEM
171 
172 // Policy used to allocate comptaglines
173 /**
174  * Legacy mode allocates a comptagline for 64kb page. This mode will always allocate
175  * contiguous comptaglines from a ctag heap.
176  */
177 #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO_POLICY_LEGACY         0
178 /**
179  * 1TO1 mode allocates a comptagline for 64kb page. This mode will calculate
180  * comptagline offset based on physical address. This mode will allocate
181  * contiguous comptaglines if the surface is contiguous and non-contiguous
182  * comptaglines for non-contiguous surfaces.
183  */
184 #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO_POLICY_1TO1           1
185 /**
186  * 1TO4_Heap mode allocates a comptagline for 256kb page granularity. This mode
187  * will allocate comptagline from a heap. This mode will align the surface allocations
188  * to 256kb before allocating comptaglines. The comptaglines allocated will always be
189  * contiguous here.
190  * TODO: For GA10x, this mode will support < 256kb surface allocations, by sharing
191  * a comptagline with at most 3 different 64Kb allocations. This will result in
192  * miixed-contiguity config where comptaglines will be allocated contiguously as well
193  * as non-contiguous when shared with other allocations.
194  */
195 #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO_POLICY_1TO4           2
196 /**
197  * Rawmode will transfer allocation of comptaglines to HW, where HW manages
198  * comptaglines based on physical offset. The comptaglines are cleared when SW
199  * issues physical/virtual scrub to the surface before reuse.
200  */
201 #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO_POLICY_RAWMODE        3
202 
203 /**
204  * NV0080_CTRL_CMD_FB_GET_CAPS_V2
205  *
206  * This command returns the same set of framebuffer capabilities for the
207  * device as @ref NV0080_CTRL_CMD_FB_GET_CAPS. The difference is in the structure
208  * NV0080_CTRL_FB_GET_CAPS_V2_PARAMS, which contains a statically sized array,
209  * rather than a caps table pointer and a caps table size in
210  * NV0080_CTRL_FB_GET_CAPS_PARAMS.
211  *
212  *   capsTbl
213  *     This parameter specifies a pointer to the client's caps table buffer
214  *     into which the framebuffer caps bits will be written by the RM.
215  *     The caps table is an array of unsigned bytes.
216  *
217  * Possible status values returned are:
218  *   NV_OK
219  *   NV_ERR_INVALID_PARAM_STRUCT
220  *   NV_ERR_INVALID_ARGUMENT
221  *   NV_ERR_INVALID_POINTER
222  */
223 #define NV0080_CTRL_CMD_FB_GET_CAPS_V2                                  (0x801307) /* finn: Evaluated from "(FINN_NV01_DEVICE_0_FB_INTERFACE_ID << 8) | NV0080_CTRL_FB_GET_CAPS_V2_PARAMS_MESSAGE_ID" */
224 
225 #define NV0080_CTRL_FB_GET_CAPS_V2_PARAMS_MESSAGE_ID (0x7U)
226 
227 typedef struct NV0080_CTRL_FB_GET_CAPS_V2_PARAMS {
228     NvU8 capsTbl[NV0080_CTRL_FB_CAPS_TBL_SIZE];
229 } NV0080_CTRL_FB_GET_CAPS_V2_PARAMS;
230 
231 /**
232  * NV0080_CTRL_CMD_FB_SET_DEFAULT_VIDMEM_PHYSICALITY
233  *
234  * When clients allocate video memory specifying _DEFAULT (0) for
235  * NVOS32_ATTR_PHYSICALITY, RM will usually allocate contiguous memory.
236  * Clients can change that behavior with this command so that _DEFAULT maps to
237  * another value.
238  *
239  * The expectation is that clients currently implicitly rely on the default,
240  * but can be incrementally updated to explicitly specify _CONTIGUOUS where
241  * necessary and change the default for their allocations to _NONCONTIGUOUS or
242  * _ALLOW_NONCONTIGUOUS.
243  *
244  * In the future RM may be updated to globally default to _NONCONTIGUOUS or
245  * _ALLOW_NONCONTIGUOUS, and at that point this can be removed.
246  */
247 #define NV0080_CTRL_CMD_FB_SET_DEFAULT_VIDMEM_PHYSICALITY (0x801308) /* finn: Evaluated from "(FINN_NV01_DEVICE_0_FB_INTERFACE_ID << 8) | NV0080_CTRL_FB_SET_DEFAULT_VIDMEM_PHYSICALITY_PARAMS_MESSAGE_ID" */
248 
249 #define NV0080_CTRL_FB_SET_DEFAULT_VIDMEM_PHYSICALITY_PARAMS_MESSAGE_ID (0x8U)
250 
251 typedef struct NV0080_CTRL_FB_SET_DEFAULT_VIDMEM_PHYSICALITY_PARAMS {
252     NvU32 value;
253 } NV0080_CTRL_FB_SET_DEFAULT_VIDMEM_PHYSICALITY_PARAMS;
254 
255 typedef enum NV0080_CTRL_FB_DEFAULT_VIDMEM_PHYSICALITY {
256     NV0080_CTRL_FB_DEFAULT_VIDMEM_PHYSICALITY_DEFAULT = 0,
257     NV0080_CTRL_FB_DEFAULT_VIDMEM_PHYSICALITY_NONCONTIGUOUS = 1,
258     NV0080_CTRL_FB_DEFAULT_VIDMEM_PHYSICALITY_CONTIGUOUS = 2,
259     NV0080_CTRL_FB_DEFAULT_VIDMEM_PHYSICALITY_ALLOW_NONCONTIGUOUS = 3,
260 } NV0080_CTRL_FB_DEFAULT_VIDMEM_PHYSICALITY;
261 
262 
263 /* _ctrl0080fb_h_ */
264