1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 1993-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 #include "nvacpitypes.h"
25 
26 #ifndef _ACPIGENFUNCS_H_
27 #define _ACPIGENFUNCS_H_
28 
29 #define NV_ACPI_DSM_READ_SIZE (4*1024)
30 
31 #define NV_ACPI_GENERIC_FUNC_START                  0x0200
32 #define NV_ACPI_GENERIC_FUNC_COUNT                  8
33 
34 // Only use these when using the generic function ACPI_DSM_FUNCTION_CURRENT.
35 #define NV_ACPI_GENERIC_FUNC_DISPLAYSTATUS          (NV_ACPI_GENERIC_FUNC_START+0x00)  // Get Display & Hot-Key information
36 #define NV_ACPI_GENERIC_FUNC_MDTL                   (NV_ACPI_GENERIC_FUNC_START+0x01)  // Display Toggle List
37 #define NV_ACPI_GENERIC_FUNC_GETOBJBYTYPE           (NV_ACPI_GENERIC_FUNC_START+0x02)  // Get the firmware object
38 #define NV_ACPI_GENERIC_FUNC_GETALLOBJS             (NV_ACPI_GENERIC_FUNC_START+0x03)  // Get the directory and all objects
39 #define NV_ACPI_GENERIC_FUNC_GETEVENTLIST           (NV_ACPI_GENERIC_FUNC_START+0x04)  // Get the List of required Event Notifiers and their meaning
40 #define NV_ACPI_GENERIC_FUNC_CALLBACKS              (NV_ACPI_GENERIC_FUNC_START+0x05)  // Get the list of system-required callbacks
41 #define NV_ACPI_GENERIC_FUNC_GETBACKLIGHT           (NV_ACPI_GENERIC_FUNC_START+0x06)  // Get the Backlight
42 #define NV_ACPI_GENERIC_FUNC_MSTL                   (NV_ACPI_GENERIC_FUNC_START+0x07)  // Get Multiple Stream Topology Toggle info
43 
44 // structure used for NV_ACPI_GENERIC_FUNC_CTL_TESTSUBFUNCENABLED and NV_ACPI_GENERIC_FUNC_CTL_REMAPFUNC calls.
45 typedef struct
46 {
47     ACPI_DSM_FUNCTION acpiDsmFunction;
48     NvU32             acpiDsmSubFunction;
49     NvU32             status;
50 } DSMTESTCTL, *PDSMTESTCTL;
51 
52 // when adding new generic functions, change NV_ACPI_GENERIC_FUNC_LAST_SUBFUNCTION to last entry.
53 #define NV_ACPI_GENERIC_FUNC_LAST_SUBFUNCTION       (NV_ACPI_GENERIC_FUNC_MSTL)
54 ct_assert(NV_ACPI_GENERIC_FUNC_COUNT == ((NV_ACPI_GENERIC_FUNC_LAST_SUBFUNCTION-NV_ACPI_GENERIC_FUNC_START)+1));
55 
56 // These are not DSM functions, but used by clients (such as DD) to choose special ctrl0073 processing related to DSM.
57 #define NV_ACPI_GENERIC_FUNC_CTL_START              0x0600
58 #define NV_ACPI_GENERIC_FUNC_CTL_TESTSUBFUNCENABLED (NV_ACPI_GENERIC_FUNC_CTL_START+0x00) // exec testIfDsmSubFunctionEnabled
59 #define NV_ACPI_GENERIC_FUNC_CTL_REMAPFUNC          (NV_ACPI_GENERIC_FUNC_CTL_START+0x01) // exec remapDsmFunctionAndSubFunction
60 #define NV_ACPI_GENERIC_FUNC_CTL_GETFUNCSUPPORT     (NV_ACPI_GENERIC_FUNC_CTL_START+0x02) // get generic dsm supported functions
61                                                                                           //
62 // when adding new control functions, change NV_ACPI_GENERIC_FUNC_CTL_LAST_SUBFUNCTION to last entry.
63 #define NV_ACPI_GENERIC_FUNC_CTL_LAST_SUBFUNCTION   (NV_ACPI_GENERIC_FUNC_CTL_GETFUNCSUPPORT)
64 #define NV_ACPI_GENERIC_FUNC_CTL_COUNT              ((NV_ACPI_GENERIC_FUNC_CTL_LAST_SUBFUNCTION-NV_ACPI_GENERIC_FUNC_CTL_START)+1)
65 
66 #define IS_GENERIC_DSM_FUNC_SUPPORTED(package, subfunc) (((package >> (subfunc-NV_ACPI_GENERIC_FUNC_START)) & NVBIT(0)) ? true : false)
67 
68 // status for dsm functions.
69 #define DSM_FUNC_STATUS_UNKNOWN  0 // untried
70 #define DSM_FUNC_STATUS_FAILED   1 // tried but failed
71 #define DSM_FUNC_STATUS_SUCCESS  2 // tried and successful
72 #define DSM_FUNC_STATUS_DISABLED 3 // disabled via regkey
73 #define DSM_FUNC_STATUS_OVERRIDE 4 // regkey or code hack override
74 
75 //
76 // common NV definitions used in ACPI dsm calls in particular.
77 //
78 #define NV_ACPI_ALL_FUNC_SUPPORT       0x00000000   // Common is supported subfunction.
79 #define NV_ACPI_ALL_FUNC_SUPPORTED     NVBIT(NV_ACPI_ALL_FUNC_SUPPORT) // is common Function supported?
80 #define NV_ACPI_ALL_SUBFUNC_UNKNOWN   0xFFFFFFFF   // Common define for unknown ACPI sub-function
81 
82 #endif // _ACPIGENFUNCS_H_
83 
84