1 /* 2 * SPDX-FileCopyrightText: Copyright (c) 1993-2022 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 #ifndef _ACPICOMMON_H_ 25 #define _ACPICOMMON_H_ 26 27 #include "acpigenfuncs.h" 28 #include "core/core.h" 29 #include "rmconfig.h" 30 31 #include "platform/nbsi/nbsi_read.h" 32 NV_STATUS getAcpiDsmObjectData(OBJGPU *, NvU8**, NvU32 *, ACPI_DSM_FUNCTION, NBSI_GLOB_TYPE, NBSI_VALIDATE); 33 34 NV_STATUS testIfDsmFuncSupported(OBJGPU *, ACPI_DSM_FUNCTION); 35 NV_STATUS testIfDsmSubFunctionEnabled(OBJGPU *, ACPI_DSM_FUNCTION, NvU32); 36 NV_STATUS remapDsmFunctionAndSubFunction(OBJGPU *, ACPI_DSM_FUNCTION *, NvU32 *); 37 NV_STATUS getDsmGetObjectSubfunction(OBJGPU *, ACPI_DSM_FUNCTION *, NvU32 *, NvU32*); 38 void cacheDsmSupportedFunction(OBJGPU *, ACPI_DSM_FUNCTION, NvU32, NvU32 *, NvU32); 39 NV_STATUS checkDsmCall(OBJGPU *, ACPI_DSM_FUNCTION *, NvU32 *, NvU32 *, NvU16 *); 40 void acpiDsmInit(OBJGPU *); 41 NV_STATUS getLicenseKey(OBJGPU *, NvU32, NvU32 *, NvU16 *); 42 void uncacheDsmFuncStatus(OBJGPU *, ACPI_DSM_FUNCTION, NvU32); 43 44 // useful macros 45 #if NV_PRINTF_ENABLED 46 #define DSMFuncStr(func) (func <= ACPI_DSM_FUNCTION_CURRENT ? DSMCalls[func] : DSMCalls[ACPI_DSM_FUNCTION_COUNT]) 47 #endif 48 49 #define isDsmGetSuppFuncListCached(pGpu, acpiDsmFunction) (pGpu->acpi.dsm[acpiDsmFunction].suppFuncStatus != DSM_FUNC_STATUS_UNKNOWN) 50 #define isDsmGetSuppFuncListFailed(pGpu, acpiDsmFunction) (pGpu->acpi.dsm[acpiDsmFunction].suppFuncStatus == DSM_FUNC_STATUS_FAILED) 51 #define isGenericDsmFunction(acpiDsmFunction) (acpiDsmFunction >= ACPI_DSM_FUNCTION_COUNT) 52 #define isGenericDsmSubFunction(acpiDsmSubFunction) (acpiDsmSubFunction >= NV_ACPI_GENERIC_FUNC_START) 53 54 55 #define NV_ACPI_ALL_FUNC_SUPPORT 0x00000000 // Common is supported subfunction. 56 #define NV_ACPI_ALL_FUNC_SUPPORTED NVBIT(NV_ACPI_ALL_FUNC_SUPPORT) // is common Function supported? 57 #define NV_ACPI_ALL_SUBFUNC_UNKNOWN 0xFFFFFFFF // Common define for unknown ACPI sub-function 58 59 // All the callbacks (MXM, NBCI, NVHG) use the same bits. These are common. 60 #define NV_ACPI_CALLBACKS_ARG_POSTPOWERSTATE 2:2 61 #define NV_ACPI_CALLBACKS_ARG_POSTPOWERSTATE_NOTIFY 0x00000001 62 #define NV_ACPI_CALLBACKS_ARG_CURRENTPOWERSTATE 7:4 63 #define NV_ACPI_CALLBACKS_ARG_3DSTEREOSTATE_ACTIVE 8:8 64 #define NV_ACPI_CALLBACKS_ARG_3DSTEREOSTATE_ACTIVE_NO 0x00000000 65 #define NV_ACPI_CALLBACKS_ARG_3DSTEREOSTATE_ACTIVE_YES 0x00000001 66 67 68 #define NV_ACPI_CALLBACKS_RET_POSTPOWERSTATE 2:2 69 #define NV_ACPI_CALLBACKS_RET_POSTPOWERSTATE_NOTIFY 0x00000001 70 #define NV_ACPI_CALLBACKS_RET_HOTPLUG 9:9 71 #define NV_ACPI_CALLBACKS_RET_HOTPLUG_NOTIFY 0x00000001 72 #define NV_ACPI_CALLBACKS_RET_CONFIG 10:10 73 #define NV_ACPI_CALLBACKS_RET_CONFIG_NOTIFY 0x00000001 74 #define NV_ACPI_CALLBACKS_RET_3DSTEREOSTATE_ACTIVE 12:12 75 #define NV_ACPI_CALLBACKS_RET_3DSTEREOSTATE_ACTIVE_NOTIFY 0x00000001 76 77 #define ACPI_NOTIFY_DOCK_EVENT 0x77 78 #define ACPI_NOTIFY_PANEL_SWITCH 0x80 79 #define ACPI_NOTIFY_DEVICE_HOTPLUG 0x81 80 #define ACPI_NOTIFY_CYCLE_DISPLAY_HOTKEY 0x82 81 #define ACPI_NOTIFY_NEXT_DISPLAY_HOTKEY 0x83 82 #define ACPI_NOTIFY_PREV_DISPLAY_HOTKEY 0x84 83 #define ACPI_NOTIFY_CYCLE_BRIGHTNESS_HOTKEY 0x85 84 #define ACPI_NOTIFY_INC_BRIGHTNESS_HOTKEY 0x86 85 #define ACPI_NOTIFY_DEC_BRIGHTNESS_HOTKEY 0x87 86 #define ACPI_NOTIFY_ZERO_BRIGHTNESS_HOTKEY 0x88 87 #define ACPI_NOTIFY_VIDEO_WAKEUP 0x90 88 89 #define ACPI_NOTIFY_GPS_STATUS_CHANGE 0xC0 90 91 #define ACPI_NOTIFY_BACKLIGHT_OFF 0xC1 92 #define ACPI_NOTIFY_BACKLIGHT_ON 0xC2 93 94 #define ACPI_NOTIFY_POWER_LEVEL_D1 0xD1 95 #define ACPI_NOTIFY_POWER_LEVEL_D2 0xD2 96 #define ACPI_NOTIFY_POWER_LEVEL_D3 0xD3 97 #define ACPI_NOTIFY_POWER_LEVEL_D4 0xD4 98 #define ACPI_NOTIFY_POWER_LEVEL_D5 0xD5 99 100 #define ACPI_VIDEO_NOTIFY_PROBE 0x81 101 102 #define NV_ACPI_DSM_READ_SIZE (4*1024) // 4K as per spec 103 104 // **************************************************** 105 // For _ROM Get ROM Data Method 106 // **************************************************** 107 #define ROM_METHOD_MAX_RETURN_BUFFER_SIZE 0x1000 108 109 // these are debug strings for printing which DSM subfunction didn't work. 110 // These map directly to the ACPI_DSM_FUNCTION enum in gpu/gpu.h. 111 #if NV_PRINTF_ENABLED 112 extern const char * const DSMCalls[]; 113 #endif 114 115 #endif // _ACPICOMMON_H_ 116 117