diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2c18f790..c98ddf258 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -520,41 +520,6 @@ jobs: name: fastfetch-freebsd-amd64 path: ./fastfetch-*.* - dragonfly-amd64: - name: DragonFly-amd64 - runs-on: ubuntu-latest - permissions: - security-events: write - contents: read - steps: - - name: checkout repository - uses: actions/checkout@v4 - - - name: run VM - uses: vmactions/dragonflybsd-vm@v1 - with: - usesh: yes - prepare: | - uname -a - pkg update - pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3-tcl xfce4-conf egl opencl ocl-icd v4l_compat chafa libelf - - run: | - cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On . - cmake --build . --target package --verbose -j4 - ./fastfetch --list-features - time ./fastfetch -c presets/ci.jsonc --stat false - time ./fastfetch -c presets/ci.jsonc --format json - time ./flashfetch - ldd fastfetch - ctest --output-on-failure - - - name: upload artifacts - uses: actions/upload-artifact@v4 - with: - name: fastfetch-dragonfly-amd64 - path: ./fastfetch-*.* - openbsd-amd64: name: OpenBSD-amd64 runs-on: ubuntu-latest @@ -659,9 +624,6 @@ jobs: - name: copy necessary dlls run: cp /clang64/bin/{OpenCL,vulkan-1}.dll . - - name: download amd_ags - run: curl -LO https://github.com/GPUOpen-LibrariesAndSDKs/AGS_SDK/raw/master/ags_lib/lib/amd_ags_x64.dll - - name: list features run: ./fastfetch --list-features @@ -709,7 +671,6 @@ jobs: - freebsd-amd64 - openbsd-amd64 - netbsd-amd64 - - dragonfly-amd64 - sunos-amd64 - windows-amd64 permissions: diff --git a/CHANGELOG.md b/CHANGELOG.md index 01270a8eb..68c0626e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,44 @@ +# 2.40.0 + +Changes: +* In `key-format` of `LocalIP` module, `{name}` has been renamed to `{ifname}` for consistency (LocalIP, #1639) + +Features: +* Support Warp Terminal font detection (TerminalFont, Windows) +* Support more AMD GPU information using ADL SDK, including memory type detection (GPU, Windows) +* Support Intel dGPU memory type detection (GPU, Windows) +* Support Nvidia VMEM type detection via NVAPI (GPU, Windows, #993) +* Support Boot manager detection for OpenBSD and NetBSD (Bootmgr, OpenBSD / NetBSD) +* Use `SystemConfiguration` for DNS entries detection (DNS, macOS) +* Add `systemd-resolved` support for DNS module (DNS, Linux, #1646) +* Improve performance and accuracy of Wifi detection on FreeBSD using ioctl (Wifi, FreeBSD) +* Support remaining time reporting for batteries on NetBSD (Battery, NetBSD) +* Add new Mac models support (Host, macOS) +* Load config from fastfetch binary path with `--config` option (#1649) +* Support TPM detection on macOS (TPM, macOS) +* Support IPv6 client address report (Users, Linux / Windows) +* Support default route detection for IPv6 (LocalIP, Linux) +* Round seconds to the nearest minute to match the behavior of `uptime` command (Uptime) + +Bugfixes: +* Fix `outputColor` not working when `length` is set in Separator module (#1644) +* Fix CPU detection on PowerPC platforms (#1640, CPU, Linux) +* Fix battery manufacture date detection (Battery, macOS) +* Fix battery critical state detection (Battery, Linux) +* Fix Warp Terminal PID detection (Terminal, macOS) +* Remove disk creation time detection support on SunOS as ctim is file status change timestamp, not creation time (Disk, SunOS) +* Fall back to KDGKBINFO if `usbhid` fails (Keyboard, FreeBSD) +* Fix multiple paging file support (Swap, Windows) +* Fix memleaks, code smells in multiple modules +* Fix boot time calculation on NetBSD (Uptime, NetBSD) +* Temporarily fix Hyprland version detection (WM, Linux, #1657) + +Logo: +* Fix opensuse-tumbleweed_small (#1636) +* Change WiiLinuxNgx to more generic name with aliases Wii-Linux and WiiLinux (#1633) +* Change name of Xray-OS to Ada (#1651) +* Change Nexa Linux logo (#1653) + # 2.39.1 Bugfixes: @@ -336,7 +377,7 @@ Features: * Support tilix version detection (Terminal, Linux) * Support percent type config in module level. Example: -```json +```jsonc { "type": "memory", "percent": { diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b6d54ae3..b5af69cfc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url project(fastfetch - VERSION 2.39.1 + VERSION 2.40.0 LANGUAGES C DESCRIPTION "Fast neofetch-like system information tool" HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch" @@ -708,7 +708,6 @@ elseif(FreeBSD) src/detection/uptime/uptime_bsd.c src/detection/users/users_linux.c src/detection/wallpaper/wallpaper_linux.c - src/detection/wifi/wifi_bsd.c src/detection/wm/wm_nosupport.c src/detection/de/de_linux.c src/detection/wmtheme/wmtheme_linux.c @@ -720,10 +719,12 @@ elseif(FreeBSD) if(DragonFly) list(APPEND LIBFASTFETCH_SRC src/detection/bluetooth/bluetooth_nosupport.c + src/detection/wifi/wifi_nosupport.c ) else() list(APPEND LIBFASTFETCH_SRC src/detection/bluetooth/bluetooth_bsd.c + src/detection/wifi/wifi_bsd.c ) endif() elseif(NetBSD) @@ -739,7 +740,7 @@ elseif(NetBSD) src/detection/bluetooth/bluetooth_nosupport.c src/detection/bluetoothradio/bluetoothradio_nosupport.c src/detection/board/board_nbsd.c - src/detection/bootmgr/bootmgr_nosupport.c + src/detection/bootmgr/bootmgr_bsd.c src/detection/brightness/brightness_nbsd.c src/detection/btrfs/btrfs_nosupport.c src/detection/chassis/chassis_nbsd.c @@ -817,22 +818,22 @@ elseif(OpenBSD) src/common/processing_linux.c src/common/sysctl.c src/detection/battery/battery_obsd.c - src/detection/bios/bios_nosupport.c + src/detection/bios/bios_windows.c src/detection/bluetooth/bluetooth_nosupport.c src/detection/bluetoothradio/bluetoothradio_nosupport.c - src/detection/board/board_nosupport.c - src/detection/bootmgr/bootmgr_nosupport.c + src/detection/board/board_windows.c + src/detection/bootmgr/bootmgr_bsd.c src/detection/brightness/brightness_obsd.c src/detection/btrfs/btrfs_nosupport.c - src/detection/chassis/chassis_nosupport.c + src/detection/chassis/chassis_windows.c src/detection/cpu/cpu_obsd.c - src/detection/cpucache/cpucache_nosupport.c + src/detection/cpucache/cpucache_shared.c src/detection/cpuusage/cpuusage_bsd.c src/detection/cursor/cursor_linux.c src/detection/disk/disk_bsd.c src/detection/dns/dns_linux.c src/detection/physicaldisk/physicaldisk_nosupport.c - src/detection/physicalmemory/physicalmemory_nosupport.c + src/detection/physicalmemory/physicalmemory_linux.c src/detection/diskio/diskio_obsd.c src/detection/displayserver/linux/displayserver_linux.c src/detection/displayserver/linux/drm.c @@ -889,6 +890,7 @@ elseif(OpenBSD) src/detection/zpool/zpool_nosupport.c src/util/platform/FFPlatform_unix.c src/util/binary_linux.c + src/util/smbiosHelper.c ) elseif(APPLE) list(APPEND LIBFASTFETCH_SRC @@ -911,7 +913,7 @@ elseif(APPLE) src/detection/cpuusage/cpuusage_apple.c src/detection/cursor/cursor_apple.m src/detection/disk/disk_bsd.c - src/detection/dns/dns_linux.c + src/detection/dns/dns_apple.c src/detection/physicaldisk/physicaldisk_apple.c src/detection/physicalmemory/physicalmemory_apple.m src/detection/diskio/diskio_apple.c @@ -945,7 +947,7 @@ elseif(APPLE) src/detection/terminalshell/terminalshell_linux.c src/detection/terminalsize/terminalsize_linux.c src/detection/theme/theme_nosupport.c - src/detection/tpm/tpm_nosupport.c + src/detection/tpm/tpm_apple.c src/detection/uptime/uptime_bsd.c src/detection/users/users_linux.c src/detection/wallpaper/wallpaper_apple.m diff --git a/debian/changelog b/debian/changelog index 97e282adf..cc9db9c92 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +fastfetch (2.39.1) jammy; urgency=medium + + * Update to 2.39.1 + + -- Carter Li Fri, 21 Mar 2025 11:02:19 +0800 + fastfetch (2.39.0ubuntu1) jammy; urgency=medium * Remove unwanted debugging code diff --git a/debian/files b/debian/files index 795f7e02a..9e8529510 100644 --- a/debian/files +++ b/debian/files @@ -1 +1 @@ -fastfetch_2.39.0ubuntu1_source.buildinfo universe/utils optional +fastfetch_2.39.1_source.buildinfo universe/utils optional diff --git a/presets/examples/24.jsonc b/presets/examples/24.jsonc index 37c27c4b2..b9f8fef65 100644 --- a/presets/examples/24.jsonc +++ b/presets/examples/24.jsonc @@ -28,38 +28,38 @@ { "type": "title", "key": "{#90}{$1}│ {#92}User {#90}│", - "format": "{$2}{$3}{user-name} {#2}[{home-dir}]" + "format": "{$2}{$3}{user-name} {#2}[{home-dir}]" }, { "type": "users", "key": "{#90}{$1}│ {#92}Users {#90}│", "myselfOnly": false, - "format": "{$2}{$3}{1}@{host-name}{/host-name}localhost{/}{?client-ip} {#2}[IP:{client-ip}]{?} {#2}[Login time: {login-time}]", + "format": "{$2}{$3}{1}@{host-name}{/host-name}localhost{/}{?client-ip} {#2}[IP:{client-ip}]{?} [Login time: {login-time}]" }, { "type": "datetime", "key": "{#90}{$1}│ {#92}Datetime {#90}│", - "format": "{$2}{$3}{year}-{month-pretty}-{day-in-month} {hour-pretty}:{minute-pretty}:{second-pretty} {#2}{weekday} {#2}[W{week}] {#2}[UTC{offset-from-utc}]" + "format": "{$2}{$3}{year}-{month-pretty}-{day-in-month} {hour-pretty}:{minute-pretty}:{second-pretty} [{weekday}] [W{week}] [UTC{offset-from-utc}]" }, { "type": "title", - "key": "{#90}{$1}│ {#93}Host: {#90}│", - "format": "{$2}{$3}{#1}{#36}{host-name}" + "key": "{#90}{$1}│ {#93}Host {#90}│", + "format": "{$2}{$3}{host-name}" }, { "type": "host", "key": "{#90}{$1}│ {#93}Machine {#90}│", - "format": "{$2}{$3}{name} {#2}{version}" + "format": "{$2}{$3}{name} {#2}{version}" }, { "type": "os", "key": "{#90}{$1}│ {#93}OS {#90}│", - "format": "{$2}{$3}{pretty-name} {codename} {#2}[v{version}] {#2}[{arch}]" + "format": "{$2}{$3}{?pretty-name}{pretty-name}{?}{/pretty-name}{name}{/} {codename} {#2}[v{version}] [{arch}]" }, { "type": "kernel", "key": "{#90}{$1}│ {#93}Kernel {#90}│", - "format": "{$2}{$3}{sysname} {#2}[v{release}]" + "format": "{$2}{$3}{sysname} {#2}[v{release}]" }, { "type": "uptime", @@ -71,14 +71,14 @@ "key": "{#90}{$1}│ {#91}CPU {#90}│", "showPeCoreCount": true, "temp": true, - "format": "{$2}{$3}{name} {#2}[C:{core-types}] {#2}[{freq-max}]" + "format": "{$2}{$3}{name} {#2}[C:{core-types}] [{freq-max}]" }, { "type": "gpu", "key": "{#90}{$1}│ {#91}GPU {#90}│", "detectionMethod": "auto", "driverSpecific": true, - "format": "{$2}{$3}{name} {#2}[C:{core-count}] {#2}[{type}]" + "format": "{$2}{$3}{name} {#2}[C:{core-count}]{?frequency} [{frequency}]{?} [{type}]" }, { "type": "memory", @@ -98,7 +98,7 @@ { "type": "terminal", "key": "{#90}{$1}│ {#95}Terminal {#90}│", - "format": "{$2}{$3}{pretty-name} {#2}[{version}] [PID:{pid}]" + "format": "{$2}{$3}{pretty-name} {#2}[{version}] [PID:{pid}]" }, { "type": "terminalfont", diff --git a/presets/examples/26.jsonc b/presets/examples/26.jsonc new file mode 100644 index 000000000..9029f5a5e --- /dev/null +++ b/presets/examples/26.jsonc @@ -0,0 +1,165 @@ +// Modified from: 24.jsonc +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "padding": { + "top": 2 + } + }, + "display": { + "separator": "", + "constants": [ + // CONSTANT {$1} - VERTICAL BARS AT START AND 75th CHARACTERS FORWARD AND BACKWARD + "\u001b[90m│ │\u001b[60D\u001b[39m" + ] + }, + "modules": [ + // CUSTOM - Top UI bar + { + "type": "custom", + "key": "{#90}╭ Keys ───────╮", + "format": "{#90}╭ Values ────────────────────────────────────────────────────╮", + }, + { + "type": "title", + "key": "{#90}│ {#92}User {#90}│", + "format": "{$1}{user-name} {#2}[{home-dir}]" + }, + { + "type": "users", + "key": "{#90}│ {#92}Users {#90}│", + "myselfOnly": false, + "format": "{$1}{1}@{host-name}{/host-name}localhost{/}{?client-ip} {#2}[IP:{client-ip}]{?} [Login time: {login-time}]" + }, + { + "type": "datetime", + "key": "{#90}│ {#92}Datetime {#90}│", + "format": "{$1}{year}-{month-pretty}-{day-in-month} {hour-pretty}:{minute-pretty}:{second-pretty} {#2}[{weekday}] [W{week}] [UTC{offset-from-utc}]" + }, + { + "type": "title", + "key": "{#90}│ {#93}Host {#90}│", + "format": "{$1}{host-name}" + }, + { + "type": "host", + "key": "{#90}│ {#93}Machine {#90}│", + "format": "{$1}{name} {#2}{version}" + }, + { + "type": "os", + "key": "{#90}│ {#93}OS {#90}│", + "format": "{$1}{?pretty-name}{pretty-name}{?}{/pretty-name}{name}{/} {codename} {#2}[v{version}] [{arch}]" + }, + { + "type": "kernel", + "key": "{#90}│ {#93}Kernel {#90}│", + "format": "{$1}{sysname} {#2}[v{release}]" + }, + { + "type": "uptime", + "key": "{#90}│ {#93}Uptime {#90}│", + "format": "{$1}{?days}{days} Days + {?}{hours}:{minutes}:{seconds}" + }, + { + "type": "cpu", + "key": "{#90}│ {#91}CPU {#90}│", + "showPeCoreCount": true, + "temp": true, + "format": "{$1}{name} {#2}[C:{core-types}] [{freq-max}]" + }, + { + "type": "gpu", + "key": "{#90}│ {#91}GPU {#90}│", + "detectionMethod": "auto", + "driverSpecific": true, + "format": "{$1}{name} {#2}[C:{core-count}]{?frequency} [{frequency}]{?} {#2}[{type}]" + }, + { + "type": "memory", + "key": "{#90}│ {#91}Memory {#90}│", + "format": "{$1}{used} / {total} ({percentage})" + }, + { + "type": "disk", + "key": "{#90}│ {#91}Disk {#90}│", + "format": "{$1}{size-used} / {size-total} ({size-percentage})" + }, + { + "type": "poweradapter", + "key": "{#90}│ {#91}Power {#90}│", + "format": "{$1}{name}" + }, + { + "type": "terminal", + "key": "{#90}│ {#95}Terminal {#90}│", + "format": "{$1}{pretty-name} {#2}[{version}] [PID:{pid}]" + }, + { + "type": "terminalfont", + "key": "{#90}│ {#95}Font {#90}│", + "format": "{$1}{name} {#2}[{size}]" + }, + { + "type": "shell", + "key": "{#90}│ {#95}Shell {#90}│", + "format": "{$1}{pretty-name} {#2}[v{version}] [PID:{pid}]" + }, + { + // localip IPv4 + "type": "localip", + "key": "{#90}│ {#94}Local IPv4 {#90}│", + "showPrefixLen": true, + "showIpv4": true, + "showIpv6": false, + "showMtu": true, + "format": "{$1}{ifname}: {ipv4} {#2}[MTU:{mtu}]" + }, + { + // localip IPv6 + "type": "localip", + "key": "{#90}│ {#94}Local IPv6 {#90}│", + "showPrefixLen": true, + "showIpv4": false, + "showIpv6": true, + "showMtu": true, + "format": "{$1}{ifname}: {ipv6} {#2}[MTU:{mtu}]" + }, + { + "type": "publicip", + "key": "{#90}│ {#94}Public IPv4 {#90}│", + "ipv6": false, + "format": "{$1}{ip} {#2}[{location}]" + }, + { + "type": "publicip", + "key": "{#90}│ {#94}Public IPv6 {#90}│", + "ipv6": true, + "format": "{$1}{ip} {#2}[{location}]" + }, + // CUSTOM - Button UI bar + { + "type": "custom", + "key": "{#90}╰─────────────╯", + "format": "{#90}╰────────────────────────────────────────────────────────────╯", + }, + "break", + { + "type": "custom", + "key": " ", + "format": "{#90}╭ Colors ───────────────────────────────────────────────────────────────────╮", + }, + { + "type": "custom", + "format": "{#90}│ {#40} {#41} {#42} {#43} {#44} {#45} {#46} {#47} {#} {#90}│", + }, + { + "type": "custom", + "format": "{#90}│ {#100} {#101} {#102} {#103} {#104} {#105} {#106} {#107} {#} {#90}│", + }, + { + "type": "custom", + "format": "{#90}╰───────────────────────────────────────────────────────────────────────────╯", + }, + ] + } diff --git a/src/3rdparty/ags/amd_ags.h b/src/3rdparty/ags/amd_ags.h deleted file mode 100644 index 60b2dc7f6..000000000 --- a/src/3rdparty/ags/amd_ags.h +++ /dev/null @@ -1,383 +0,0 @@ -// -// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. -// -// 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 -/// \mainpage -/// AGS Library Overview -/// -------------------- -/// This document provides an overview of the AGS (AMD GPU Services) library. The AGS library provides software developers with the ability to query -/// AMD GPU software and hardware state information that is not normally available through standard operating systems or graphic APIs. -/// -/// The latest version of the API is publicly hosted here: https://github.com/GPUOpen-LibrariesAndSDKs/AGS_SDK/. -/// It is also worth checking http://gpuopen.com/gaming-product/amd-gpu-services-ags-library/ for any updates and articles on AGS. -/// \internal -/// Online documentation is publicly hosted here: http://gpuopen-librariesandsdks.github.io/ags/ -/// \endinternal -/// -/// --------------------------------------- -/// What's new in AGS 6.2 since version 6.1 -/// --------------------------------------- -/// AGS 6.2 includes the following updates: -/// * Shader clock intrinsics -/// * Minor improvements and fixes -/// -/// --------------------------------------- -/// What's new in AGS 6.1 since version 6.0 -/// --------------------------------------- -/// AGS 6.1 includes the following updates: -/// * RDNA3 detection -/// -/// --------------------------------------- -/// What's new in AGS 6.0 since version 5.4.2 -/// --------------------------------------- -/// AGS 6.0 includes the following updates: -/// * DX12 ray tracing hit token for RDNA2 hardware. -/// * Shader intrinsic that exposes ReadLaneAt in DX12. -/// * Shader intrinsics that expose explicit float conversions in DX12. -/// * Refactored and revised API to minimize user error. -/// * Added agsGetVersionNumber. -/// * Detection for external GPUs. -/// * Detection of RDNA2 architecture. -/// * Grouped the more established intrinsics together into per year support. -/// * Function pointer typedefs for the API -/// -/// --------------------------------------- -/// What's new in AGS 5.4.2 since version 5.4.1 -/// --------------------------------------- -/// AGS 5.4.2 includes the following updates: -/// * sharedMemoryInBytes has been reinstated. -/// * Clock speed returned for APUs. -/// -/// --------------------------------------- -/// What's new in AGS 5.4.1 since version 5.4.0 -/// --------------------------------------- -/// AGS 5.4.1 includes the following updates: -/// * AsicFamily_Count to help with code maintenance. -/// * Visual Studio 2019 support. -/// * x86 support -/// * BaseInstance and BaseVertex intrinsics along with corresponding caps bits. -/// * GetWaveSize intrinsic along with corresponding caps bits. -/// -/// --------------------------------------- -/// What's new in AGS 5.4 since version 5.3 -/// --------------------------------------- -/// AGS 5.4 includes the following updates: -/// * A more detailed description of the GPU architecture, now including RDNA GPUs. -/// * Radeon 7 core and memory speeds returned. -/// * Draw index and Atomic U64 intrinsics for both DX11 and DX12. -/// -/// --------------------------------------- -/// What's new in AGS 5.3 since version 5.2 -/// --------------------------------------- -/// AGS 5.3 includes the following updates: -/// * DX11 deferred context support for Multi Draw Indirect and UAV Overlap extensions. -/// * A Radeon Software Version helper to determine whether the installed driver meets your game's minimum driver version requirements. -/// * Freesync HDR Gamma 2.2 mode which uses a 1010102 swapchain and can be considered as an alternative to using the 64 bit swapchain required for Freesync HDR scRGB. -/// -/// Using the AGS library -/// --------------------- -/// It is recommended to take a look at the source code for the samples that come with the AGS SDK: -/// * AGSSample -/// * CrossfireSample -/// * EyefinitySample -/// The AGSSample application is the simplest of the three examples and demonstrates the code required to initialize AGS and use it to query the GPU and Eyefinity state. -/// The CrossfireSample application demonstrates the use of the new API to transfer resources on GPUs in Crossfire mode. Lastly, the EyefinitySample application provides a more -/// extensive example of Eyefinity setup than the basic example provided in AGSSample. -/// There are other samples on Github that demonstrate the DirectX shader extensions, such as the Barycentrics11 and Barycentrics12 samples. -/// -/// To add AGS support to an existing project, follow these steps: -/// * Link your project against the correct import library. Choose from either the 32 bit or 64 bit version. -/// * Copy the AGS dll into the same directory as your game executable. -/// * Include the amd_ags.h header file from your source code. -/// * Include the AGS hlsl files if you are using the shader intrinsics. -/// * Declare a pointer to an AGSContext and make this available for all subsequent calls to AGS. -/// * On game initialization, call \ref agsInitialize passing in the address of the context. On success, this function will return a valid context pointer. -/// -/// Don't forget to cleanup AGS by calling \ref agsDeInitialize when the app exits, after the device has been destroyed. - -#ifndef AMD_AGS_H -#define AMD_AGS_H - -#define AMD_AGS_VERSION_MAJOR 6 ///< AGS major version -#define AMD_AGS_VERSION_MINOR 2 ///< AGS minor version -#define AMD_AGS_VERSION_PATCH 0 ///< AGS patch version - -#ifdef __cplusplus -extern "C" { -#endif - -/// \defgroup Defines AGS defines -/// @{ -#if defined (AGS_GCC) -#define AMD_AGS_API -#else -#define AMD_AGS_API __declspec(dllexport) ///< AGS exported functions -#endif - -#define AGS_MAKE_VERSION( major, minor, patch ) ( ( major << 22 ) | ( minor << 12 ) | patch ) ///< Macro to create the app and engine versions for the fields in \ref AGSDX12ExtensionParams and \ref AGSDX11ExtensionParams and the Radeon Software Version -#define AGS_UNSPECIFIED_VERSION 0xFFFFAD00 ///< Use this to specify no version -#define AGS_CURRENT_VERSION AGS_MAKE_VERSION( AMD_AGS_VERSION_MAJOR, AMD_AGS_VERSION_MINOR, AMD_AGS_VERSION_PATCH ) ///< Macro to return the current AGS version as defined by the AGS header file -/// @} - -/// \defgroup enums General enumerations -/// @{ - -/// The return codes -typedef enum AGSReturnCode -{ - AGS_SUCCESS, ///< Successful function call - AGS_FAILURE, ///< Failed to complete call for some unspecified reason - AGS_INVALID_ARGS, ///< Invalid arguments into the function - AGS_OUT_OF_MEMORY, ///< Out of memory when allocating space internally - AGS_MISSING_D3D_DLL, ///< Returned when a D3D dll fails to load - AGS_LEGACY_DRIVER, ///< Returned if a feature is not present in the installed driver - AGS_NO_AMD_DRIVER_INSTALLED, ///< Returned if the AMD GPU driver does not appear to be installed - AGS_EXTENSION_NOT_SUPPORTED, ///< Returned if the driver does not support the requested driver extension - AGS_ADL_FAILURE, ///< Failure in ADL (the AMD Display Library) - AGS_DX_FAILURE, ///< Failure from DirectX runtime - AGS_D3DDEVICE_NOT_CREATED ///< Failure due to not creating the D3D device successfully via AGS. -} AGSReturnCode; - -/// @} - -typedef struct AGSContext AGSContext; ///< All function calls in AGS require a pointer to a context. This is generated via \ref agsInitialize - -/// The rectangle struct used by AGS. -typedef struct AGSRect -{ - int offsetX; ///< Offset on X axis - int offsetY; ///< Offset on Y axis - int width; ///< Width of rectangle - int height; ///< Height of rectangle -} AGSRect; - -/// The display info struct used to describe a display enumerated by AGS -typedef struct AGSDisplayInfo -{ - char name[ 256 ]; ///< The name of the display - char displayDeviceName[ 32 ]; ///< The display device name, i.e. DISPLAY_DEVICE::DeviceName - - unsigned int isPrimaryDisplay : 1; ///< Whether this display is marked as the primary display - unsigned int HDR10 : 1; ///< HDR10 is supported on this display - unsigned int dolbyVision : 1; ///< Dolby Vision is supported on this display - unsigned int freesync : 1; ///< Freesync is supported on this display - unsigned int freesyncHDR : 1; ///< Freesync HDR is supported on this display - unsigned int eyefinityInGroup : 1; ///< The display is part of the Eyefinity group - unsigned int eyefinityPreferredDisplay : 1; ///< The display is the preferred display in the Eyefinity group for displaying the UI - unsigned int eyefinityInPortraitMode : 1; ///< The display is in the Eyefinity group but in portrait mode - unsigned int reservedPadding : 24; ///< Reserved for future use - - int maxResolutionX; ///< The maximum supported resolution of the unrotated display - int maxResolutionY; ///< The maximum supported resolution of the unrotated display - float maxRefreshRate; ///< The maximum supported refresh rate of the display - - AGSRect currentResolution; ///< The current resolution and position in the desktop, ignoring Eyefinity bezel compensation - AGSRect visibleResolution; ///< The visible resolution and position. When Eyefinity bezel compensation is enabled this will - ///< be the sub region in the Eyefinity single large surface (SLS) - float currentRefreshRate; ///< The current refresh rate - - int eyefinityGridCoordX; ///< The X coordinate in the Eyefinity grid. -1 if not in an Eyefinity group - int eyefinityGridCoordY; ///< The Y coordinate in the Eyefinity grid. -1 if not in an Eyefinity group - - double chromaticityRedX; ///< Red display primary X coord - double chromaticityRedY; ///< Red display primary Y coord - - double chromaticityGreenX; ///< Green display primary X coord - double chromaticityGreenY; ///< Green display primary Y coord - - double chromaticityBlueX; ///< Blue display primary X coord - double chromaticityBlueY; ///< Blue display primary Y coord - - double chromaticityWhitePointX; ///< White point X coord - double chromaticityWhitePointY; ///< White point Y coord - - double screenDiffuseReflectance; ///< Percentage expressed between 0 - 1 - double screenSpecularReflectance; ///< Percentage expressed between 0 - 1 - - double minLuminance; ///< The minimum luminance of the display in nits - double maxLuminance; ///< The maximum luminance of the display in nits - double avgLuminance; ///< The average luminance of the display in nits - - int logicalDisplayIndex; ///< The internally used index of this display - int adlAdapterIndex; ///< The internally used ADL adapter index - int reserved; ///< reserved field -} AGSDisplayInfo; - -/// The ASIC family -typedef enum AsicFamily -{ - AsicFamily_Unknown, ///< Unknown architecture, potentially from another IHV. Check \ref AGSDeviceInfo::vendorId - AsicFamily_PreGCN, ///< Pre GCN architecture. - AsicFamily_GCN1, ///< AMD GCN 1 architecture: Oland, Cape Verde, Pitcairn & Tahiti. - AsicFamily_GCN2, ///< AMD GCN 2 architecture: Hawaii & Bonaire. This also includes APUs Kaveri and Carrizo. - AsicFamily_GCN3, ///< AMD GCN 3 architecture: Tonga & Fiji. - AsicFamily_GCN4, ///< AMD GCN 4 architecture: Polaris. - AsicFamily_Vega, ///< AMD Vega architecture, including Raven Ridge (ie AMD Ryzen CPU + AMD Vega GPU). - AsicFamily_RDNA, ///< AMD RDNA architecture - AsicFamily_RDNA2, ///< AMD RDNA2 architecture - AsicFamily_RDNA3, ///< AMD RDNA3 architecture - - AsicFamily_Count ///< Number of enumerated ASIC families -} AsicFamily; - -/// The device info struct used to describe a physical GPU enumerated by AGS -typedef struct AGSDeviceInfo -{ - const char* adapterString; ///< The adapter name string - AsicFamily asicFamily; ///< Set to Unknown if not AMD hardware - unsigned int isAPU : 1; ///< Whether this device is an APU - unsigned int isPrimaryDevice : 1; ///< Whether this device is marked as the primary device - unsigned int isExternal :1; ///< Whether this device is a detachable, external device - unsigned int reservedPadding : 29; ///< Reserved for future use - - int vendorId; ///< The vendor id - int deviceId; ///< The device id - int revisionId; ///< The revision id - - int numCUs; ///< Number of compute units - int numWGPs; ///< Number of RDNA Work Group Processors. Only valid if ASIC is RDNA onwards. - - int numROPs; ///< Number of ROPs - int coreClock; ///< Core clock speed at 100% power in MHz - int memoryClock; ///< Memory clock speed at 100% power in MHz - int memoryBandwidth; ///< Memory bandwidth in MB/s - float teraFlops; ///< Teraflops of GPU. Zero if not GCN onwards. Calculated from iCoreClock * iNumCUs * 64 Pixels/clk * 2 instructions/MAD - - unsigned long long localMemoryInBytes; ///< The size of local memory in bytes. 0 for non AMD hardware. - unsigned long long sharedMemoryInBytes; ///< The size of system memory available to the GPU in bytes. It is important to factor this into your VRAM budget for APUs - ///< as the reported local memory will only be a small fraction of the total memory available to the GPU. - - int numDisplays; ///< The number of active displays found to be attached to this adapter. - AGSDisplayInfo* displays; ///< List of displays allocated by AGS to be numDisplays in length. - - int eyefinityEnabled; ///< Indicates if Eyefinity is active - int eyefinityGridWidth; ///< Contains width of the multi-monitor grid that makes up the Eyefinity Single Large Surface. - int eyefinityGridHeight; ///< Contains height of the multi-monitor grid that makes up the Eyefinity Single Large Surface. - int eyefinityResolutionX; ///< Contains width in pixels of the multi-monitor Single Large Surface. - int eyefinityResolutionY; ///< Contains height in pixels of the multi-monitor Single Large Surface. - int eyefinityBezelCompensated; ///< Indicates if bezel compensation is used for the current SLS display area. 1 if enabled, and 0 if disabled. - - int adlAdapterIndex; ///< Internally used index into the ADL list of adapters - int reserved; ///< reserved field -} AGSDeviceInfo; - -/// \defgroup general General API functions -/// API for initialization, cleanup, HDR display modes and Crossfire GPU count -/// @{ - -typedef void* (__stdcall *AGS_ALLOC_CALLBACK)( size_t allocationSize ); ///< AGS user defined allocation prototype -typedef void (__stdcall *AGS_FREE_CALLBACK)( void* allocationPtr ); ///< AGS user defined free prototype - -/// The configuration options that can be passed in to \ref agsInitialize -typedef struct AGSConfiguration -{ - AGS_ALLOC_CALLBACK allocCallback; ///< Optional memory allocation callback. If not supplied, malloc() is used - AGS_FREE_CALLBACK freeCallback; ///< Optional memory freeing callback. If not supplied, free() is used -} AGSConfiguration; - -/// The top level GPU information returned from \ref agsInitialize -typedef struct AGSGPUInfo -{ - const char* driverVersion; ///< The AMD driver package version - const char* radeonSoftwareVersion; ///< The Radeon Software Version - - int numDevices; ///< Number of GPUs in the system - AGSDeviceInfo* devices; ///< List of GPUs in the system -} AGSGPUInfo; - -/// The struct to specify the display settings to the driver. -typedef struct AGSDisplaySettings AGSDisplaySettings; - - -/// The result returned from \ref agsCheckDriverVersion -typedef enum AGSDriverVersionResult -{ - AGS_SOFTWAREVERSIONCHECK_OK, ///< The reported Radeon Software Version is newer or the same as the required version - AGS_SOFTWAREVERSIONCHECK_OLDER, ///< The reported Radeon Software Version is older than the required version - AGS_SOFTWAREVERSIONCHECK_UNDEFINED ///< The check could not determine as result. This could be because it is a private or custom driver or just invalid arguments. -} AGSDriverVersionResult; - -/// -/// Helper function to check the installed software version against the required software version. -/// -/// \param [in] radeonSoftwareVersionReported The Radeon Software Version returned from \ref AGSGPUInfo::radeonSoftwareVersion. -/// \param [in] radeonSoftwareVersionRequired The Radeon Software Version to check against. This is specificed using \ref AGS_MAKE_VERSION. -/// \return The result of the check. -/// -AMD_AGS_API AGSDriverVersionResult agsCheckDriverVersion( const char* radeonSoftwareVersionReported, unsigned int radeonSoftwareVersionRequired ); - -/// -/// Function to return the AGS version number. -/// -/// \return The version number made using AGS_MAKE_VERSION( AMD_AGS_VERSION_MAJOR, AMD_AGS_VERSION_MINOR, AMD_AGS_VERSION_PATCH ). -/// -AMD_AGS_API int agsGetVersionNumber(); - -/// -/// Function used to initialize the AGS library. -/// agsVersion must be specified as AGS_CURRENT_VERSION or the call will return \ref AGS_INVALID_ARGS. -/// Must be called prior to any of the subsequent AGS API calls. -/// Must be called prior to ID3D11Device or ID3D12Device creation. -/// \note The caller of this function should handle the possibility of the call failing in the cases below. One option is to do a vendor id check and only call \ref agsInitialize if there is an AMD GPU present. -/// \note This function will fail with \ref AGS_NO_AMD_DRIVER_INSTALLED if there is no AMD driver found on the system. -/// \note This function will fail with \ref AGS_LEGACY_DRIVER in Catalyst versions before 12.20. -/// -/// \param [in] agsVersion The API version specified using the \ref AGS_CURRENT_VERSION macro. If this does not match the version in the binary this initialization call will fail. -/// \param [in] config Optional pointer to a AGSConfiguration struct to override the default library configuration. -/// \param [out] context Address of a pointer to a context. This function allocates a context on the heap which is then required for all subsequent API calls. -/// \param [out] gpuInfo Optional pointer to a AGSGPUInfo struct which will get filled in for all the GPUs in the system. -/// -AMD_AGS_API AGSReturnCode agsInitialize( int agsVersion, const AGSConfiguration* config, AGSContext** context, AGSGPUInfo* gpuInfo ); - -/// -/// Function used to clean up the AGS library. -/// -/// \param [in] context Pointer to a context. This function will deallocate the context from the heap. -/// -AMD_AGS_API AGSReturnCode agsDeInitialize( AGSContext* context ); - -/// -/// Function used to set a specific display into HDR mode -/// \note Setting all of the values apart from color space and transfer function to zero will cause the display to use defaults. -/// \note Call this function after each mode change (switch to fullscreen, any change in swapchain etc). -/// \note HDR10 PQ mode requires a 1010102 swapchain. -/// \note HDR10 scRGB mode requires an FP16 swapchain. -/// \note Freesync HDR scRGB mode requires an FP16 swapchain. -/// \note Freesync HDR Gamma 2.2 mode requires a 1010102 swapchain. -/// \note Dolby Vision requires a 8888 UNORM swapchain. -/// -/// \param [in] context Pointer to a context. This is generated by \ref agsInitialize -/// \param [in] deviceIndex The index of the device listed in \ref AGSGPUInfo::devices. -/// \param [in] displayIndex The index of the display listed in \ref AGSDeviceInfo::displays. -/// \param [in] settings Pointer to the display settings to use. -/// -AMD_AGS_API AGSReturnCode agsSetDisplayMode( AGSContext* context, int deviceIndex, int displayIndex, const AGSDisplaySettings* settings ); - -/// @} - -/// @} - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // AMD_AGS_H diff --git a/src/3rdparty/ags/repo.json b/src/3rdparty/ags/repo.json deleted file mode 100644 index 5acc6559d..000000000 --- a/src/3rdparty/ags/repo.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "home": "https://github.com/GPUOpen-LibrariesAndSDKs/AGS_SDK", - "license": "MIT (embeded in source)", - "version": "AGS v6.2.0", - "author": "Advanced Micro Devices, Inc", - "modified": "CarterLi" -} diff --git a/src/3rdparty/display-library/adl_defines.h b/src/3rdparty/display-library/adl_defines.h new file mode 100644 index 000000000..b3aa731b6 --- /dev/null +++ b/src/3rdparty/display-library/adl_defines.h @@ -0,0 +1,2596 @@ +// +// Copyright (c) 2016 - 2022 Advanced Micro Devices, Inc. All rights reserved. +// +// MIT LICENSE: +// 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 adl_defines.h +/// \brief Contains all definitions exposed by ADL for \ALL platforms.\n Included in ADL SDK +/// +/// This file contains all definitions used by ADL. +/// The ADL definitions include the following: +/// \li ADL error codes +/// \li Enumerations for the ADLDisplayInfo structure +/// \li Maximum limits +/// + +#ifndef ADL_DEFINES_H_ +#define ADL_DEFINES_H_ + +/// \defgroup DEFINES Constants and Definitions +/// @{ + +/// \defgroup define_misc Miscellaneous Constant Definitions +/// @{ + +/// \name General Definitions +/// @{ + +/// Defines ADL_TRUE +#define ADL_TRUE 1 +/// Defines ADL_FALSE +#define ADL_FALSE 0 + +/// Defines the maximum string length +#define ADL_MAX_CHAR 4096 +/// Defines the maximum string length +#define ADL_MAX_PATH 256 +/// Defines the maximum number of supported adapters +#define ADL_MAX_ADAPTERS 250 +/// Defines the maxumum number of supported displays +#define ADL_MAX_DISPLAYS 150 +/// Defines the maxumum string length for device name +#define ADL_MAX_DEVICENAME 32 +/// Defines for all adapters +#define ADL_ADAPTER_INDEX_ALL -1 +/// Defines APIs with iOption none +#define ADL_MAIN_API_OPTION_NONE 0 +/// @} + +/// \name Definitions for iOption parameter used by +/// ADL_Display_DDCBlockAccess_Get() +/// @{ + +/// Switch to DDC line 2 before sending the command to the display. +#define ADL_DDC_OPTION_SWITCHDDC2 0x00000001 +/// Save command in the registry under a unique key, corresponding to parameter \b iCommandIndex +#define ADL_DDC_OPTION_RESTORECOMMAND 0x00000002 +/// Combine write-read DDC block access command. +#define ADL_DDC_OPTION_COMBOWRITEREAD 0x00000010 +/// Direct DDC access to the immediate device connected to graphics card. +/// MST with this option set: DDC command is sent to first branch. +/// MST with this option not set: DDC command is sent to the end node sink device. +#define ADL_DDC_OPTION_SENDTOIMMEDIATEDEVICE 0x00000020 +/// @} + +/// \name Values for +/// ADLI2C.iAction used with ADL_Display_WriteAndReadI2C() +/// @{ + +#define ADL_DL_I2C_ACTIONREAD 0x00000001 +#define ADL_DL_I2C_ACTIONWRITE 0x00000002 +#define ADL_DL_I2C_ACTIONREAD_REPEATEDSTART 0x00000003 +#define ADL_DL_I2C_ACTIONIS_PRESENT 0x00000004 +/// @} + + +/// @} //Misc + +/// \defgroup define_adl_results Result Codes +/// This group of definitions are the various results returned by all ADL functions \n +/// @{ +/// All OK, but need to wait +#define ADL_OK_WAIT 4 +/// All OK, but need restart +#define ADL_OK_RESTART 3 +/// All OK but need mode change +#define ADL_OK_MODE_CHANGE 2 +/// All OK, but with warning +#define ADL_OK_WARNING 1 +/// ADL function completed successfully +#define ADL_OK 0 +/// Generic Error. Most likely one or more of the Escape calls to the driver failed! +#define ADL_ERR -1 +/// ADL not initialized +#define ADL_ERR_NOT_INIT -2 +/// One of the parameter passed is invalid +#define ADL_ERR_INVALID_PARAM -3 +/// One of the parameter size is invalid +#define ADL_ERR_INVALID_PARAM_SIZE -4 +/// Invalid ADL index passed +#define ADL_ERR_INVALID_ADL_IDX -5 +/// Invalid controller index passed +#define ADL_ERR_INVALID_CONTROLLER_IDX -6 +/// Invalid display index passed +#define ADL_ERR_INVALID_DIPLAY_IDX -7 +/// Function not supported by the driver +#define ADL_ERR_NOT_SUPPORTED -8 +/// Null Pointer error +#define ADL_ERR_NULL_POINTER -9 +/// Call can't be made due to disabled adapter +#define ADL_ERR_DISABLED_ADAPTER -10 +/// Invalid Callback +#define ADL_ERR_INVALID_CALLBACK -11 +/// Display Resource conflict +#define ADL_ERR_RESOURCE_CONFLICT -12 +//Failed to update some of the values. Can be returned by set request that include multiple values if not all values were successfully committed. +#define ADL_ERR_SET_INCOMPLETE -20 +/// There's no Linux XDisplay in Linux Console environment +#define ADL_ERR_NO_XDISPLAY -21 +/// escape call failed becuse of incompatiable driver found in driver store +#define ADL_ERR_CALL_TO_INCOMPATIABLE_DRIVER -22 +/// not running as administrator +#define ADL_ERR_NO_ADMINISTRATOR_PRIVILEGES -23 +/// Feature Sync Start api is not called yet +#define ADL_ERR_FEATURESYNC_NOT_STARTED -24 +/// Adapter is in an invalid power state +#define ADL_ERR_INVALID_POWER_STATE -25 + +/// @} +/// + +/// \defgroup define_display_type Display Type +/// Define Monitor/CRT display type +/// @{ +/// Define Monitor display type +#define ADL_DT_MONITOR 0 +/// Define TV display type +#define ADL_DT_TELEVISION 1 +/// Define LCD display type +#define ADL_DT_LCD_PANEL 2 +/// Define DFP display type +#define ADL_DT_DIGITAL_FLAT_PANEL 3 +/// Define Componment Video display type +#define ADL_DT_COMPONENT_VIDEO 4 +/// Define Projector display type +#define ADL_DT_PROJECTOR 5 +/// @} + +/// \defgroup define_display_connection_type Display Connection Type +/// @{ +/// Define unknown display output type +#define ADL_DOT_UNKNOWN 0 +/// Define composite display output type +#define ADL_DOT_COMPOSITE 1 +/// Define SVideo display output type +#define ADL_DOT_SVIDEO 2 +/// Define analog display output type +#define ADL_DOT_ANALOG 3 +/// Define digital display output type +#define ADL_DOT_DIGITAL 4 +/// @} + +/// \defgroup define_color_type Display Color Type and Source +/// Define Display Color Type and Source +/// @{ +#define ADL_DISPLAY_COLOR_BRIGHTNESS (1 << 0) +#define ADL_DISPLAY_COLOR_CONTRAST (1 << 1) +#define ADL_DISPLAY_COLOR_SATURATION (1 << 2) +#define ADL_DISPLAY_COLOR_HUE (1 << 3) +#define ADL_DISPLAY_COLOR_TEMPERATURE (1 << 4) + +/// Color Temperature Source is EDID +#define ADL_DISPLAY_COLOR_TEMPERATURE_SOURCE_EDID (1 << 5) +/// Color Temperature Source is User +#define ADL_DISPLAY_COLOR_TEMPERATURE_SOURCE_USER (1 << 6) +/// @} + +/// \defgroup define_adjustment_capabilities Display Adjustment Capabilities +/// Display adjustment capabilities values. Returned by ADL_Display_AdjustCaps_Get +/// @{ +#define ADL_DISPLAY_ADJUST_OVERSCAN (1 << 0) +#define ADL_DISPLAY_ADJUST_VERT_POS (1 << 1) +#define ADL_DISPLAY_ADJUST_HOR_POS (1 << 2) +#define ADL_DISPLAY_ADJUST_VERT_SIZE (1 << 3) +#define ADL_DISPLAY_ADJUST_HOR_SIZE (1 << 4) +#define ADL_DISPLAY_ADJUST_SIZEPOS (ADL_DISPLAY_ADJUST_VERT_POS | ADL_DISPLAY_ADJUST_HOR_POS | ADL_DISPLAY_ADJUST_VERT_SIZE | ADL_DISPLAY_ADJUST_HOR_SIZE) +#define ADL_DISPLAY_CUSTOMMODES (1<<5) +#define ADL_DISPLAY_ADJUST_UNDERSCAN (1<<6) +/// @} + +///Down-scale support +#define ADL_DISPLAY_CAPS_DOWNSCALE (1 << 0) + +/// Sharpness support +#define ADL_DISPLAY_CAPS_SHARPNESS (1 << 0) + +/// \defgroup define_desktop_config Desktop Configuration Flags +/// These flags are used by ADL_DesktopConfig_xxx +/// \deprecated This API has been deprecated because it was only used for RandR 1.1 (Red Hat 5.x) distributions which is now not supported. +/// @{ +#define ADL_DESKTOPCONFIG_UNKNOWN 0 /* UNKNOWN desktop config */ +#define ADL_DESKTOPCONFIG_SINGLE (1 << 0) /* Single */ +#define ADL_DESKTOPCONFIG_CLONE (1 << 2) /* Clone */ +#define ADL_DESKTOPCONFIG_BIGDESK_H (1 << 4) /* Big Desktop Horizontal */ +#define ADL_DESKTOPCONFIG_BIGDESK_V (1 << 5) /* Big Desktop Vertical */ +#define ADL_DESKTOPCONFIG_BIGDESK_HR (1 << 6) /* Big Desktop Reverse Horz */ +#define ADL_DESKTOPCONFIG_BIGDESK_VR (1 << 7) /* Big Desktop Reverse Vert */ +#define ADL_DESKTOPCONFIG_RANDR12 (1 << 8) /* RandR 1.2 Multi-display */ +/// @} + +/// needed for ADLDDCInfo structure +#define ADL_MAX_DISPLAY_NAME 256 + +/// \defgroup define_edid_flags Values for ulDDCInfoFlag +/// defines for ulDDCInfoFlag EDID flag +/// @{ +#define ADL_DISPLAYDDCINFOEX_FLAG_PROJECTORDEVICE (1 << 0) +#define ADL_DISPLAYDDCINFOEX_FLAG_EDIDEXTENSION (1 << 1) +#define ADL_DISPLAYDDCINFOEX_FLAG_DIGITALDEVICE (1 << 2) +#define ADL_DISPLAYDDCINFOEX_FLAG_HDMIAUDIODEVICE (1 << 3) +#define ADL_DISPLAYDDCINFOEX_FLAG_SUPPORTS_AI (1 << 4) +#define ADL_DISPLAYDDCINFOEX_FLAG_SUPPORT_xvYCC601 (1 << 5) +#define ADL_DISPLAYDDCINFOEX_FLAG_SUPPORT_xvYCC709 (1 << 6) +/// @} + +/// \defgroup define_displayinfo_connector Display Connector Type +/// defines for ADLDisplayInfo.iDisplayConnector +/// @{ +#define ADL_DISPLAY_CONTYPE_UNKNOWN 0 +#define ADL_DISPLAY_CONTYPE_VGA 1 +#define ADL_DISPLAY_CONTYPE_DVI_D 2 +#define ADL_DISPLAY_CONTYPE_DVI_I 3 +#define ADL_DISPLAY_CONTYPE_ATICVDONGLE_NTSC 4 +#define ADL_DISPLAY_CONTYPE_ATICVDONGLE_JPN 5 +#define ADL_DISPLAY_CONTYPE_ATICVDONGLE_NONI2C_JPN 6 +#define ADL_DISPLAY_CONTYPE_ATICVDONGLE_NONI2C_NTSC 7 +#define ADL_DISPLAY_CONTYPE_PROPRIETARY 8 +#define ADL_DISPLAY_CONTYPE_HDMI_TYPE_A 10 +#define ADL_DISPLAY_CONTYPE_HDMI_TYPE_B 11 +#define ADL_DISPLAY_CONTYPE_SVIDEO 12 +#define ADL_DISPLAY_CONTYPE_COMPOSITE 13 +#define ADL_DISPLAY_CONTYPE_RCA_3COMPONENT 14 +#define ADL_DISPLAY_CONTYPE_DISPLAYPORT 15 +#define ADL_DISPLAY_CONTYPE_EDP 16 +#define ADL_DISPLAY_CONTYPE_WIRELESSDISPLAY 17 +#define ADL_DISPLAY_CONTYPE_USB_TYPE_C 18 +/// @} + +/// TV Capabilities and Standards +/// \defgroup define_tv_caps TV Capabilities and Standards +/// \deprecated Dropping support for TV displays +/// @{ +#define ADL_TV_STANDARDS (1 << 0) +#define ADL_TV_SCART (1 << 1) + +/// TV Standards Definitions +#define ADL_STANDARD_NTSC_M (1 << 0) +#define ADL_STANDARD_NTSC_JPN (1 << 1) +#define ADL_STANDARD_NTSC_N (1 << 2) +#define ADL_STANDARD_PAL_B (1 << 3) +#define ADL_STANDARD_PAL_COMB_N (1 << 4) +#define ADL_STANDARD_PAL_D (1 << 5) +#define ADL_STANDARD_PAL_G (1 << 6) +#define ADL_STANDARD_PAL_H (1 << 7) +#define ADL_STANDARD_PAL_I (1 << 8) +#define ADL_STANDARD_PAL_K (1 << 9) +#define ADL_STANDARD_PAL_K1 (1 << 10) +#define ADL_STANDARD_PAL_L (1 << 11) +#define ADL_STANDARD_PAL_M (1 << 12) +#define ADL_STANDARD_PAL_N (1 << 13) +#define ADL_STANDARD_PAL_SECAM_D (1 << 14) +#define ADL_STANDARD_PAL_SECAM_K (1 << 15) +#define ADL_STANDARD_PAL_SECAM_K1 (1 << 16) +#define ADL_STANDARD_PAL_SECAM_L (1 << 17) +/// @} + + +/// \defgroup define_video_custom_mode Video Custom Mode flags +/// Component Video Custom Mode flags. This is used by the iFlags parameter in ADLCustomMode +/// @{ +#define ADL_CUSTOMIZEDMODEFLAG_MODESUPPORTED (1 << 0) +#define ADL_CUSTOMIZEDMODEFLAG_NOTDELETETABLE (1 << 1) +#define ADL_CUSTOMIZEDMODEFLAG_INSERTBYDRIVER (1 << 2) +#define ADL_CUSTOMIZEDMODEFLAG_INTERLACED (1 << 3) +#define ADL_CUSTOMIZEDMODEFLAG_BASEMODE (1 << 4) +/// @} + +/// \defgroup define_ddcinfoflag Values used for DDCInfoFlag +/// ulDDCInfoFlag field values used by the ADLDDCInfo structure +/// @{ +#define ADL_DISPLAYDDCINFOEX_FLAG_PROJECTORDEVICE (1 << 0) +#define ADL_DISPLAYDDCINFOEX_FLAG_EDIDEXTENSION (1 << 1) +#define ADL_DISPLAYDDCINFOEX_FLAG_DIGITALDEVICE (1 << 2) +#define ADL_DISPLAYDDCINFOEX_FLAG_HDMIAUDIODEVICE (1 << 3) +#define ADL_DISPLAYDDCINFOEX_FLAG_SUPPORTS_AI (1 << 4) +#define ADL_DISPLAYDDCINFOEX_FLAG_SUPPORT_xvYCC601 (1 << 5) +#define ADL_DISPLAYDDCINFOEX_FLAG_SUPPORT_xvYCC709 (1 << 6) +/// @} + +/// \defgroup define_cv_dongle Values used by ADL_CV_DongleSettings_xxx +/// The following is applicable to ADL_DISPLAY_CONTYPE_ATICVDONGLE_JP and ADL_DISPLAY_CONTYPE_ATICVDONGLE_NONI2C_D only +/// \deprecated Dropping support for Component Video displays +/// @{ +#define ADL_DISPLAY_CV_DONGLE_D1 (1 << 0) +#define ADL_DISPLAY_CV_DONGLE_D2 (1 << 1) +#define ADL_DISPLAY_CV_DONGLE_D3 (1 << 2) +#define ADL_DISPLAY_CV_DONGLE_D4 (1 << 3) +#define ADL_DISPLAY_CV_DONGLE_D5 (1 << 4) + +/// The following is applicable to ADL_DISPLAY_CONTYPE_ATICVDONGLE_NA and ADL_DISPLAY_CONTYPE_ATICVDONGLE_NONI2C only + +#define ADL_DISPLAY_CV_DONGLE_480I (1 << 0) +#define ADL_DISPLAY_CV_DONGLE_480P (1 << 1) +#define ADL_DISPLAY_CV_DONGLE_540P (1 << 2) +#define ADL_DISPLAY_CV_DONGLE_720P (1 << 3) +#define ADL_DISPLAY_CV_DONGLE_1080I (1 << 4) +#define ADL_DISPLAY_CV_DONGLE_1080P (1 << 5) +#define ADL_DISPLAY_CV_DONGLE_16_9 (1 << 6) +#define ADL_DISPLAY_CV_DONGLE_720P50 (1 << 7) +#define ADL_DISPLAY_CV_DONGLE_1080I25 (1 << 8) +#define ADL_DISPLAY_CV_DONGLE_576I25 (1 << 9) +#define ADL_DISPLAY_CV_DONGLE_576P50 (1 << 10) +#define ADL_DISPLAY_CV_DONGLE_1080P24 (1 << 11) +#define ADL_DISPLAY_CV_DONGLE_1080P25 (1 << 12) +#define ADL_DISPLAY_CV_DONGLE_1080P30 (1 << 13) +#define ADL_DISPLAY_CV_DONGLE_1080P50 (1 << 14) +/// @} + +/// \defgroup define_formats_ovr Formats Override Settings +/// Display force modes flags +/// @{ +/// +#define ADL_DISPLAY_FORMAT_FORCE_720P 0x00000001 +#define ADL_DISPLAY_FORMAT_FORCE_1080I 0x00000002 +#define ADL_DISPLAY_FORMAT_FORCE_1080P 0x00000004 +#define ADL_DISPLAY_FORMAT_FORCE_720P50 0x00000008 +#define ADL_DISPLAY_FORMAT_FORCE_1080I25 0x00000010 +#define ADL_DISPLAY_FORMAT_FORCE_576I25 0x00000020 +#define ADL_DISPLAY_FORMAT_FORCE_576P50 0x00000040 +#define ADL_DISPLAY_FORMAT_FORCE_1080P24 0x00000080 +#define ADL_DISPLAY_FORMAT_FORCE_1080P25 0x00000100 +#define ADL_DISPLAY_FORMAT_FORCE_1080P30 0x00000200 +#define ADL_DISPLAY_FORMAT_FORCE_1080P50 0x00000400 + +///< Below are \b EXTENDED display mode flags + +#define ADL_DISPLAY_FORMAT_CVDONGLEOVERIDE 0x00000001 +#define ADL_DISPLAY_FORMAT_CVMODEUNDERSCAN 0x00000002 +#define ADL_DISPLAY_FORMAT_FORCECONNECT_SUPPORTED 0x00000004 +#define ADL_DISPLAY_FORMAT_RESTRICT_FORMAT_SELECTION 0x00000008 +#define ADL_DISPLAY_FORMAT_SETASPECRATIO 0x00000010 +#define ADL_DISPLAY_FORMAT_FORCEMODES 0x00000020 +#define ADL_DISPLAY_FORMAT_LCDRTCCOEFF 0x00000040 +/// @} + +/// Defines used by OD5 +#define ADL_PM_PARAM_DONT_CHANGE 0 + +/// The following defines Bus types +/// @{ +#define ADL_BUSTYPE_PCI 0 /* PCI bus */ +#define ADL_BUSTYPE_AGP 1 /* AGP bus */ +#define ADL_BUSTYPE_PCIE 2 /* PCI Express bus */ +#define ADL_BUSTYPE_PCIE_GEN2 3 /* PCI Express 2nd generation bus */ +#define ADL_BUSTYPE_PCIE_GEN3 4 /* PCI Express 3rd generation bus */ +#define ADL_BUSTYPE_PCIE_GEN4 5 /* PCI Express 4th generation bus */ +/// @} + +/// \defgroup define_ws_caps Workstation Capabilities +/// Workstation values +/// @{ + +/// This value indicates that the workstation card supports active stereo though stereo output connector +#define ADL_STEREO_SUPPORTED (1 << 2) +/// This value indicates that the workstation card supports active stereo via "blue-line" +#define ADL_STEREO_BLUE_LINE (1 << 3) +/// This value is used to turn off stereo mode. +#define ADL_STEREO_OFF 0 +/// This value indicates that the workstation card supports active stereo. This is also used to set the stereo mode to active though the stereo output connector +#define ADL_STEREO_ACTIVE (1 << 1) +/// This value indicates that the workstation card supports auto-stereo monitors with horizontal interleave. This is also used to set the stereo mode to use the auto-stereo monitor with horizontal interleave +#define ADL_STEREO_AUTO_HORIZONTAL (1 << 30) +/// This value indicates that the workstation card supports auto-stereo monitors with vertical interleave. This is also used to set the stereo mode to use the auto-stereo monitor with vertical interleave +#define ADL_STEREO_AUTO_VERTICAL (1 << 31) +/// This value indicates that the workstation card supports passive stereo, ie. non stereo sync +#define ADL_STEREO_PASSIVE (1 << 6) +/// This value indicates that the workstation card supports auto-stereo monitors with vertical interleave. This is also used to set the stereo mode to use the auto-stereo monitor with vertical interleave +#define ADL_STEREO_PASSIVE_HORIZ (1 << 7) +/// This value indicates that the workstation card supports auto-stereo monitors with vertical interleave. This is also used to set the stereo mode to use the auto-stereo monitor with vertical interleave +#define ADL_STEREO_PASSIVE_VERT (1 << 8) +/// This value indicates that the workstation card supports auto-stereo monitors with Samsung. +#define ADL_STEREO_AUTO_SAMSUNG (1 << 11) +/// This value indicates that the workstation card supports auto-stereo monitors with Tridility. +#define ADL_STEREO_AUTO_TSL (1 << 12) +/// This value indicates that the workstation card supports DeepBitDepth (10 bpp) +#define ADL_DEEPBITDEPTH_10BPP_SUPPORTED (1 << 5) + +/// This value indicates that the workstation supports 8-Bit Grayscale +#define ADL_8BIT_GREYSCALE_SUPPORTED (1 << 9) +/// This value indicates that the workstation supports CUSTOM TIMING +#define ADL_CUSTOM_TIMING_SUPPORTED (1 << 10) + +/// Load balancing is supported. +#define ADL_WORKSTATION_LOADBALANCING_SUPPORTED 0x00000001 +/// Load balancing is available. +#define ADL_WORKSTATION_LOADBALANCING_AVAILABLE 0x00000002 + +/// Load balancing is disabled. +#define ADL_WORKSTATION_LOADBALANCING_DISABLED 0x00000000 +/// Load balancing is Enabled. +#define ADL_WORKSTATION_LOADBALANCING_ENABLED 0x00000001 + + + +/// @} + +/// \defgroup define_adapterspeed speed setting from the adapter +/// @{ +#define ADL_CONTEXT_SPEED_UNFORCED 0 /* default asic running speed */ +#define ADL_CONTEXT_SPEED_FORCEHIGH 1 /* asic running speed is forced to high */ +#define ADL_CONTEXT_SPEED_FORCELOW 2 /* asic running speed is forced to low */ + +#define ADL_ADAPTER_SPEEDCAPS_SUPPORTED (1 << 0) /* change asic running speed setting is supported */ +/// @} + +/// \defgroup define_glsync Genlock related values +/// GL-Sync port types (unique values) +/// @{ +/// Unknown port of GL-Sync module +#define ADL_GLSYNC_PORT_UNKNOWN 0 +/// BNC port of of GL-Sync module +#define ADL_GLSYNC_PORT_BNC 1 +/// RJ45(1) port of of GL-Sync module +#define ADL_GLSYNC_PORT_RJ45PORT1 2 +/// RJ45(2) port of of GL-Sync module +#define ADL_GLSYNC_PORT_RJ45PORT2 3 + +// GL-Sync Genlock settings mask (bit-vector) + +/// None of the ADLGLSyncGenlockConfig members are valid +#define ADL_GLSYNC_CONFIGMASK_NONE 0 +/// The ADLGLSyncGenlockConfig.lSignalSource member is valid +#define ADL_GLSYNC_CONFIGMASK_SIGNALSOURCE (1 << 0) +/// The ADLGLSyncGenlockConfig.iSyncField member is valid +#define ADL_GLSYNC_CONFIGMASK_SYNCFIELD (1 << 1) +/// The ADLGLSyncGenlockConfig.iSampleRate member is valid +#define ADL_GLSYNC_CONFIGMASK_SAMPLERATE (1 << 2) +/// The ADLGLSyncGenlockConfig.lSyncDelay member is valid +#define ADL_GLSYNC_CONFIGMASK_SYNCDELAY (1 << 3) +/// The ADLGLSyncGenlockConfig.iTriggerEdge member is valid +#define ADL_GLSYNC_CONFIGMASK_TRIGGEREDGE (1 << 4) +/// The ADLGLSyncGenlockConfig.iScanRateCoeff member is valid +#define ADL_GLSYNC_CONFIGMASK_SCANRATECOEFF (1 << 5) +/// The ADLGLSyncGenlockConfig.lFramelockCntlVector member is valid +#define ADL_GLSYNC_CONFIGMASK_FRAMELOCKCNTL (1 << 6) + + +// GL-Sync Framelock control mask (bit-vector) + +/// Framelock is disabled +#define ADL_GLSYNC_FRAMELOCKCNTL_NONE 0 +/// Framelock is enabled +#define ADL_GLSYNC_FRAMELOCKCNTL_ENABLE ( 1 << 0) + +#define ADL_GLSYNC_FRAMELOCKCNTL_DISABLE ( 1 << 1) +#define ADL_GLSYNC_FRAMELOCKCNTL_SWAP_COUNTER_RESET ( 1 << 2) +#define ADL_GLSYNC_FRAMELOCKCNTL_SWAP_COUNTER_ACK ( 1 << 3) +#define ADL_GLSYNC_FRAMELOCKCNTL_VERSION_KMD (1 << 4) + +#define ADL_GLSYNC_FRAMELOCKCNTL_STATE_ENABLE ( 1 << 0) +#define ADL_GLSYNC_FRAMELOCKCNTL_STATE_KMD (1 << 4) + +// GL-Sync Framelock counters mask (bit-vector) +#define ADL_GLSYNC_COUNTER_SWAP ( 1 << 0 ) + +// GL-Sync Signal Sources (unique values) + +/// GL-Sync signal source is undefined +#define ADL_GLSYNC_SIGNALSOURCE_UNDEFINED 0x00000100 +/// GL-Sync signal source is Free Run +#define ADL_GLSYNC_SIGNALSOURCE_FREERUN 0x00000101 +/// GL-Sync signal source is the BNC GL-Sync port +#define ADL_GLSYNC_SIGNALSOURCE_BNCPORT 0x00000102 +/// GL-Sync signal source is the RJ45(1) GL-Sync port +#define ADL_GLSYNC_SIGNALSOURCE_RJ45PORT1 0x00000103 +/// GL-Sync signal source is the RJ45(2) GL-Sync port +#define ADL_GLSYNC_SIGNALSOURCE_RJ45PORT2 0x00000104 + + +// GL-Sync Signal Types (unique values) + +/// GL-Sync signal type is unknown +#define ADL_GLSYNC_SIGNALTYPE_UNDEFINED 0 +/// GL-Sync signal type is 480I +#define ADL_GLSYNC_SIGNALTYPE_480I 1 +/// GL-Sync signal type is 576I +#define ADL_GLSYNC_SIGNALTYPE_576I 2 +/// GL-Sync signal type is 480P +#define ADL_GLSYNC_SIGNALTYPE_480P 3 +/// GL-Sync signal type is 576P +#define ADL_GLSYNC_SIGNALTYPE_576P 4 +/// GL-Sync signal type is 720P +#define ADL_GLSYNC_SIGNALTYPE_720P 5 +/// GL-Sync signal type is 1080P +#define ADL_GLSYNC_SIGNALTYPE_1080P 6 +/// GL-Sync signal type is 1080I +#define ADL_GLSYNC_SIGNALTYPE_1080I 7 +/// GL-Sync signal type is SDI +#define ADL_GLSYNC_SIGNALTYPE_SDI 8 +/// GL-Sync signal type is TTL +#define ADL_GLSYNC_SIGNALTYPE_TTL 9 +/// GL_Sync signal type is Analog +#define ADL_GLSYNC_SIGNALTYPE_ANALOG 10 + +// GL-Sync Sync Field options (unique values) + +///GL-Sync sync field option is undefined +#define ADL_GLSYNC_SYNCFIELD_UNDEFINED 0 +///GL-Sync sync field option is Sync to Field 1 (used for Interlaced signal types) +#define ADL_GLSYNC_SYNCFIELD_BOTH 1 +///GL-Sync sync field option is Sync to Both fields (used for Interlaced signal types) +#define ADL_GLSYNC_SYNCFIELD_1 2 + + +// GL-Sync trigger edge options (unique values) + +/// GL-Sync trigger edge is undefined +#define ADL_GLSYNC_TRIGGEREDGE_UNDEFINED 0 +/// GL-Sync trigger edge is the rising edge +#define ADL_GLSYNC_TRIGGEREDGE_RISING 1 +/// GL-Sync trigger edge is the falling edge +#define ADL_GLSYNC_TRIGGEREDGE_FALLING 2 +/// GL-Sync trigger edge is both the rising and the falling edge +#define ADL_GLSYNC_TRIGGEREDGE_BOTH 3 + + +// GL-Sync scan rate coefficient/multiplier options (unique values) + +/// GL-Sync scan rate coefficient/multiplier is undefined +#define ADL_GLSYNC_SCANRATECOEFF_UNDEFINED 0 +/// GL-Sync scan rate coefficient/multiplier is 5 +#define ADL_GLSYNC_SCANRATECOEFF_x5 1 +/// GL-Sync scan rate coefficient/multiplier is 4 +#define ADL_GLSYNC_SCANRATECOEFF_x4 2 +/// GL-Sync scan rate coefficient/multiplier is 3 +#define ADL_GLSYNC_SCANRATECOEFF_x3 3 +/// GL-Sync scan rate coefficient/multiplier is 5:2 (SMPTE) +#define ADL_GLSYNC_SCANRATECOEFF_x5_DIV_2 4 +/// GL-Sync scan rate coefficient/multiplier is 2 +#define ADL_GLSYNC_SCANRATECOEFF_x2 5 +/// GL-Sync scan rate coefficient/multiplier is 3 : 2 +#define ADL_GLSYNC_SCANRATECOEFF_x3_DIV_2 6 +/// GL-Sync scan rate coefficient/multiplier is 5 : 4 +#define ADL_GLSYNC_SCANRATECOEFF_x5_DIV_4 7 +/// GL-Sync scan rate coefficient/multiplier is 1 (default) +#define ADL_GLSYNC_SCANRATECOEFF_x1 8 +/// GL-Sync scan rate coefficient/multiplier is 4 : 5 +#define ADL_GLSYNC_SCANRATECOEFF_x4_DIV_5 9 +/// GL-Sync scan rate coefficient/multiplier is 2 : 3 +#define ADL_GLSYNC_SCANRATECOEFF_x2_DIV_3 10 +/// GL-Sync scan rate coefficient/multiplier is 1 : 2 +#define ADL_GLSYNC_SCANRATECOEFF_x1_DIV_2 11 +/// GL-Sync scan rate coefficient/multiplier is 2 : 5 (SMPTE) +#define ADL_GLSYNC_SCANRATECOEFF_x2_DIV_5 12 +/// GL-Sync scan rate coefficient/multiplier is 1 : 3 +#define ADL_GLSYNC_SCANRATECOEFF_x1_DIV_3 13 +/// GL-Sync scan rate coefficient/multiplier is 1 : 4 +#define ADL_GLSYNC_SCANRATECOEFF_x1_DIV_4 14 +/// GL-Sync scan rate coefficient/multiplier is 1 : 5 +#define ADL_GLSYNC_SCANRATECOEFF_x1_DIV_5 15 + + +// GL-Sync port (signal presence) states (unique values) + +/// GL-Sync port state is undefined +#define ADL_GLSYNC_PORTSTATE_UNDEFINED 0 +/// GL-Sync port is not connected +#define ADL_GLSYNC_PORTSTATE_NOCABLE 1 +/// GL-Sync port is Idle +#define ADL_GLSYNC_PORTSTATE_IDLE 2 +/// GL-Sync port has an Input signal +#define ADL_GLSYNC_PORTSTATE_INPUT 3 +/// GL-Sync port is Output +#define ADL_GLSYNC_PORTSTATE_OUTPUT 4 + + +// GL-Sync LED types (used index within ADL_Workstation_GLSyncPortState_Get returned ppGlSyncLEDs array) (unique values) + +/// Index into the ADL_Workstation_GLSyncPortState_Get returned ppGlSyncLEDs array for the one LED of the BNC port +#define ADL_GLSYNC_LEDTYPE_BNC 0 +/// Index into the ADL_Workstation_GLSyncPortState_Get returned ppGlSyncLEDs array for the Left LED of the RJ45(1) or RJ45(2) port +#define ADL_GLSYNC_LEDTYPE_RJ45_LEFT 0 +/// Index into the ADL_Workstation_GLSyncPortState_Get returned ppGlSyncLEDs array for the Right LED of the RJ45(1) or RJ45(2) port +#define ADL_GLSYNC_LEDTYPE_RJ45_RIGHT 1 + + +// GL-Sync LED colors (unique values) + +/// GL-Sync LED undefined color +#define ADL_GLSYNC_LEDCOLOR_UNDEFINED 0 +/// GL-Sync LED is unlit +#define ADL_GLSYNC_LEDCOLOR_NOLIGHT 1 +/// GL-Sync LED is yellow +#define ADL_GLSYNC_LEDCOLOR_YELLOW 2 +/// GL-Sync LED is red +#define ADL_GLSYNC_LEDCOLOR_RED 3 +/// GL-Sync LED is green +#define ADL_GLSYNC_LEDCOLOR_GREEN 4 +/// GL-Sync LED is flashing green +#define ADL_GLSYNC_LEDCOLOR_FLASH_GREEN 5 + + +// GL-Sync Port Control (refers one GL-Sync Port) (unique values) + +/// Used to configure the RJ54(1) or RJ42(2) port of GL-Sync is as Idle +#define ADL_GLSYNC_PORTCNTL_NONE 0x00000000 +/// Used to configure the RJ54(1) or RJ42(2) port of GL-Sync is as Output +#define ADL_GLSYNC_PORTCNTL_OUTPUT 0x00000001 + + +// GL-Sync Mode Control (refers one Display/Controller) (bitfields) + +/// Used to configure the display to use internal timing (not genlocked) +#define ADL_GLSYNC_MODECNTL_NONE 0x00000000 +/// Bitfield used to configure the display as genlocked (either as Timing Client or as Timing Server) +#define ADL_GLSYNC_MODECNTL_GENLOCK 0x00000001 +/// Bitfield used to configure the display as Timing Server +#define ADL_GLSYNC_MODECNTL_TIMINGSERVER 0x00000002 + +// GL-Sync Mode Status +/// Display is currently not genlocked +#define ADL_GLSYNC_MODECNTL_STATUS_NONE 0x00000000 +/// Display is currently genlocked +#define ADL_GLSYNC_MODECNTL_STATUS_GENLOCK 0x00000001 +/// Display requires a mode switch +#define ADL_GLSYNC_MODECNTL_STATUS_SETMODE_REQUIRED 0x00000002 +/// Display is capable of being genlocked +#define ADL_GLSYNC_MODECNTL_STATUS_GENLOCK_ALLOWED 0x00000004 + +#define ADL_MAX_GLSYNC_PORTS 8 +#define ADL_MAX_GLSYNC_PORT_LEDS 8 + +/// @} + +/// \defgroup define_crossfirestate CrossfireX state of a particular adapter CrossfireX combination +/// @{ +#define ADL_XFIREX_STATE_NOINTERCONNECT ( 1 << 0 ) /* Dongle / cable is missing */ +#define ADL_XFIREX_STATE_DOWNGRADEPIPES ( 1 << 1 ) /* CrossfireX can be enabled if pipes are downgraded */ +#define ADL_XFIREX_STATE_DOWNGRADEMEM ( 1 << 2 ) /* CrossfireX cannot be enabled unless mem downgraded */ +#define ADL_XFIREX_STATE_REVERSERECOMMENDED ( 1 << 3 ) /* Card reversal recommended, CrossfireX cannot be enabled. */ +#define ADL_XFIREX_STATE_3DACTIVE ( 1 << 4 ) /* 3D client is active - CrossfireX cannot be safely enabled */ +#define ADL_XFIREX_STATE_MASTERONSLAVE ( 1 << 5 ) /* Dongle is OK but master is on slave */ +#define ADL_XFIREX_STATE_NODISPLAYCONNECT ( 1 << 6 ) /* No (valid) display connected to master card. */ +#define ADL_XFIREX_STATE_NOPRIMARYVIEW ( 1 << 7 ) /* CrossfireX is enabled but master is not current primary device */ +#define ADL_XFIREX_STATE_DOWNGRADEVISMEM ( 1 << 8 ) /* CrossfireX cannot be enabled unless visible mem downgraded */ +#define ADL_XFIREX_STATE_LESSTHAN8LANE_MASTER ( 1 << 9 ) /* CrossfireX can be enabled however performance not optimal due to <8 lanes */ +#define ADL_XFIREX_STATE_LESSTHAN8LANE_SLAVE ( 1 << 10 ) /* CrossfireX can be enabled however performance not optimal due to <8 lanes */ +#define ADL_XFIREX_STATE_PEERTOPEERFAILED ( 1 << 11 ) /* CrossfireX cannot be enabled due to failed peer to peer test */ +#define ADL_XFIREX_STATE_MEMISDOWNGRADED ( 1 << 16 ) /* Notification that memory is currently downgraded */ +#define ADL_XFIREX_STATE_PIPESDOWNGRADED ( 1 << 17 ) /* Notification that pipes are currently downgraded */ +#define ADL_XFIREX_STATE_XFIREXACTIVE ( 1 << 18 ) /* CrossfireX is enabled on current device */ +#define ADL_XFIREX_STATE_VISMEMISDOWNGRADED ( 1 << 19 ) /* Notification that visible FB memory is currently downgraded */ +#define ADL_XFIREX_STATE_INVALIDINTERCONNECTION ( 1 << 20 ) /* Cannot support current inter-connection configuration */ +#define ADL_XFIREX_STATE_NONP2PMODE ( 1 << 21 ) /* CrossfireX will only work with clients supporting non P2P mode */ +#define ADL_XFIREX_STATE_DOWNGRADEMEMBANKS ( 1 << 22 ) /* CrossfireX cannot be enabled unless memory banks downgraded */ +#define ADL_XFIREX_STATE_MEMBANKSDOWNGRADED ( 1 << 23 ) /* Notification that memory banks are currently downgraded */ +#define ADL_XFIREX_STATE_DUALDISPLAYSALLOWED ( 1 << 24 ) /* Extended desktop or clone mode is allowed. */ +#define ADL_XFIREX_STATE_P2P_APERTURE_MAPPING ( 1 << 25 ) /* P2P mapping was through peer aperture */ +#define ADL_XFIREX_STATE_P2PFLUSH_REQUIRED ADL_XFIREX_STATE_P2P_APERTURE_MAPPING /* For back compatible */ +#define ADL_XFIREX_STATE_XSP_CONNECTED ( 1 << 26 ) /* There is CrossfireX side port connection between GPUs */ +#define ADL_XFIREX_STATE_ENABLE_CF_REBOOT_REQUIRED ( 1 << 27 ) /* System needs a reboot bofore enable CrossfireX */ +#define ADL_XFIREX_STATE_DISABLE_CF_REBOOT_REQUIRED ( 1 << 28 ) /* System needs a reboot after disable CrossfireX */ +#define ADL_XFIREX_STATE_DRV_HANDLE_DOWNGRADE_KEY ( 1 << 29 ) /* Indicate base driver handles the downgrade key updating */ +#define ADL_XFIREX_STATE_CF_RECONFIG_REQUIRED ( 1 << 30 ) /* CrossfireX need to be reconfigured by CCC because of a LDA chain broken */ +#define ADL_XFIREX_STATE_ERRORGETTINGSTATUS ( 1 << 31 ) /* Could not obtain current status */ +/// @} + +/////////////////////////////////////////////////////////////////////////// +// ADL_DISPLAY_ADJUSTMENT_PIXELFORMAT adjustment values +// (bit-vector) +/////////////////////////////////////////////////////////////////////////// +/// \defgroup define_pixel_formats Pixel Formats values +/// This group defines the various Pixel Formats that a particular digital display can support. \n +/// Since a display can support multiple formats, these values can be bit-or'ed to indicate the various formats \n +/// @{ +#define ADL_DISPLAY_PIXELFORMAT_UNKNOWN 0 +#define ADL_DISPLAY_PIXELFORMAT_RGB (1 << 0) +#define ADL_DISPLAY_PIXELFORMAT_YCRCB444 (1 << 1) //Limited range +#define ADL_DISPLAY_PIXELFORMAT_YCRCB422 (1 << 2) //Limited range +#define ADL_DISPLAY_PIXELFORMAT_RGB_LIMITED_RANGE (1 << 3) +#define ADL_DISPLAY_PIXELFORMAT_RGB_FULL_RANGE ADL_DISPLAY_PIXELFORMAT_RGB //Full range +#define ADL_DISPLAY_PIXELFORMAT_YCRCB420 (1 << 4) +/// @} + +/// \defgroup define_contype Connector Type Values +/// ADLDisplayConfig.ulConnectorType defines +/// @{ +#define ADL_DL_DISPLAYCONFIG_CONTYPE_UNKNOWN 0 +#define ADL_DL_DISPLAYCONFIG_CONTYPE_CV_NONI2C_JP 1 +#define ADL_DL_DISPLAYCONFIG_CONTYPE_CV_JPN 2 +#define ADL_DL_DISPLAYCONFIG_CONTYPE_CV_NA 3 +#define ADL_DL_DISPLAYCONFIG_CONTYPE_CV_NONI2C_NA 4 +#define ADL_DL_DISPLAYCONFIG_CONTYPE_VGA 5 +#define ADL_DL_DISPLAYCONFIG_CONTYPE_DVI_D 6 +#define ADL_DL_DISPLAYCONFIG_CONTYPE_DVI_I 7 +#define ADL_DL_DISPLAYCONFIG_CONTYPE_HDMI_TYPE_A 8 +#define ADL_DL_DISPLAYCONFIG_CONTYPE_HDMI_TYPE_B 9 +#define ADL_DL_DISPLAYCONFIG_CONTYPE_DISPLAYPORT 10 +/// @} + +/////////////////////////////////////////////////////////////////////////// +// ADL_DISPLAY_DISPLAYINFO_ Definitions +// for ADLDisplayInfo.iDisplayInfoMask and ADLDisplayInfo.iDisplayInfoValue +// (bit-vector) +/////////////////////////////////////////////////////////////////////////// +/// \defgroup define_displayinfomask Display Info Mask Values +/// @{ +#define ADL_DISPLAY_DISPLAYINFO_DISPLAYCONNECTED 0x00000001 +#define ADL_DISPLAY_DISPLAYINFO_DISPLAYMAPPED 0x00000002 +#define ADL_DISPLAY_DISPLAYINFO_NONLOCAL 0x00000004 +#define ADL_DISPLAY_DISPLAYINFO_FORCIBLESUPPORTED 0x00000008 +#define ADL_DISPLAY_DISPLAYINFO_GENLOCKSUPPORTED 0x00000010 +#define ADL_DISPLAY_DISPLAYINFO_MULTIVPU_SUPPORTED 0x00000020 +#define ADL_DISPLAY_DISPLAYINFO_LDA_DISPLAY 0x00000040 +#define ADL_DISPLAY_DISPLAYINFO_MODETIMING_OVERRIDESSUPPORTED 0x00000080 + +#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_SINGLE 0x00000100 +#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_CLONE 0x00000200 + +/// Legacy support for XP +#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_2VSTRETCH 0x00000400 +#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_2HSTRETCH 0x00000800 +#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_EXTENDED 0x00001000 + +/// More support manners +#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_NSTRETCH1GPU 0x00010000 +#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_NSTRETCHNGPU 0x00020000 +#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_RESERVED2 0x00040000 +#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_RESERVED3 0x00080000 + +/// Projector display type +#define ADL_DISPLAY_DISPLAYINFO_SHOWTYPE_PROJECTOR 0x00100000 + +/// @} + + +/////////////////////////////////////////////////////////////////////////// +// ADL_ADAPTER_DISPLAY_MANNER_SUPPORTED_ Definitions +// for ADLAdapterDisplayCap of ADL_Adapter_Display_Cap() +// (bit-vector) +/////////////////////////////////////////////////////////////////////////// +/// \defgroup define_adaptermanner Adapter Manner Support Values +/// @{ +#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_NOTACTIVE 0x00000001 +#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_SINGLE 0x00000002 +#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_CLONE 0x00000004 +#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_NSTRETCH1GPU 0x00000008 +#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_NSTRETCHNGPU 0x00000010 + +/// Legacy support for XP +#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_2VSTRETCH 0x00000020 +#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_2HSTRETCH 0x00000040 +#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_EXTENDED 0x00000080 + +#define ADL_ADAPTER_DISPLAYCAP_PREFERDISPLAY_SUPPORTED 0x00000100 +#define ADL_ADAPTER_DISPLAYCAP_BEZEL_SUPPORTED 0x00000200 + + +/////////////////////////////////////////////////////////////////////////// +// ADL_DISPLAY_DISPLAYMAP_MANNER_ Definitions +// for ADLDisplayMap.iDisplayMapMask and ADLDisplayMap.iDisplayMapValue +// (bit-vector) +/////////////////////////////////////////////////////////////////////////// +#define ADL_DISPLAY_DISPLAYMAP_MANNER_RESERVED 0x00000001 +#define ADL_DISPLAY_DISPLAYMAP_MANNER_NOTACTIVE 0x00000002 +#define ADL_DISPLAY_DISPLAYMAP_MANNER_SINGLE 0x00000004 +#define ADL_DISPLAY_DISPLAYMAP_MANNER_CLONE 0x00000008 +#define ADL_DISPLAY_DISPLAYMAP_MANNER_RESERVED1 0x00000010 // Removed NSTRETCH +#define ADL_DISPLAY_DISPLAYMAP_MANNER_HSTRETCH 0x00000020 +#define ADL_DISPLAY_DISPLAYMAP_MANNER_VSTRETCH 0x00000040 +#define ADL_DISPLAY_DISPLAYMAP_MANNER_VLD 0x00000080 + +/// @} + +/////////////////////////////////////////////////////////////////////////// +// ADL_DISPLAY_DISPLAYMAP_OPTION_ Definitions +// for iOption in function ADL_Display_DisplayMapConfig_Get +// (bit-vector) +/////////////////////////////////////////////////////////////////////////// +#define ADL_DISPLAY_DISPLAYMAP_OPTION_GPUINFO 0x00000001 + +/////////////////////////////////////////////////////////////////////////// +// ADL_DISPLAY_DISPLAYTARGET_ Definitions +// for ADLDisplayTarget.iDisplayTargetMask and ADLDisplayTarget.iDisplayTargetValue +// (bit-vector) +/////////////////////////////////////////////////////////////////////////// +#define ADL_DISPLAY_DISPLAYTARGET_PREFERRED 0x00000001 + +/////////////////////////////////////////////////////////////////////////// +// ADL_DISPLAY_POSSIBLEMAPRESULT_VALID Definitions +// for ADLPossibleMapResult.iPossibleMapResultMask and ADLPossibleMapResult.iPossibleMapResultValue +// (bit-vector) +/////////////////////////////////////////////////////////////////////////// +#define ADL_DISPLAY_POSSIBLEMAPRESULT_VALID 0x00000001 +#define ADL_DISPLAY_POSSIBLEMAPRESULT_BEZELSUPPORTED 0x00000002 +#define ADL_DISPLAY_POSSIBLEMAPRESULT_OVERLAPSUPPORTED 0x00000004 + +/////////////////////////////////////////////////////////////////////////// +// ADL_DISPLAY_MODE_ Definitions +// for ADLMode.iModeMask, ADLMode.iModeValue, and ADLMode.iModeFlag +// (bit-vector) +/////////////////////////////////////////////////////////////////////////// +/// \defgroup define_displaymode Display Mode Values +/// @{ +#define ADL_DISPLAY_MODE_COLOURFORMAT_565 0x00000001 +#define ADL_DISPLAY_MODE_COLOURFORMAT_8888 0x00000002 +#define ADL_DISPLAY_MODE_ORIENTATION_SUPPORTED_000 0x00000004 +#define ADL_DISPLAY_MODE_ORIENTATION_SUPPORTED_090 0x00000008 +#define ADL_DISPLAY_MODE_ORIENTATION_SUPPORTED_180 0x00000010 +#define ADL_DISPLAY_MODE_ORIENTATION_SUPPORTED_270 0x00000020 +#define ADL_DISPLAY_MODE_REFRESHRATE_ROUNDED 0x00000040 +#define ADL_DISPLAY_MODE_REFRESHRATE_ONLY 0x00000080 + +#define ADL_DISPLAY_MODE_PROGRESSIVE_FLAG 0 +#define ADL_DISPLAY_MODE_INTERLACED_FLAG 2 +/// @} + +/////////////////////////////////////////////////////////////////////////// +// ADL_OSMODEINFO Definitions +/////////////////////////////////////////////////////////////////////////// +/// \defgroup define_osmode OS Mode Values +/// @{ +#define ADL_OSMODEINFOXPOS_DEFAULT -640 +#define ADL_OSMODEINFOYPOS_DEFAULT 0 +#define ADL_OSMODEINFOXRES_DEFAULT 640 +#define ADL_OSMODEINFOYRES_DEFAULT 480 +#define ADL_OSMODEINFOXRES_DEFAULT800 800 +#define ADL_OSMODEINFOYRES_DEFAULT600 600 +#define ADL_OSMODEINFOREFRESHRATE_DEFAULT 60 +#define ADL_OSMODEINFOCOLOURDEPTH_DEFAULT 8 +#define ADL_OSMODEINFOCOLOURDEPTH_DEFAULT16 16 +#define ADL_OSMODEINFOCOLOURDEPTH_DEFAULT24 24 +#define ADL_OSMODEINFOCOLOURDEPTH_DEFAULT32 32 +#define ADL_OSMODEINFOORIENTATION_DEFAULT 0 +#define ADL_OSMODEINFOORIENTATION_DEFAULT_WIN7 DISPLAYCONFIG_ROTATION_FORCE_UINT32 +#define ADL_OSMODEFLAG_DEFAULT 0 +/// @} + +/////////////////////////////////////////////////////////////////////////// +// ADLThreadingModel Enumeration +/////////////////////////////////////////////////////////////////////////// +/// \defgroup thread_model +/// Used with \ref ADL_Main_ControlX2_Create and \ref ADL2_Main_ControlX2_Create to specify how ADL handles API calls when executed by multiple threads concurrently. +/// \brief Declares ADL threading behavior. +/// @{ +typedef enum ADLThreadingModel +{ + ADL_THREADING_UNLOCKED = 0, /*!< Default behavior. ADL will not enforce serialization of ADL API executions by multiple threads. Multiple threads will be allowed to enter to ADL at the same time. Note that ADL library is not guaranteed to be thread-safe. Client that calls ADL_Main_Control_Create have to provide its own mechanism for ADL calls serialization. */ + ADL_THREADING_LOCKED /*!< ADL will enforce serialization of ADL API when called by multiple threads. Only single thread will be allowed to enter ADL API at the time. This option makes ADL calls thread-safe. You shouldn't use this option if ADL calls will be executed on Linux on x-server rendering thread. It can cause the application to hung. */ +}ADLThreadingModel; + +/// @} +/////////////////////////////////////////////////////////////////////////// +// ADLPurposeCode Enumeration +/////////////////////////////////////////////////////////////////////////// +enum ADLPurposeCode +{ + ADL_PURPOSECODE_NORMAL = 0, + ADL_PURPOSECODE_HIDE_MODE_SWITCH, + ADL_PURPOSECODE_MODE_SWITCH, + ADL_PURPOSECODE_ATTATCH_DEVICE, + ADL_PURPOSECODE_DETACH_DEVICE, + ADL_PURPOSECODE_SETPRIMARY_DEVICE, + ADL_PURPOSECODE_GDI_ROTATION, + ADL_PURPOSECODE_ATI_ROTATION +}; +/////////////////////////////////////////////////////////////////////////// +// ADLAngle Enumeration +/////////////////////////////////////////////////////////////////////////// +enum ADLAngle +{ + ADL_ANGLE_LANDSCAPE = 0, + ADL_ANGLE_ROTATERIGHT = 90, + ADL_ANGLE_ROTATE180 = 180, + ADL_ANGLE_ROTATELEFT = 270, +}; + +/////////////////////////////////////////////////////////////////////////// +// ADLOrientationDataType Enumeration +/////////////////////////////////////////////////////////////////////////// +enum ADLOrientationDataType +{ + ADL_ORIENTATIONTYPE_OSDATATYPE, + ADL_ORIENTATIONTYPE_NONOSDATATYPE +}; + +/////////////////////////////////////////////////////////////////////////// +// ADLPanningMode Enumeration +/////////////////////////////////////////////////////////////////////////// +enum ADLPanningMode +{ + ADL_PANNINGMODE_NO_PANNING = 0, + ADL_PANNINGMODE_AT_LEAST_ONE_NO_PANNING = 1, + ADL_PANNINGMODE_ALLOW_PANNING = 2, +}; + +/////////////////////////////////////////////////////////////////////////// +// ADLLARGEDESKTOPTYPE Enumeration +/////////////////////////////////////////////////////////////////////////// +enum ADLLARGEDESKTOPTYPE +{ + ADL_LARGEDESKTOPTYPE_NORMALDESKTOP = 0, + ADL_LARGEDESKTOPTYPE_PSEUDOLARGEDESKTOP = 1, + ADL_LARGEDESKTOPTYPE_VERYLARGEDESKTOP = 2 +}; + +/////////////////////////////////////////////////////////////////////////// +// ADLPlatform Enumeration +/////////////////////////////////////////////////////////////////////////// +enum ADLPlatForm +{ + GRAPHICS_PLATFORM_DESKTOP = 0, + GRAPHICS_PLATFORM_MOBILE = 1 +}; + +/////////////////////////////////////////////////////////////////////////// +// ADLGraphicCoreGeneration Enumeration +/////////////////////////////////////////////////////////////////////////// +enum ADLGraphicCoreGeneration +{ + ADL_GRAPHIC_CORE_GENERATION_UNDEFINED = 0, + ADL_GRAPHIC_CORE_GENERATION_PRE_GCN = 1, + ADL_GRAPHIC_CORE_GENERATION_GCN = 2, + ADL_GRAPHIC_CORE_GENERATION_RDNA = 3 +}; + +// Other Definitions for internal use + +// Values for ADL_Display_WriteAndReadI2CRev_Get() + +#define ADL_I2C_MAJOR_API_REV 0x00000001 +#define ADL_I2C_MINOR_DEFAULT_API_REV 0x00000000 +#define ADL_I2C_MINOR_OEM_API_REV 0x00000001 + +// Values for ADL_Display_WriteAndReadI2C() +#define ADL_DL_I2C_LINE_OEM 0x00000001 +#define ADL_DL_I2C_LINE_OD_CONTROL 0x00000002 +#define ADL_DL_I2C_LINE_OEM2 0x00000003 +#define ADL_DL_I2C_LINE_OEM3 0x00000004 +#define ADL_DL_I2C_LINE_OEM4 0x00000005 +#define ADL_DL_I2C_LINE_OEM5 0x00000006 +#define ADL_DL_I2C_LINE_OEM6 0x00000007 +#define ADL_DL_I2C_LINE_GPIO 0x00000008 + +// Max size of I2C data buffer +#define ADL_DL_I2C_MAXDATASIZE 0x00000018 +#define ADL_DL_I2C_MAXWRITEDATASIZE 0x0000000C +#define ADL_DL_I2C_MAXADDRESSLENGTH 0x00000006 +#define ADL_DL_I2C_MAXOFFSETLENGTH 0x00000004 + +// I2C clock speed in KHz +#define ADL_DL_I2C_SPEED_50K 50 +#define ADL_DL_I2C_SPEED_100K 100 +#define ALD_DL_I2C_SPEED_400K 400 +#define ADL_DL_I2C_SPEED_1M 1000 +#define ADL_DL_I2C_SPEED_2M 2300 + +/// Values for ADLDisplayProperty.iPropertyType +#define ADL_DL_DISPLAYPROPERTY_TYPE_UNKNOWN 0 +#define ADL_DL_DISPLAYPROPERTY_TYPE_EXPANSIONMODE 1 +#define ADL_DL_DISPLAYPROPERTY_TYPE_USEUNDERSCANSCALING 2 +/// Enables ITC processing for HDMI panels that are capable of the feature +#define ADL_DL_DISPLAYPROPERTY_TYPE_ITCFLAGENABLE 9 +#define ADL_DL_DISPLAYPROPERTY_TYPE_DOWNSCALE 11 +#define ADL_DL_DISPLAYPROPERTY_TYPE_INTEGER_SCALING 12 + + +/// Values for ADLDisplayContent.iContentType +/// Certain HDMI panels that support ITC have support for a feature such that, the display on the panel +/// can be adjusted to optimize the view of the content being displayed, depending on the type of content. +#define ADL_DL_DISPLAYCONTENT_TYPE_GRAPHICS 1 +#define ADL_DL_DISPLAYCONTENT_TYPE_PHOTO 2 +#define ADL_DL_DISPLAYCONTENT_TYPE_CINEMA 4 +#define ADL_DL_DISPLAYCONTENT_TYPE_GAME 8 + + + +//values for ADLDisplayProperty.iExpansionMode +#define ADL_DL_DISPLAYPROPERTY_EXPANSIONMODE_CENTER 0 +#define ADL_DL_DISPLAYPROPERTY_EXPANSIONMODE_FULLSCREEN 1 +#define ADL_DL_DISPLAYPROPERTY_EXPANSIONMODE_ASPECTRATIO 2 + + +///\defgroup define_dither_states Dithering options +/// @{ +/// Dithering disabled. +#define ADL_DL_DISPLAY_DITHER_DISABLED 0 +/// Use default driver settings for dithering. Note that the default setting could be dithering disabled. +#define ADL_DL_DISPLAY_DITHER_DRIVER_DEFAULT 1 +/// Temporal dithering to 6 bpc. Note that if the input is 12 bits, the two least significant bits will be truncated. +#define ADL_DL_DISPLAY_DITHER_FM6 2 +/// Temporal dithering to 8 bpc. +#define ADL_DL_DISPLAY_DITHER_FM8 3 +/// Temporal dithering to 10 bpc. +#define ADL_DL_DISPLAY_DITHER_FM10 4 +/// Spatial dithering to 6 bpc. Note that if the input is 12 bits, the two least significant bits will be truncated. +#define ADL_DL_DISPLAY_DITHER_DITH6 5 +/// Spatial dithering to 8 bpc. +#define ADL_DL_DISPLAY_DITHER_DITH8 6 +/// Spatial dithering to 10 bpc. +#define ADL_DL_DISPLAY_DITHER_DITH10 7 +/// Spatial dithering to 6 bpc. Random number generators are reset every frame, so the same input value of a certain pixel will always be dithered to the same output value. Note that if the input is 12 bits, the two least significant bits will be truncated. +#define ADL_DL_DISPLAY_DITHER_DITH6_NO_FRAME_RAND 8 +/// Spatial dithering to 8 bpc. Random number generators are reset every frame, so the same input value of a certain pixel will always be dithered to the same output value. +#define ADL_DL_DISPLAY_DITHER_DITH8_NO_FRAME_RAND 9 +/// Spatial dithering to 10 bpc. Random number generators are reset every frame, so the same input value of a certain pixel will always be dithered to the same output value. +#define ADL_DL_DISPLAY_DITHER_DITH10_NO_FRAME_RAND 10 +/// Truncation to 6 bpc. +#define ADL_DL_DISPLAY_DITHER_TRUN6 11 +/// Truncation to 8 bpc. +#define ADL_DL_DISPLAY_DITHER_TRUN8 12 +/// Truncation to 10 bpc. +#define ADL_DL_DISPLAY_DITHER_TRUN10 13 +/// Truncation to 10 bpc followed by spatial dithering to 8 bpc. +#define ADL_DL_DISPLAY_DITHER_TRUN10_DITH8 14 +/// Truncation to 10 bpc followed by spatial dithering to 6 bpc. +#define ADL_DL_DISPLAY_DITHER_TRUN10_DITH6 15 +/// Truncation to 10 bpc followed by temporal dithering to 8 bpc. +#define ADL_DL_DISPLAY_DITHER_TRUN10_FM8 16 +/// Truncation to 10 bpc followed by temporal dithering to 6 bpc. +#define ADL_DL_DISPLAY_DITHER_TRUN10_FM6 17 +/// Truncation to 10 bpc followed by spatial dithering to 8 bpc and temporal dithering to 6 bpc. +#define ADL_DL_DISPLAY_DITHER_TRUN10_DITH8_FM6 18 +/// Spatial dithering to 10 bpc followed by temporal dithering to 8 bpc. +#define ADL_DL_DISPLAY_DITHER_DITH10_FM8 19 +/// Spatial dithering to 10 bpc followed by temporal dithering to 6 bpc. +#define ADL_DL_DISPLAY_DITHER_DITH10_FM6 20 +/// Truncation to 8 bpc followed by spatial dithering to 6 bpc. +#define ADL_DL_DISPLAY_DITHER_TRUN8_DITH6 21 +/// Truncation to 8 bpc followed by temporal dithering to 6 bpc. +#define ADL_DL_DISPLAY_DITHER_TRUN8_FM6 22 +/// Spatial dithering to 8 bpc followed by temporal dithering to 6 bpc. +#define ADL_DL_DISPLAY_DITHER_DITH8_FM6 23 +#define ADL_DL_DISPLAY_DITHER_LAST ADL_DL_DISPLAY_DITHER_DITH8_FM6 +/// @} + + +/// Display Get Cached EDID flag +#define ADL_MAX_EDIDDATA_SIZE 256 // number of UCHAR +#define ADL_MAX_OVERRIDEEDID_SIZE 512 // number of UCHAR +#define ADL_MAX_EDID_EXTENSION_BLOCKS 3 + +#define ADL_DL_CONTROLLER_OVERLAY_ALPHA 0 +#define ADL_DL_CONTROLLER_OVERLAY_ALPHAPERPIX 1 + +#define ADL_DL_DISPLAY_DATA_PACKET__INFO_PACKET_RESET 0x00000000 +#define ADL_DL_DISPLAY_DATA_PACKET__INFO_PACKET_SET 0x00000001 +#define ADL_DL_DISPLAY_DATA_PACKET__INFO_PACKET_SCAN 0x00000002 + +///\defgroup define_display_packet Display Data Packet Types +/// @{ +#define ADL_DL_DISPLAY_DATA_PACKET__TYPE__AVI 0x00000001 +#define ADL_DL_DISPLAY_DATA_PACKET__TYPE__GAMMUT 0x00000002 +#define ADL_DL_DISPLAY_DATA_PACKET__TYPE__VENDORINFO 0x00000004 +#define ADL_DL_DISPLAY_DATA_PACKET__TYPE__HDR 0x00000008 +#define ADL_DL_DISPLAY_DATA_PACKET__TYPE__SPD 0x00000010 +/// @} + +// matrix types +#define ADL_GAMUT_MATRIX_SD 1 // SD matrix i.e. BT601 +#define ADL_GAMUT_MATRIX_HD 2 // HD matrix i.e. BT709 + +///\defgroup define_clockinfo_flags Clock flags +/// Used by ADLAdapterODClockInfo.iFlag +/// @{ +#define ADL_DL_CLOCKINFO_FLAG_FULLSCREEN3DONLY 0x00000001 +#define ADL_DL_CLOCKINFO_FLAG_ALWAYSFULLSCREEN3D 0x00000002 +#define ADL_DL_CLOCKINFO_FLAG_VPURECOVERYREDUCED 0x00000004 +#define ADL_DL_CLOCKINFO_FLAG_THERMALPROTECTION 0x00000008 +/// @} + +// Supported GPUs +// ADL_Display_PowerXpressActiveGPU_Get() +#define ADL_DL_POWERXPRESS_GPU_INTEGRATED 1 +#define ADL_DL_POWERXPRESS_GPU_DISCRETE 2 + +// Possible values for lpOperationResult +// ADL_Display_PowerXpressActiveGPU_Get() +#define ADL_DL_POWERXPRESS_SWITCH_RESULT_STARTED 1 // Switch procedure has been started - Windows platform only +#define ADL_DL_POWERXPRESS_SWITCH_RESULT_DECLINED 2 // Switch procedure cannot be started - All platforms +#define ADL_DL_POWERXPRESS_SWITCH_RESULT_ALREADY 3 // System already has required status - All platforms +#define ADL_DL_POWERXPRESS_SWITCH_RESULT_DEFERRED 5 // Switch was deferred and requires an X restart - Linux platform only + +// PowerXpress support version +// ADL_Display_PowerXpressVersion_Get() +#define ADL_DL_POWERXPRESS_VERSION_MAJOR 2 // Current PowerXpress support version 2.0 +#define ADL_DL_POWERXPRESS_VERSION_MINOR 0 + +#define ADL_DL_POWERXPRESS_VERSION (((ADL_DL_POWERXPRESS_VERSION_MAJOR) << 16) | ADL_DL_POWERXPRESS_VERSION_MINOR) + +//values for ADLThermalControllerInfo.iThermalControllerDomain +#define ADL_DL_THERMAL_DOMAIN_OTHER 0 +#define ADL_DL_THERMAL_DOMAIN_GPU 1 + +//values for ADLThermalControllerInfo.iFlags +#define ADL_DL_THERMAL_FLAG_INTERRUPT 1 +#define ADL_DL_THERMAL_FLAG_FANCONTROL 2 + +///\defgroup define_fanctrl Fan speed cotrol +/// Values for ADLFanSpeedInfo.iFlags +/// @{ +#define ADL_DL_FANCTRL_SUPPORTS_PERCENT_READ 1 +#define ADL_DL_FANCTRL_SUPPORTS_PERCENT_WRITE 2 +#define ADL_DL_FANCTRL_SUPPORTS_RPM_READ 4 +#define ADL_DL_FANCTRL_SUPPORTS_RPM_WRITE 8 +/// @} + +//values for ADLFanSpeedValue.iSpeedType +#define ADL_DL_FANCTRL_SPEED_TYPE_PERCENT 1 +#define ADL_DL_FANCTRL_SPEED_TYPE_RPM 2 + +//values for ADLFanSpeedValue.iFlags +#define ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED 1 + +// MVPU interfaces +#define ADL_DL_MAX_MVPU_ADAPTERS 4 +#define MVPU_ADAPTER_0 0x00000001 +#define MVPU_ADAPTER_1 0x00000002 +#define MVPU_ADAPTER_2 0x00000004 +#define MVPU_ADAPTER_3 0x00000008 +#define ADL_DL_MAX_REGISTRY_PATH 256 + +//values for ADLMVPUStatus.iStatus +#define ADL_DL_MVPU_STATUS_OFF 0 +#define ADL_DL_MVPU_STATUS_ON 1 + +// values for ASIC family +///\defgroup define_Asic_type Detailed asic types +/// Defines for Adapter ASIC family type +/// @{ +#define ADL_ASIC_UNDEFINED 0 +#define ADL_ASIC_DISCRETE (1 << 0) +#define ADL_ASIC_INTEGRATED (1 << 1) +#define ADL_ASIC_WORKSTATION (1 << 2) +#define ADL_ASIC_FIREMV (1 << 3) +#define ADL_ASIC_XGP (1 << 4) +#define ADL_ASIC_FUSION (1 << 5) +#define ADL_ASIC_FIRESTREAM (1 << 6) +#define ADL_ASIC_EMBEDDED (1 << 7) +// Backward compatibility +#define ADL_ASIC_FIREGL ADL_ASIC_WORKSTATION +/// @} + +///\defgroup define_detailed_timing_flags Detailed Timimg Flags +/// Defines for ADLDetailedTiming.sTimingFlags field +/// @{ +#define ADL_DL_TIMINGFLAG_DOUBLE_SCAN 0x0001 +//sTimingFlags is set when the mode is INTERLACED, if not PROGRESSIVE +#define ADL_DL_TIMINGFLAG_INTERLACED 0x0002 +//sTimingFlags is set when the Horizontal Sync is POSITIVE, if not NEGATIVE +#define ADL_DL_TIMINGFLAG_H_SYNC_POLARITY 0x0004 +//sTimingFlags is set when the Vertical Sync is POSITIVE, if not NEGATIVE +#define ADL_DL_TIMINGFLAG_V_SYNC_POLARITY 0x0008 +/// @} + +///\defgroup define_modetiming_standard Timing Standards +/// Defines for ADLDisplayModeInfo.iTimingStandard field +/// @{ +#define ADL_DL_MODETIMING_STANDARD_CVT 0x00000001 // CVT Standard +#define ADL_DL_MODETIMING_STANDARD_GTF 0x00000002 // GFT Standard +#define ADL_DL_MODETIMING_STANDARD_DMT 0x00000004 // DMT Standard +#define ADL_DL_MODETIMING_STANDARD_CUSTOM 0x00000008 // User-defined standard +#define ADL_DL_MODETIMING_STANDARD_DRIVER_DEFAULT 0x00000010 // Remove Mode from overriden list +#define ADL_DL_MODETIMING_STANDARD_CVT_RB 0x00000020 // CVT-RB Standard +/// @} + +// \defgroup define_xserverinfo driver x-server info +/// These flags are used by ADL_XServerInfo_Get() +// @ + +/// Xinerama is active in the x-server, Xinerama extension may report it to be active but it +/// may not be active in x-server +#define ADL_XSERVERINFO_XINERAMAACTIVE (1<<0) + +/// RandR 1.2 is supported by driver, RandR extension may report version 1.2 +/// but driver may not support it +#define ADL_XSERVERINFO_RANDR12SUPPORTED (1<<1) +// @ + + +///\defgroup define_eyefinity_constants Eyefinity Definitions +/// @{ + +#define ADL_CONTROLLERVECTOR_0 1 // ADL_CONTROLLERINDEX_0 = 0, (1 << ADL_CONTROLLERINDEX_0) +#define ADL_CONTROLLERVECTOR_1 2 // ADL_CONTROLLERINDEX_1 = 1, (1 << ADL_CONTROLLERINDEX_1) + +#define ADL_DISPLAY_SLSGRID_ORIENTATION_000 0x00000001 +#define ADL_DISPLAY_SLSGRID_ORIENTATION_090 0x00000002 +#define ADL_DISPLAY_SLSGRID_ORIENTATION_180 0x00000004 +#define ADL_DISPLAY_SLSGRID_ORIENTATION_270 0x00000008 +#define ADL_DISPLAY_SLSGRID_CAP_OPTION_RELATIVETO_LANDSCAPE 0x00000001 +#define ADL_DISPLAY_SLSGRID_CAP_OPTION_RELATIVETO_CURRENTANGLE 0x00000002 +#define ADL_DISPLAY_SLSGRID_PORTAIT_MODE 0x00000004 +#define ADL_DISPLAY_SLSGRID_KEEPTARGETROTATION 0x00000080 + +#define ADL_DISPLAY_SLSGRID_SAMEMODESLS_SUPPORT 0x00000010 +#define ADL_DISPLAY_SLSGRID_MIXMODESLS_SUPPORT 0x00000020 +#define ADL_DISPLAY_SLSGRID_DISPLAYROTATION_SUPPORT 0x00000040 +#define ADL_DISPLAY_SLSGRID_DESKTOPROTATION_SUPPORT 0x00000080 + + +#define ADL_DISPLAY_SLSMAP_SLSLAYOUTMODE_FIT 0x0100 +#define ADL_DISPLAY_SLSMAP_SLSLAYOUTMODE_FILL 0x0200 +#define ADL_DISPLAY_SLSMAP_SLSLAYOUTMODE_EXPAND 0x0400 + +#define ADL_DISPLAY_SLSMAP_IS_SLS 0x1000 +#define ADL_DISPLAY_SLSMAP_IS_SLSBUILDER 0x2000 +#define ADL_DISPLAY_SLSMAP_IS_CLONEVT 0x4000 + +#define ADL_DISPLAY_SLSMAPCONFIG_GET_OPTION_RELATIVETO_LANDSCAPE 0x00000001 +#define ADL_DISPLAY_SLSMAPCONFIG_GET_OPTION_RELATIVETO_CURRENTANGLE 0x00000002 + +#define ADL_DISPLAY_SLSMAPCONFIG_CREATE_OPTION_RELATIVETO_LANDSCAPE 0x00000001 +#define ADL_DISPLAY_SLSMAPCONFIG_CREATE_OPTION_RELATIVETO_CURRENTANGLE 0x00000002 + +#define ADL_DISPLAY_SLSMAPCONFIG_REARRANGE_OPTION_RELATIVETO_LANDSCAPE 0x00000001 +#define ADL_DISPLAY_SLSMAPCONFIG_REARRANGE_OPTION_RELATIVETO_CURRENTANGLE 0x00000002 + +#define ADL_SLS_SAMEMODESLS_SUPPORT 0x0001 +#define ADL_SLS_MIXMODESLS_SUPPORT 0x0002 +#define ADL_SLS_DISPLAYROTATIONSLS_SUPPORT 0x0004 +#define ADL_SLS_DESKTOPROTATIONSLS_SUPPORT 0x0008 + +#define ADL_SLS_TARGETS_INVALID 0x0001 +#define ADL_SLS_MODES_INVALID 0x0002 +#define ADL_SLS_ROTATIONS_INVALID 0x0004 +#define ADL_SLS_POSITIONS_INVALID 0x0008 +#define ADL_SLS_LAYOUTMODE_INVALID 0x0010 + +#define ADL_DISPLAY_SLSDISPLAYOFFSET_VALID 0x0002 + +#define ADL_DISPLAY_SLSGRID_RELATIVETO_LANDSCAPE 0x00000010 +#define ADL_DISPLAY_SLSGRID_RELATIVETO_CURRENTANGLE 0x00000020 + + +/// The bit mask identifies displays is currently in bezel mode. +#define ADL_DISPLAY_SLSMAP_BEZELMODE 0x00000010 +/// The bit mask identifies displays from this map is arranged. +#define ADL_DISPLAY_SLSMAP_DISPLAYARRANGED 0x00000002 +/// The bit mask identifies this map is currently in used for the current adapter. +#define ADL_DISPLAY_SLSMAP_CURRENTCONFIG 0x00000004 + +///For onlay active SLS map info +#define ADL_DISPLAY_SLSMAPINDEXLIST_OPTION_ACTIVE 0x00000001 + +///For Bezel +#define ADL_DISPLAY_BEZELOFFSET_STEPBYSTEPSET 0x00000004 +#define ADL_DISPLAY_BEZELOFFSET_COMMIT 0x00000008 + +typedef enum SLS_ImageCropType { + Fit = 1, + Fill = 2, + Expand = 3 +}SLS_ImageCropType; + + +typedef enum DceSettingsType { + DceSetting_HdmiLq, + DceSetting_DpSettings, + DceSetting_Protection + +} DceSettingsType; + +typedef enum DpLinkRate { + DPLinkRate_Unknown, + DPLinkRate_RBR, + DPLinkRate_2_16Gbps, + DPLinkRate_2_43Gbps, + DPLinkRate_HBR, + DPLinkRate_4_32Gbps, + DPLinkRate_HBR2, + DPLinkRate_HBR3, + DPLinkRate_UHBR10, + DPLinkRate_UHBR13D5, + DPLinkRate_UHBR20 + +} DpLinkRate; + +/// @} + +///\defgroup define_powerxpress_constants PowerXpress Definitions +/// @{ + +/// The bit mask identifies PX caps for ADLPXConfigCaps.iPXConfigCapMask and ADLPXConfigCaps.iPXConfigCapValue +#define ADL_PX_CONFIGCAPS_SPLASHSCREEN_SUPPORT 0x0001 +#define ADL_PX_CONFIGCAPS_CF_SUPPORT 0x0002 +#define ADL_PX_CONFIGCAPS_MUXLESS 0x0004 +#define ADL_PX_CONFIGCAPS_PROFILE_COMPLIANT 0x0008 +#define ADL_PX_CONFIGCAPS_NON_AMD_DRIVEN_DISPLAYS 0x0010 +#define ADL_PX_CONFIGCAPS_FIXED_SUPPORT 0x0020 +#define ADL_PX_CONFIGCAPS_DYNAMIC_SUPPORT 0x0040 +#define ADL_PX_CONFIGCAPS_HIDE_AUTO_SWITCH 0x0080 + +/// The bit mask identifies PX schemes for ADLPXSchemeRange +#define ADL_PX_SCHEMEMASK_FIXED 0x0001 +#define ADL_PX_SCHEMEMASK_DYNAMIC 0x0002 + +/// PX Schemes +typedef enum ADLPXScheme +{ + ADL_PX_SCHEME_INVALID = 0, + ADL_PX_SCHEME_FIXED = ADL_PX_SCHEMEMASK_FIXED, + ADL_PX_SCHEME_DYNAMIC = ADL_PX_SCHEMEMASK_DYNAMIC +}ADLPXScheme; + +/// Just keep the old definitions for compatibility, need to be removed later +typedef enum PXScheme +{ + PX_SCHEME_INVALID = 0, + PX_SCHEME_FIXED = 1, + PX_SCHEME_DYNAMIC = 2 +} PXScheme; + + +/// @} + +///\defgroup define_appprofiles For Application Profiles +/// @{ + +#define ADL_APP_PROFILE_FILENAME_LENGTH 256 +#define ADL_APP_PROFILE_TIMESTAMP_LENGTH 32 +#define ADL_APP_PROFILE_VERSION_LENGTH 32 +#define ADL_APP_PROFILE_PROPERTY_LENGTH 64 + +enum ApplicationListType +{ + ADL_PX40_MRU, + ADL_PX40_MISSED, + ADL_PX40_DISCRETE, + ADL_PX40_INTEGRATED, + ADL_MMD_PROFILED, + ADL_PX40_TOTAL +}; + +typedef enum ADLProfilePropertyType +{ + ADL_PROFILEPROPERTY_TYPE_BINARY = 0, + ADL_PROFILEPROPERTY_TYPE_BOOLEAN, + ADL_PROFILEPROPERTY_TYPE_DWORD, + ADL_PROFILEPROPERTY_TYPE_QWORD, + ADL_PROFILEPROPERTY_TYPE_ENUMERATED, + ADL_PROFILEPROPERTY_TYPE_STRING +}ADLProfilePropertyType; + + +//Virtual display type returning virtual display type and for request for creating a dummy target ID (xInput or remote play) +typedef enum ADL_VIRTUALDISPLAY_TYPE +{ + ADL_VIRTUALDISPLAY_NONE = 0, + ADL_VIRTUALDISPLAY_XINPUT = 1, //Requested for xInput + ADL_VIRTUALDISPLAY_REMOTEPLAY = 2, //Requested for emulated display during remote play + ADL_VIRTUALDISPLAY_GENERIC = 10 //Generic virtual display, af a type different than any of the above special ones +}ADL_VIRTUALDISPLAY_TYPE; + +/// @} + +///\defgroup define_dp12 For Display Port 1.2 +/// @{ + +/// Maximum Relative Address Link +#define ADL_MAX_RAD_LINK_COUNT 15 + +/// @} + +///\defgroup defines_gamutspace Driver Supported Gamut Space +/// @{ + +/// The flags desribes that gamut is related to source or to destination and to overlay or to graphics +#define ADL_GAMUT_REFERENCE_SOURCE (1 << 0) +#define ADL_GAMUT_GAMUT_VIDEO_CONTENT (1 << 1) + +/// The flags are used to describe the source of gamut and how read information from struct ADLGamutData +#define ADL_CUSTOM_WHITE_POINT (1 << 0) +#define ADL_CUSTOM_GAMUT (1 << 1) +#define ADL_GAMUT_REMAP_ONLY (1 << 2) + +/// The define means the predefined gamut values . +///Driver uses to find entry in the table and apply appropriate gamut space. +#define ADL_GAMUT_SPACE_CCIR_709 (1 << 0) +#define ADL_GAMUT_SPACE_CCIR_601 (1 << 1) +#define ADL_GAMUT_SPACE_ADOBE_RGB (1 << 2) +#define ADL_GAMUT_SPACE_CIE_RGB (1 << 3) +#define ADL_GAMUT_SPACE_CUSTOM (1 << 4) +#define ADL_GAMUT_SPACE_CCIR_2020 (1 << 5) +#define ADL_GAMUT_SPACE_APPCTRL (1 << 6) + +/// Predefine white point values are structed similar to gamut . +#define ADL_WHITE_POINT_5000K (1 << 0) +#define ADL_WHITE_POINT_6500K (1 << 1) +#define ADL_WHITE_POINT_7500K (1 << 2) +#define ADL_WHITE_POINT_9300K (1 << 3) +#define ADL_WHITE_POINT_CUSTOM (1 << 4) + +///gamut and white point coordinates are from 0.0 -1.0 and divider is used to find the real value . +/// X float = X int /divider +#define ADL_GAMUT_WHITEPOINT_DIVIDER 10000 + +///gamma a0 coefficient uses the following divider: +#define ADL_REGAMMA_COEFFICIENT_A0_DIVIDER 10000000 +///gamma a1 ,a2,a3 coefficients use the following divider: +#define ADL_REGAMMA_COEFFICIENT_A1A2A3_DIVIDER 1000 + +///describes whether the coefficients are from EDID or custom user values. +#define ADL_EDID_REGAMMA_COEFFICIENTS (1 << 0) +///Used for struct ADLRegamma. Feature if set use gamma ramp, if missing use regamma coefficents +#define ADL_USE_GAMMA_RAMP (1 << 4) +///Used for struct ADLRegamma. If the gamma ramp flag is used then the driver could apply de gamma corretion to the supplied curve and this depends on this flag +#define ADL_APPLY_DEGAMMA (1 << 5) +///specifies that standard SRGB gamma should be applied +#define ADL_EDID_REGAMMA_PREDEFINED_SRGB (1 << 1) +///specifies that PQ gamma curve should be applied +#define ADL_EDID_REGAMMA_PREDEFINED_PQ (1 << 2) +///specifies that PQ gamma curve should be applied, lower max nits +#define ADL_EDID_REGAMMA_PREDEFINED_PQ_2084_INTERIM (1 << 3) +///specifies that 3.6 gamma should be applied +#define ADL_EDID_REGAMMA_PREDEFINED_36 (1 << 6) +///specifies that BT709 gama should be applied +#define ADL_EDID_REGAMMA_PREDEFINED_BT709 (1 << 7) +///specifies that regamma should be disabled, and application controls regamma content (of the whole screen) +#define ADL_EDID_REGAMMA_PREDEFINED_APPCTRL (1 << 8) + +/// @} + +/// \defgroup define_ddcinfo_pixelformats DDCInfo Pixel Formats +/// @{ +/// defines for iPanelPixelFormat in struct ADLDDCInfo2 +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB656 0x00000001L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB666 0x00000002L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB888 0x00000004L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB101010 0x00000008L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB161616 0x00000010L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB_RESERVED1 0x00000020L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB_RESERVED2 0x00000040L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB_RESERVED3 0x00000080L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_XRGB_BIAS101010 0x00000100L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR444_8BPCC 0x00000200L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR444_10BPCC 0x00000400L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR444_12BPCC 0x00000800L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR422_8BPCC 0x00001000L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR422_10BPCC 0x00002000L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR422_12BPCC 0x00004000L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR420_8BPCC 0x00008000L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR420_10BPCC 0x00010000L +#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR420_12BPCC 0x00020000L +/// @} + +/// \defgroup define_source_content_TF ADLSourceContentAttributes transfer functions (gamma) +/// @{ +/// defines for iTransferFunction in ADLSourceContentAttributes +#define ADL_TF_sRGB 0x0001 ///< sRGB +#define ADL_TF_BT709 0x0002 ///< BT.709 +#define ADL_TF_PQ2084 0x0004 ///< PQ2084 +#define ADL_TF_PQ2084_INTERIM 0x0008 ///< PQ2084-Interim +#define ADL_TF_LINEAR_0_1 0x0010 ///< Linear 0 - 1 +#define ADL_TF_LINEAR_0_125 0x0020 ///< Linear 0 - 125 +#define ADL_TF_DOLBYVISION 0x0040 ///< DolbyVision +#define ADL_TF_GAMMA_22 0x0080 ///< Plain 2.2 gamma curve +/// @} + +/// \defgroup define_source_content_CS ADLSourceContentAttributes color spaces +/// @{ +/// defines for iColorSpace in ADLSourceContentAttributes +#define ADL_CS_sRGB 0x0001 ///< sRGB +#define ADL_CS_BT601 0x0002 ///< BT.601 +#define ADL_CS_BT709 0x0004 ///< BT.709 +#define ADL_CS_BT2020 0x0008 ///< BT.2020 +#define ADL_CS_ADOBE 0x0010 ///< Adobe RGB +#define ADL_CS_P3 0x0020 ///< DCI-P3 +#define ADL_CS_scRGB_MS_REF 0x0040 ///< scRGB (MS Reference) +#define ADL_CS_DISPLAY_NATIVE 0x0080 ///< Display Native +#define ADL_CS_APP_CONTROL 0x0100 ///< Application Controlled +#define ADL_CS_DOLBYVISION 0x0200 ///< DolbyVision +/// @} + +/// \defgroup define_HDR_support ADLDDCInfo2 HDR support options +/// @{ +/// defines for iSupportedHDR in ADLDDCInfo2 +#define ADL_HDR_CEA861_3 0x0001 ///< HDR10/CEA861.3 HDR supported +#define ADL_HDR_DOLBYVISION 0x0002 ///< \deprecated DolbyVision HDR supported +#define ADL_HDR_FREESYNC_HDR 0x0004 ///< FreeSync HDR supported +/// @} + +/// \defgroup define_FreesyncFlags ADLDDCInfo2 Freesync HDR flags +/// @{ +/// defines for iFreesyncFlags in ADLDDCInfo2 +#define ADL_HDR_FREESYNC_BACKLIGHT_SUPPORT 0x0001 ///< Global backlight control supported +#define ADL_HDR_FREESYNC_LOCAL_DIMMING 0x0002 ///< Local dimming supported +/// @} + +/// \defgroup define_source_content_flags ADLSourceContentAttributes flags +/// @{ +/// defines for iFlags in ADLSourceContentAttributes +#define ADL_SCA_LOCAL_DIMMING_DISABLE 0x0001 ///< Disable local dimming +/// @} + +/// \defgroup define_dbd_state Deep Bit Depth +/// @{ + +/// defines for ADL_Workstation_DeepBitDepth_Get and ADL_Workstation_DeepBitDepth_Set functions +// This value indicates that the deep bit depth state is forced off +#define ADL_DEEPBITDEPTH_FORCEOFF 0 +/// This value indicates that the deep bit depth state is set to auto, the driver will automatically enable the +/// appropriate deep bit depth state depending on what connected display supports. +#define ADL_DEEPBITDEPTH_10BPP_AUTO 1 +/// This value indicates that the deep bit depth state is forced on to 10 bits per pixel, this is regardless if the display +/// supports 10 bpp. +#define ADL_DEEPBITDEPTH_10BPP_FORCEON 2 + +/// defines for ADLAdapterConfigMemory of ADL_Adapter_ConfigMemory_Get +/// If this bit is set, it indicates that the Deep Bit Depth pixel is set on the display +#define ADL_ADAPTER_CONFIGMEMORY_DBD (1 << 0) +/// If this bit is set, it indicates that the display is rotated (90, 180 or 270) +#define ADL_ADAPTER_CONFIGMEMORY_ROTATE (1 << 1) +/// If this bit is set, it indicates that passive stereo is set on the display +#define ADL_ADAPTER_CONFIGMEMORY_STEREO_PASSIVE (1 << 2) +/// If this bit is set, it indicates that the active stereo is set on the display +#define ADL_ADAPTER_CONFIGMEMORY_STEREO_ACTIVE (1 << 3) +/// If this bit is set, it indicates that the tear free vsync is set on the display +#define ADL_ADAPTER_CONFIGMEMORY_ENHANCEDVSYNC (1 << 4) +#define ADL_ADAPTER_CONFIGMEMORY_TEARFREEVSYNC (1 << 4) +/// @} + +/// \defgroup define_adl_validmemoryrequiredfields Memory Type +/// @{ + +/// This group defines memory types in ADLMemoryRequired struct \n +/// Indicates that this is the visible memory +#define ADL_MEMORYREQTYPE_VISIBLE (1 << 0) +/// Indicates that this is the invisible memory. +#define ADL_MEMORYREQTYPE_INVISIBLE (1 << 1) +/// Indicates that this is amount of visible memory per GPU that should be reserved for all other allocations. +#define ADL_MEMORYREQTYPE_GPURESERVEDVISIBLE (1 << 2) +/// @} + +/// \defgroup define_adapter_tear_free_status +/// Used in ADL_Adapter_TEAR_FREE_Set and ADL_Adapter_TFD_Get functions to indicate the tear free +/// desktop status. +/// @{ +/// Tear free desktop is enabled. +#define ADL_ADAPTER_TEAR_FREE_ON 1 +/// Tear free desktop can't be enabled due to a lack of graphic adapter memory. +#define ADL_ADAPTER_TEAR_FREE_NOTENOUGHMEM -1 +/// Tear free desktop can't be enabled due to quad buffer stereo being enabled. +#define ADL_ADAPTER_TEAR_FREE_OFF_ERR_QUADBUFFERSTEREO -2 +/// Tear free desktop can't be enabled due to MGPU-SLS being enabled. +#define ADL_ADAPTER_TEAR_FREE_OFF_ERR_MGPUSLD -3 +/// Tear free desktop is disabled. +#define ADL_ADAPTER_TEAR_FREE_OFF 0 +/// @} + +/// \defgroup define_adapter_crossdisplay_platforminfo +/// Used in ADL_Adapter_CrossDisplayPlatformInfo_Get function to indicate the Crossdisplay platform info. +/// @{ +/// CROSSDISPLAY platform. +#define ADL_CROSSDISPLAY_PLATFORM (1 << 0) +/// CROSSDISPLAY platform for Lasso station. +#define ADL_CROSSDISPLAY_PLATFORM_LASSO (1 << 1) +/// CROSSDISPLAY platform for docking station. +#define ADL_CROSSDISPLAY_PLATFORM_DOCKSTATION (1 << 2) +/// @} + +/// \defgroup define_adapter_crossdisplay_option +/// Used in ADL_Adapter_CrossdisplayInfoX2_Set function to indicate cross display options. +/// @{ +/// Checking if 3D application is runnning. If yes, not to do switch, return ADL_OK_WAIT; otherwise do switch. +#define ADL_CROSSDISPLAY_OPTION_NONE 0 +/// Force switching without checking for running 3D applications +#define ADL_CROSSDISPLAY_OPTION_FORCESWITCH (1 << 0) +/// @} + +/// \defgroup define_adapter_states Adapter Capabilities +/// These defines the capabilities supported by an adapter. It is used by \ref ADL_Adapter_ConfigureState_Get +/// @{ +/// Indicates that the adapter is headless (i.e. no displays can be connected to it) +#define ADL_ADAPTERCONFIGSTATE_HEADLESS ( 1 << 2 ) +/// Indicates that the adapter is configured to define the main rendering capabilities. For example, adapters +/// in Crossfire(TM) configuration, this bit would only be set on the adapter driving the display(s). +#define ADL_ADAPTERCONFIGSTATE_REQUISITE_RENDER ( 1 << 0 ) +/// Indicates that the adapter is configured to be used to unload some of the rendering work for a particular +/// requisite rendering adapter. For eample, for adapters in a Crossfire configuration, this bit would be set +/// on all adapters that are currently not driving the display(s) +#define ADL_ADAPTERCONFIGSTATE_ANCILLARY_RENDER ( 1 << 1 ) +/// Indicates that scatter gather feature enabled on the adapter +#define ADL_ADAPTERCONFIGSTATE_SCATTERGATHER ( 1 << 4 ) +/// @} + +/// \defgroup define_controllermode_ulModifiers +/// These defines the detailed actions supported by set viewport. It is used by \ref ADL_Display_ViewPort_Set +/// @{ +/// Indicate that the viewport set will change the view position +#define ADL_CONTROLLERMODE_CM_MODIFIER_VIEW_POSITION 0x00000001 +/// Indicate that the viewport set will change the view PanLock +#define ADL_CONTROLLERMODE_CM_MODIFIER_VIEW_PANLOCK 0x00000002 +/// Indicate that the viewport set will change the view size +#define ADL_CONTROLLERMODE_CM_MODIFIER_VIEW_SIZE 0x00000008 +/// @} + +/// \defgroup defines for Mirabilis +/// These defines are used for the Mirabilis feature +/// @{ +/// +/// Indicates the maximum number of audio sample rates +#define ADL_MAX_AUDIO_SAMPLE_RATE_COUNT 16 +/// @} + +/////////////////////////////////////////////////////////////////////////// +// ADLMultiChannelSplitStateFlag Enumeration +/////////////////////////////////////////////////////////////////////////// +enum ADLMultiChannelSplitStateFlag +{ + ADLMultiChannelSplit_Unitialized = 0, + ADLMultiChannelSplit_Disabled = 1, + ADLMultiChannelSplit_Enabled = 2, + ADLMultiChannelSplit_SaveProfile = 3 +}; + +/////////////////////////////////////////////////////////////////////////// +// ADLSampleRate Enumeration +/////////////////////////////////////////////////////////////////////////// +enum ADLSampleRate +{ + ADLSampleRate_32KHz =0, + ADLSampleRate_44P1KHz, + ADLSampleRate_48KHz, + ADLSampleRate_88P2KHz, + ADLSampleRate_96KHz, + ADLSampleRate_176P4KHz, + ADLSampleRate_192KHz, + ADLSampleRate_384KHz, //DP1.2 + ADLSampleRate_768KHz, //DP1.2 + ADLSampleRate_Undefined +}; + +/// \defgroup define_overdrive6_capabilities +/// These defines the capabilities supported by Overdrive 6. It is used by \ref ADL_Overdrive6_Capabilities_Get +/// @{ +/// Indicate that core (engine) clock can be changed. +#define ADL_OD6_CAPABILITY_SCLK_CUSTOMIZATION 0x00000001 +/// Indicate that memory clock can be changed. +#define ADL_OD6_CAPABILITY_MCLK_CUSTOMIZATION 0x00000002 +/// Indicate that graphics activity reporting is supported. +#define ADL_OD6_CAPABILITY_GPU_ACTIVITY_MONITOR 0x00000004 +/// Indicate that power limit can be customized. +#define ADL_OD6_CAPABILITY_POWER_CONTROL 0x00000008 +/// Indicate that SVI2 Voltage Control is supported. +#define ADL_OD6_CAPABILITY_VOLTAGE_CONTROL 0x00000010 +/// Indicate that OD6+ percentage adjustment is supported. +#define ADL_OD6_CAPABILITY_PERCENT_ADJUSTMENT 0x00000020 +/// Indicate that Thermal Limit Unlock is supported. +#define ADL_OD6_CAPABILITY_THERMAL_LIMIT_UNLOCK 0x00000040 +///Indicate that Fan speed needs to be displayed in RPM +#define ADL_OD6_CAPABILITY_FANSPEED_IN_RPM 0x00000080 +/// @} + +/// \defgroup define_overdrive6_supported_states +/// These defines the power states supported by Overdrive 6. It is used by \ref ADL_Overdrive6_Capabilities_Get +/// @{ +/// Indicate that overdrive is supported in the performance state. This is currently the only state supported. +#define ADL_OD6_SUPPORTEDSTATE_PERFORMANCE 0x00000001 +/// Do not use. Reserved for future use. +#define ADL_OD6_SUPPORTEDSTATE_POWER_SAVING 0x00000002 +/// @} + +/// \defgroup define_overdrive6_getstateinfo +/// These defines the power states to get information about. It is used by \ref ADL_Overdrive6_StateInfo_Get +/// @{ +/// Get default clocks for the performance state. +#define ADL_OD6_GETSTATEINFO_DEFAULT_PERFORMANCE 0x00000001 +/// Do not use. Reserved for future use. +#define ADL_OD6_GETSTATEINFO_DEFAULT_POWER_SAVING 0x00000002 +/// Get clocks for current state. Currently this is the same as \ref ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE +/// since only performance state is supported. +#define ADL_OD6_GETSTATEINFO_CURRENT 0x00000003 +/// Get the modified clocks (if any) for the performance state. If clocks were not modified +/// through Overdrive 6, then this will return the same clocks as \ref ADL_OD6_GETSTATEINFO_DEFAULT_PERFORMANCE. +#define ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE 0x00000004 +/// Do not use. Reserved for future use. +#define ADL_OD6_GETSTATEINFO_CUSTOM_POWER_SAVING 0x00000005 +/// @} + +/// \defgroup define_overdrive6_getstate and define_overdrive6_getmaxclockadjust +/// These defines the power states to get information about. It is used by \ref ADL_Overdrive6_StateEx_Get and \ref ADL_Overdrive6_MaxClockAdjust_Get +/// @{ +/// Get default clocks for the performance state. Only performance state is currently supported. +#define ADL_OD6_STATE_PERFORMANCE 0x00000001 +/// @} + +/// \defgroup define_overdrive6_setstate +/// These define which power state to set customized clocks on. It is used by \ref ADL_Overdrive6_State_Set +/// @{ +/// Set customized clocks for the performance state. +#define ADL_OD6_SETSTATE_PERFORMANCE 0x00000001 +/// Do not use. Reserved for future use. +#define ADL_OD6_SETSTATE_POWER_SAVING 0x00000002 +/// @} + +/// \defgroup define_overdrive6_thermalcontroller_caps +/// These defines the capabilities of the GPU thermal controller. It is used by \ref ADL_Overdrive6_ThermalController_Caps +/// @{ +/// GPU thermal controller is supported. +#define ADL_OD6_TCCAPS_THERMAL_CONTROLLER 0x00000001 +/// GPU fan speed control is supported. +#define ADL_OD6_TCCAPS_FANSPEED_CONTROL 0x00000002 +/// Fan speed percentage can be read. +#define ADL_OD6_TCCAPS_FANSPEED_PERCENT_READ 0x00000100 +/// Fan speed can be set by specifying a percentage value. +#define ADL_OD6_TCCAPS_FANSPEED_PERCENT_WRITE 0x00000200 +/// Fan speed RPM (revolutions-per-minute) can be read. +#define ADL_OD6_TCCAPS_FANSPEED_RPM_READ 0x00000400 +/// Fan speed can be set by specifying an RPM value. +#define ADL_OD6_TCCAPS_FANSPEED_RPM_WRITE 0x00000800 +/// @} + +/// \defgroup define_overdrive6_fanspeed_type +/// These defines the fan speed type being reported. It is used by \ref ADL_Overdrive6_FanSpeed_Get +/// @{ +/// Fan speed reported in percentage. +#define ADL_OD6_FANSPEED_TYPE_PERCENT 0x00000001 +/// Fan speed reported in RPM. +#define ADL_OD6_FANSPEED_TYPE_RPM 0x00000002 +/// Fan speed has been customized by the user, and fan is not running in automatic mode. +#define ADL_OD6_FANSPEED_USER_DEFINED 0x00000100 +/// @} + +/// \defgroup define_overdrive_EventCounter_type +/// These defines the EventCounter type being reported. It is used by \ref ADL2_OverdriveN_CountOfEvents_Get ,can be used on older OD version supported ASICs also. +/// @{ +#define ADL_ODN_EVENTCOUNTER_THERMAL 0 +#define ADL_ODN_EVENTCOUNTER_VPURECOVERY 1 +/// @} + +/////////////////////////////////////////////////////////////////////////// +// ADLODNControlType Enumeration +/////////////////////////////////////////////////////////////////////////// +enum ADLODNControlType +{ + ODNControlType_Current = 0, + ODNControlType_Default, + ODNControlType_Auto, + ODNControlType_Manual +}; + +enum ADLODNDPMMaskType +{ + ADL_ODN_DPM_CLOCK = 1 << 0, + ADL_ODN_DPM_VDDC = 1 << 1, + ADL_ODN_DPM_MASK = 1 << 2, +}; + +//ODN features Bits for ADLODNCapabilitiesX2 +enum ADLODNFeatureControl +{ + ADL_ODN_SCLK_DPM = 1 << 0, + ADL_ODN_MCLK_DPM = 1 << 1, + ADL_ODN_SCLK_VDD = 1 << 2, + ADL_ODN_MCLK_VDD = 1 << 3, + ADL_ODN_FAN_SPEED_MIN = 1 << 4, + ADL_ODN_FAN_SPEED_TARGET = 1 << 5, + ADL_ODN_ACOUSTIC_LIMIT_SCLK = 1 << 6, + ADL_ODN_TEMPERATURE_FAN_MAX = 1 << 7, + ADL_ODN_TEMPERATURE_SYSTEM = 1 << 8, + ADL_ODN_POWER_LIMIT = 1 << 9, + ADL_ODN_SCLK_AUTO_LIMIT = 1 << 10, + ADL_ODN_MCLK_AUTO_LIMIT = 1 << 11, + ADL_ODN_SCLK_DPM_MASK_ENABLE = 1 << 12, + ADL_ODN_MCLK_DPM_MASK_ENABLE = 1 << 13, + ADL_ODN_MCLK_UNDERCLOCK_ENABLE = 1 << 14, + ADL_ODN_SCLK_DPM_THROTTLE_NOTIFY = 1 << 15, + ADL_ODN_POWER_UTILIZATION = 1 << 16, + ADL_ODN_PERF_TUNING_SLIDER = 1 << 17, + ADL_ODN_REMOVE_WATTMAN_PAGE = 1 << 31 // Internal Only +}; + +//If any new feature is added, PPLIB only needs to add ext feature ID and Item ID(Seeting ID). These IDs should match the drive defined in CWDDEPM.h +enum ADLODNExtFeatureControl +{ + ADL_ODN_EXT_FEATURE_MEMORY_TIMING_TUNE = 1 << 0, + ADL_ODN_EXT_FEATURE_FAN_ZERO_RPM_CONTROL = 1 << 1, + ADL_ODN_EXT_FEATURE_AUTO_UV_ENGINE = 1 << 2, //Auto under voltage + ADL_ODN_EXT_FEATURE_AUTO_OC_ENGINE = 1 << 3, //Auto OC Enine + ADL_ODN_EXT_FEATURE_AUTO_OC_MEMORY = 1 << 4, //Auto OC memory + ADL_ODN_EXT_FEATURE_FAN_CURVE = 1 << 5 //Fan curve + +}; + +//If any new feature is added, PPLIB only needs to add ext feature ID and Item ID(Seeting ID).These IDs should match the drive defined in CWDDEPM.h +enum ADLODNExtSettingId +{ + ADL_ODN_PARAMETER_AC_TIMING = 0, + ADL_ODN_PARAMETER_FAN_ZERO_RPM_CONTROL, + ADL_ODN_PARAMETER_AUTO_UV_ENGINE, + ADL_ODN_PARAMETER_AUTO_OC_ENGINE, + ADL_ODN_PARAMETER_AUTO_OC_MEMORY, + ADL_ODN_PARAMETER_FAN_CURVE_TEMPERATURE_1, + ADL_ODN_PARAMETER_FAN_CURVE_SPEED_1, + ADL_ODN_PARAMETER_FAN_CURVE_TEMPERATURE_2, + ADL_ODN_PARAMETER_FAN_CURVE_SPEED_2, + ADL_ODN_PARAMETER_FAN_CURVE_TEMPERATURE_3, + ADL_ODN_PARAMETER_FAN_CURVE_SPEED_3, + ADL_ODN_PARAMETER_FAN_CURVE_TEMPERATURE_4, + ADL_ODN_PARAMETER_FAN_CURVE_SPEED_4, + ADL_ODN_PARAMETER_FAN_CURVE_TEMPERATURE_5, + ADL_ODN_PARAMETER_FAN_CURVE_SPEED_5, + ADL_ODN_POWERGAUGE, + ODN_COUNT + +} ; + +//OD8 Capability features bits +enum ADLOD8FeatureControl +{ + ADL_OD8_GFXCLK_LIMITS = 1 << 0, + ADL_OD8_GFXCLK_CURVE = 1 << 1, + ADL_OD8_UCLK_MAX = 1 << 2, + ADL_OD8_POWER_LIMIT = 1 << 3, + ADL_OD8_ACOUSTIC_LIMIT_SCLK = 1 << 4, //FanMaximumRpm + ADL_OD8_FAN_SPEED_MIN = 1 << 5, //FanMinimumPwm + ADL_OD8_TEMPERATURE_FAN = 1 << 6, //FanTargetTemperature + ADL_OD8_TEMPERATURE_SYSTEM = 1 << 7, //MaxOpTemp + ADL_OD8_MEMORY_TIMING_TUNE = 1 << 8, + ADL_OD8_FAN_ZERO_RPM_CONTROL = 1 << 9 , + ADL_OD8_AUTO_UV_ENGINE = 1 << 10, //Auto under voltage + ADL_OD8_AUTO_OC_ENGINE = 1 << 11, //Auto overclock engine + ADL_OD8_AUTO_OC_MEMORY = 1 << 12, //Auto overclock memory + ADL_OD8_FAN_CURVE = 1 << 13, //Fan curve + ADL_OD8_WS_AUTO_FAN_ACOUSTIC_LIMIT = 1 << 14, //Workstation Manual Fan controller + ADL_OD8_GFXCLK_QUADRATIC_CURVE = 1 << 15, + ADL_OD8_OPTIMIZED_GPU_POWER_MODE = 1 << 16, + ADL_OD8_ODVOLTAGE_LIMIT = 1 << 17, + ADL_OD8_ADV_OC_LIMITS = 1 << 18, //Advanced OC limits. + ADL_OD8_PER_ZONE_GFX_VOLTAGE_OFFSET = 1 << 19, //Per Zone gfx voltage offset feature + ADL_OD8_AUTO_CURVE_OPTIMIZER = 1 << 20, //Auto per zone tuning. + ADL_OD8_GFX_VOLTAGE_LIMIT = 1 << 21, //Voltage limit slider + ADL_OD8_TDC_LIMIT = 1 << 22, //TDC slider + ADL_OD8_FULL_CONTROL_MODE = 1 << 23, //Full control + ADL_OD8_POWER_SAVING_FEATURE_CONTROL = 1 << 24, //Power saving feature control + ADL_OD8_POWER_GAUGE = 1 << 25 //Power Gauge +}; + + +typedef enum ADLOD8SettingId +{ + OD8_GFXCLK_FMAX = 0, + OD8_GFXCLK_FMIN, + OD8_GFXCLK_FREQ1, + OD8_GFXCLK_VOLTAGE1, + OD8_GFXCLK_FREQ2, + OD8_GFXCLK_VOLTAGE2, + OD8_GFXCLK_FREQ3, + OD8_GFXCLK_VOLTAGE3, + OD8_UCLK_FMAX, + OD8_POWER_PERCENTAGE, + OD8_FAN_MIN_SPEED, + OD8_FAN_ACOUSTIC_LIMIT, + OD8_FAN_TARGET_TEMP, + OD8_OPERATING_TEMP_MAX, + OD8_AC_TIMING, + OD8_FAN_ZERORPM_CONTROL, + OD8_AUTO_UV_ENGINE_CONTROL, + OD8_AUTO_OC_ENGINE_CONTROL, + OD8_AUTO_OC_MEMORY_CONTROL, + OD8_FAN_CURVE_TEMPERATURE_1, + OD8_FAN_CURVE_SPEED_1, + OD8_FAN_CURVE_TEMPERATURE_2, + OD8_FAN_CURVE_SPEED_2, + OD8_FAN_CURVE_TEMPERATURE_3, + OD8_FAN_CURVE_SPEED_3, + OD8_FAN_CURVE_TEMPERATURE_4, + OD8_FAN_CURVE_SPEED_4, + OD8_FAN_CURVE_TEMPERATURE_5, + OD8_FAN_CURVE_SPEED_5, + OD8_WS_FAN_AUTO_FAN_ACOUSTIC_LIMIT, + OD8_GFXCLK_CURVE_COEFFICIENT_A, // As part of the agreement with UI team, the min/max voltage limits for the + OD8_GFXCLK_CURVE_COEFFICIENT_B, // quadratic curve graph will be stored in the min and max limits of + OD8_GFXCLK_CURVE_COEFFICIENT_C, // coefficient a, b and c. A, b and c themselves do not have limits. + OD8_GFXCLK_CURVE_VFT_FMIN, + OD8_UCLK_FMIN, + OD8_FAN_ZERO_RPM_STOP_TEMPERATURE, + OD8_OPTIMZED_POWER_MODE, + OD8_OD_VOLTAGE,// RSX - voltage offset feature + OD8_ADV_OC_LIMITS_SETTING, + OD8_PER_ZONE_GFX_VOLTAGE_OFFSET_POINT_1, + OD8_PER_ZONE_GFX_VOLTAGE_OFFSET_POINT_2, + OD8_PER_ZONE_GFX_VOLTAGE_OFFSET_POINT_3, + OD8_PER_ZONE_GFX_VOLTAGE_OFFSET_POINT_4, + OD8_PER_ZONE_GFX_VOLTAGE_OFFSET_POINT_5, + OD8_PER_ZONE_GFX_VOLTAGE_OFFSET_POINT_6, + OD8_AUTO_CURVE_OPTIMIZER_SETTING, + OD8_GFX_VOLTAGE_LIMIT_SETTING, + OD8_TDC_PERCENTAGE, + OD8_FULL_CONTROL_MODE_SETTING, + OD8_IDLE_POWER_SAVING_FEATURE_CONTROL, + OD8_RUNTIME_POWER_SAVING_FEATURE_CONTROL, + OD8_POWER_GAUGE, + OD8_COUNT +} ADLOD8SettingId; + + +//Define Performance Metrics Log max sensors number +#define ADL_PMLOG_MAX_SENSORS 256 + +/// \deprecated Replaced with ADL_PMLOG_SENSORS +typedef enum ADLSensorType +{ + SENSOR_MAXTYPES = 0, + PMLOG_CLK_GFXCLK = 1, // Current graphic clock value in MHz + PMLOG_CLK_MEMCLK = 2, // Current memory clock value in MHz + PMLOG_CLK_SOCCLK = 3, + PMLOG_CLK_UVDCLK1 = 4, + PMLOG_CLK_UVDCLK2 = 5, + PMLOG_CLK_VCECLK = 6, + PMLOG_CLK_VCNCLK = 7, + PMLOG_TEMPERATURE_EDGE = 8, // Current edge of the die temperature value in C + PMLOG_TEMPERATURE_MEM = 9, + PMLOG_TEMPERATURE_VRVDDC = 10, + PMLOG_TEMPERATURE_VRMVDD = 11, + PMLOG_TEMPERATURE_LIQUID = 12, + PMLOG_TEMPERATURE_PLX = 13, + PMLOG_FAN_RPM = 14, // Current fan RPM value + PMLOG_FAN_PERCENTAGE = 15, // Current ratio of fan RPM and max RPM + PMLOG_SOC_VOLTAGE = 16, + PMLOG_SOC_POWER = 17, + PMLOG_SOC_CURRENT = 18, + PMLOG_INFO_ACTIVITY_GFX = 19, // Current graphic activity level in percentage + PMLOG_INFO_ACTIVITY_MEM = 20, // Current memory activity level in percentage + PMLOG_GFX_VOLTAGE = 21, // Current graphic voltage in mV + PMLOG_MEM_VOLTAGE = 22, + PMLOG_ASIC_POWER = 23, // Current ASIC power draw in Watt + PMLOG_TEMPERATURE_VRSOC = 24, + PMLOG_TEMPERATURE_VRMVDD0 = 25, + PMLOG_TEMPERATURE_VRMVDD1 = 26, + PMLOG_TEMPERATURE_HOTSPOT = 27, // Current center of the die temperature value in C + PMLOG_TEMPERATURE_GFX = 28, + PMLOG_TEMPERATURE_SOC = 29, + PMLOG_GFX_POWER = 30, + PMLOG_GFX_CURRENT = 31, + PMLOG_TEMPERATURE_CPU = 32, + PMLOG_CPU_POWER = 33, + PMLOG_CLK_CPUCLK = 34, + PMLOG_THROTTLER_STATUS = 35, // A bit map of GPU throttle information. If a bit is set, the bit represented type of thorttling occurred in the last metrics sampling period + PMLOG_CLK_VCN1CLK1 = 36, + PMLOG_CLK_VCN1CLK2 = 37, + PMLOG_SMART_POWERSHIFT_CPU = 38, + PMLOG_SMART_POWERSHIFT_DGPU = 39, + PMLOG_BUS_SPEED = 40, // Current PCIE bus speed running + PMLOG_BUS_LANES = 41, // Current PCIE bus lanes using + PMLOG_TEMPERATURE_LIQUID0 = 42, + PMLOG_TEMPERATURE_LIQUID1 = 43, + PMLOG_CLK_FCLK = 44, + PMLOG_THROTTLER_STATUS_CPU = 45, + PMLOG_SSPAIRED_ASICPOWER = 46, // apuPower + PMLOG_SSTOTAL_POWERLIMIT = 47, // Total Power limit + PMLOG_SSAPU_POWERLIMIT = 48, // APU Power limit + PMLOG_SSDGPU_POWERLIMIT = 49, // DGPU Power limit + PMLOG_TEMPERATURE_HOTSPOT_GCD = 50, + PMLOG_TEMPERATURE_HOTSPOT_MCD = 51, + PMLOG_THROTTLER_TEMP_EDGE_PERCENTAGE = 52, + PMLOG_THROTTLER_TEMP_HOTSPOT_PERCENTAGE = 53, + PMLOG_THROTTLER_TEMP_HOTSPOT_GCD_PERCENTAGE = 54, + PMLOG_THROTTLER_TEMP_HOTSPOT_MCD_PERCENTAGE = 55, + PMLOG_THROTTLER_TEMP_MEM_PERCENTAGE = 56, + PMLOG_THROTTLER_TEMP_VR_GFX_PERCENTAGE = 57, + PMLOG_THROTTLER_TEMP_VR_MEM0_PERCENTAGE = 58, + PMLOG_THROTTLER_TEMP_VR_MEM1_PERCENTAGE = 59, + PMLOG_THROTTLER_TEMP_VR_SOC_PERCENTAGE = 60, + PMLOG_THROTTLER_TEMP_LIQUID0_PERCENTAGE = 61, + PMLOG_THROTTLER_TEMP_LIQUID1_PERCENTAGE = 62, + PMLOG_THROTTLER_TEMP_PLX_PERCENTAGE = 63, + PMLOG_THROTTLER_TDC_GFX_PERCENTAGE = 64, + PMLOG_THROTTLER_TDC_SOC_PERCENTAGE = 65, + PMLOG_THROTTLER_TDC_USR_PERCENTAGE = 66, + PMLOG_THROTTLER_PPT0_PERCENTAGE = 67, + PMLOG_THROTTLER_PPT1_PERCENTAGE = 68, + PMLOG_THROTTLER_PPT2_PERCENTAGE = 69, + PMLOG_THROTTLER_PPT3_PERCENTAGE = 70, + PMLOG_THROTTLER_FIT_PERCENTAGE = 71, + PMLOG_THROTTLER_GFX_APCC_PLUS_PERCENTAGE = 72, + PMLOG_BOARD_POWER = 73, + PMLOG_MAX_SENSORS_REAL +} ADLSensorType; + + +//Throttle Status +typedef enum ADL_THROTTLE_NOTIFICATION +{ + ADL_PMLOG_THROTTLE_POWER = 1 << 0, + ADL_PMLOG_THROTTLE_THERMAL = 1 << 1, + ADL_PMLOG_THROTTLE_CURRENT = 1 << 2, +} ADL_THROTTLE_NOTIFICATION; + +typedef enum ADL_PMLOG_SENSORS +{ + ADL_SENSOR_MAXTYPES = 0, + ADL_PMLOG_CLK_GFXCLK = 1, + ADL_PMLOG_CLK_MEMCLK = 2, + ADL_PMLOG_CLK_SOCCLK = 3, + ADL_PMLOG_CLK_UVDCLK1 = 4, + ADL_PMLOG_CLK_UVDCLK2 = 5, + ADL_PMLOG_CLK_VCECLK = 6, + ADL_PMLOG_CLK_VCNCLK = 7, + ADL_PMLOG_TEMPERATURE_EDGE = 8, + ADL_PMLOG_TEMPERATURE_MEM = 9, + ADL_PMLOG_TEMPERATURE_VRVDDC = 10, + ADL_PMLOG_TEMPERATURE_VRMVDD = 11, + ADL_PMLOG_TEMPERATURE_LIQUID = 12, + ADL_PMLOG_TEMPERATURE_PLX = 13, + ADL_PMLOG_FAN_RPM = 14, + ADL_PMLOG_FAN_PERCENTAGE = 15, + ADL_PMLOG_SOC_VOLTAGE = 16, + ADL_PMLOG_SOC_POWER = 17, + ADL_PMLOG_SOC_CURRENT = 18, + ADL_PMLOG_INFO_ACTIVITY_GFX = 19, + ADL_PMLOG_INFO_ACTIVITY_MEM = 20, + ADL_PMLOG_GFX_VOLTAGE = 21, + ADL_PMLOG_MEM_VOLTAGE = 22, + ADL_PMLOG_ASIC_POWER = 23, + ADL_PMLOG_TEMPERATURE_VRSOC = 24, + ADL_PMLOG_TEMPERATURE_VRMVDD0 = 25, + ADL_PMLOG_TEMPERATURE_VRMVDD1 = 26, + ADL_PMLOG_TEMPERATURE_HOTSPOT = 27, + ADL_PMLOG_TEMPERATURE_GFX = 28, + ADL_PMLOG_TEMPERATURE_SOC = 29, + ADL_PMLOG_GFX_POWER = 30, + ADL_PMLOG_GFX_CURRENT = 31, + ADL_PMLOG_TEMPERATURE_CPU = 32, + ADL_PMLOG_CPU_POWER = 33, + ADL_PMLOG_CLK_CPUCLK = 34, + ADL_PMLOG_THROTTLER_STATUS = 35, // GFX + ADL_PMLOG_CLK_VCN1CLK1 = 36, + ADL_PMLOG_CLK_VCN1CLK2 = 37, + ADL_PMLOG_SMART_POWERSHIFT_CPU = 38, + ADL_PMLOG_SMART_POWERSHIFT_DGPU = 39, + ADL_PMLOG_BUS_SPEED = 40, + ADL_PMLOG_BUS_LANES = 41, + ADL_PMLOG_TEMPERATURE_LIQUID0 = 42, + ADL_PMLOG_TEMPERATURE_LIQUID1 = 43, + ADL_PMLOG_CLK_FCLK = 44, + ADL_PMLOG_THROTTLER_STATUS_CPU = 45, + ADL_PMLOG_SSPAIRED_ASICPOWER = 46, // apuPower + ADL_PMLOG_SSTOTAL_POWERLIMIT = 47, // Total Power limit + ADL_PMLOG_SSAPU_POWERLIMIT = 48, // APU Power limit + ADL_PMLOG_SSDGPU_POWERLIMIT = 49, // DGPU Power limit + ADL_PMLOG_TEMPERATURE_HOTSPOT_GCD = 50, + ADL_PMLOG_TEMPERATURE_HOTSPOT_MCD = 51, + ADL_PMLOG_THROTTLER_TEMP_EDGE_PERCENTAGE = 52, + ADL_PMLOG_THROTTLER_TEMP_HOTSPOT_PERCENTAGE = 53, + ADL_PMLOG_THROTTLER_TEMP_HOTSPOT_GCD_PERCENTAGE = 54, + ADL_PMLOG_THROTTLER_TEMP_HOTSPOT_MCD_PERCENTAGE = 55, + ADL_PMLOG_THROTTLER_TEMP_MEM_PERCENTAGE = 56, + ADL_PMLOG_THROTTLER_TEMP_VR_GFX_PERCENTAGE = 57, + ADL_PMLOG_THROTTLER_TEMP_VR_MEM0_PERCENTAGE = 58, + ADL_PMLOG_THROTTLER_TEMP_VR_MEM1_PERCENTAGE = 59, + ADL_PMLOG_THROTTLER_TEMP_VR_SOC_PERCENTAGE = 60, + ADL_PMLOG_THROTTLER_TEMP_LIQUID0_PERCENTAGE = 61, + ADL_PMLOG_THROTTLER_TEMP_LIQUID1_PERCENTAGE = 62, + ADL_PMLOG_THROTTLER_TEMP_PLX_PERCENTAGE = 63, + ADL_PMLOG_THROTTLER_TDC_GFX_PERCENTAGE = 64, + ADL_PMLOG_THROTTLER_TDC_SOC_PERCENTAGE = 65, + ADL_PMLOG_THROTTLER_TDC_USR_PERCENTAGE = 66, + ADL_PMLOG_THROTTLER_PPT0_PERCENTAGE = 67, + ADL_PMLOG_THROTTLER_PPT1_PERCENTAGE = 68, + ADL_PMLOG_THROTTLER_PPT2_PERCENTAGE = 69, + ADL_PMLOG_THROTTLER_PPT3_PERCENTAGE = 70, + ADL_PMLOG_THROTTLER_FIT_PERCENTAGE = 71, + ADL_PMLOG_THROTTLER_GFX_APCC_PLUS_PERCENTAGE = 72, + ADL_PMLOG_BOARD_POWER = 73, + ADL_PMLOG_MAX_SENSORS_REAL +} ADL_PMLOG_SENSORS; + +/// \defgroup define_ecc_mode_states +/// These defines the ECC(Error Correction Code) state. It is used by \ref ADL_Workstation_ECC_Get,ADL_Workstation_ECC_Set +/// @{ +/// Error Correction is OFF. +#define ECC_MODE_OFF 0 +/// Error Correction is ECCV2. +#define ECC_MODE_ON 2 +/// Error Correction is HBM. +#define ECC_MODE_HBM 3 +/// @} + +/// \defgroup define_board_layout_flags +/// These defines are the board layout flags state which indicates what are the valid properties of \ref ADLBoardLayoutInfo . It is used by \ref ADL_Adapter_BoardLayout_Get +/// @{ +/// Indicates the number of slots is valid. +#define ADL_BLAYOUT_VALID_NUMBER_OF_SLOTS 0x1 +/// Indicates the slot sizes are valid. Size of the slot consists of the length and width. +#define ADL_BLAYOUT_VALID_SLOT_SIZES 0x2 +/// Indicates the connector offsets are valid. +#define ADL_BLAYOUT_VALID_CONNECTOR_OFFSETS 0x4 +/// Indicates the connector lengths is valid. +#define ADL_BLAYOUT_VALID_CONNECTOR_LENGTHS 0x8 +/// @} + +/// \defgroup define_max_constants +/// These defines are the maximum value constants. +/// @{ +/// Indicates the Maximum supported slots on board. +#define ADL_ADAPTER_MAX_SLOTS 4 +/// Indicates the Maximum supported connectors on slot. +#define ADL_ADAPTER_MAX_CONNECTORS 10 +/// Indicates the Maximum supported properties of connection +#define ADL_MAX_CONNECTION_TYPES 32 +/// Indicates the Maximum relative address link count. +#define ADL_MAX_RELATIVE_ADDRESS_LINK_COUNT 15 +/// Indicates the Maximum size of EDID data block size +#define ADL_MAX_DISPLAY_EDID_DATA_SIZE 1024 +/// Indicates the Maximum count of Error Records. +#define ADL_MAX_ERROR_RECORDS_COUNT 256 +/// Indicates the maximum number of power states supported +#define ADL_MAX_POWER_POLICY 6 +/// @} + +/// \defgroup define_connection_types +/// These defines are the connection types constants which indicates what are the valid connection type of given connector. It is used by \ref ADL_Adapter_SupportedConnections_Get +/// @{ +/// Indicates the VGA connection type is valid. +#define ADL_CONNECTION_TYPE_VGA 0 +/// Indicates the DVI_I connection type is valid. +#define ADL_CONNECTION_TYPE_DVI 1 +/// Indicates the DVI_SL connection type is valid. +#define ADL_CONNECTION_TYPE_DVI_SL 2 +/// Indicates the HDMI connection type is valid. +#define ADL_CONNECTION_TYPE_HDMI 3 +/// Indicates the DISPLAY PORT connection type is valid. +#define ADL_CONNECTION_TYPE_DISPLAY_PORT 4 +/// Indicates the Active dongle DP->DVI(single link) connection type is valid. +#define ADL_CONNECTION_TYPE_ACTIVE_DONGLE_DP_DVI_SL 5 +/// Indicates the Active dongle DP->DVI(double link) connection type is valid. +#define ADL_CONNECTION_TYPE_ACTIVE_DONGLE_DP_DVI_DL 6 +/// Indicates the Active dongle DP->HDMI connection type is valid. +#define ADL_CONNECTION_TYPE_ACTIVE_DONGLE_DP_HDMI 7 +/// Indicates the Active dongle DP->VGA connection type is valid. +#define ADL_CONNECTION_TYPE_ACTIVE_DONGLE_DP_VGA 8 +/// Indicates the Passive dongle DP->HDMI connection type is valid. +#define ADL_CONNECTION_TYPE_PASSIVE_DONGLE_DP_HDMI 9 +/// Indicates the Active dongle DP->VGA connection type is valid. +#define ADL_CONNECTION_TYPE_PASSIVE_DONGLE_DP_DVI 10 +/// Indicates the MST type is valid. +#define ADL_CONNECTION_TYPE_MST 11 +/// Indicates the active dongle, all types. +#define ADL_CONNECTION_TYPE_ACTIVE_DONGLE 12 +/// Indicates the Virtual Connection Type. +#define ADL_CONNECTION_TYPE_VIRTUAL 13 +/// Macros for generating bitmask from index. +#define ADL_CONNECTION_BITMAST_FROM_INDEX(index) (1 << index) +/// @} + +/// \defgroup define_connection_properties +/// These defines are the connection properties which indicates what are the valid properties of given connection type. It is used by \ref ADL_Adapter_SupportedConnections_Get +/// @{ +/// Indicates the property Bitrate is valid. +#define ADL_CONNECTION_PROPERTY_BITRATE 0x1 +/// Indicates the property number of lanes is valid. +#define ADL_CONNECTION_PROPERTY_NUMBER_OF_LANES 0x2 +/// Indicates the property 3D caps is valid. +#define ADL_CONNECTION_PROPERTY_3DCAPS 0x4 +/// Indicates the property output bandwidth is valid. +#define ADL_CONNECTION_PROPERTY_OUTPUT_BANDWIDTH 0x8 +/// Indicates the property colordepth is valid. +#define ADL_CONNECTION_PROPERTY_COLORDEPTH 0x10 +/// @} + +/// \defgroup define_lanecount_constants +/// These defines are the Lane count constants which will be used in DP & etc. +/// @{ +/// Indicates if lane count is unknown +#define ADL_LANECOUNT_UNKNOWN 0 +/// Indicates if lane count is 1 +#define ADL_LANECOUNT_ONE 1 +/// Indicates if lane count is 2 +#define ADL_LANECOUNT_TWO 2 +/// Indicates if lane count is 4 +#define ADL_LANECOUNT_FOUR 4 +/// Indicates if lane count is 8 +#define ADL_LANECOUNT_EIGHT 8 +/// Indicates default value of lane count +#define ADL_LANECOUNT_DEF ADL_LANECOUNT_FOUR +/// @} + +/// \defgroup define_linkrate_constants +/// These defines are the link rate constants which will be used in DP & etc. +/// @{ +/// Indicates if link rate is unknown +#define ADL_LINK_BITRATE_UNKNOWN 0 +/// Indicates if link rate is 1.62Ghz +#define ADL_LINK_BITRATE_1_62_GHZ 0x06 +/// Indicates if link rate is 2.7Ghz +#define ADL_LINK_BITRATE_2_7_GHZ 0x0A +/// Indicates if link rate is 5.4Ghz +#define ADL_LINK_BITRATE_5_4_GHZ 0x14 + +/// Indicates if link rate is 8.1Ghz +#define ADL_LINK_BITRATE_8_1_GHZ 0x1E +/// Indicates default value of link rate +#define ADL_LINK_BITRATE_DEF ADL_LINK_BITRATE_2_7_GHZ +/// @} + +/// \defgroup define_colordepth_constants +/// These defines are the color depth constants which will be used in DP & etc. +/// @{ +#define ADL_CONNPROP_S3D_ALTERNATE_TO_FRAME_PACK 0x00000001 +/// @} + + +/// \defgroup define_colordepth_constants +/// These defines are the color depth constants which will be used in DP & etc. +/// @{ +/// Indicates if color depth is unknown +#define ADL_COLORDEPTH_UNKNOWN 0 +/// Indicates if color depth is 666 +#define ADL_COLORDEPTH_666 1 +/// Indicates if color depth is 888 +#define ADL_COLORDEPTH_888 2 +/// Indicates if color depth is 101010 +#define ADL_COLORDEPTH_101010 3 +/// Indicates if color depth is 121212 +#define ADL_COLORDEPTH_121212 4 +/// Indicates if color depth is 141414 +#define ADL_COLORDEPTH_141414 5 +/// Indicates if color depth is 161616 +#define ADL_COLORDEPTH_161616 6 +/// Indicates default value of color depth +#define ADL_COLOR_DEPTH_DEF ADL_COLORDEPTH_888 +/// @} + + +/// \defgroup define_emulation_status +/// These defines are the status of emulation +/// @{ +/// Indicates if real device is connected. +#define ADL_EMUL_STATUS_REAL_DEVICE_CONNECTED 0x1 +/// Indicates if emulated device is presented. +#define ADL_EMUL_STATUS_EMULATED_DEVICE_PRESENT 0x2 +/// Indicates if emulated device is used. +#define ADL_EMUL_STATUS_EMULATED_DEVICE_USED 0x4 +/// In case when last active real/emulated device used (when persistence is enabled but no emulation enforced then persistence will use last connected/emulated device). +#define ADL_EMUL_STATUS_LAST_ACTIVE_DEVICE_USED 0x8 +/// @} + +/// \defgroup define_emulation_mode +/// These defines are the modes of emulation +/// @{ +/// Indicates if no emulation is used +#define ADL_EMUL_MODE_OFF 0 +/// Indicates if emulation is used when display connected +#define ADL_EMUL_MODE_ON_CONNECTED 1 +/// Indicates if emulation is used when display dis connected +#define ADL_EMUL_MODE_ON_DISCONNECTED 2 +/// Indicates if emulation is used always +#define ADL_EMUL_MODE_ALWAYS 3 +/// @} + +/// \defgroup define_emulation_query +/// These defines are the modes of emulation +/// @{ +/// Indicates Data from real device +#define ADL_QUERY_REAL_DATA 0 +/// Indicates Emulated data +#define ADL_QUERY_EMULATED_DATA 1 +/// Indicates Data currently in use +#define ADL_QUERY_CURRENT_DATA 2 +/// @} + +/// \defgroup define_persistence_state +/// These defines are the states of persistence +/// @{ +/// Indicates persistence is disabled +#define ADL_EDID_PERSISTANCE_DISABLED 0 +/// Indicates persistence is enabled +#define ADL_EDID_PERSISTANCE_ENABLED 1 +/// @} + +/// \defgroup define_connector_types Connector Type +/// defines for ADLConnectorInfo.iType +/// @{ +/// Indicates unknown Connector type +#define ADL_CONNECTOR_TYPE_UNKNOWN 0 +/// Indicates VGA Connector type +#define ADL_CONNECTOR_TYPE_VGA 1 +/// Indicates DVI-D Connector type +#define ADL_CONNECTOR_TYPE_DVI_D 2 +/// Indicates DVI-I Connector type +#define ADL_CONNECTOR_TYPE_DVI_I 3 +/// Indicates Active Dongle-NA Connector type +#define ADL_CONNECTOR_TYPE_ATICVDONGLE_NA 4 +/// Indicates Active Dongle-JP Connector type +#define ADL_CONNECTOR_TYPE_ATICVDONGLE_JP 5 +/// Indicates Active Dongle-NONI2C Connector type +#define ADL_CONNECTOR_TYPE_ATICVDONGLE_NONI2C 6 +/// Indicates Active Dongle-NONI2C-D Connector type +#define ADL_CONNECTOR_TYPE_ATICVDONGLE_NONI2C_D 7 +/// Indicates HDMI-Type A Connector type +#define ADL_CONNECTOR_TYPE_HDMI_TYPE_A 8 +/// Indicates HDMI-Type B Connector type +#define ADL_CONNECTOR_TYPE_HDMI_TYPE_B 9 +/// Indicates Display port Connector type +#define ADL_CONNECTOR_TYPE_DISPLAYPORT 10 +/// Indicates EDP Connector type +#define ADL_CONNECTOR_TYPE_EDP 11 +/// Indicates MiniDP Connector type +#define ADL_CONNECTOR_TYPE_MINI_DISPLAYPORT 12 +/// Indicates Virtual Connector type +#define ADL_CONNECTOR_TYPE_VIRTUAL 13 +/// Indicates USB type C Connector type +#define ADL_CONNECTOR_TYPE_USB_TYPE_C 14 +/// @} + +/// \defgroup define_freesync_usecase +/// These defines are to specify use cases in which FreeSync should be enabled +/// They are a bit mask. To specify FreeSync for more than one use case, the input value +/// should be set to include multiple bits set +/// @{ +/// Indicates FreeSync is enabled for Static Screen case +#define ADL_FREESYNC_USECASE_STATIC 0x1 +/// Indicates FreeSync is enabled for Video use case +#define ADL_FREESYNC_USECASE_VIDEO 0x2 +/// Indicates FreeSync is enabled for Gaming use case +#define ADL_FREESYNC_USECASE_GAMING 0x4 +/// @} + +/// \defgroup define_freesync_caps +/// These defines are used to retrieve FreeSync display capabilities. +/// GPU support flag also indicates whether the display is +/// connected to a GPU that actually supports FreeSync +/// @{ +#define ADL_FREESYNC_CAP_SUPPORTED (1 << 0) +#define ADL_FREESYNC_CAP_GPUSUPPORTED (1 << 1) +#define ADL_FREESYNC_CAP_DISPLAYSUPPORTED (1 << 2) +#define ADL_FREESYNC_CAP_CURRENTMODESUPPORTED (1 << 3) +#define ADL_FREESYNC_CAP_NOCFXORCFXSUPPORTED (1 << 4) +#define ADL_FREESYNC_CAP_NOGENLOCKORGENLOCKSUPPORTED (1 << 5) +#define ADL_FREESYNC_CAP_BORDERLESSWINDOWSUPPORTED (1 << 6) +/// @} + +/// \defgroup define_freesync_labelIndex +/// These defines are used to retrieve which FreeSync label to use +/// @{ +#define ADL_FREESYNC_LABEL_UNSUPPORTED 0 +#define ADL_FREESYNC_LABEL_FREESYNC 1 +#define ADL_FREESYNC_LABEL_ADAPTIVE_SYNC 2 +#define ADL_FREESYNC_LABEL_VRR 3 +#define ADL_FREESYNC_LABEL_FREESYNC_PREMIUM 4 +#define ADL_FREESYNC_LABEL_FREESYNC_PREMIUM_PRO 5 +/// @} + +/// Freesync Power optimization masks +/// @{ +#define ADL_FREESYNC_POWEROPTIMIZATION_SUPPORTED_MASK (1 << 0) +#define ADL_FREESYNC_POWEROPTIMIZATION_ENABLED_MASK (1 << 1) +#define ADL_FREESYNC_POWEROPTIMIZATION_DEFAULT_VALUE_MASK (1 << 2) +/// @} + +/// \defgroup define_MST_CommandLine_execute +/// @{ +/// Indicates the MST command line for branch message if the bit is set. Otherwise, it is display message +#define ADL_MST_COMMANDLINE_PATH_MSG 0x1 +/// Indicates the MST command line to send message in broadcast way it the bit is set +#define ADL_MST_COMMANDLINE_BROADCAST 0x2 + +/// @} + + +/// \defgroup define_Adapter_CloneTypes_Get +/// @{ +/// Indicates there is crossGPU clone with non-AMD dispalys +#define ADL_CROSSGPUDISPLAYCLONE_AMD_WITH_NONAMD 0x1 +/// Indicates there is crossGPU clone +#define ADL_CROSSGPUDISPLAYCLONE 0x2 + +/// @} + +/// \defgroup define_D3DKMT_HANDLE +/// @{ +/// Handle can be used to create Device Handle when using CreateDevice() +typedef unsigned int ADL_D3DKMT_HANDLE; +/// @} + + +// End Bracket for Constants and Definitions. Add new groups ABOVE this line! + +/// @} + + +typedef enum ADL_RAS_ERROR_INJECTION_MODE +{ + ADL_RAS_ERROR_INJECTION_MODE_SINGLE = 1, + ADL_RAS_ERROR_INJECTION_MODE_MULTIPLE = 2 +}ADL_RAS_ERROR_INJECTION_MODE; + + +typedef enum ADL_RAS_BLOCK_ID +{ + ADL_RAS_BLOCK_ID_UMC = 0, + ADL_RAS_BLOCK_ID_SDMA, + ADL_RAS_BLOCK_ID_GFX_HUB, + ADL_RAS_BLOCK_ID_MMHUB, + ADL_RAS_BLOCK_ID_ATHUB, + ADL_RAS_BLOCK_ID_PCIE_BIF, + ADL_RAS_BLOCK_ID_HDP, + ADL_RAS_BLOCK_ID_XGMI_WAFL, + ADL_RAS_BLOCK_ID_DF, + ADL_RAS_BLOCK_ID_SMN, + ADL_RAS_BLOCK_ID_SEM, + ADL_RAS_BLOCK_ID_MP0, + ADL_RAS_BLOCK_ID_MP1, + ADL_RAS_BLOCK_ID_FUSE +}ADL_RAS_BLOCK_ID; + +typedef enum ADL_MEM_SUB_BLOCK_ID +{ + ADL_RAS__UMC_HBM = 0, + ADL_RAS__UMC_SRAM = 1 +}ADL_MEM_SUB_BLOCK_ID; + +typedef enum _ADL_RAS_ERROR_TYPE +{ + ADL_RAS_ERROR__NONE = 0, + ADL_RAS_ERROR__PARITY = 1, + ADL_RAS_ERROR__SINGLE_CORRECTABLE = 2, + ADL_RAS_ERROR__PARITY_SINGLE_CORRECTABLE = 3, + ADL_RAS_ERROR__MULTI_UNCORRECTABLE = 4, + ADL_RAS_ERROR__PARITY_MULTI_UNCORRECTABLE = 5, + ADL_RAS_ERROR__SINGLE_CORRECTABLE_MULTI_UNCORRECTABLE = 6, + ADL_RAS_ERROR__PARITY_SINGLE_CORRECTABLE_MULTI_UNCORRECTABLE = 7, + ADL_RAS_ERROR__POISON = 8, + ADL_RAS_ERROR__PARITY_POISON = 9, + ADL_RAS_ERROR__SINGLE_CORRECTABLE_POISON = 10, + ADL_RAS_ERROR__PARITY_SINGLE_CORRECTABLE_POISON = 11, + ADL_RAS_ERROR__MULTI_UNCORRECTABLE_POISON = 12, + ADL_RAS_ERROR__PARITY_MULTI_UNCORRECTABLE_POISON = 13, + ADL_RAS_ERROR__SINGLE_CORRECTABLE_MULTI_UNCORRECTABLE_POISON = 14, + ADL_RAS_ERROR__PARITY_SINGLE_CORRECTABLE_MULTI_UNCORRECTABLE_POISON = 15 +}ADL_RAS_ERROR_TYPE; + +typedef enum ADL_RAS_INJECTION_METHOD +{ + ADL_RAS_ERROR__UMC_METH_COHERENT = 0, + ADL_RAS_ERROR__UMC_METH_SINGLE_SHOT = 1, + ADL_RAS_ERROR__UMC_METH_PERSISTENT = 2, + ADL_RAS_ERROR__UMC_METH_PERSISTENT_DISABLE = 3 +}ADL_RAS_INJECTION_METHOD; + +// Driver event types +typedef enum ADL_DRIVER_EVENT_TYPE +{ + ADL_EVENT_ID_AUTO_FEATURE_COMPLETED = 30, + ADL_EVENT_ID_FEATURE_AVAILABILITY = 31, + +} ADL_DRIVER_EVENT_TYPE; + + +//UIFeature Ids +typedef enum ADL_UIFEATURES_GROUP +{ + ADL_UIFEATURES_GROUP_DVR = 0, + ADL_UIFEATURES_GROUP_TURBOSYNC = 1, + ADL_UIFEATURES_GROUP_FRAMEMETRICSMONITOR = 2, + ADL_UIFEATURES_GROUP_FRTC = 3, + ADL_UIFEATURES_GROUP_XVISION = 4, + ADL_UIFEATURES_GROUP_BLOCKCHAIN = 5, + ADL_UIFEATURES_GROUP_GAMEINTELLIGENCE = 6, + ADL_UIFEATURES_GROUP_CHILL = 7, + ADL_UIFEATURES_GROUP_DELAG = 8, + ADL_UIFEATURES_GROUP_BOOST = 9, + ADL_UIFEATURES_GROUP_USU = 10, + ADL_UIFEATURES_GROUP_XGMI = 11, + ADL_UIFEATURES_GROUP_PROVSR = 12, + ADL_UIFEATURES_GROUP_SMA = 13, + ADL_UIFEATURES_GROUP_CAMERA = 14, + ADL_UIFEATURES_GROUP_FRTCPRO = 15 +} ADL_UIFEATURES_GROUP; + + + +/// Maximum brightness supported by Radeon LED interface +#define ADL_RADEON_LED_MAX_BRIGHTNESS 2 + +/// Maximum speed supported by Radeon LED interface +#define ADL_RADEON_LED_MAX_SPEED 4 + +/// Maximum RGB supported by Radeon LED interface +#define ADL_RADEON_LED_MAX_RGB 255 + +/// Maximum MORSE code supported string +#define ADL_RADEON_LED_MAX_MORSE_CODE 260 + +/// Maximum LED ROW ON GRID +#define ADL_RADEON_LED_MAX_LED_ROW_ON_GRID 7 + +/// Maximum LED COLUMN ON GRID +#define ADL_RADEON_LED_MAX_LED_COLUMN_ON_GRID 24 + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief +/// +/// +/// +/// +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef enum ADL_RADEON_USB_LED_BAR_CONTROLS +{ + RadeonLEDBarControl_OFF = 0, + RadeonLEDBarControl_Static, + RadeonLEDBarControl_Rainbow, + RadeonLEDBarControl_Swirl, + RadeonLEDBarControl_Chase, + RadeonLEDBarControl_Bounce, + RadeonLEDBarControl_MorseCode, + RadeonLEDBarControl_ColorCycle, + RadeonLEDBarControl_Breathing, + RadeonLEDBarControl_CustomPattern, + RadeonLEDBarControl_MAX +}ADL_RADEON_USB_LED_BAR_CONTROLS; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief +/// +/// +/// +/// +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef unsigned int RadeonLEDBARSupportedControl; + + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief +/// +/// +/// +/// +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef enum ADL_RADEON_USB_LED_CONTROL_CONFIGS +{ + RadeonLEDPattern_Speed = 0, + RadeonLEDPattern_Brightness, + RadeonLEDPattern_Direction, + RadeonLEDPattern_Color, + RadeonLEDPattern_MAX +}ADL_RADEON_USB_LED_CONTROL_CONFIGS; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief +/// +/// +/// +/// +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef unsigned int RadeonLEDBARSupportedConfig; + +//User blob feature settings +typedef enum ADL_USER_SETTINGS +{ + ADL_USER_SETTINGS_ENHANCEDSYNC = 1 << 0, //notify Enhanced Sync settings change + ADL_USER_SETTINGS_CHILL_PROFILE = 1 << 1, //notify Chill settings change + ADL_USER_SETTINGS_DELAG_PROFILE = 1 << 2, //notify Delag settings change + ADL_USER_SETTINGS_BOOST_PROFILE = 1 << 3, //notify Boost settings change + ADL_USER_SETTINGS_USU_PROFILE = 1 << 4, //notify USU settings change + ADL_USER_SETTINGS_CVDC_PROFILE = 1 << 5, //notify Color Vision Deficiency Corretion settings change + ADL_USER_SETTINGS_SCE_PROFILE = 1 << 6, + ADL_USER_SETTINGS_PROVSR = 1 << 7 + } ADL_USER_SETTINGS; + +#define ADL_REG_DEVICE_FUNCTION_1 0x00000001 +#endif /* ADL_DEFINES_H_ */ + + diff --git a/src/3rdparty/display-library/adl_sdk.h b/src/3rdparty/display-library/adl_sdk.h new file mode 100644 index 000000000..0923a6abb --- /dev/null +++ b/src/3rdparty/display-library/adl_sdk.h @@ -0,0 +1,46 @@ +// +// Copyright (c) 2016 - 2022 Advanced Micro Devices, Inc. All rights reserved. +// +// MIT LICENSE: +// 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 adl_sdk.h +/// \brief Contains the definition of the Memory Allocation Callback.\n Included in ADL SDK +/// +/// \n\n +/// This file contains the definition of the Memory Allocation Callback.\n +/// It also includes definitions of the respective structures and constants.\n +/// This is the only header file to be included in a C/C++ project using ADL + +#ifndef ADL_SDK_H_ +#define ADL_SDK_H_ + +#include "adl_structures.h" + +#if defined (LINUX) +#define __stdcall +#endif /* (LINUX) */ + +/// Memory Allocation Call back +typedef void* ( __stdcall *ADL_MAIN_MALLOC_CALLBACK )( int ); + +#define ADL_SDK_MAJOR_VERSION 17 +#define ADL_SDK_MINOR_VERSION 1 + +#endif /* ADL_SDK_H_ */ diff --git a/src/3rdparty/display-library/adl_structures.h b/src/3rdparty/display-library/adl_structures.h new file mode 100644 index 000000000..601ad74bd --- /dev/null +++ b/src/3rdparty/display-library/adl_structures.h @@ -0,0 +1,4289 @@ +// +// Copyright (c) 2016 - 2022 Advanced Micro Devices, Inc. All rights reserved. +// +// MIT LICENSE: +// 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 adl_structures.h +///\brief This file contains the structure declarations that are used by the public ADL interfaces for \ALL platforms.\n Included in ADL SDK +/// +/// All data structures used in AMD Display Library (ADL) public interfaces should be defined in this header file. +/// + +#ifndef ADL_STRUCTURES_H_ +#define ADL_STRUCTURES_H_ + +#include "adl_defines.h" +#include +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the graphics adapter. +/// +/// This structure is used to store various information about the graphics adapter. This +/// information can be returned to the user. Alternatively, it can be used to access various driver calls to set +/// or fetch various settings upon the user's request. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct AdapterInfo +{ +/// \ALL_STRUCT_MEM + +/// Size of the structure. + int iSize; +/// The ADL index handle. One GPU may be associated with one or two index handles + int iAdapterIndex; +/// The unique device ID associated with this adapter. + char strUDID[ADL_MAX_PATH]; +/// The BUS number associated with this adapter. + int iBusNumber; +/// The driver number associated with this adapter. + int iDeviceNumber; +/// The function number. + int iFunctionNumber; +/// The vendor ID associated with this adapter. + int iVendorID; +/// Adapter name. + char strAdapterName[ADL_MAX_PATH]; +/// Display name. For example, "\\\\Display0" for Windows or ":0:0" for Linux. + char strDisplayName[ADL_MAX_PATH]; +/// Present or not; 1 if present and 0 if not present.It the logical adapter is present, the display name such as \\\\.\\Display1 can be found from OS + int iPresent; + +#if defined (_WIN32) || defined (_WIN64) +/// \WIN_STRUCT_MEM + +/// Exist or not; 1 is exist and 0 is not present. + int iExist; +/// Driver registry path. + char strDriverPath[ADL_MAX_PATH]; +/// Driver registry path Ext for. + char strDriverPathExt[ADL_MAX_PATH]; +/// PNP string from Windows. + char strPNPString[ADL_MAX_PATH]; +/// It is generated from EnumDisplayDevices. + int iOSDisplayIndex; + +#endif /* (_WIN32) || (_WIN64) */ + +#if defined (LINUX) +/// \LNX_STRUCT_MEM + +/// Internal X screen number from GPUMapInfo (DEPRICATED use XScreenInfo) + int iXScreenNum; +/// Internal driver index from GPUMapInfo + int iDrvIndex; +/// \deprecated Internal x config file screen identifier name. Use XScreenInfo instead. + char strXScreenConfigName[ADL_MAX_PATH]; + +#endif /* (LINUX) */ +} AdapterInfo, *LPAdapterInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the Linux X screen information. +/// +/// This structure is used to store the current screen number and xorg.conf ID name assoicated with an adapter index. +/// This structure is updated during ADL_Main_Control_Refresh or ADL_ScreenInfo_Update. +/// Note: This structure should be used in place of iXScreenNum and strXScreenConfigName in AdapterInfo as they will be +/// deprecated. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +#if defined (LINUX) +typedef struct XScreenInfo +{ +/// Internal X screen number from GPUMapInfo. + int iXScreenNum; +/// Internal x config file screen identifier name. + char strXScreenConfigName[ADL_MAX_PATH]; +} XScreenInfo, *LPXScreenInfo; +#endif /* (LINUX) */ + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about an controller mode +/// +/// This structure is used to store information of an controller mode +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLAdapterCaps +{ + /// AdapterID for this adapter + int iAdapterID; + /// Number of controllers for this adapter + int iNumControllers; + /// Number of displays for this adapter + int iNumDisplays; + /// Number of overlays for this adapter + int iNumOverlays; + /// Number of GLSyncConnectors + int iNumOfGLSyncConnectors; + /// The bit mask identifies the adapter caps + int iCapsMask; + /// The bit identifies the adapter caps \ref define_adapter_caps + int iCapsValue; +}ADLAdapterCaps; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing additional information about the ASIC memory +/// +/// This structure is used to store additional information about the ASIC memory. This +/// information can be returned to the user. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLMemoryInfo2 +{ + /// Memory size in bytes. + long long iMemorySize; + /// Memory type in string. + char strMemoryType[ADL_MAX_PATH]; + /// Highest default performance level Memory bandwidth in Mbytes/s + long long iMemoryBandwidth; + /// HyperMemory size in bytes. + long long iHyperMemorySize; + + /// Invisible Memory size in bytes. + long long iInvisibleMemorySize; + /// Visible Memory size in bytes. + long long iVisibleMemorySize; +} ADLMemoryInfo2, *LPADLMemoryInfo2; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing additional information about the ASIC memory +/// +/// This structure is used to store additional information about the ASIC memory. This +/// information can be returned to the user. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLMemoryInfo3 +{ + /// Memory size in bytes. + long long iMemorySize; + /// Memory type in string. + char strMemoryType[ADL_MAX_PATH]; + /// Highest default performance level Memory bandwidth in Mbytes/s + long long iMemoryBandwidth; + /// HyperMemory size in bytes. + long long iHyperMemorySize; + + /// Invisible Memory size in bytes. + long long iInvisibleMemorySize; + /// Visible Memory size in bytes. + long long iVisibleMemorySize; + /// Vram vendor ID + long long iVramVendorRevId; +} ADLMemoryInfo3, *LPADLMemoryInfo3; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing additional information about the ASIC memory +/// +/// This structure is used to store additional information about the ASIC memory. This +/// information can be returned to the user. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLMemoryInfoX4 +{ + /// Memory size in bytes. + long long iMemorySize; + /// Memory type in string. + char strMemoryType[ADL_MAX_PATH]; + /// Highest default performance level Memory bandwidth in Mbytes/s + long long iMemoryBandwidth; + /// HyperMemory size in bytes. + long long iHyperMemorySize; + + /// Invisible Memory size in bytes. + long long iInvisibleMemorySize; + /// Visible Memory size in bytes. + long long iVisibleMemorySize; + /// Vram vendor ID + long long iVramVendorRevId; + /// Memory Bandiwidth that is calculated and finalized on the driver side, grab and go. + long long iMemoryBandwidthX2; + /// Memory Bit Rate that is calculated and finalized on the driver side, grab and go. + long long iMemoryBitRateX2; + +} ADLMemoryInfoX4, *LPADLMemoryInfoX4; + +/////////////////////////////////////////////////////////////////////////// +// ADLvRamVendor Enumeration +/////////////////////////////////////////////////////////////////////////// +enum ADLvRamVendors +{ + ADLvRamVendor_Unsupported = 0x0, + ADLvRamVendor_SAMSUNG, + ADLvRamVendor_INFINEON, + ADLvRamVendor_ELPIDA, + ADLvRamVendor_ETRON, + ADLvRamVendor_NANYA, + ADLvRamVendor_HYNIX, + ADLvRamVendor_MOSEL, + ADLvRamVendor_WINBOND, + ADLvRamVendor_ESMT, + ADLvRamVendor_MICRON = 0xF, + ADLvRamVendor_Undefined +}; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about components of ASIC GCN architecture +/// +/// Elements of GCN info are compute units, number of Tex (Texture filtering units) , number of ROPs (render back-ends). +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLGcnInfo +{ + int CuCount; //Number of compute units on the ASIC. + int TexCount; //Number of texture mapping units. + int RopCount; //Number of Render backend Units. + int ASICFamilyId; //Such SI, VI. See /inc/asic_reg/atiid.h for family ids + int ASICRevisionId; //Such as Ellesmere, Fiji. For example - VI family revision ids are stored in /inc/asic_reg/vi_id.h +}ADLGcnInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related virtual segment config information. +/// +/// This structure is used to store information related virtual segment config +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLVirtualSegmentSettingsOutput +{ + int virtualSegmentSupported; // 1 - subsequent values are valid + int virtualSegmentDefault; //virtual segment default, 1: enable, 0: disable + int virtualSegmentCurrent; //virtual segment current, 1: enable, 0: disable + int iMinSizeInMB; //minimum value + int iMaxSizeInMB; //maximum value + int icurrentSizeInMB; //last configured otherwise same as factory default + int idefaultSizeInMB; //factory default + int iMask; //fileds for extension in the future + int iValue; //fileds for extension in the future +} ADLVirtualSegmentSettingsOutput; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing information about the Chipset. +/// +/// This structure is used to store various information about the Chipset. This +/// information can be returned to the user. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLChipSetInfo +{ + int iBusType; ///< Bus type. + int iBusSpeedType; ///Maximum Bus Speed of the current platform + int iMaxPCIELaneWidth; ///< Number of PCIE lanes. + int iCurrentPCIELaneWidth; ///< Current PCIE Lane Width + int iSupportedAGPSpeeds; ///< Bit mask or AGP transfer speed. + int iCurrentAGPSpeed; ///< Current AGP speed +} ADLChipSetInfo, *LPADLChipSetInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the ASIC memory. +/// +/// This structure is used to store various information about the ASIC memory. This +/// information can be returned to the user. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLMemoryInfo +{ +/// Memory size in bytes. + long long iMemorySize; +/// Memory type in string. + char strMemoryType[ADL_MAX_PATH]; +/// Memory bandwidth in Mbytes/s. + long long iMemoryBandwidth; +} ADLMemoryInfo, *LPADLMemoryInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about memory required by type +/// +/// This structure is returned by ADL_Adapter_ConfigMemory_Get, which given a desktop and display configuration +/// will return the Memory used. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLMemoryRequired +{ + long long iMemoryReq; /// Memory in bytes required + int iType; /// Type of Memory \ref define_adl_validmemoryrequiredfields + int iDisplayFeatureValue; /// Display features \ref define_adl_visiblememoryfeatures that are using this type of memory +} ADLMemoryRequired, *LPADLMemoryRequired; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the features associated with a display +/// +/// This structure is a parameter to ADL_Adapter_ConfigMemory_Get, which given a desktop and display configuration +/// will return the Memory used. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLMemoryDisplayFeatures +{ + int iDisplayIndex; /// ADL Display index + int iDisplayFeatureValue; /// features that the display is using \ref define_adl_visiblememoryfeatures +} ADLMemoryDisplayFeatures, *LPADLMemoryDisplayFeatures; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing DDC information. +/// +/// This structure is used to store various DDC information that can be returned to the user. +/// Note that all fields of type int are actually defined as unsigned int types within the driver. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDDCInfo +{ +/// Size of the structure + int ulSize; +/// Indicates whether the attached display supports DDC. If this field is zero on return, no other DDC information fields will be used. + int ulSupportsDDC; +/// Returns the manufacturer ID of the display device. Should be zeroed if this information is not available. + int ulManufacturerID; +/// Returns the product ID of the display device. Should be zeroed if this information is not available. + int ulProductID; +/// Returns the name of the display device. Should be zeroed if this information is not available. + char cDisplayName[ADL_MAX_DISPLAY_NAME]; +/// Returns the maximum Horizontal supported resolution. Should be zeroed if this information is not available. + int ulMaxHResolution; +/// Returns the maximum Vertical supported resolution. Should be zeroed if this information is not available. + int ulMaxVResolution; +/// Returns the maximum supported refresh rate. Should be zeroed if this information is not available. + int ulMaxRefresh; +/// Returns the display device preferred timing mode's horizontal resolution. + int ulPTMCx; +/// Returns the display device preferred timing mode's vertical resolution. + int ulPTMCy; +/// Returns the display device preferred timing mode's refresh rate. + int ulPTMRefreshRate; +/// Return EDID flags. + int ulDDCInfoFlag; +} ADLDDCInfo, *LPADLDDCInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing DDC information. +/// +/// This structure is used to store various DDC information that can be returned to the user. +/// Note that all fields of type int are actually defined as unsigned int types within the driver. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDDCInfo2 +{ +/// Size of the structure + int ulSize; +/// Indicates whether the attached display supports DDC. If this field is zero on return, no other DDC +/// information fields will be used. + int ulSupportsDDC; +/// Returns the manufacturer ID of the display device. Should be zeroed if this information is not available. + int ulManufacturerID; +/// Returns the product ID of the display device. Should be zeroed if this information is not available. + int ulProductID; +/// Returns the name of the display device. Should be zeroed if this information is not available. + char cDisplayName[ADL_MAX_DISPLAY_NAME]; +/// Returns the maximum Horizontal supported resolution. Should be zeroed if this information is not available. + int ulMaxHResolution; +/// Returns the maximum Vertical supported resolution. Should be zeroed if this information is not available. + int ulMaxVResolution; +/// Returns the maximum supported refresh rate. Should be zeroed if this information is not available. + int ulMaxRefresh; +/// Returns the display device preferred timing mode's horizontal resolution. + int ulPTMCx; +/// Returns the display device preferred timing mode's vertical resolution. + int ulPTMCy; +/// Returns the display device preferred timing mode's refresh rate. + int ulPTMRefreshRate; +/// Return EDID flags. + int ulDDCInfoFlag; +/// Returns 1 if the display supported packed pixel, 0 otherwise + int bPackedPixelSupported; +/// Returns the Pixel formats the display supports \ref define_ddcinfo_pixelformats + int iPanelPixelFormat; +/// Return EDID serial ID. + int ulSerialID; +/// Return minimum monitor luminance data + int ulMinLuminanceData; +/// Return average monitor luminance data + int ulAvgLuminanceData; +/// Return maximum monitor luminance data + int ulMaxLuminanceData; + +/// Bit vector of supported transfer functions \ref define_source_content_TF + int iSupportedTransferFunction; + +/// Bit vector of supported color spaces \ref define_source_content_CS + int iSupportedColorSpace; + +/// Display Red Chromaticity X coordinate multiplied by 10000 + int iNativeDisplayChromaticityRedX; +/// Display Red Chromaticity Y coordinate multiplied by 10000 + int iNativeDisplayChromaticityRedY; +/// Display Green Chromaticity X coordinate multiplied by 10000 + int iNativeDisplayChromaticityGreenX; +/// Display Green Chromaticity Y coordinate multiplied by 10000 + int iNativeDisplayChromaticityGreenY; +/// Display Blue Chromaticity X coordinate multiplied by 10000 + int iNativeDisplayChromaticityBlueX; +/// Display Blue Chromaticity Y coordinate multiplied by 10000 + int iNativeDisplayChromaticityBlueY; +/// Display White Point X coordinate multiplied by 10000 + int iNativeDisplayChromaticityWhitePointX; +/// Display White Point Y coordinate multiplied by 10000 + int iNativeDisplayChromaticityWhitePointY; +/// Display diffuse screen reflectance 0-1 (100%) in units of 0.01 + int iDiffuseScreenReflectance; +/// Display specular screen reflectance 0-1 (100%) in units of 0.01 + int iSpecularScreenReflectance; +/// Bit vector of supported color spaces \ref define_HDR_support + int iSupportedHDR; +/// Bit vector for freesync flags + int iFreesyncFlags; + +/// Return minimum monitor luminance without dimming data + int ulMinLuminanceNoDimmingData; + + int ulMaxBacklightMaxLuminanceData; + int ulMinBacklightMaxLuminanceData; + int ulMaxBacklightMinLuminanceData; + int ulMinBacklightMinLuminanceData; + + // Reserved for future use + int iReserved[4]; +} ADLDDCInfo2, *LPADLDDCInfo2; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information controller Gamma settings. +/// +/// This structure is used to store the red, green and blue color channel information for the. +/// controller gamma setting. This information is returned by ADL, and it can also be used to +/// set the controller gamma setting. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLGamma +{ +/// Red color channel gamma value. + float fRed; +/// Green color channel gamma value. + float fGreen; +/// Blue color channel gamma value. + float fBlue; +} ADLGamma, *LPADLGamma; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about component video custom modes. +/// +/// This structure is used to store the component video custom mode. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLCustomMode +{ +/// Custom mode flags. They are returned by the ADL driver. + int iFlags; +/// Custom mode width. + int iModeWidth; +/// Custom mode height. + int iModeHeight; +/// Custom mode base width. + int iBaseModeWidth; +/// Custom mode base height. + int iBaseModeHeight; +/// Custom mode refresh rate. + int iRefreshRate; +} ADLCustomMode, *LPADLCustomMode; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing Clock information for OD5 calls. +/// +/// This structure is used to retrieve clock information for OD5 calls. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLGetClocksOUT +{ + long ulHighCoreClock; + long ulHighMemoryClock; + long ulHighVddc; + long ulCoreMin; + long ulCoreMax; + long ulMemoryMin; + long ulMemoryMax; + long ulActivityPercent; + long ulCurrentCoreClock; + long ulCurrentMemoryClock; + long ulReserved; +} ADLGetClocksOUT; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing HDTV information for display calls. +/// +/// This structure is used to retrieve HDTV information information for display calls. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDisplayConfig +{ +/// Size of the structure + long ulSize; +/// HDTV connector type. + long ulConnectorType; +/// HDTV capabilities. + long ulDeviceData; +/// Overridden HDTV capabilities. + long ulOverridedDeviceData; +/// Reserved field + long ulReserved; +} ADLDisplayConfig; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the display device. +/// +/// This structure is used to store display device information +/// such as display index, type, name, connection status, mapped adapter and controller indexes, +/// whether or not multiple VPUs are supported, local display connections or not (through Lasso), etc. +/// This information can be returned to the user. Alternatively, it can be used to access various driver calls to set +/// or fetch various display device related settings upon the user's request. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDisplayID +{ +/// The logical display index belonging to this adapter. + int iDisplayLogicalIndex; + +///\brief The physical display index. +/// For example, display index 2 from adapter 2 can be used by current adapter 1.\n +/// So current adapter may enumerate this adapter as logical display 7 but the physical display +/// index is still 2. + int iDisplayPhysicalIndex; + +/// The persistent logical adapter index for the display. + int iDisplayLogicalAdapterIndex; + +///\brief The persistent physical adapter index for the display. +/// It can be the current adapter or a non-local adapter. \n +/// If this adapter index is different than the current adapter, +/// the Display Non Local flag is set inside DisplayInfoValue. + int iDisplayPhysicalAdapterIndex; +} ADLDisplayID, *LPADLDisplayID; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the display device. +/// +/// This structure is used to store various information about the display device. This +/// information can be returned to the user, or used to access various driver calls to set +/// or fetch various display-device-related settings upon the user's request +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDisplayInfo +{ +/// The DisplayID structure + ADLDisplayID displayID; + +///\deprecated The controller index to which the display is mapped.\n Will not be used in the future\n + int iDisplayControllerIndex; + +/// The display's EDID name. + char strDisplayName[ADL_MAX_PATH]; + +/// The display's manufacturer name. + char strDisplayManufacturerName[ADL_MAX_PATH]; + +/// The Display type. For example: CRT, TV, CV, DFP. + int iDisplayType; + +/// The display output type. For example: HDMI, SVIDEO, COMPONMNET VIDEO. + int iDisplayOutputType; + +/// The connector type for the device. + int iDisplayConnector; + +///\brief The bit mask identifies the number of bits ADLDisplayInfo is currently using. \n +/// It will be the sum all the bit definitions in ADL_DISPLAY_DISPLAYINFO_xxx. + int iDisplayInfoMask; + +/// The bit mask identifies the display status. \ref define_displayinfomask + int iDisplayInfoValue; +} ADLDisplayInfo, *LPADLDisplayInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the display port MST device. +/// +/// This structure is used to store various MST information about the display port device. This +/// information can be returned to the user, or used to access various driver calls to +/// fetch various display-device-related settings upon the user's request +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDisplayDPMSTInfo +{ + /// The ADLDisplayID structure + ADLDisplayID displayID; + + /// total bandwidth available on the DP connector + int iTotalAvailableBandwidthInMpbs; + /// bandwidth allocated to this display + int iAllocatedBandwidthInMbps; + + // info from DAL DpMstSinkInfo + /// string identifier for the display + char strGlobalUniqueIdentifier[ADL_MAX_PATH]; + + /// The link count of relative address, rad[0] upto rad[linkCount] are valid + int radLinkCount; + /// The physical connector ID, used to identify the physical DP port + int iPhysicalConnectorID; + + /// Relative address, address scheme starts from source side + char rad[ADL_MAX_RAD_LINK_COUNT]; +} ADLDisplayDPMSTInfo, *LPADLDisplayDPMSTInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing the display mode definition used per controller. +/// +/// This structure is used to store the display mode definition used per controller. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDisplayMode +{ +/// Vertical resolution (in pixels). + int iPelsHeight; +/// Horizontal resolution (in pixels). + int iPelsWidth; +/// Color depth. + int iBitsPerPel; +/// Refresh rate. + int iDisplayFrequency; +} ADLDisplayMode; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing detailed timing parameters. +/// +/// This structure is used to store the detailed timing parameters. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDetailedTiming +{ +/// Size of the structure. + int iSize; +/// Timing flags. \ref define_detailed_timing_flags + short sTimingFlags; +/// Total width (columns). + short sHTotal; +/// Displayed width. + short sHDisplay; +/// Horizontal sync signal offset. + short sHSyncStart; +/// Horizontal sync signal width. + short sHSyncWidth; +/// Total height (rows). + short sVTotal; +/// Displayed height. + short sVDisplay; +/// Vertical sync signal offset. + short sVSyncStart; +/// Vertical sync signal width. + short sVSyncWidth; +/// Pixel clock value. + short sPixelClock; +/// Overscan right. + short sHOverscanRight; +/// Overscan left. + short sHOverscanLeft; +/// Overscan bottom. + short sVOverscanBottom; +/// Overscan top. + short sVOverscanTop; + short sOverscan8B; + short sOverscanGR; +} ADLDetailedTiming; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing display mode information. +/// +/// This structure is used to store the display mode information. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDisplayModeInfo +{ +/// Timing standard of the current mode. \ref define_modetiming_standard + int iTimingStandard; +/// Applicable timing standards for the current mode. + int iPossibleStandard; +/// Refresh rate factor. + int iRefreshRate; +/// Num of pixels in a row. + int iPelsWidth; +/// Num of pixels in a column. + int iPelsHeight; +/// Detailed timing parameters. + ADLDetailedTiming sDetailedTiming; +} ADLDisplayModeInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing information about display property. +/// +/// This structure is used to store the display property for the current adapter. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDisplayProperty +{ +/// Must be set to sizeof the structure + int iSize; +/// Must be set to \ref ADL_DL_DISPLAYPROPERTY_TYPE_EXPANSIONMODE or \ref ADL_DL_DISPLAYPROPERTY_TYPE_USEUNDERSCANSCALING + int iPropertyType; +/// Get or Set \ref ADL_DL_DISPLAYPROPERTY_EXPANSIONMODE_CENTER or \ref ADL_DL_DISPLAYPROPERTY_EXPANSIONMODE_FULLSCREEN or \ref ADL_DL_DISPLAYPROPERTY_EXPANSIONMODE_ASPECTRATIO or \ref ADL_DL_DISPLAYPROPERTY_TYPE_ITCFLAGENABLE + int iExpansionMode; +/// Display Property supported? 1: Supported, 0: Not supported + int iSupport; +/// Display Property current value + int iCurrent; +/// Display Property Default value + int iDefault; +} ADLDisplayProperty; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Clock. +/// +/// This structure is used to store the clock information for the current adapter +/// such as core clock and memory clock info. +///\nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLClockInfo +{ +/// Core clock in 10 KHz. + int iCoreClock; +/// Memory clock in 10 KHz. + int iMemoryClock; +} ADLClockInfo, *LPADLClockInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about I2C. +/// +/// This structure is used to store the I2C information for the current adapter. +/// This structure is used by the ADL_Display_WriteAndReadI2C() function. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLI2C +{ +/// Size of the structure + int iSize; +/// Numerical value representing hardware I2C. + int iLine; +/// The 7-bit I2C slave device address, shifted one bit to the left. + int iAddress; +/// The offset of the data from the address. + int iOffset; +/// Read from or write to slave device. \ref ADL_DL_I2C_ACTIONREAD or \ref ADL_DL_I2C_ACTIONWRITE or \ref ADL_DL_I2C_ACTIONREAD_REPEATEDSTART + int iAction; +/// I2C clock speed in KHz. + int iSpeed; +/// A numerical value representing the number of bytes to be sent or received on the I2C bus. + int iDataSize; +/// Address of the characters which are to be sent or received on the I2C bus. + char *pcData; +} ADLI2C; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about EDID data. +/// +/// This structure is used to store the information about EDID data for the adapter. +/// This structure is used by the ADL_Display_EdidData_Get() and ADL_Display_EdidData_Set() functions. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDisplayEDIDData +{ +/// Size of the structure + int iSize; +/// Set to 0 + int iFlag; + /// Size of cEDIDData. Set by ADL_Display_EdidData_Get() upon return + int iEDIDSize; +/// 0, 1 or 2. If set to 3 or above an error ADL_ERR_INVALID_PARAM is generated + int iBlockIndex; +/// EDID data + char cEDIDData[ADL_MAX_EDIDDATA_SIZE]; +/// Reserved + int iReserved[4]; +}ADLDisplayEDIDData; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about input of controller overlay adjustment. +/// +/// This structure is used to store the information about input of controller overlay adjustment for the adapter. +/// This structure is used by the ADL_Display_ControllerOverlayAdjustmentCaps_Get, ADL_Display_ControllerOverlayAdjustmentData_Get, and +/// ADL_Display_ControllerOverlayAdjustmentData_Set() functions. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLControllerOverlayInput +{ +/// Should be set to the sizeof the structure + int iSize; +///\ref ADL_DL_CONTROLLER_OVERLAY_ALPHA or \ref ADL_DL_CONTROLLER_OVERLAY_ALPHAPERPIX + int iOverlayAdjust; +/// Data. + int iValue; +/// Should be 0. + int iReserved; +} ADLControllerOverlayInput; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about overlay adjustment. +/// +/// This structure is used to store the information about overlay adjustment for the adapter. +/// This structure is used by the ADLControllerOverlayInfo() function. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLAdjustmentinfo +{ +/// Default value + int iDefault; +/// Minimum value + int iMin; +/// Maximum Value + int iMax; +/// Step value + int iStep; +} ADLAdjustmentinfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about controller overlay information. +/// +/// This structure is used to store information about controller overlay info for the adapter. +/// This structure is used by the ADL_Display_ControllerOverlayAdjustmentCaps_Get() function. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLControllerOverlayInfo +{ +/// Should be set to the sizeof the structure + int iSize; +/// Data. + ADLAdjustmentinfo sOverlayInfo; +/// Should be 0. + int iReserved[3]; +} ADLControllerOverlayInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing GL-Sync module information. +/// +/// This structure is used to retrieve GL-Sync module information for +/// Workstation Framelock/Genlock. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLGLSyncModuleID +{ +/// Unique GL-Sync module ID. + int iModuleID; +/// GL-Sync GPU port index (to be passed into ADLGLSyncGenlockConfig.lSignalSource and ADLGlSyncPortControl.lSignalSource). + int iGlSyncGPUPort; +/// GL-Sync module firmware version of Boot Sector. + int iFWBootSectorVersion; +/// GL-Sync module firmware version of User Sector. + int iFWUserSectorVersion; +} ADLGLSyncModuleID , *LPADLGLSyncModuleID; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing GL-Sync ports capabilities. +/// +/// This structure is used to retrieve hardware capabilities for the ports of the GL-Sync module +/// for Workstation Framelock/Genlock (such as port type and number of associated LEDs). +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLGLSyncPortCaps +{ +/// Port type. Bitfield of ADL_GLSYNC_PORTTYPE_* \ref define_glsync + int iPortType; +/// Number of LEDs associated for this port. + int iNumOfLEDs; +}ADLGLSyncPortCaps, *LPADLGLSyncPortCaps; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing GL-Sync Genlock settings. +/// +/// This structure is used to get and set genlock settings for the GPU ports of the GL-Sync module +/// for Workstation Framelock/Genlock.\n +/// \see define_glsync +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLGLSyncGenlockConfig +{ +/// Specifies what fields in this structure are valid \ref define_glsync + int iValidMask; +/// Delay (ms) generating a sync signal. + int iSyncDelay; +/// Vector of framelock control bits. Bitfield of ADL_GLSYNC_FRAMELOCKCNTL_* \ref define_glsync + int iFramelockCntlVector; +/// Source of the sync signal. Either GL_Sync GPU Port index or ADL_GLSYNC_SIGNALSOURCE_* \ref define_glsync + int iSignalSource; +/// Use sampled sync signal. A value of 0 specifies no sampling. + int iSampleRate; +/// For interlaced sync signals, the value can be ADL_GLSYNC_SYNCFIELD_1 or *_BOTH \ref define_glsync + int iSyncField; +/// The signal edge that should trigger synchronization. ADL_GLSYNC_TRIGGEREDGE_* \ref define_glsync + int iTriggerEdge; +/// Scan rate multiplier applied to the sync signal. ADL_GLSYNC_SCANRATECOEFF_* \ref define_glsync + int iScanRateCoeff; +}ADLGLSyncGenlockConfig, *LPADLGLSyncGenlockConfig; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing GL-Sync port information. +/// +/// This structure is used to get status of the GL-Sync ports (BNC or RJ45s) +/// for Workstation Framelock/Genlock. +/// \see define_glsync +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLGlSyncPortInfo +{ +/// Type of GL-Sync port (ADL_GLSYNC_PORT_*). + int iPortType; +/// The number of LEDs for this port. It's also filled within ADLGLSyncPortCaps. + int iNumOfLEDs; +/// Port state ADL_GLSYNC_PORTSTATE_* \ref define_glsync + int iPortState; +/// Scanned frequency for this port (vertical refresh rate in milliHz; 60000 means 60 Hz). + int iFrequency; +/// Used for ADL_GLSYNC_PORT_BNC. It is ADL_GLSYNC_SIGNALTYPE_* \ref define_glsync + int iSignalType; +/// Used for ADL_GLSYNC_PORT_RJ45PORT*. It is GL_Sync GPU Port index or ADL_GLSYNC_SIGNALSOURCE_*. \ref define_glsync + int iSignalSource; +} ADLGlSyncPortInfo, *LPADLGlSyncPortInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing GL-Sync port control settings. +/// +/// This structure is used to configure the GL-Sync ports (RJ45s only) +/// for Workstation Framelock/Genlock. +/// \see define_glsync +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLGlSyncPortControl +{ +/// Port to control ADL_GLSYNC_PORT_RJ45PORT1 or ADL_GLSYNC_PORT_RJ45PORT2 \ref define_glsync + int iPortType; +/// Port control data ADL_GLSYNC_PORTCNTL_* \ref define_glsync + int iControlVector; +/// Source of the sync signal. Either GL_Sync GPU Port index or ADL_GLSYNC_SIGNALSOURCE_* \ref define_glsync + int iSignalSource; +} ADLGlSyncPortControl; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing GL-Sync mode of a display. +/// +/// This structure is used to get and set GL-Sync mode settings for a display connected to +/// an adapter attached to a GL-Sync module for Workstation Framelock/Genlock. +/// \see define_glsync +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLGlSyncMode +{ +/// Mode control vector. Bitfield of ADL_GLSYNC_MODECNTL_* \ref define_glsync + int iControlVector; +/// Mode status vector. Bitfield of ADL_GLSYNC_MODECNTL_STATUS_* \ref define_glsync + int iStatusVector; +/// Index of GL-Sync connector used to genlock the display/controller. + int iGLSyncConnectorIndex; +} ADLGlSyncMode, *LPADLGlSyncMode; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing GL-Sync mode of a display. +/// +/// This structure is used to get and set GL-Sync mode settings for a display connected to +/// an adapter attached to a GL-Sync module for Workstation Framelock/Genlock. +/// \see define_glsync +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLGlSyncMode2 +{ +/// Mode control vector. Bitfield of ADL_GLSYNC_MODECNTL_* \ref define_glsync + int iControlVector; +/// Mode status vector. Bitfield of ADL_GLSYNC_MODECNTL_STATUS_* \ref define_glsync + int iStatusVector; +/// Index of GL-Sync connector used to genlock the display/controller. + int iGLSyncConnectorIndex; +/// Index of the display to which this GLSync applies to. + int iDisplayIndex; +} ADLGlSyncMode2, *LPADLGlSyncMode2; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing the packet info of a display. +/// +/// This structure is used to get and set the packet information of a display. +/// This structure is used by ADLDisplayDataPacket. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLInfoPacket +{ + char hb0; + char hb1; + char hb2; +/// sb0~sb27 + char sb[28]; +}ADLInfoPacket; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing the AVI packet info of a display. +/// +/// This structure is used to get and set AVI the packet info of a display. +/// This structure is used by ADLDisplayDataPacket. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLAVIInfoPacket //Valid user defined data/ +{ +/// byte 3, bit 7 + char bPB3_ITC; +/// byte 5, bit [7:4]. + char bPB5; +}ADLAVIInfoPacket; + +// Overdrive clock setting structure definition. + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing the Overdrive clock setting. +/// +/// This structure is used to get the Overdrive clock setting. +/// This structure is used by ADLAdapterODClockInfo. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODClockSetting +{ +/// Deafult clock + int iDefaultClock; +/// Current clock + int iCurrentClock; +/// Maximum clcok + int iMaxClock; +/// Minimum clock + int iMinClock; +/// Requested clcock + int iRequestedClock; +/// Step + int iStepClock; +} ADLODClockSetting; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing the Overdrive clock information. +/// +/// This structure is used to get the Overdrive clock information. +/// This structure is used by the ADL_Display_ODClockInfo_Get() function. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLAdapterODClockInfo +{ +/// Size of the structure + int iSize; +/// Flag \ref define_clockinfo_flags + int iFlags; +/// Memory Clock + ADLODClockSetting sMemoryClock; +/// Engine Clock + ADLODClockSetting sEngineClock; +} ADLAdapterODClockInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing the Overdrive clock configuration. +/// +/// This structure is used to set the Overdrive clock configuration. +/// This structure is used by the ADL_Display_ODClockConfig_Set() function. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLAdapterODClockConfig +{ +/// Size of the structure + int iSize; +/// Flag \ref define_clockinfo_flags + int iFlags; +/// Memory Clock + int iMemoryClock; +/// Engine Clock + int iEngineClock; +} ADLAdapterODClockConfig; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about current power management related activity. +/// +/// This structure is used to store information about current power management related activity. +/// This structure (Overdrive 5 interfaces) is used by the ADL_PM_CurrentActivity_Get() function. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLPMActivity +{ +/// Must be set to the size of the structure + int iSize; +/// Current engine clock. + int iEngineClock; +/// Current memory clock. + int iMemoryClock; +/// Current core voltage. + int iVddc; +/// GPU utilization. + int iActivityPercent; +/// Performance level index. + int iCurrentPerformanceLevel; +/// Current PCIE bus speed. + int iCurrentBusSpeed; +/// Number of PCIE bus lanes. + int iCurrentBusLanes; +/// Maximum number of PCIE bus lanes. + int iMaximumBusLanes; +/// Reserved for future purposes. + int iReserved; +} ADLPMActivity; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about thermal controller. +/// +/// This structure is used to store information about thermal controller. +/// This structure is used by ADL_PM_ThermalDevices_Enum. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLThermalControllerInfo +{ +/// Must be set to the size of the structure + int iSize; +/// Possible valies: \ref ADL_DL_THERMAL_DOMAIN_OTHER or \ref ADL_DL_THERMAL_DOMAIN_GPU. + int iThermalDomain; +/// GPU 0, 1, etc. + int iDomainIndex; +/// Possible valies: \ref ADL_DL_THERMAL_FLAG_INTERRUPT or \ref ADL_DL_THERMAL_FLAG_FANCONTROL + int iFlags; +} ADLThermalControllerInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about thermal controller temperature. +/// +/// This structure is used to store information about thermal controller temperature. +/// This structure is used by the ADL_PM_Temperature_Get() function. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLTemperature +{ +/// Must be set to the size of the structure + int iSize; +/// Temperature in millidegrees Celsius. + int iTemperature; +} ADLTemperature; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about thermal controller fan speed. +/// +/// This structure is used to store information about thermal controller fan speed. +/// This structure is used by the ADL_PM_FanSpeedInfo_Get() function. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLFanSpeedInfo +{ +/// Must be set to the size of the structure + int iSize; +/// \ref define_fanctrl + int iFlags; +/// Minimum possible fan speed value in percents. + int iMinPercent; +/// Maximum possible fan speed value in percents. + int iMaxPercent; +/// Minimum possible fan speed value in RPM. + int iMinRPM; +/// Maximum possible fan speed value in RPM. + int iMaxRPM; +} ADLFanSpeedInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about fan speed reported by thermal controller. +/// +/// This structure is used to store information about fan speed reported by thermal controller. +/// This structure is used by the ADL_Overdrive5_FanSpeed_Get() and ADL_Overdrive5_FanSpeed_Set() functions. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLFanSpeedValue +{ +/// Must be set to the size of the structure + int iSize; +/// Possible valies: \ref ADL_DL_FANCTRL_SPEED_TYPE_PERCENT or \ref ADL_DL_FANCTRL_SPEED_TYPE_RPM + int iSpeedType; +/// Fan speed value + int iFanSpeed; +/// The only flag for now is: \ref ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED + int iFlags; +} ADLFanSpeedValue; + +//////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing the range of Overdrive parameter. +/// +/// This structure is used to store information about the range of Overdrive parameter. +/// This structure is used by ADLODParameters. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODParameterRange +{ +/// Minimum parameter value. + int iMin; +/// Maximum parameter value. + int iMax; +/// Parameter step value. + int iStep; +} ADLODParameterRange; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive parameters. +/// +/// This structure is used to store information about Overdrive parameters. +/// This structure is used by the ADL_Overdrive5_ODParameters_Get() function. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODParameters +{ +/// Must be set to the size of the structure + int iSize; +/// Number of standard performance states. + int iNumberOfPerformanceLevels; +/// Indicates whether the GPU is capable to measure its activity. + int iActivityReportingSupported; +/// Indicates whether the GPU supports discrete performance levels or performance range. + int iDiscretePerformanceLevels; +/// Reserved for future use. + int iReserved; +/// Engine clock range. + ADLODParameterRange sEngineClock; +/// Memory clock range. + ADLODParameterRange sMemoryClock; +/// Core voltage range. + ADLODParameterRange sVddc; +} ADLODParameters; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive level. +/// +/// This structure is used to store information about Overdrive level. +/// This structure is used by ADLODPerformanceLevels. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODPerformanceLevel +{ +/// Engine clock. + int iEngineClock; +/// Memory clock. + int iMemoryClock; +/// Core voltage. + int iVddc; +} ADLODPerformanceLevel; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive performance levels. +/// +/// This structure is used to store information about Overdrive performance levels. +/// This structure is used by the ADL_Overdrive5_ODPerformanceLevels_Get() and ADL_Overdrive5_ODPerformanceLevels_Set() functions. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODPerformanceLevels +{ +/// Must be set to sizeof( \ref ADLODPerformanceLevels ) + sizeof( \ref ADLODPerformanceLevel ) * (ADLODParameters.iNumberOfPerformanceLevels - 1) + int iSize; + int iReserved; +/// Array of performance state descriptors. Must have ADLODParameters.iNumberOfPerformanceLevels elements. + ADLODPerformanceLevel aLevels [1]; +} ADLODPerformanceLevels; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the proper CrossfireX chains combinations. +/// +/// This structure is used to store information about the CrossfireX chains combination for a particular adapter. +/// This structure is used by the ADL_Adapter_Crossfire_Caps(), ADL_Adapter_Crossfire_Get(), and ADL_Adapter_Crossfire_Set() functions. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLCrossfireComb +{ +/// Number of adapters in this combination. + int iNumLinkAdapter; +/// A list of ADL indexes of the linked adapters in this combination. + int iAdaptLink[3]; +} ADLCrossfireComb; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing CrossfireX state and error information. +/// +/// This structure is used to store state and error information about a particular adapter CrossfireX combination. +/// This structure is used by the ADL_Adapter_Crossfire_Get() function. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLCrossfireInfo +{ +/// Current error code of this CrossfireX combination. + int iErrorCode; +/// Current \ref define_crossfirestate + int iState; +/// If CrossfireX is supported by this combination. The value is either \ref ADL_TRUE or \ref ADL_FALSE. + int iSupported; +} ADLCrossfireInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing information about the BIOS. +/// +/// This structure is used to store various information about the Chipset. This +/// information can be returned to the user. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLBiosInfo +{ + char strPartNumber[ADL_MAX_PATH]; ///< Part number. + char strVersion[ADL_MAX_PATH]; ///< Version number. + char strDate[ADL_MAX_PATH]; ///< BIOS date in yyyy/mm/dd hh:mm format. +} ADLBiosInfo, *LPADLBiosInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing information about adapter location. +/// +/// This structure is used to store information about adapter location. +/// This structure is used by ADLMVPUStatus. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLAdapterLocation +{ +/// PCI Bus number : 8 bits + int iBus; +/// Device number : 5 bits + int iDevice; +/// Function number : 3 bits + int iFunction; +} ADLAdapterLocation,ADLBdf; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing version information +/// +/// This structure is used to store software version information, description of the display device and a web link to the latest installed Catalyst drivers. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLVersionsInfo +{ + /// Driver Release (Packaging) Version (e.g. 8.71-100128n-094835E-ATI) + char strDriverVer[ADL_MAX_PATH]; + /// Catalyst Version(e.g. "10.1"). + char strCatalystVersion[ADL_MAX_PATH]; + /// Web link to an XML file with information about the latest AMD drivers and locations (e.g. "http://www.amd.com/us/driverxml" ) + char strCatalystWebLink[ADL_MAX_PATH]; +} ADLVersionsInfo, *LPADLVersionsInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing version information +/// +/// This structure is used to store software version information, description of the display device and a web link to the latest installed Catalyst drivers. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLVersionsInfoX2 +{ + /// Driver Release (Packaging) Version (e.g. "16.20.1035-160621a-303814C") + char strDriverVer[ADL_MAX_PATH]; + /// Catalyst Version(e.g. "15.8"). + char strCatalystVersion[ADL_MAX_PATH]; + /// Crimson Version(e.g. "16.6.2"). + char strCrimsonVersion[ADL_MAX_PATH]; + /// Web link to an XML file with information about the latest AMD drivers and locations (e.g. "http://support.amd.com/drivers/xml/driver_09_us.xml" ) + char strCatalystWebLink[ADL_MAX_PATH]; +} ADLVersionsInfoX2, *LPADLVersionsInfoX2; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing information about MultiVPU capabilities. +/// +/// This structure is used to store information about MultiVPU capabilities. +/// This structure is used by the ADL_Display_MVPUCaps_Get() function. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLMVPUCaps +{ +/// Must be set to sizeof( ADLMVPUCaps ). + int iSize; +/// Number of adapters. + int iAdapterCount; +/// Bits set for all possible MVPU masters. \ref MVPU_ADAPTER_0 .. \ref MVPU_ADAPTER_3 + int iPossibleMVPUMasters; +/// Bits set for all possible MVPU slaves. \ref MVPU_ADAPTER_0 .. \ref MVPU_ADAPTER_3 + int iPossibleMVPUSlaves; +/// Registry path for each adapter. + char cAdapterPath[ADL_DL_MAX_MVPU_ADAPTERS][ADL_DL_MAX_REGISTRY_PATH]; +} ADLMVPUCaps; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing information about MultiVPU status. +/// +/// This structure is used to store information about MultiVPU status. +/// Ths structure is used by the ADL_Display_MVPUStatus_Get() function. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLMVPUStatus +{ +/// Must be set to sizeof( ADLMVPUStatus ). + int iSize; +/// Number of active adapters. + int iActiveAdapterCount; +/// MVPU status. + int iStatus; +/// PCI Bus/Device/Function for each active adapter participating in MVPU. + ADLAdapterLocation aAdapterLocation[ADL_DL_MAX_MVPU_ADAPTERS]; +} ADLMVPUStatus; + +// Displays Manager structures + +/////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing information about the activatable source. +/// +/// This structure is used to store activatable source information +/// This information can be returned to the user. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLActivatableSource +{ + /// The Persistent logical Adapter Index. + int iAdapterIndex; + /// The number of Activatable Sources. + int iNumActivatableSources; + /// The bit mask identifies the number of bits ActivatableSourceValue is using. (Not currnetly used) + int iActivatableSourceMask; + /// The bit mask identifies the status. (Not currnetly used) + int iActivatableSourceValue; +} ADLActivatableSource, *LPADLActivatableSource; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing information about display mode. +/// +/// This structure is used to store the display mode for the current adapter +/// such as X, Y positions, screen resolutions, orientation, +/// color depth, refresh rate, progressive or interlace mode, etc. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLMode +{ +/// Adapter index. + int iAdapterIndex; +/// Display IDs. + ADLDisplayID displayID; +/// Screen position X coordinate. + int iXPos; +/// Screen position Y coordinate. + int iYPos; +/// Screen resolution Width. + int iXRes; +/// Screen resolution Height. + int iYRes; +/// Screen Color Depth. E.g., 16, 32. + int iColourDepth; +/// Screen refresh rate. Could be fractional E.g. 59.97 + float fRefreshRate; +/// Screen orientation. E.g., 0, 90, 180, 270. + int iOrientation; +/// Vista mode flag indicating Progressive or Interlaced mode. + int iModeFlag; +/// The bit mask identifying the number of bits this Mode is currently using. It is the sum of all the bit definitions defined in \ref define_displaymode + int iModeMask; +/// The bit mask identifying the display status. The detailed definition is in \ref define_displaymode + int iModeValue; +} ADLMode, *LPADLMode; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing information about display target information. +/// +/// This structure is used to store the display target information. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDisplayTarget +{ + /// The Display ID. + ADLDisplayID displayID; + + /// The display map index identify this manner and the desktop surface. + int iDisplayMapIndex; + + /// The bit mask identifies the number of bits DisplayTarget is currently using. It is the sum of all the bit definitions defined in \ref ADL_DISPLAY_DISPLAYTARGET_PREFERRED. + int iDisplayTargetMask; + + /// The bit mask identifies the display status. The detailed definition is in \ref ADL_DISPLAY_DISPLAYTARGET_PREFERRED. + int iDisplayTargetValue; +} ADLDisplayTarget, *LPADLDisplayTarget; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the display SLS bezel Mode information. +/// +/// This structure is used to store the display SLS bezel Mode information. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tagADLBezelTransientMode +{ + /// Adapter Index + int iAdapterIndex; + + /// SLS Map Index + int iSLSMapIndex; + + /// The mode index + int iSLSModeIndex; + + /// The mode + ADLMode displayMode; + + /// The number of bezel offsets belongs to this map + int iNumBezelOffset; + + /// The first bezel offset array index in the native mode array + int iFirstBezelOffsetArrayIndex; + + /// The bit mask identifies the bits this structure is currently using. It will be the total OR of all the bit definitions. + int iSLSBezelTransientModeMask; + + /// The bit mask identifies the display status. The detail definition is defined below. + int iSLSBezelTransientModeValue; +} ADLBezelTransientMode, *LPADLBezelTransientMode; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing information about the adapter display manner. +/// +/// This structure is used to store adapter display manner information +/// This information can be returned to the user. Alternatively, it can be used to access various driver calls to +/// fetch various display device related display manner settings upon the user's request. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLAdapterDisplayCap +{ + /// The Persistent logical Adapter Index. + int iAdapterIndex; + /// The bit mask identifies the number of bits AdapterDisplayCap is currently using. Sum all the bits defined in ADL_ADAPTER_DISPLAYCAP_XXX + int iAdapterDisplayCapMask; + /// The bit mask identifies the status. Refer to ADL_ADAPTER_DISPLAYCAP_XXX + int iAdapterDisplayCapValue; +} ADLAdapterDisplayCap, *LPADLAdapterDisplayCap; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about display mapping. +/// +/// This structure is used to store the display mapping data such as display manner. +/// For displays with horizontal or vertical stretch manner, +/// this structure also stores the display order, display row, and column data. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDisplayMap +{ +/// The current display map index. It is the OS desktop index. For example, if the OS index 1 is showing clone mode, the display map will be 1. + int iDisplayMapIndex; + +/// The Display Mode for the current map + ADLMode displayMode; + +/// The number of display targets belongs to this map\n + int iNumDisplayTarget; + +/// The first target array index in the Target array\n + int iFirstDisplayTargetArrayIndex; + +/// The bit mask identifies the number of bits DisplayMap is currently using. It is the sum of all the bit definitions defined in ADL_DISPLAY_DISPLAYMAP_MANNER_xxx. + int iDisplayMapMask; + +///The bit mask identifies the display status. The detailed definition is in ADL_DISPLAY_DISPLAYMAP_MANNER_xxx. + int iDisplayMapValue; +} ADLDisplayMap, *LPADLDisplayMap; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing information about the display device possible map for one GPU +/// +/// This structure is used to store the display device possible map +/// This information can be returned to the user. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLPossibleMap +{ + /// The current PossibleMap index. Each PossibleMap is assigned an index + int iIndex; + /// The adapter index identifying the GPU for which to validate these Maps & Targets + int iAdapterIndex; + /// Number of display Maps for this GPU to be validated + int iNumDisplayMap; + /// The display Maps list to validate + ADLDisplayMap* displayMap; + /// the number of display Targets for these display Maps + int iNumDisplayTarget; + /// The display Targets list for these display Maps to be validated. + ADLDisplayTarget* displayTarget; +} ADLPossibleMap, *LPADLPossibleMap; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing information about display possible mapping. +/// +/// This structure is used to store the display possible mapping's controller index for the current display. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLPossibleMapping +{ + int iDisplayIndex; ///< The display index. Each display is assigned an index. + int iDisplayControllerIndex; ///< The controller index to which display is mapped. + int iDisplayMannerSupported; ///< The supported display manner. +} ADLPossibleMapping, *LPADLPossibleMapping; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing information about the validated display device possible map result. +/// +/// This structure is used to store the validated display device possible map result +/// This information can be returned to the user. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLPossibleMapResult +{ + /// The current display map index. It is the OS Desktop index. For example, OS Index 1 showing clone mode. The Display Map will be 1. + int iIndex; + // The bit mask identifies the number of bits PossibleMapResult is currently using. It will be the sum all the bit definitions defined in ADL_DISPLAY_POSSIBLEMAPRESULT_VALID. + int iPossibleMapResultMask; + /// The bit mask identifies the possible map result. The detail definition is defined in ADL_DISPLAY_POSSIBLEMAPRESULT_XXX. + int iPossibleMapResultValue; +} ADLPossibleMapResult, *LPADLPossibleMapResult; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the display SLS Grid information. +/// +/// This structure is used to store the display SLS Grid information. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLSLSGrid +{ +/// The Adapter index. + int iAdapterIndex; + +/// The grid index. + int iSLSGridIndex; + +/// The grid row. + int iSLSGridRow; + +/// The grid column. + int iSLSGridColumn; + +/// The grid bit mask identifies the number of bits DisplayMap is currently using. Sum of all bits defined in ADL_DISPLAY_SLSGRID_ORIENTATION_XXX + int iSLSGridMask; + +/// The grid bit value identifies the display status. Refer to ADL_DISPLAY_SLSGRID_ORIENTATION_XXX + int iSLSGridValue; +} ADLSLSGrid, *LPADLSLSGrid; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the display SLS Map information. +/// +/// This structure is used to store the display SLS Map information. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLSLSMap +{ + /// The Adapter Index + int iAdapterIndex; + + /// The current display map index. It is the OS Desktop index. For example, OS Index 1 showing clone mode. The Display Map will be 1. + int iSLSMapIndex; + + /// Indicate the current grid + ADLSLSGrid grid; + + /// OS surface index + int iSurfaceMapIndex; + + /// Screen orientation. E.g., 0, 90, 180, 270 + int iOrientation; + + /// The number of display targets belongs to this map + int iNumSLSTarget; + + /// The first target array index in the Target array + int iFirstSLSTargetArrayIndex; + + /// The number of native modes belongs to this map + int iNumNativeMode; + + /// The first native mode array index in the native mode array + int iFirstNativeModeArrayIndex; + + /// The number of bezel modes belongs to this map + int iNumBezelMode; + + /// The first bezel mode array index in the native mode array + int iFirstBezelModeArrayIndex; + + /// The number of bezel offsets belongs to this map + int iNumBezelOffset; + + /// The first bezel offset array index in the + int iFirstBezelOffsetArrayIndex; + + /// The bit mask identifies the number of bits DisplayMap is currently using. Sum all the bit definitions defined in ADL_DISPLAY_SLSMAP_XXX. + int iSLSMapMask; + + /// The bit mask identifies the display map status. Refer to ADL_DISPLAY_SLSMAP_XXX + int iSLSMapValue; +} ADLSLSMap, *LPADLSLSMap; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the display SLS Offset information. +/// +/// This structure is used to store the display SLS Offset information. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLSLSOffset +{ + /// The Adapter Index + int iAdapterIndex; + + /// The current display map index. It is the OS Desktop index. For example, OS Index 1 showing clone mode. The Display Map will be 1. + int iSLSMapIndex; + + /// The Display ID. + ADLDisplayID displayID; + + /// SLS Bezel Mode Index + int iBezelModeIndex; + + /// SLS Bezel Offset X + int iBezelOffsetX; + + /// SLS Bezel Offset Y + int iBezelOffsetY; + + /// SLS Display Width + int iDisplayWidth; + + /// SLS Display Height + int iDisplayHeight; + + /// The bit mask identifies the number of bits Offset is currently using. + int iBezelOffsetMask; + + /// The bit mask identifies the display status. + int iBezelffsetValue; +} ADLSLSOffset, *LPADLSLSOffset; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the display SLS Mode information. +/// +/// This structure is used to store the display SLS Mode information. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLSLSMode +{ + /// The Adapter Index + int iAdapterIndex; + + /// The current display map index. It is the OS Desktop index. For example, OS Index 1 showing clone mode. The Display Map will be 1. + int iSLSMapIndex; + + /// The mode index + int iSLSModeIndex; + + /// The mode for this map. + ADLMode displayMode; + + /// The bit mask identifies the number of bits Mode is currently using. + int iSLSNativeModeMask; + + /// The bit mask identifies the display status. + int iSLSNativeModeValue; +} ADLSLSMode, *LPADLSLSMode; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the display Possible SLS Map information. +/// +/// This structure is used to store the display Possible SLS Map information. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLPossibleSLSMap +{ + /// The current display map index. It is the OS Desktop index. + /// For example, OS Index 1 showing clone mode. The Display Map will be 1. + int iSLSMapIndex; + + /// Number of display map to be validated. + int iNumSLSMap; + + /// The display map list for validation + ADLSLSMap* lpSLSMap; + + /// the number of display map config to be validated. + int iNumSLSTarget; + + /// The display target list for validation. + ADLDisplayTarget* lpDisplayTarget; +} ADLPossibleSLSMap, *LPADLPossibleSLSMap; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the SLS targets. +/// +/// This structure is used to store the SLS targets information. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLSLSTarget +{ + /// the logic adapter index + int iAdapterIndex; + + /// The SLS map index + int iSLSMapIndex; + + /// The target ID + ADLDisplayTarget displayTarget; + + /// Target postion X in SLS grid + int iSLSGridPositionX; + + /// Target postion Y in SLS grid + int iSLSGridPositionY; + + /// The view size width, height and rotation angle per SLS Target + ADLMode viewSize; + + /// The bit mask identifies the bits in iSLSTargetValue are currently used + int iSLSTargetMask; + + /// The bit mask identifies status info. It is for function extension purpose + int iSLSTargetValue; +} ADLSLSTarget, *LPADLSLSTarget; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the Adapter offset stepping size. +/// +/// This structure is used to store the Adapter offset stepping size information. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLBezelOffsetSteppingSize +{ + /// the logic adapter index + int iAdapterIndex; + + /// The SLS map index + int iSLSMapIndex; + + /// Bezel X stepping size offset + int iBezelOffsetSteppingSizeX; + + /// Bezel Y stepping size offset + int iBezelOffsetSteppingSizeY; + + /// Identifies the bits this structure is currently using. It will be the total OR of all the bit definitions. + int iBezelOffsetSteppingSizeMask; + + /// Bit mask identifies the display status. + int iBezelOffsetSteppingSizeValue; +} ADLBezelOffsetSteppingSize, *LPADLBezelOffsetSteppingSize; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the overlap offset info for all the displays for each SLS mode. +/// +/// This structure is used to store the no. of overlapped modes for each SLS Mode once user finishes the configuration from Overlap Widget +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLSLSOverlappedMode +{ + /// the SLS mode for which the overlap is configured + ADLMode SLSMode; + /// the number of target displays in SLS. + int iNumSLSTarget; + /// the first target array index in the target array + int iFirstTargetArrayIndex; +}ADLSLSTargetOverlap, *LPADLSLSTargetOverlap; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about driver supported PowerExpress Config Caps +/// +/// This structure is used to store the driver supported PowerExpress Config Caps +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLPXConfigCaps +{ + /// The Persistent logical Adapter Index. + int iAdapterIndex; + + /// The bit mask identifies the number of bits PowerExpress Config Caps is currently using. It is the sum of all the bit definitions defined in ADL_PX_CONFIGCAPS_XXXX /ref define_powerxpress_constants. + int iPXConfigCapMask; + + /// The bit mask identifies the PowerExpress Config Caps value. The detailed definition is in ADL_PX_CONFIGCAPS_XXXX /ref define_powerxpress_constants. + int iPXConfigCapValue; +} ADLPXConfigCaps, *LPADLPXConfigCaps; + +///////////////////////////////////////////////////////////////////////////////////////// +///\brief Enum containing PX or HG type +/// +/// This enum is used to get PX or hG type +/// +/// \nosubgrouping +////////////////////////////////////////////////////////////////////////////////////////// +typedef enum ADLPxType +{ + //Not AMD related PX/HG or not PX or HG at all + ADL_PX_NONE = 0, + //A+A PX + ADL_SWITCHABLE_AMDAMD = 1, + // A+A HG + ADL_HG_AMDAMD = 2, + //A+I PX + ADL_SWITCHABLE_AMDOTHER = 3, + //A+I HG + ADL_HG_AMDOTHER = 4, +}ADLPxType; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about an application +/// +/// This structure is used to store basic information of an application +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLApplicationData +{ + /// Path Name + char strPathName[ADL_MAX_PATH]; + /// File Name + char strFileName[ADL_APP_PROFILE_FILENAME_LENGTH]; + /// Creation timestamp + char strTimeStamp[ADL_APP_PROFILE_TIMESTAMP_LENGTH]; + /// Version + char strVersion[ADL_APP_PROFILE_VERSION_LENGTH]; +}ADLApplicationData; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about an application +/// +/// This structure is used to store basic information of an application +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLApplicationDataX2 +{ + /// Path Name + wchar_t strPathName[ADL_MAX_PATH]; + /// File Name + wchar_t strFileName[ADL_APP_PROFILE_FILENAME_LENGTH]; + /// Creation timestamp + wchar_t strTimeStamp[ADL_APP_PROFILE_TIMESTAMP_LENGTH]; + /// Version + wchar_t strVersion[ADL_APP_PROFILE_VERSION_LENGTH]; +}ADLApplicationDataX2; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about an application +/// +/// This structure is used to store basic information of an application including process id +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLApplicationDataX3 +{ + /// Path Name + wchar_t strPathName[ADL_MAX_PATH]; + /// File Name + wchar_t strFileName[ADL_APP_PROFILE_FILENAME_LENGTH]; + /// Creation timestamp + wchar_t strTimeStamp[ADL_APP_PROFILE_TIMESTAMP_LENGTH]; + /// Version + wchar_t strVersion[ADL_APP_PROFILE_VERSION_LENGTH]; + //Application Process id + unsigned int iProcessId; +}ADLApplicationDataX3; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information of a property of an application profile +/// +/// This structure is used to store property information of an application profile +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct PropertyRecord +{ + /// Property Name + char strName [ADL_APP_PROFILE_PROPERTY_LENGTH]; + /// Property Type + ADLProfilePropertyType eType; + /// Data Size in bytes + int iDataSize; + /// Property Value, can be any data type + unsigned char uData[1]; +}PropertyRecord; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about an application profile +/// +/// This structure is used to store information of an application profile +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLApplicationProfile +{ + /// Number of properties + int iCount; + /// Buffer to store all property records + PropertyRecord record[1]; +}ADLApplicationProfile; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about an OD5 Power Control feature +/// +/// This structure is used to store information of an Power Control feature +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLPowerControlInfo +{ +/// Minimum value. +int iMinValue; +/// Maximum value. +int iMaxValue; +/// The minimum change in between minValue and maxValue. +int iStepValue; + } ADLPowerControlInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about an controller mode +/// +/// This structure is used to store information of an controller mode +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLControllerMode +{ + /// This falg indicates actions that will be applied by set viewport + /// The value can be a combination of ADL_CONTROLLERMODE_CM_MODIFIER_VIEW_POSITION, + /// ADL_CONTROLLERMODE_CM_MODIFIER_VIEW_PANLOCK and ADL_CONTROLLERMODE_CM_MODIFIER_VIEW_SIZE + int iModifiers; + + /// Horizontal view starting position + int iViewPositionCx; + + /// Vertical view starting position + int iViewPositionCy; + + /// Horizontal left panlock position + int iViewPanLockLeft; + + /// Horizontal right panlock position + int iViewPanLockRight; + + /// Vertical top panlock position + int iViewPanLockTop; + + /// Vertical bottom panlock position + int iViewPanLockBottom; + + /// View resolution in pixels (width) + int iViewResolutionCx; + + /// View resolution in pixels (hight) + int iViewResolutionCy; +}ADLControllerMode; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about a display +/// +/// This structure is used to store information about a display +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDisplayIdentifier +{ + /// ADL display index + long ulDisplayIndex; + + /// manufacturer ID of the display + long ulManufacturerId; + + /// product ID of the display + long ulProductId; + + /// serial number of the display + long ulSerialNo; +} ADLDisplayIdentifier; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive 6 clock range +/// +/// This structure is used to store information about Overdrive 6 clock range +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD6ParameterRange +{ + /// The starting value of the clock range + int iMin; + /// The ending value of the clock range + int iMax; + /// The minimum increment between clock values + int iStep; +} ADLOD6ParameterRange; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive 6 capabilities +/// +/// This structure is used to store information about Overdrive 6 capabilities +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD6Capabilities +{ + /// Contains a bitmap of the OD6 capability flags. Possible values: \ref ADL_OD6_CAPABILITY_SCLK_CUSTOMIZATION, + /// \ref ADL_OD6_CAPABILITY_MCLK_CUSTOMIZATION, \ref ADL_OD6_CAPABILITY_GPU_ACTIVITY_MONITOR + int iCapabilities; + /// Contains a bitmap indicating the power states + /// supported by OD6. Currently only the performance state + /// is supported. Possible Values: \ref ADL_OD6_SUPPORTEDSTATE_PERFORMANCE + int iSupportedStates; + /// Number of levels. OD6 will always use 2 levels, which describe + /// the minimum to maximum clock ranges. + /// The 1st level indicates the minimum clocks, and the 2nd level + /// indicates the maximum clocks. + int iNumberOfPerformanceLevels; + /// Contains the hard limits of the sclk range. Overdrive + /// clocks cannot be set outside this range. + ADLOD6ParameterRange sEngineClockRange; + /// Contains the hard limits of the mclk range. Overdrive + /// clocks cannot be set outside this range. + ADLOD6ParameterRange sMemoryClockRange; + + /// Value for future extension + int iExtValue; + /// Mask for future extension + int iExtMask; +} ADLOD6Capabilities; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive 6 clock values. +/// +/// This structure is used to store information about Overdrive 6 clock values. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD6PerformanceLevel +{ + /// Engine (core) clock. + int iEngineClock; + /// Memory clock. + int iMemoryClock; +} ADLOD6PerformanceLevel; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive 6 clocks. +/// +/// This structure is used to store information about Overdrive 6 clocks. This is a +/// variable-sized structure. iNumberOfPerformanceLevels indicate how many elements +/// are contained in the aLevels array. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD6StateInfo +{ + /// Number of levels. OD6 uses clock ranges instead of discrete performance levels. + /// iNumberOfPerformanceLevels is always 2. The 1st level indicates the minimum clocks + /// in the range. The 2nd level indicates the maximum clocks in the range. + int iNumberOfPerformanceLevels; + + /// Value for future extension + int iExtValue; + /// Mask for future extension + int iExtMask; + + /// Variable-sized array of levels. + /// The number of elements in the array is specified by iNumberofPerformanceLevels. + ADLOD6PerformanceLevel aLevels [1]; +} ADLOD6StateInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about current Overdrive 6 performance status. +/// +/// This structure is used to store information about current Overdrive 6 performance status. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD6CurrentStatus +{ + /// Current engine clock in 10 KHz. + int iEngineClock; + /// Current memory clock in 10 KHz. + int iMemoryClock; + /// Current GPU activity in percent. This + /// indicates how "busy" the GPU is. + int iActivityPercent; + /// Not used. Reserved for future use. + int iCurrentPerformanceLevel; + /// Current PCI-E bus speed + int iCurrentBusSpeed; + /// Current PCI-E bus # of lanes + int iCurrentBusLanes; + /// Maximum possible PCI-E bus # of lanes + int iMaximumBusLanes; + + /// Value for future extension + int iExtValue; + /// Mask for future extension + int iExtMask; +} ADLOD6CurrentStatus; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive 6 thermal contoller capabilities +/// +/// This structure is used to store information about Overdrive 6 thermal controller capabilities +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD6ThermalControllerCaps +{ + /// Contains a bitmap of thermal controller capability flags. Possible values: \ref ADL_OD6_TCCAPS_THERMAL_CONTROLLER, \ref ADL_OD6_TCCAPS_FANSPEED_CONTROL, + /// \ref ADL_OD6_TCCAPS_FANSPEED_PERCENT_READ, \ref ADL_OD6_TCCAPS_FANSPEED_PERCENT_WRITE, \ref ADL_OD6_TCCAPS_FANSPEED_RPM_READ, \ref ADL_OD6_TCCAPS_FANSPEED_RPM_WRITE + int iCapabilities; + /// Minimum fan speed expressed as a percentage + int iFanMinPercent; + /// Maximum fan speed expressed as a percentage + int iFanMaxPercent; + /// Minimum fan speed expressed in revolutions-per-minute + int iFanMinRPM; + /// Maximum fan speed expressed in revolutions-per-minute + int iFanMaxRPM; + + /// Value for future extension + int iExtValue; + /// Mask for future extension + int iExtMask; +} ADLOD6ThermalControllerCaps; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive 6 fan speed information +/// +/// This structure is used to store information about Overdrive 6 fan speed information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD6FanSpeedInfo +{ + /// Contains a bitmap of the valid fan speed type flags. Possible values: \ref ADL_OD6_FANSPEED_TYPE_PERCENT, \ref ADL_OD6_FANSPEED_TYPE_RPM, \ref ADL_OD6_FANSPEED_USER_DEFINED + int iSpeedType; + /// Contains current fan speed in percent (if valid flag exists in iSpeedType) + int iFanSpeedPercent; + /// Contains current fan speed in RPM (if valid flag exists in iSpeedType) + int iFanSpeedRPM; + + /// Value for future extension + int iExtValue; + /// Mask for future extension + int iExtMask; +} ADLOD6FanSpeedInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive 6 fan speed value +/// +/// This structure is used to store information about Overdrive 6 fan speed value +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD6FanSpeedValue +{ + /// Indicates the units of the fan speed. Possible values: \ref ADL_OD6_FANSPEED_TYPE_PERCENT, \ref ADL_OD6_FANSPEED_TYPE_RPM + int iSpeedType; + /// Fan speed value (units as indicated above) + int iFanSpeed; + + /// Value for future extension + int iExtValue; + /// Mask for future extension + int iExtMask; +} ADLOD6FanSpeedValue; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive 6 PowerControl settings. +/// +/// This structure is used to store information about Overdrive 6 PowerControl settings. +/// PowerControl is the feature which allows the performance characteristics of the GPU +/// to be adjusted by changing the PowerTune power limits. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD6PowerControlInfo +{ + /// The minimum PowerControl adjustment value + int iMinValue; + /// The maximum PowerControl adjustment value + int iMaxValue; + /// The minimum difference between PowerControl adjustment values + int iStepValue; + + /// Value for future extension + int iExtValue; + /// Mask for future extension + int iExtMask; +} ADLOD6PowerControlInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive 6 PowerControl settings. +/// +/// This structure is used to store information about Overdrive 6 PowerControl settings. +/// PowerControl is the feature which allows the performance characteristics of the GPU +/// to be adjusted by changing the PowerTune power limits. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD6VoltageControlInfo +{ + /// The minimum VoltageControl adjustment value + int iMinValue; + /// The maximum VoltageControl adjustment value + int iMaxValue; + /// The minimum difference between VoltageControl adjustment values + int iStepValue; + + /// Value for future extension + int iExtValue; + /// Mask for future extension + int iExtMask; +} ADLOD6VoltageControlInfo; + +//////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing ECC statistics namely SEC counts and DED counts +/// Single error count - count of errors that can be corrected +/// Doubt Error Detect - count of errors that cannot be corrected +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLECCData +{ + // Single error count - count of errors that can be corrected + int iSec; + // Double error detect - count of errors that cannot be corrected + int iDed; +} ADLECCData; + +/// \brief Handle to ADL client context. +/// +/// ADL clients obtain context handle from initial call to \ref ADL2_Main_Control_Create. +/// Clients have to pass the handle to each subsequent ADL call and finally destroy +/// the context with call to \ref ADL2_Main_Control_Destroy +/// \nosubgrouping +typedef void *ADL_CONTEXT_HANDLE; + +/// \brief Handle to ADL Frame Monitor Token. +/// +/// Frame Monitor clients obtain handle from initial call to \ref ADL2_Adapter_FrameMetrics_FrameDuration_Enable +/// Clients have to pass the handle to each subsequent ADL call to \ref ADL2_Adapter_FrameMetrics_FrameDuration_Get +/// and finally destroy the token with call to \ref ADL2_Adapter_FrameMetrics_FrameDuration_Disable +/// \nosubgrouping +typedef void *ADL_FRAME_DURATION_HANDLE; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing the display mode definition used per controller. +/// +/// This structure is used to store the display mode definition used per controller. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDisplayModeX2 +{ +/// Horizontal resolution (in pixels). + int iWidth; +/// Vertical resolution (in lines). + int iHeight; +/// Interlaced/Progressive. The value will be set for Interlaced as ADL_DL_TIMINGFLAG_INTERLACED. If not set it is progressive. Refer define_detailed_timing_flags. + int iScanType; +/// Refresh rate. + int iRefreshRate; +/// Timing Standard. Refer define_modetiming_standard. + int iTimingStandard; +} ADLDisplayModeX2; + +typedef enum ADLAppProcessState +{ + APP_PROC_INVALID = 0, // Invalid Application + APP_PROC_PREMPTION = 1, // The Application is being set up for Process Creation + APP_PROC_CREATION = 2, // The Application's Main Process is created by the OS + APP_PROC_READ = 3, // The Application's Data is ready to be read + APP_PROC_WAIT = 4, // The Application is waiting for Timeout or Notification to Resume + APP_PROC_RUNNING = 5, // The Application is running + APP_PROC_TERMINATE = 6 // The Application is about to terminate +}ADLAppProcessState; + +typedef enum ADLAppInterceptionListType +{ + ADL_INVALID_FORMAT = 0, + ADL_IMAGEFILEFORMAT = 1, + ADL_ENVVAR = 2 +}ADLAppInterceptionListType; + +typedef struct ADLAppInterceptionInfo +{ + wchar_t AppName[ADL_MAX_PATH]; // the file name of the application or env var + unsigned int ProcessId; + ADLAppInterceptionListType AppFormat; + ADLAppProcessState AppState; +} ADLAppInterceptionInfo; + +typedef enum ADL_AP_DATABASE // same as _SHARED_AP_DATABASE in "inc/shared/shared_escape.h" +{ + ADL_AP_DATABASE__SYSTEM, + ADL_AP_DATABASE__USER, + ADL_AP_DATABASE__OEM +} ADL_AP_DATABASE; + +typedef struct ADLAppInterceptionInfoX2 +{ + wchar_t AppName[ADL_MAX_PATH]; // the file name of the application or env var + unsigned int ProcessId; + unsigned int WaitForResumeNeeded; + wchar_t CommandLine[ADL_MAX_PATH]; // The command line on app start/stop event + ADLAppInterceptionListType AppFormat; + ADLAppProcessState AppState; +} ADLAppInterceptionInfoX2; + +typedef struct ADLAppInterceptionInfoX3 +{ + wchar_t AppName[ADL_MAX_PATH]; // the file name of the application or env var + unsigned int ProcessId; + unsigned int WaitForResumeNeeded; + unsigned int RayTracingStatus; // returns the Ray Tracing status if it is enabled atleast once in session. + wchar_t CommandLine[ADL_MAX_PATH]; // The command line on app start/stop event + ADLAppInterceptionListType AppFormat; + ADLAppProcessState AppState; +} ADLAppInterceptionInfoX3; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information info for a property record in a profile +/// +/// This structure is used to store info for a property record in a profile +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLPropertyRecordCreate +{ + /// Name of the property + wchar_t * strPropertyName; + /// Data type of the property + ADLProfilePropertyType eType; + // Value of the property + wchar_t * strPropertyValue; +} ADLPropertyRecordCreate; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information info for an application record +/// +/// This structure is used to store info for an application record +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLApplicationRecord +{ + /// Title of the application + wchar_t * strTitle; + /// File path of the application + wchar_t * strPathName; + /// File name of the application + wchar_t * strFileName; + /// File versin the application + wchar_t * strVersion; + /// Nostes on the application + wchar_t * strNotes; + /// Driver area which the application uses + wchar_t * strArea; + /// Name of profile assigned to the application + wchar_t * strProfileName; + // Source where this application record come from + ADL_AP_DATABASE recordSource; +} ADLApplicationRecord; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive 6 extension capabilities +/// +/// This structure is used to store information about Overdrive 6 extension capabilities +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD6CapabilitiesEx +{ + /// Contains a bitmap of the OD6 extension capability flags. Possible values: \ref ADL_OD6_CAPABILITY_SCLK_CUSTOMIZATION, + /// \ref ADL_OD6_CAPABILITY_MCLK_CUSTOMIZATION, \ref ADL_OD6_CAPABILITY_GPU_ACTIVITY_MONITOR, + /// \ref ADL_OD6_CAPABILITY_POWER_CONTROL, \ref ADL_OD6_CAPABILITY_VOLTAGE_CONTROL, \ref ADL_OD6_CAPABILITY_PERCENT_ADJUSTMENT, + //// \ref ADL_OD6_CAPABILITY_THERMAL_LIMIT_UNLOCK + int iCapabilities; + /// The Power states that support clock and power customization. Only performance state is currently supported. + /// Possible Values: \ref ADL_OD6_SUPPORTEDSTATE_PERFORMANCE + int iSupportedStates; + /// Returns the hard limits of the SCLK overdrive adjustment range. Overdrive clocks should not be adjusted outside of this range. The values are specified as +/- percentages. + ADLOD6ParameterRange sEngineClockPercent; + /// Returns the hard limits of the MCLK overdrive adjustment range. Overdrive clocks should not be adjusted outside of this range. The values are specified as +/- percentages. + ADLOD6ParameterRange sMemoryClockPercent; + /// Returns the hard limits of the Power Limit adjustment range. Power limit should not be adjusted outside this range. The values are specified as +/- percentages. + ADLOD6ParameterRange sPowerControlPercent; + /// Reserved for future expansion of the structure. + int iExtValue; + /// Reserved for future expansion of the structure. + int iExtMask; +} ADLOD6CapabilitiesEx; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive 6 extension state information +/// +/// This structure is used to store information about Overdrive 6 extension state information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD6StateEx +{ + /// The current engine clock adjustment value, specified as a +/- percent. + int iEngineClockPercent; + /// The current memory clock adjustment value, specified as a +/- percent. + int iMemoryClockPercent; + /// The current power control adjustment value, specified as a +/- percent. + int iPowerControlPercent; + /// Reserved for future expansion of the structure. + int iExtValue; + /// Reserved for future expansion of the structure. + int iExtMask; +} ADLOD6StateEx; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive 6 extension recommended maximum clock adjustment values +/// +/// This structure is used to store information about Overdrive 6 extension recommended maximum clock adjustment values +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD6MaxClockAdjust +{ + /// The recommended maximum engine clock adjustment in percent, for the specified power limit value. + int iEngineClockMax; + /// The recommended maximum memory clock adjustment in percent, for the specified power limit value. + /// Currently the memory is independent of the Power Limit setting, so iMemoryClockMax will always return the maximum + /// possible adjustment value. This field is here for future enhancement in case we add a dependency between Memory Clock + /// adjustment and Power Limit setting. + int iMemoryClockMax; + /// Reserved for future expansion of the structure. + int iExtValue; + /// Reserved for future expansion of the structure. + int iExtMask; +} ADLOD6MaxClockAdjust; + +//////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing the Connector information +/// +/// this structure is used to get the connector information like length, positions & etc. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLConnectorInfo +{ + ///index of the connector(0-based) + int iConnectorIndex; + ///used for disply identification/ordering + int iConnectorId; + ///index of the slot, 0-based index. + int iSlotIndex; + ///Type of the connector. \ref define_connector_types + int iType; + ///Position of the connector(in millimeters), from the right side of the slot. + int iOffset; + ///Length of the connector(in millimeters). + int iLength; +} ADLConnectorInfo; + +//////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing the slot information +/// +/// this structure is used to get the slot information like length of the slot, no of connectors on the slot & etc. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLBracketSlotInfo +{ + ///index of the slot, 0-based index. + int iSlotIndex; + ///length of the slot(in millimeters). + int iLength; + ///width of the slot(in millimeters). + int iWidth; +} ADLBracketSlotInfo; + +//////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing MST branch information +/// +/// this structure is used to store the MST branch information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLMSTRad +{ + ///depth of the link. + int iLinkNumber; + /// Relative address, address scheme starts from source side + char rad[ADL_MAX_RAD_LINK_COUNT]; +} ADLMSTRad; + +//////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing port information +/// +/// this structure is used to get the display or MST branch information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDevicePort +{ + ///index of the connector. + int iConnectorIndex; + ///Relative MST address. If MST RAD contains 0 it means DP or Root of the MST topology. For non DP connectors MST RAD is ignored. + ADLMSTRad aMSTRad; +} ADLDevicePort; + +//////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing supported connection types and properties +/// +/// this structure is used to get the supported connection types and supported properties of given connector +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLSupportedConnections +{ + ///Bit vector of supported connections. Bitmask is defined in constants section. \ref define_connection_types + int iSupportedConnections; + ///Array of bitvectors. Each bit vector represents supported properties for one connection type. Index of this array is connection type (bit number in mask). + int iSupportedProperties[ADL_MAX_CONNECTION_TYPES]; +} ADLSupportedConnections; + +//////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing connection state of the connector +/// +/// this structure is used to get the current Emulation status and mode of the given connector +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLConnectionState +{ + ///The value is bit vector. Each bit represents status. See masks constants for details. \ref define_emulation_status + int iEmulationStatus; + ///It contains information about current emulation mode. See constants for details. \ref define_emulation_mode + int iEmulationMode; + ///If connection is active it will contain display id, otherwise CWDDEDI_INVALID_DISPLAY_INDEX + int iDisplayIndex; +} ADLConnectionState; + +//////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing connection properties information +/// +/// this structure is used to retrieve the properties of connection type +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLConnectionProperties +{ + //Bit vector. Represents actual properties. Supported properties for specific connection type. \ref define_connection_properties + int iValidProperties; + //Bitrate(in MHz). Could be used for MST branch, DP or DP active dongle. \ref define_linkrate_constants + int iBitrate; + //Number of lanes in DP connection. \ref define_lanecount_constants + int iNumberOfLanes; + //Color depth(in bits). \ref define_colordepth_constants + int iColorDepth; + //3D capabilities. It could be used for some dongles. For instance: alternate framepack. Value of this property is bit vector. + int iStereo3DCaps; + ///Output Bandwidth. Could be used for MST branch, DP or DP Active dongle. \ref define_linkrate_constants + int iOutputBandwidth; +} ADLConnectionProperties; + +//////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing connection information +/// +/// this structure is used to retrieve the data from driver which includes +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLConnectionData +{ + ///Connection type. based on the connection type either iNumberofPorts or IDataSize,EDIDdata is valid, \ref define_connection_types + int iConnectionType; + ///Specifies the connection properties. + ADLConnectionProperties aConnectionProperties; + ///Number of ports + int iNumberofPorts; + ///Number of Active Connections + int iActiveConnections; + ///actual size of EDID data block size. + int iDataSize; + ///EDID Data + char EdidData[ADL_MAX_DISPLAY_EDID_DATA_SIZE]; +} ADLConnectionData; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about an controller mode including Number of Connectors +/// +/// This structure is used to store information of an controller mode +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLAdapterCapsX2 +{ + /// AdapterID for this adapter + int iAdapterID; + /// Number of controllers for this adapter + int iNumControllers; + /// Number of displays for this adapter + int iNumDisplays; + /// Number of overlays for this adapter + int iNumOverlays; + /// Number of GLSyncConnectors + int iNumOfGLSyncConnectors; + /// The bit mask identifies the adapter caps + int iCapsMask; + /// The bit identifies the adapter caps \ref define_adapter_caps + int iCapsValue; + /// Number of Connectors for this adapter + int iNumConnectors; +}ADLAdapterCapsX2; + +typedef enum ADL_ERROR_RECORD_SEVERITY +{ + ADL_GLOBALLY_UNCORRECTED = 1, + ADL_LOCALLY_UNCORRECTED = 2, + ADL_DEFFERRED = 3, + ADL_CORRECTED = 4 +}ADL_ERROR_RECORD_SEVERITY; + +typedef union _ADL_ECC_EDC_FLAG +{ + struct + { + unsigned int isEccAccessing : 1; + unsigned int reserved : 31; + }bits; + unsigned int u32All; +}ADL_ECC_EDC_FLAG; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about EDC Error Record +/// +/// This structure is used to store EDC Error Record +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLErrorRecord +{ + // Severity of error + ADL_ERROR_RECORD_SEVERITY Severity; + + // Is the counter valid? + int countValid; + + // Counter value, if valid + unsigned int count; + + // Is the location information valid? + int locationValid; + + // Physical location of error + unsigned int CU; // CU number on which error occurred, if known + char StructureName[32]; // e.g. LDS, TCC, etc. + + // Time of error record creation (e.g. time of query, or time of poison interrupt) + char tiestamp[32]; + + unsigned int padding[3]; +}ADLErrorRecord; + +typedef enum ADL_EDC_BLOCK_ID +{ + ADL_EDC_BLOCK_ID_SQCIS = 1, + ADL_EDC_BLOCK_ID_SQCDS = 2, + ADL_EDC_BLOCK_ID_SGPR = 3, + ADL_EDC_BLOCK_ID_VGPR = 4, + ADL_EDC_BLOCK_ID_LDS = 5, + ADL_EDC_BLOCK_ID_GDS = 6, + ADL_EDC_BLOCK_ID_TCL1 = 7, + ADL_EDC_BLOCK_ID_TCL2 = 8 +}ADL_EDC_BLOCK_ID; + +typedef enum ADL_ERROR_INJECTION_MODE +{ + ADL_ERROR_INJECTION_MODE_SINGLE = 1, + ADL_ERROR_INJECTION_MODE_MULTIPLE = 2, + ADL_ERROR_INJECTION_MODE_ADDRESS = 3 +}ADL_ERROR_INJECTION_MODE; + +typedef union _ADL_ERROR_PATTERN +{ + struct + { + unsigned long EccInjVector : 16; + unsigned long EccInjEn : 9; + unsigned long EccBeatEn : 4; + unsigned long EccChEn : 4; + unsigned long reserved : 31; + } bits; + unsigned long long u64Value; +} ADL_ERROR_PATTERN; + +typedef struct ADL_ERROR_INJECTION_DATA +{ + unsigned long long errorAddress; + ADL_ERROR_PATTERN errorPattern; +}ADL_ERROR_INJECTION_DATA; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about EDC Error Injection +/// +/// This structure is used to store EDC Error Injection +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLErrorInjection +{ + ADL_EDC_BLOCK_ID blockId; + ADL_ERROR_INJECTION_MODE errorInjectionMode; +}ADLErrorInjection; + +typedef struct ADLErrorInjectionX2 +{ + ADL_EDC_BLOCK_ID blockId; + ADL_ERROR_INJECTION_MODE errorInjectionMode; + ADL_ERROR_INJECTION_DATA errorInjectionData; +}ADLErrorInjectionX2; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing per display FreeSync capability information. +/// +/// This structure is used to store the FreeSync capability of both the display and +/// the GPU the display is connected to. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLFreeSyncCap +{ + /// FreeSync capability flags. \ref define_freesync_caps + int iCaps; + /// Reports minimum FreeSync refresh rate supported by the display in micro hertz + int iMinRefreshRateInMicroHz; + /// Reports maximum FreeSync refresh rate supported by the display in micro hertz + int iMaxRefreshRateInMicroHz; + /// Index of FreeSync Label to use: ADL_FREESYNC_LABEL_* + unsigned char ucLabelIndex; + /// Reserved + char cReserved[3]; + int iReserved[4]; +} ADLFreeSyncCap; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing per display Display Connectivty Experience Settings +/// +/// This structure is used to store the Display Connectivity Experience settings of a +/// display +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDceSettings +{ + DceSettingsType type; // Defines which structure is in the union below + union + { + struct + { + bool qualityDetectionEnabled; + } HdmiLq; + struct + { + DpLinkRate linkRate; // Read-only + unsigned int numberOfActiveLanes; // Read-only + unsigned int numberofTotalLanes; // Read-only + int relativePreEmphasis; // Allowable values are -2 to +2 + int relativeVoltageSwing; // Allowable values are -2 to +2 + int persistFlag; + } DpLink; + struct + { + bool linkProtectionEnabled; // Read-only + } Protection; + } Settings; + int iReserved[15]; +} ADLDceSettings; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Graphic Core +/// +/// This structure is used to get Graphic Core Info +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLGraphicCoreInfo +{ + /// indicate the graphic core generation + int iGCGen; + + union + { + /// Total number of CUs. Valid for GCN (iGCGen == GCN) + int iNumCUs; + /// Total number of WGPs. Valid for RDNA (iGCGen == RDNA) + int iNumWGPs; + }; + + union + { + /// Number of processing elements per CU. Valid for GCN (iGCGen == GCN) + int iNumPEsPerCU; + /// Number of processing elements per WGP. Valid for RDNA (iGCGen == RDNA) + int iNumPEsPerWGP; + }; + + /// Total number of SIMDs. Valid for Pre GCN (iGCGen == Pre-GCN) + int iNumSIMDs; + + /// Total number of ROPs. Valid for both GCN and Pre GCN + int iNumROPs; + + /// reserved for future use + int iReserved[11]; +}ADLGraphicCoreInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive N clock range +/// +/// This structure is used to store information about Overdrive N clock range +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODNParameterRange +{ + /// The starting value of the clock range + int iMode; + /// The starting value of the clock range + int iMin; + /// The ending value of the clock range + int iMax; + /// The minimum increment between clock values + int iStep; + /// The default clock values + int iDefault; +} ADLODNParameterRange; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive N capabilities +/// +/// This structure is used to store information about Overdrive N capabilities +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODNCapabilities +{ + /// Number of levels which describe the minimum to maximum clock ranges. + /// The 1st level indicates the minimum clocks, and the 2nd level + /// indicates the maximum clocks. + int iMaximumNumberOfPerformanceLevels; + /// Contains the hard limits of the sclk range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange sEngineClockRange; + /// Contains the hard limits of the mclk range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange sMemoryClockRange; + /// Contains the hard limits of the vddc range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange svddcRange; + /// Contains the hard limits of the power range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange power; + /// Contains the hard limits of the power range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange powerTuneTemperature; + /// Contains the hard limits of the Temperature range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange fanTemperature; + /// Contains the hard limits of the Fan range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange fanSpeed; + /// Contains the hard limits of the Fan range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange minimumPerformanceClock; +} ADLODNCapabilities; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive N capabilities +/// +/// This structure is used to store information about Overdrive N capabilities +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODNCapabilitiesX2 +{ + /// Number of levels which describe the minimum to maximum clock ranges. + /// The 1st level indicates the minimum clocks, and the 2nd level + /// indicates the maximum clocks. + int iMaximumNumberOfPerformanceLevels; + /// bit vector, which tells what are the features are supported. + /// \ref: ADLODNFEATURECONTROL + int iFlags; + /// Contains the hard limits of the sclk range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange sEngineClockRange; + /// Contains the hard limits of the mclk range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange sMemoryClockRange; + /// Contains the hard limits of the vddc range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange svddcRange; + /// Contains the hard limits of the power range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange power; + /// Contains the hard limits of the power range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange powerTuneTemperature; + /// Contains the hard limits of the Temperature range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange fanTemperature; + /// Contains the hard limits of the Fan range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange fanSpeed; + /// Contains the hard limits of the Fan range. Overdrive + /// clocks cannot be set outside this range. + ADLODNParameterRange minimumPerformanceClock; + /// Contains the hard limits of the throttleNotification + ADLODNParameterRange throttleNotificaion; + /// Contains the hard limits of the Auto Systemclock + ADLODNParameterRange autoSystemClock; +} ADLODNCapabilitiesX2; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive level. +/// +/// This structure is used to store information about Overdrive level. +/// This structure is used by ADLODPerformanceLevels. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODNPerformanceLevel +{ + /// clock. + int iClock; + /// VDCC. + int iVddc; + /// enabled + int iEnabled; +} ADLODNPerformanceLevel; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive N performance levels. +/// +/// This structure is used to store information about Overdrive performance levels. +/// This structure is used by the ADL_OverdriveN_ODPerformanceLevels_Get() and ADL_OverdriveN_ODPerformanceLevels_Set() functions. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODNPerformanceLevels +{ + int iSize; + //Automatic/manual + int iMode; + /// Must be set to sizeof( \ref ADLODPerformanceLevels ) + sizeof( \ref ADLODPerformanceLevel ) * (ADLODParameters.iNumberOfPerformanceLevels - 1) + int iNumberOfPerformanceLevels; + /// Array of performance state descriptors. Must have ADLODParameters.iNumberOfPerformanceLevels elements. + ADLODNPerformanceLevel aLevels[1]; +} ADLODNPerformanceLevels; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive N Fan Speed. +/// +/// This structure is used to store information about Overdrive Fan control . +/// This structure is used by the ADL_OverdriveN_ODPerformanceLevels_Get() and ADL_OverdriveN_ODPerformanceLevels_Set() functions. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODNFanControl +{ + int iMode; + int iFanControlMode; + int iCurrentFanSpeedMode; + int iCurrentFanSpeed; + int iTargetFanSpeed; + int iTargetTemperature; + int iMinPerformanceClock; + int iMinFanLimit; +} ADLODNFanControl; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive N power limit. +/// +/// This structure is used to store information about Overdrive power limit. +/// This structure is used by the ADL_OverdriveN_ODPerformanceLevels_Get() and ADL_OverdriveN_ODPerformanceLevels_Set() functions. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODNPowerLimitSetting +{ + int iMode; + int iTDPLimit; + int iMaxOperatingTemperature; +} ADLODNPowerLimitSetting; + +typedef struct ADLODNPerformanceStatus +{ + int iCoreClock; + int iMemoryClock; + int iDCEFClock; + int iGFXClock; + int iUVDClock; + int iVCEClock; + int iGPUActivityPercent; + int iCurrentCorePerformanceLevel; + int iCurrentMemoryPerformanceLevel; + int iCurrentDCEFPerformanceLevel; + int iCurrentGFXPerformanceLevel; + int iUVDPerformanceLevel; + int iVCEPerformanceLevel; + int iCurrentBusSpeed; + int iCurrentBusLanes; + int iMaximumBusLanes; + int iVDDC; + int iVDDCI; +} ADLODNPerformanceStatus; + +///\brief Structure containing information about Overdrive level. +/// +/// This structure is used to store information about Overdrive level. +/// This structure is used by ADLODPerformanceLevels. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODNPerformanceLevelX2 +{ + /// clock. + int iClock; + /// VDCC. + int iVddc; + /// enabled + int iEnabled; + /// MASK + int iControl; +} ADLODNPerformanceLevelX2; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive N performance levels. +/// +/// This structure is used to store information about Overdrive performance levels. +/// This structure is used by the ADL_OverdriveN_ODPerformanceLevels_Get() and ADL_OverdriveN_ODPerformanceLevels_Set() functions. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLODNPerformanceLevelsX2 +{ + int iSize; + //Automatic/manual + int iMode; + /// Must be set to sizeof( \ref ADLODPerformanceLevels ) + sizeof( \ref ADLODPerformanceLevel ) * (ADLODParameters.iNumberOfPerformanceLevels - 1) + int iNumberOfPerformanceLevels; + /// Array of performance state descriptors. Must have ADLODParameters.iNumberOfPerformanceLevels elements. + ADLODNPerformanceLevelX2 aLevels[1]; +} ADLODNPerformanceLevelsX2; + +typedef enum ADLODNCurrentPowerType +{ + ODN_GPU_TOTAL_POWER = 0, + ODN_GPU_PPT_POWER, + ODN_GPU_SOCKET_POWER, + ODN_GPU_CHIP_POWER +} ADLODNCurrentPowerType; + +// in/out: CWDDEPM_CURRENTPOWERPARAMETERS +typedef struct ADLODNCurrentPowerParameters +{ + int size; + ADLODNCurrentPowerType powerType; + int currentPower; +} ADLODNCurrentPowerParameters; + +//ODN Ext range data structure +typedef struct ADLODNExtSingleInitSetting +{ + int mode; + int minValue; + int maxValue; + int step; + int defaultValue; +} ADLODNExtSingleInitSetting; + +//OD8 Ext range data structure +typedef struct ADLOD8SingleInitSetting +{ + int featureID; + int minValue; + int maxValue; + int defaultValue; +} ADLOD8SingleInitSetting; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive8 initial setting +/// +/// This structure is used to store information about Overdrive8 initial setting +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD8InitSetting +{ + int count; + int overdrive8Capabilities; + ADLOD8SingleInitSetting od8SettingTable[OD8_COUNT]; +} ADLOD8InitSetting; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive8 current setting +/// +/// This structure is used to store information about Overdrive8 current setting +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLOD8CurrentSetting +{ + int count; + int Od8SettingTable[OD8_COUNT]; +} ADLOD8CurrentSetting; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Overdrive8 set setting +/// +/// This structure is used to store information about Overdrive8 set setting +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLOD8SingleSetSetting +{ + int value; + int requested; // 0 - default , 1 - requested + int reset; // 0 - do not reset , 1 - reset setting back to default +} ADLOD8SingleSetSetting; + +typedef struct ADLOD8SetSetting +{ + int count; + ADLOD8SingleSetSetting od8SettingTable[OD8_COUNT]; +} ADLOD8SetSetting; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Performance Metrics data +/// +/// This structure is used to store information about Performance Metrics data output +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLSingleSensorData +{ + int supported; + int value; +} ADLSingleSensorData; + +typedef struct ADLPMLogDataOutput +{ + int size; + ADLSingleSensorData sensors[ADL_PMLOG_MAX_SENSORS]; +}ADLPMLogDataOutput; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about PPLog settings. +/// +/// This structure is used to store information about PPLog settings. +/// This structure is used by the ADL2_PPLogSettings_Set() and ADL2_PPLogSettings_Get() functions. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLPPLogSettings +{ + int BreakOnAssert; + int BreakOnWarn; + int LogEnabled; + int LogFieldMask; + int LogDestinations; + int LogSeverityEnabled; + int LogSourceMask; + int PowerProfilingEnabled; + int PowerProfilingTimeInterval; +}ADLPPLogSettings; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related Frames Per Second for AC and DC. +/// +/// This structure is used to store information related AC and DC Frames Per Second settings +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLFPSSettingsOutput +{ + /// size + int ulSize; + /// FPS Monitor is enabled in the AC state if 1 + int bACFPSEnabled; + /// FPS Monitor is enabled in the DC state if 1 + int bDCFPSEnabled; + /// Current Value of FPS Monitor in AC state + int ulACFPSCurrent; + /// Current Value of FPS Monitor in DC state + int ulDCFPSCurrent; + /// Maximum FPS Threshold allowed in PPLib for AC + int ulACFPSMaximum; + /// Minimum FPS Threshold allowed in PPLib for AC + int ulACFPSMinimum; + /// Maximum FPS Threshold allowed in PPLib for DC + int ulDCFPSMaximum; + /// Minimum FPS Threshold allowed in PPLib for DC + int ulDCFPSMinimum; +} ADLFPSSettingsOutput; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related Frames Per Second for AC and DC. +/// +/// This structure is used to store information related AC and DC Frames Per Second settings +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLFPSSettingsInput +{ + /// size + int ulSize; + /// Settings are for Global FPS (used by CCC) + int bGlobalSettings; + /// Current Value of FPS Monitor in AC state + int ulACFPSCurrent; + /// Current Value of FPS Monitor in DC state + int ulDCFPSCurrent; + /// Reserved + int ulReserved[6]; +} ADLFPSSettingsInput; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related power management logging. +/// +/// This structure is used to store support information for power management logging. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +enum { ADL_PMLOG_MAX_SUPPORTED_SENSORS = 256 }; + +typedef struct ADLPMLogSupportInfo +{ + /// list of sensors defined by ADL_PMLOG_SENSORS + unsigned short usSensors[ADL_PMLOG_MAX_SUPPORTED_SENSORS]; + /// Reserved + int ulReserved[16]; +} ADLPMLogSupportInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information to start power management logging. +/// +/// This structure is used as input to ADL2_Adapter_PMLog_Start +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLPMLogStartInput +{ + /// list of sensors defined by ADL_PMLOG_SENSORS + unsigned short usSensors[ADL_PMLOG_MAX_SUPPORTED_SENSORS]; + /// Sample rate in milliseconds + unsigned long ulSampleRate; + /// Reserved + int ulReserved[15]; +} ADLPMLogStartInput; + +typedef struct ADLPMLogData +{ + /// Structure version + unsigned int ulVersion; + /// Current driver sample rate + unsigned int ulActiveSampleRate; + /// Timestamp of last update + unsigned long long ulLastUpdated; + /// 2D array of senesor and values + unsigned int ulValues[ADL_PMLOG_MAX_SUPPORTED_SENSORS][2]; + /// Reserved + unsigned int ulReserved[256]; +} ADLPMLogData; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information to start power management logging. +/// +/// This structure is returned as output from ADL2_Adapter_PMLog_Start +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLPMLogStartOutput +{ + /// Pointer to memory address containing logging data + union + { + void* pLoggingAddress; + unsigned long long ptr_LoggingAddress; + }; + /// Reserved + int ulReserved[14]; +} ADLPMLogStartOutput; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information to query limts of power management logging. +/// +/// This structure is returned as output from ADL2_Adapter_PMLog_SensorLimits_Get +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLPMLogSensorLimits +{ + int SensorLimits[ADL_PMLOG_MAX_SENSORS][2]; //index 0: min, 1: max +} ADLPMLogSensorLimits; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related RAS Get Error Counts Information +/// +/// This structure is used to store RAS Error Counts Get Input Information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLRASGetErrorCountsInput +{ + unsigned int Reserved[16]; +} ADLRASGetErrorCountsInput; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related RAS Get Error Counts Information +/// +/// This structure is used to store RAS Error Counts Get Output Information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLRASGetErrorCountsOutput +{ + unsigned int CorrectedErrors; // includes both DRAM and SRAM ECC + unsigned int UnCorrectedErrors; // includes both DRAM and SRAM ECC + unsigned int Reserved[14]; +} ADLRASGetErrorCountsOutput; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related RAS Get Error Counts Information +/// +/// This structure is used to store RAS Error Counts Get Information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLRASGetErrorCounts +{ + unsigned int InputSize; + ADLRASGetErrorCountsInput Input; + unsigned int OutputSize; + ADLRASGetErrorCountsOutput Output; +} ADLRASGetErrorCounts; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related RAS Error Counts Reset Information +/// +/// This structure is used to store RAS Error Counts Reset Input Information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLRASResetErrorCountsInput +{ + unsigned int Reserved[8]; +} ADLRASResetErrorCountsInput; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related RAS Error Counts Reset Information +/// +/// This structure is used to store RAS Error Counts Reset Output Information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLRASResetErrorCountsOutput +{ + unsigned int Reserved[8]; +} ADLRASResetErrorCountsOutput; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related RAS Error Counts Reset Information +/// +/// This structure is used to store RAS Error Counts Reset Information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLRASResetErrorCounts +{ + unsigned int InputSize; + ADLRASResetErrorCountsInput Input; + unsigned int OutputSize; + ADLRASResetErrorCountsOutput Output; +} ADLRASResetErrorCounts; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related RAS Error Injection information +/// +/// This structure is used to store RAS Error Injection input information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLRASErrorInjectonInput +{ + unsigned long long Address; + ADL_RAS_INJECTION_METHOD Value; + ADL_RAS_BLOCK_ID BlockId; + ADL_RAS_ERROR_TYPE InjectErrorType; + ADL_MEM_SUB_BLOCK_ID SubBlockIndex; + unsigned int padding[9]; +} ADLRASErrorInjectonInput; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related RAS Error Injection information +/// +/// This structure is used to store RAS Error Injection output information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLRASErrorInjectionOutput +{ + unsigned int ErrorInjectionStatus; + unsigned int padding[15]; +} ADLRASErrorInjectionOutput; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related RAS Error Injection information +/// +/// This structure is used to store RAS Error Injection information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLRASErrorInjection +{ + unsigned int InputSize; + ADLRASErrorInjectonInput Input; + unsigned int OutputSize; + ADLRASErrorInjectionOutput Output; +} ADLRASErrorInjection; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about an application +/// +/// This structure is used to store basic information of a recently ran or currently running application +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLSGApplicationInfo +{ + /// Application file name + wchar_t strFileName[ADL_MAX_PATH]; + /// Application file path + wchar_t strFilePath[ADL_MAX_PATH]; + /// Application version + wchar_t strVersion[ADL_MAX_PATH]; + /// Timestamp at which application has run + long long int timeStamp; + /// Holds whether the applicaition profile exists or not + unsigned int iProfileExists; + /// The GPU on which application runs + unsigned int iGPUAffinity; + /// The BDF of the GPU on which application runs + ADLBdf GPUBdf; +} ADLSGApplicationInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related Frames Per Second for AC and DC. +/// +/// This structure is used to store information related AC and DC Frames Per Second settings +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +enum { ADLPreFlipPostProcessingInfoInvalidLUTIndex = 0xFFFFFFFF }; + +enum ADLPreFlipPostProcessingLUTAlgorithm +{ + ADLPreFlipPostProcessingLUTAlgorithm_Default = 0, + ADLPreFlipPostProcessingLUTAlgorithm_Full, + ADLPreFlipPostProcessingLUTAlgorithm_Approximation +}; + +typedef struct ADLPreFlipPostProcessingInfo +{ + /// size + int ulSize; + /// Current active state + int bEnabled; + /// Current selected LUT index. 0xFFFFFFF returned if nothing selected. + int ulSelectedLUTIndex; + /// Current selected LUT Algorithm + int ulSelectedLUTAlgorithm; + /// Reserved + int ulReserved[12]; +} ADLPreFlipPostProcessingInfo; + +typedef struct ADL_ERROR_REASON +{ + int boost; //ON, when boost is Enabled + int delag; //ON, when delag is Enabled + int chill; //ON, when chill is Enabled + int proVsr; //ON, when proVsr is Enabled +}ADL_ERROR_REASON; + +typedef struct ADL_ERROR_REASON2 +{ + int boost; //ON, when boost is Enabled + int delag; //ON, when delag is Enabled + int chill; //ON, when chill is Enabled + int proVsr; //ON, when proVsr is Enabled + int upscale; //ON, when RSR is Enabled +}ADL_ERROR_REASON2; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about DELAG Settings change reason +/// +/// Elements of DELAG settings changed reason. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_DELAG_NOTFICATION_REASON +{ + int HotkeyChanged; //Set when Hotkey value is changed + int GlobalEnableChanged; //Set when Global enable value is changed + int GlobalLimitFPSChanged; //Set when Global enable value is changed +}ADL_DELAG_NOTFICATION_REASON; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about DELAG Settings +/// +/// Elements of DELAG settings. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_DELAG_SETTINGS +{ + int Hotkey; // Hotkey value + int GlobalEnable; //Global enable value + int GlobalLimitFPS; //Global Limit FPS + int GlobalLimitFPS_MinLimit; //Gloabl Limit FPS slider min limit value + int GlobalLimitFPS_MaxLimit; //Gloabl Limit FPS slider max limit value + int GlobalLimitFPS_Step; //Gloabl Limit FPS step value +}ADL_DELAG_SETTINGS; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about BOOST Settings change reason +/// +/// Elements of BOOST settings changed reason. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_BOOST_NOTFICATION_REASON +{ + int HotkeyChanged; //Set when Hotkey value is changed + int GlobalEnableChanged; //Set when Global enable value is changed + int GlobalMinResChanged; //Set when Global min resolution value is changed +}ADL_BOOST_NOTFICATION_REASON; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about BOOST Settings +/// +/// Elements of BOOST settings. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_BOOST_SETTINGS +{ + int Hotkey; // Hotkey value + int GlobalEnable; //Global enable value + int GlobalMinRes; //Gloabl Min Resolution value + int GlobalMinRes_MinLimit; //Gloabl Min Resolution slider min limit value + int GlobalMinRes_MaxLimit; //Gloabl Min Resolution slider max limit value + int GlobalMinRes_Step; //Gloabl Min Resolution step value +}ADL_BOOST_SETTINGS; + + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about ProVSR Settings change reason +/// +/// Elements of ProVSR settings changed reason. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_PROVSR_NOTFICATION_REASON +{ + int HotkeyChanged; //Set when Hotkey value is changed + int GlobalEnableChanged; //Set when Global enable value is changed +}ADL_PROVSR_NOTFICATION_REASON; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Pro VSR Settings +/// +/// Elements of ProVSR settings. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_PROVSR_SETTINGS +{ + int Hotkey; // Hotkey value + int GlobalEnable; //Global enable value +}ADL_PROVSR_SETTINGS; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about Image Boost(OGL) Settings change reason +/// +/// Elements of Image Boost settings changed reason. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_IMAGE_BOOST_NOTFICATION_REASON +{ + int HotkeyChanged; //Set when Hotkey value is changed + int GlobalEnableChanged; //Set when Global enable value is changed +}ADL_IMAGE_BOOST_NOTFICATION_REASON; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about OGL IMAGE BOOST Settings +/// +/// Elements of OGL IMAGE BOOST settings. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_IMAGE_BOOST_SETTINGS +{ + int Hotkey; // Hotkey value + int GlobalEnable; //Global enable value +}ADL_IMAGE_BOOST_SETTINGS; + +///////////////////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about RIS Settings change reason +/// +/// Elements of RIS settings changed reason. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_RIS_NOTFICATION_REASON +{ + unsigned int GlobalEnableChanged; //Set when Global enable value is changed + unsigned int GlobalSharpeningDegreeChanged; //Set when Global sharpening Degree value is changed +}ADL_RIS_NOTFICATION_REASON; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about RIS Settings +/// +/// Elements of RIS settings. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_RIS_SETTINGS +{ + int GlobalEnable; //Global enable value + int GlobalSharpeningDegree; //Global sharpening value + int GlobalSharpeningDegree_MinLimit; //Gloabl sharpening slider min limit value + int GlobalSharpeningDegree_MaxLimit; //Gloabl sharpening slider max limit value + int GlobalSharpeningDegree_Step; //Gloabl sharpening step value +}ADL_RIS_SETTINGS; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about CHILL Settings change reason +/// +/// Elements of Chiil settings changed reason. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_CHILL_NOTFICATION_REASON +{ + int HotkeyChanged; //Set when Hotkey value is changed + int GlobalEnableChanged; //Set when Global enable value is changed + int GlobalMinFPSChanged; //Set when Global min FPS value is changed + int GlobalMaxFPSChanged; //Set when Global max FPS value is changed +}ADL_CHILL_NOTFICATION_REASON; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about CHILL Settings +/// +/// Elements of Chill settings. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_CHILL_SETTINGS +{ + int Hotkey; // Hotkey value + int GlobalEnable; //Global enable value + int GlobalMinFPS; //Global Min FPS value + int GlobalMaxFPS; //Global Max FPS value + int GlobalFPS_MinLimit; //Gloabl FPS slider min limit value + int GlobalFPS_MaxLimit; //Gloabl FPS slider max limit value + int GlobalFPS_Step; //Gloabl FPS Slider step value +}ADL_CHILL_SETTINGS; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about DRIVERUPSCALE Settings change reason +/// +/// Elements of DRIVERUPSCALE settings changed reason. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_DRIVERUPSCALE_NOTFICATION_REASON +{ + int ModeOverrideEnabledChanged; //Set when Global min resolution value is changed + int GlobalEnabledChanged; //Set when Global enable value is changed +}ADL_DRIVERUPSCALE_NOTFICATION_REASON; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about DRIVERUPSCALE Settings +/// +/// Elements of DRIVERUPSCALE settings. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_DRIVERUPSCALE_SETTINGS +{ + int ModeOverrideEnabled; + int GlobalEnabled; +}ADL_DRIVERUPSCALE_SETTINGS; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure Containing R G B values for Radeon USB LED Bar +/// +/// Elements of RGB Values. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_RADEON_LED_COLOR_CONFIG +{ + unsigned short R : 8; // Red Value + unsigned short G : 8; // Green Value + unsigned short B : 8; // Blue Value +}ADL_RADEON_LED_COLOR_CONFIG; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure Containing All Generic LED configuration for user requested LED pattern. The driver will apply the confgiuration as requested +/// +/// Elements of Radeon USB LED configuration. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_RADEON_LED_PATTERN_CONFIG_GENERIC +{ + short brightness : 8; // Brightness of LED + short speed : 8; // Speed of LED pattern + bool directionCounterClockWise; //Direction of LED Pattern + ADL_RADEON_LED_COLOR_CONFIG colorConfig; // RGB value of LED pattern + char morseCodeText[ADL_RADEON_LED_MAX_MORSE_CODE]; // Morse Code user input for Morse Code LED pattern + char morseCodeTextOutPut[ADL_RADEON_LED_MAX_MORSE_CODE]; // Driver set output representation of Morse Code + int morseCodeTextOutPutLen; // Length of Morse Code output +}ADL_RADEON_LED_PATTERN_CONFIG_GENERIC; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure Containing All custom grid pattern LED configuration for user requested LED grid pattern. The driver will apply the confgiuration as requested +/// +/// Elements of Radeon USB LED custom grid configuration. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_RADEON_LED_CUSTOM_LED_CONFIG +{ + short brightness : 8; // Brightness of LED + ADL_RADEON_LED_COLOR_CONFIG colorConfig[ADL_RADEON_LED_MAX_LED_ROW_ON_GRID][ADL_RADEON_LED_MAX_LED_COLUMN_ON_GRID]; // Full grid array representation of Radeon LED to be populated by user +}ADL_RADEON_LED_CUSTOM_GRID_LED_CONFIG; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure Containing All Radeon USB LED requests and controls. +/// +/// Elements of Radeon USB LED Controls. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_RADEON_LED_PATTERN_CONFIG +{ + ADL_RADEON_USB_LED_BAR_CONTROLS control; //Requested LED pattern + + union + { + ADL_RADEON_LED_PATTERN_CONFIG_GENERIC genericPararmeters; //Requested pattern configuration settings + ADL_RADEON_LED_CUSTOM_GRID_LED_CONFIG customGridConfig; //Requested custom grid configuration settings + }; +}ADL_RADEON_LED_PATTERN_CONFIG; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about the graphics adapter with extended caps +/// +/// This structure is used to store various information about the graphics adapter. This +/// information can be returned to the user. Alternatively, it can be used to access various driver calls to set +/// or fetch various settings upon the user's request. +/// This AdapterInfoX2 struct extends the AdapterInfo struct in adl_structures.h +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct AdapterInfoX2 +{ + /// \ALL_STRUCT_MEM + + /// Size of the structure. + int iSize; + /// The ADL index handle. One GPU may be associated with one or two index handles + int iAdapterIndex; + /// The unique device ID associated with this adapter. + char strUDID[ADL_MAX_PATH]; + /// The BUS number associated with this adapter. + int iBusNumber; + /// The driver number associated with this adapter. + int iDeviceNumber; + /// The function number. + int iFunctionNumber; + /// The vendor ID associated with this adapter. + int iVendorID; + /// Adapter name. + char strAdapterName[ADL_MAX_PATH]; + /// Display name. For example, "\\\\Display0" + char strDisplayName[ADL_MAX_PATH]; + /// Present or not; 1 if present and 0 if not present.It the logical adapter is present, the display name such as \\\\.\\Display1 can be found from OS + int iPresent; + /// Exist or not; 1 is exist and 0 is not present. + int iExist; + /// Driver registry path. + char strDriverPath[ADL_MAX_PATH]; + /// Driver registry path Ext for. + char strDriverPathExt[ADL_MAX_PATH]; + /// PNP string from Windows. + char strPNPString[ADL_MAX_PATH]; + /// It is generated from EnumDisplayDevices. + int iOSDisplayIndex; + /// The bit mask identifies the adapter info + int iInfoMask; + /// The bit identifies the adapter info \ref define_adapter_info + int iInfoValue; +} AdapterInfoX2, *LPAdapterInfoX2; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about driver gamut space , whether it is related to source or to destination, overlay or graphics +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLGamutReference +{ + /// mask whether it is related to source or to destination, overlay or graphics + int iGamutRef; +}ADLGamutReference; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about driver supported gamut spaces , capability method +/// +/// This structure is used to get driver all supported gamut spaces +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLGamutInfo +{ + ///Any combination of following ADL_GAMUT_SPACE_CCIR_709 - ADL_GAMUT_SPACE_CUSTOM + int SupportedGamutSpace; + + ///Any combination of following ADL_WHITE_POINT_5000K - ADL_WHITE_POINT_CUSTOM + int SupportedWhitePoint; +} ADLGamutInfo; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about driver point coordinates +/// +/// This structure is used to store the driver point coodinates for gamut and white point +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLPoint +{ + /// x coordinate + int iX; + /// y coordinate + int iY; +} ADLPoint; +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about driver supported gamut coordinates +/// +/// This structure is used to store the driver supported supported gamut coordinates +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLGamutCoordinates +{ + /// red channel chromasity coordinate + ADLPoint Red; + /// green channel chromasity coordinate + ADLPoint Green; + /// blue channel chromasity coordinate + ADLPoint Blue; +} ADLGamutCoordinates; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about driver current gamut space , parent struct for ADLGamutCoordinates and ADLWhitePoint +/// This structure is used to get/set driver supported gamut space +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLGamutData +{ + ///used as mask and could be 4 options + ///BIT_0 If flag ADL_GAMUT_REFERENCE_SOURCE is asserted set operation is related to gamut source , + ///if not gamut destination + ///BIT_1 If flag ADL_GAMUT_GAMUT_VIDEO_CONTENT is asserted + ///BIT_2,BIT_3 used as mask and could be 4 options custom (2) + predefined (2) + ///0. Gamut predefined, white point predefined -> 0 | 0 + ///1. Gamut predefined, white point custom -> 0 | ADL_CUSTOM_WHITE_POINT + ///2. White point predefined, gamut custom -> 0 | ADL_CUSTOM_GAMUT + ///3. White point custom, gamut custom -> ADL_CUSTOM_GAMUT | ADL_CUSTOM_WHITE_POINT + int iFeature; + + ///one of ADL_GAMUT_SPACE_CCIR_709 - ADL_GAMUT_SPACE_CIE_RGB + int iPredefinedGamut; + + ///one of ADL_WHITE_POINT_5000K - ADL_WHITE_POINT_9300K + int iPredefinedWhitePoint; + + ///valid when in mask avails ADL_CUSTOM_WHITE_POINT + ADLPoint CustomWhitePoint; + + ///valid when in mask avails ADL_CUSTOM_GAMUT + ADLGamutCoordinates CustomGamut; +} ADLGamutData; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing detailed timing parameters. +/// +/// This structure is used to store the detailed timing parameters. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDetailedTimingX2 +{ + /// Size of the structure. + int iSize; + /// Timing flags. \ref define_detailed_timing_flags + int sTimingFlags; + /// Total width (columns). + int sHTotal; + /// Displayed width. + int sHDisplay; + /// Horizontal sync signal offset. + int sHSyncStart; + /// Horizontal sync signal width. + int sHSyncWidth; + /// Total height (rows). + int sVTotal; + /// Displayed height. + int sVDisplay; + /// Vertical sync signal offset. + int sVSyncStart; + /// Vertical sync signal width. + int sVSyncWidth; + /// Pixel clock value. + int sPixelClock; + /// Overscan right. + short sHOverscanRight; + /// Overscan left. + short sHOverscanLeft; + /// Overscan bottom. + short sVOverscanBottom; + /// Overscan top. + short sVOverscanTop; + short sOverscan8B; + short sOverscanGR; +} ADLDetailedTimingX2; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing display mode information. +/// +/// This structure is used to store the display mode information. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLDisplayModeInfoX2 +{ + /// Timing standard of the current mode. \ref define_modetiming_standard + int iTimingStandard; + /// Applicable timing standards for the current mode. + int iPossibleStandard; + /// Refresh rate factor. + int iRefreshRate; + /// Num of pixels in a row. + int iPelsWidth; + /// Num of pixels in a column. + int iPelsHeight; + /// Detailed timing parameters. + ADLDetailedTimingX2 sDetailedTiming; +} ADLDisplayModeInfoX2; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about I2C. +/// +/// This structure is used to store the I2C information for the current adapter. +/// This structure is used by \ref ADL_Display_WriteAndReadI2CLargePayload +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLI2CLargePayload +{ + /// Size of the structure + int iSize; + /// Numerical value representing hardware I2C. + int iLine; + /// The 7-bit I2C slave device address. + int iAddress; + /// The offset of the data from the address. + int iOffset; + /// Read from or write to slave device. \ref ADL_DL_I2C_ACTIONREAD or \ref ADL_DL_I2C_ACTIONWRITE + int iAction; + /// I2C clock speed in KHz. + int iSpeed; + /// I2C option flags. \ref define_ADLI2CLargePayload + int iFlags; + /// A numerical value representing the number of bytes to be sent or received on the I2C bus. + int iDataSize; + /// Address of the characters which are to be sent or received on the I2C bus. + char *pcData; +} ADLI2CLargePayload; + +/// Size in bytes of the Feature Name +#define ADL_FEATURE_NAME_LENGTH 16 + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing the Multimedia Feature Name +/// +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLFeatureName +{ + /// The Feature Name + char FeatureName[ADL_FEATURE_NAME_LENGTH]; +} ADLFeatureName, *LPADLFeatureName; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about MM Feature Capabilities. +/// +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLFeatureCaps +{ + /// The Feature Name + ADLFeatureName Name; + // char strFeatureName[ADL_FEATURE_NAME_LENGTH]; + + /// Group ID. All Features in the same group are shown sequentially in the same UI Page. + int iGroupID; + + /// Visual ID. Places one or more features in a Group Box. If zero, no Group Box is added. + int iVisualID; + + /// Page ID. All Features with the same Page ID value are shown together on the same UI page. + int iPageID; + + /// Feature Property Mask. Indicates which are the valid bits for iFeatureProperties. + int iFeatureMask; + + /// Feature Property Values. See definitions for ADL_FEATURE_PROPERTIES_XXX + int iFeatureProperties; + + /// Apperance of the User-Controlled Boolean. + int iControlType; + + /// Style of the User-Controlled Boolean. + int iControlStyle; + + /// Apperance of the Adjustment Controls. + int iAdjustmentType; + + /// Style of the Adjustment Controls. + int iAdjustmentStyle; + + /// Default user-controlled boolean value. Valid only if ADLFeatureCaps supports user-controlled boolean. + int bDefault; + + /// Minimum integer value. Valid only if ADLFeatureCaps indicates support for integers. + int iMin; + + /// Maximum integer value. Valid only if ADLFeatureCaps indicates support for integers. + int iMax; + + /// Step integer value. Valid only if ADLFeatureCaps indicates support for integers. + int iStep; + + /// Default integer value. Valid only if ADLFeatureCaps indicates support for integers. + int iDefault; + + /// Minimum float value. Valid only if ADLFeatureCaps indicates support for floats. + float fMin; + + /// Maximum float value. Valid only if ADLFeatureCaps indicates support for floats. + float fMax; + + /// Step float value. Valid only if ADLFeatureCaps indicates support for floats. + float fStep; + + /// Default float value. Valid only if ADLFeatureCaps indicates support for floats. + float fDefault; + + /// The Mask for available bits for enumerated values.(If ADLFeatureCaps supports ENUM values) + int EnumMask; +} ADLFeatureCaps, *LPADLFeatureCaps; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about MM Feature Values. +/// +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLFeatureValues +{ + /// The Feature Name + ADLFeatureName Name; + // char strFeatureName[ADL_FEATURE_NAME_LENGTH]; + + /// User controlled Boolean current value. Valid only if ADLFeatureCaps supports Boolean. + int bCurrent; + + /// Current integer value. Valid only if ADLFeatureCaps indicates support for integers. + int iCurrent; + + /// Current float value. Valid only if ADLFeatureCaps indicates support for floats. + float fCurrent; + + /// The States for the available bits for enumerated values. + int EnumStates; +} ADLFeatureValues, *LPADLFeatureValues; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing HDCP Settings info +/// +/// This structure is used to store the HDCP settings of a +/// display +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLHDCPSettings +{ + int iHDCPProtectionVersion; // Version, starting from 1 + int iHDCPCaps; //Caps used to ensure at least one protection scheme is supported, 1 is HDCP1X and 2 is HDCP22 + int iAllowAll; //Allow all is true, disable all is false + int iHDCPVale; + int iHDCPMask; +} ADLHDCPSettings; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing Mantle App info +/// +/// This structure is used to store the Mantle Driver information +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct ADLMantleAppInfo +{ + /// mantle api version + int apiVersion; + /// mantle driver version + long driverVersion; + /// mantle vendroe id + long vendorId; + /// mantle device id + long deviceId; + /// mantle gpu type; + int gpuType; + /// gpu name + char gpuName[256]; + /// mem size + int maxMemRefsPerSubmission; + /// virtual mem size + long long virtualMemPageSize; + /// mem update + long long maxInlineMemoryUpdateSize; + /// bound descriptot + long maxBoundDescriptorSets; + /// thread group size + long maxThreadGroupSize; + /// time stamp frequency + long long timestampFrequency; + /// color target + long multiColorTargetClears; +}ADLMantleAppInfo, *LPADLMantleAppInfo; + +//////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about SDIData +///This structure is used to store information about the state of the SDI whether it is on +///or off and the current size of the segment or aperture size. +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLSDIData +{ + /// The SDI state, ADL_SDI_ON or ADL_SDI_OFF, for the current SDI mode + int iSDIState; + /// Size of the memory segment for SDI (in MB). + int iSizeofSDISegment; +} ADLSDIData, *LPADLSDIData; + + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about FRTCPRO Settings +/// +/// Elements of FRTCPRO settings. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_FRTCPRO_Settings +{ + int DefaultState; //The default status for FRTC pro + int CurrentState; //The current enable/disable status for FRTC pro + unsigned int DefaultValue; //The default FPS value for FRTC pro. + unsigned int CurrentValue; //The current FPS value for FRTC pro. + unsigned int maxSupportedFps; //The max value for FRTC pro. + unsigned int minSupportedFps; //The min value for FRTC pro. +}ADL_FRTCPRO_Settings, *LPADLFRTCProSettings; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information about FRTCPRO Settings changed reason +/// +/// Reason of FRTCPRO changed. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_FRTCPRO_CHANGED_REASON +{ + int StateChanged; // FRTCPro state changed + int ValueChanged; // FRTCPro value changed +}ADL_FRTCPRO_CHANGED_REASON; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure containing the display mode definition used per controller. +/// +/// This structure is used to store the display mode definition used per controller. +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADL_DL_DISPLAY_MODE +{ + int iPelsHeight; // Vertical resolution (in pixels). + int iPelsWidth; // Horizontal resolution (in pixels). + int iBitsPerPel; // Color depth. + int iDisplayFrequency; // Refresh rate. +} ADL_DL_DISPLAY_MODE; + +///////////////////////////////////////////////////////////////////////////////////////////// +///\brief Structure containing information related DCE support +/// +/// This structure is used to store a bit vector of possible DCE support +/// +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef union _ADLDCESupport +{ + struct + { + unsigned int PrePhasis : 1; + unsigned int voltageSwing : 1; + unsigned int reserved : 30; + }bits; + unsigned int u32All; +}ADLDCESupport; + +///////////////////////////////////////////////////////////////////////////////////////////// +/// \brief Structure for Smart shift 2.0 settings +/// +/// This structure is used to return the smart shift settings +/// \nosubgrouping +//////////////////////////////////////////////////////////////////////////////////////////// +typedef struct ADLSmartShiftSettings +{ + int iMinRange; + int iMaxRange; + int iDefaultMode; //Refer to CWDDEPM_ODN_CONTROL_TYPE + int iDefaultValue; + int iCurrentMode; + int iCurrentValue; + int iFlags; //refer to define_smartshift_bits +}ADLSmartShiftSettings, *LPADLSmartShiftSettings; +#endif /* ADL_STRUCTURES_H_ */ diff --git a/src/3rdparty/display-library/repo.json b/src/3rdparty/display-library/repo.json new file mode 100644 index 000000000..2d053d1e3 --- /dev/null +++ b/src/3rdparty/display-library/repo.json @@ -0,0 +1,6 @@ +{ + "home": "https://github.com/GPUOpen-LibrariesAndSDKs/display-library", + "license": "MIT (embeded in source)", + "version": "ADL SDK 17.1", + "author": "Advanced Micro Devices, Inc" +} diff --git a/src/common/io/io_unix.c b/src/common/io/io_unix.c index 5623d2dc9..7875c7587 100644 --- a/src/common/io/io_unix.c +++ b/src/common/io/io_unix.c @@ -256,6 +256,11 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char* bool ffSuppressIO(bool suppress) { + #ifndef NDEBUG + if (instance.config.display.debugMode) + return false; + #endif + static bool init = false; static int origOut = -1; static int origErr = -1; diff --git a/src/common/io/io_windows.c b/src/common/io/io_windows.c index 9f1a96ce5..25f82cdc1 100644 --- a/src/common/io/io_windows.c +++ b/src/common/io/io_windows.c @@ -159,6 +159,11 @@ bool ffPathExpandEnv(const char* in, FFstrbuf* out) bool ffSuppressIO(bool suppress) { + #ifndef NDEBUG + if (instance.config.display.debugMode) + return false; + #endif + static bool init = false; static HANDLE hOrigOut = INVALID_HANDLE_VALUE; static HANDLE hOrigErr = INVALID_HANDLE_VALUE; diff --git a/src/common/netif/netif_linux.c b/src/common/netif/netif_linux.c index 1845ee0e2..6c0dbd1e6 100644 --- a/src/common/netif/netif_linux.c +++ b/src/common/netif/netif_linux.c @@ -7,7 +7,7 @@ #define FF_STR_INDIR(x) #x #define FF_STR(x) FF_STR_INDIR(x) -bool ffNetifGetDefaultRouteImpl(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex) +static bool getDefaultRouteIPv4(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex) { FILE* FF_AUTO_CLOSE_FILE netRoute = fopen("/proc/net/route", "r"); if (!netRoute) return false; @@ -15,12 +15,38 @@ bool ffNetifGetDefaultRouteImpl(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex) // skip first line FF_UNUSED(fscanf(netRoute, "%*[^\n]\n")); - unsigned long long destination; //, gateway, flags, refCount, use, metric, mask, mtu, + unsigned long long destination; //, gateway, flags, refCount, use, metric, mask, mtu, ... while (fscanf(netRoute, "%" FF_STR(IF_NAMESIZE) "s%llx%*[^\n]", iface, &destination) == 2) { if (destination != 0) continue; *ifIndex = if_nametoindex(iface); return true; } + iface[0] = '\0'; return false; } + +static bool getDefaultRouteIPv6(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex) +{ + FILE* FF_AUTO_CLOSE_FILE netRoute = fopen("/proc/net/ipv6_route", "r"); + if (!netRoute) return false; + + uint32_t prefixLen; + //destination, dest_prefix_len, source, src_prefix_len, next hop, metric, ref counter, use counter, flags, iface + while (fscanf(netRoute, "%*s %x %*s %*s %*s %*s %*s %*s %*s %" FF_STR(IF_NAMESIZE) "s", &prefixLen, iface) == 2) + { + if (prefixLen != 0) continue; + *ifIndex = if_nametoindex(iface); + return true; + } + iface[0] = '\0'; + return false; +} + +bool ffNetifGetDefaultRouteImpl(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex) +{ + if (getDefaultRouteIPv4(iface, ifIndex)) + return true; + + return getDefaultRouteIPv6(iface, ifIndex); +} diff --git a/src/common/parsing.c b/src/common/parsing.c index dce4cef02..d427dbbea 100644 --- a/src/common/parsing.c +++ b/src/common/parsing.c @@ -198,6 +198,12 @@ void ffParseDuration(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t s return; } + if(seconds >= 30) + { + minutes++; + seconds = 0; + } + if(days > 0) { ffStrbufAppendF(result, "%u day", days); diff --git a/src/common/thread.h b/src/common/thread.h index 4d25dd505..deb4fba15 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -65,8 +65,8 @@ struct timespec ts; if (clock_gettime(CLOCK_REALTIME, &ts) == 0) { - ts.tv_sec += ts.tv_sec / 1000; - ts.tv_nsec += (ts.tv_nsec % 1000) * 1000000; + ts.tv_sec += timeout / 1000; + ts.tv_nsec += (timeout % 1000) * 1000000; if (pthread_timedjoin_np(thread, NULL, &ts) != 0) { pthread_kill(thread, SIGTERM); diff --git a/src/detection/battery/battery_apple.c b/src/detection/battery/battery_apple.c index 4573ec181..3d7ac45c8 100644 --- a/src/detection/battery/battery_apple.c +++ b/src/detection/battery/battery_apple.c @@ -98,7 +98,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) // https://github.com/AsahiLinux/linux/blob/b5c05cbffb0488c7618106926d522cc3b43d93d5/drivers/power/supply/macsmc_power.c#L410-L419 int year = (manufactureDate[0] - '0') * 10 + (manufactureDate[1] - '0') + 2000 - 8; int month = (manufactureDate[2] - '0') * 10 + (manufactureDate[3] - '0'); - int day = (manufactureDate[4] - '0') * 10 + (manufactureDate[3] - '5'); + int day = (manufactureDate[4] - '0') * 10 + (manufactureDate[3] - '0'); ffStrbufSetF(&battery->manufactureDate, "%.4d-%.2d-%.2d", year, month, day); } } diff --git a/src/detection/battery/battery_linux.c b/src/detection/battery/battery_linux.c index 940b9d719..8a9b2c641 100644 --- a/src/detection/battery/battery_linux.c +++ b/src/detection/battery/battery_linux.c @@ -108,7 +108,7 @@ static void parseBattery(int dfd, const char* id, FFBatteryOptions* options, FFl if (ffReadFileBufferRelative(dfd, "capacity_level", &tmpBuffer)) { - ffStrbufTrimRightSpace(&result->manufacturer); + ffStrbufTrimRightSpace(&tmpBuffer); if (ffStrbufEqualS(&tmpBuffer, "Critical")) { if (result->status.length) diff --git a/src/detection/battery/battery_nbsd.c b/src/detection/battery/battery_nbsd.c index 093853336..bcff9a875 100644 --- a/src/detection/battery/battery_nbsd.c +++ b/src/detection/battery/battery_nbsd.c @@ -70,9 +70,7 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r critical = true; } else if (ffStrEquals(desc, "discharge rate")) - { prop_dictionary_get_uint(dict, "cur-value", &dischargeRate); - } } if (max > 0) @@ -92,7 +90,10 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r if (charging) ffStrbufAppendS(&battery->status, "Charging, "); else if (dischargeRate) + { ffStrbufAppendS(&battery->status, "Discharging, "); + battery->timeRemaining = (int32_t)((double)curr / dischargeRate * 3600); + } if (critical) ffStrbufAppendS(&battery->status, "Critical, "); if (acConnected) @@ -100,8 +101,11 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r ffStrbufTrimRight(&battery->status, ' '); ffStrbufTrimRight(&battery->status, ','); } + + prop_object_iterator_release(iter); } prop_object_iterator_release(itKey); + prop_object_release(root); return NULL; } diff --git a/src/detection/bios/bios_bsd.c b/src/detection/bios/bios_bsd.c index 11f762099..00b1bd394 100644 --- a/src/detection/bios/bios_bsd.c +++ b/src/detection/bios/bios_bsd.c @@ -25,7 +25,7 @@ const char* ffDetectBios(FFBiosResult* result) { ffStrbufSetStatic(&result->type, ffPathExists("/dev/efi" /*efidev*/, FF_PATHTYPE_FILE) || - ffPathExists("/boot/efi/efi/" /*efi partition*/, FF_PATHTYPE_DIRECTORY) + ffPathExists("/boot/efi/efi/" /*efi partition. Note /boot/efi exists on BIOS system*/, FF_PATHTYPE_DIRECTORY) ? "UEFI" : "BIOS"); } } diff --git a/src/detection/bios/bios_linux.c b/src/detection/bios/bios_linux.c index 98bb40c38..fc86b3a2e 100644 --- a/src/detection/bios/bios_linux.c +++ b/src/detection/bios/bios_linux.c @@ -4,7 +4,7 @@ #include -const char *ffDetectBios(FFBiosResult *bios) +const char* ffDetectBios(FFBiosResult* bios) { ffGetSmbiosValue("/sys/devices/virtual/dmi/id/bios_date", "/sys/class/dmi/id/bios_date", &bios->date); ffGetSmbiosValue("/sys/devices/virtual/dmi/id/bios_release", "/sys/class/dmi/id/bios_release", &bios->release); diff --git a/src/detection/bios/bios_windows.c b/src/detection/bios/bios_windows.c index e6737f632..500a33568 100644 --- a/src/detection/bios/bios_windows.c +++ b/src/detection/bios/bios_windows.c @@ -27,6 +27,11 @@ typedef struct _SYSTEM_BOOT_ENVIRONMENT_INFORMATION }; }; } SYSTEM_BOOT_ENVIRONMENT_INFORMATION; +#elif __OpenBSD__ +#include "common/io/io.h" + +#include +#include #endif typedef struct FFSmbiosBios @@ -89,8 +94,8 @@ const char* ffDetectBios(FFBiosResult* bios) default: break; } } - #elif __HAIKU__ - // Currently SMBIOS detection is supported in legency BIOS only + #elif __HAIKU__ || __OpenBSD__ + // Currently SMBIOS detection is supported in legancy BIOS only ffStrbufSetStatic(&bios->type, "BIOS"); #endif diff --git a/src/detection/bluetooth/bluetooth_bsd.c b/src/detection/bluetooth/bluetooth_bsd.c index 117675dad..a9a752b0d 100644 --- a/src/detection/bluetooth/bluetooth_bsd.c +++ b/src/detection/bluetooth/bluetooth_bsd.c @@ -21,5 +21,5 @@ const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFBluetoothOptions* options, FF_MA if (bt_devenum((void*) enumDev, devices) < 0) return "bt_devenum() failed"; - return 0; + return NULL; } diff --git a/src/detection/bluetoothradio/bluetoothradio_apple.m b/src/detection/bluetoothradio/bluetoothradio_apple.m index 9c0426c71..63af39d9c 100644 --- a/src/detection/bluetoothradio/bluetoothradio_apple.m +++ b/src/detection/bluetoothradio/bluetoothradio_apple.m @@ -3,12 +3,12 @@ #import -// For some reason the official declaration of IOBluetoothHostController don't include property `controllers` +// For some reason the official declaration of IOBluetoothHostController doesn't include property `controllers` @interface IOBluetoothHostController() + (id)controllers; @end -const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothResult */) +const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */) { NSArray* ctrls = IOBluetoothHostController.controllers; if(!ctrls) diff --git a/src/detection/bluetoothradio/bluetoothradio_windows.c b/src/detection/bluetoothradio/bluetoothradio_windows.c index c4482f14d..6519115a0 100644 --- a/src/detection/bluetoothradio/bluetoothradio_windows.c +++ b/src/detection/bluetoothradio/bluetoothradio_windows.c @@ -83,7 +83,7 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */) ffStrbufInitS(&device->name, blri.localInfo.name); BLUETOOTH_ADDRESS_STRUCT addr = { .ullLong = blri.localInfo.address }; - ffStrbufInitF(&device->address, "%02x:%02x:%02x:%02x:%02x:%02x", + ffStrbufInitF(&device->address, "%02X:%02X:%02X:%02X:%02X:%02X", addr.rgBytes[5], addr.rgBytes[4], addr.rgBytes[3], @@ -97,6 +97,8 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */) device->enabled = true; device->connectable = ffBluetoothIsConnectable(hRadio); device->discoverable = ffBluetoothIsDiscoverable(hRadio); + + CloseHandle(hRadio); } while (ffBluetoothFindNextRadio(hFind, &hRadio)); ffBluetoothFindRadioClose(hFind); diff --git a/src/detection/bootmgr/bootmgr.h b/src/detection/bootmgr/bootmgr.h index 082149e8e..c2d1ac2a3 100644 --- a/src/detection/bootmgr/bootmgr.h +++ b/src/detection/bootmgr/bootmgr.h @@ -6,6 +6,7 @@ typedef struct FFBootmgrResult { FFstrbuf name; FFstrbuf firmware; + uint16_t order; bool secureBoot; } FFBootmgrResult; diff --git a/src/detection/bootmgr/bootmgr_bsd.c b/src/detection/bootmgr/bootmgr_bsd.c index 86fe86fac..c2924fcf6 100644 --- a/src/detection/bootmgr/bootmgr_bsd.c +++ b/src/detection/bootmgr/bootmgr_bsd.c @@ -2,10 +2,22 @@ #include "efi_helper.h" #include "common/io/io.h" -#include +#ifdef __OpenBSD__ + #include +#else + #include +#endif #include #include +#ifdef __NetBSD__ + typedef uint16_t efi_char; +#endif + +#ifndef EFI_GLOBAL_VARIABLE + #define EFI_GLOBAL_VARIABLE { 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, { 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c } } +#endif + const char* ffDetectBootmgr(FFBootmgrResult* result) { FF_AUTO_CLOSE_FD int efifd = open("/dev/efi", O_RDWR); @@ -13,7 +25,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) uint8_t buffer[2048]; struct efi_var_ioc ioc = { - .vendor = { 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, { 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c } }, + .vendor = EFI_GLOBAL_VARIABLE, .data = buffer, }; @@ -23,8 +35,10 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) if (ioctl(efifd, EFIIOC_VAR_GET, &ioc) < 0 || ioc.datasize != 2) return "ioctl(EFIIOC_VAR_GET, BootCurrent) failed"; + result->order = *(uint16_t*)buffer; + unsigned char hex[5]; - snprintf((char*) hex, sizeof(hex), "%04X", *(uint16_t*)buffer); + snprintf((char*) hex, sizeof(hex), "%04X", result->order); ioc.datasize = sizeof(buffer); ioc.name = (efi_char[]){ 'B', 'o', 'o', 't', hex[0], hex[1], hex[2], hex[3], '\0' }; ioc.namesize = sizeof("Boot####") * 2; diff --git a/src/detection/bootmgr/bootmgr_linux.c b/src/detection/bootmgr/bootmgr_linux.c index 27738f724..7a47dc5f3 100644 --- a/src/detection/bootmgr/bootmgr_linux.c +++ b/src/detection/bootmgr/bootmgr_linux.c @@ -11,8 +11,10 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) if (ffReadFileData(FF_EFIVARS_PATH_PREFIX "BootCurrent-" FF_EFI_GLOBAL_GUID, sizeof(buffer), buffer) != 6) return "Failed to read efivar: BootCurrent"; - uint16_t value = *(uint16_t *)&buffer[4]; - snprintf((char*) buffer, sizeof(buffer), FF_EFIVARS_PATH_PREFIX "Boot%04X-" FF_EFI_GLOBAL_GUID, value); + + result->order = *(uint16_t *)&buffer[4]; + + snprintf((char*) buffer, sizeof(buffer), FF_EFIVARS_PATH_PREFIX "Boot%04X-" FF_EFI_GLOBAL_GUID, result->order); ssize_t size = ffReadFileData((const char*) buffer, sizeof(buffer), buffer); if (size < 5 + (int) sizeof(FFEfiLoadOption) || size == (ssize_t) sizeof(buffer)) diff --git a/src/detection/bootmgr/bootmgr_windows.c b/src/detection/bootmgr/bootmgr_windows.c index 54314bbad..dea46b2ea 100644 --- a/src/detection/bootmgr/bootmgr_windows.c +++ b/src/detection/bootmgr/bootmgr_windows.c @@ -1,11 +1,12 @@ #include "bootmgr.h" #include "efi_helper.h" +#include "common/io/io.h" #include const char* enablePrivilege(const wchar_t* privilege) { - HANDLE token; + FF_AUTO_CLOSE_FD HANDLE token = NULL; if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) return "OpenProcessToken() failed"; @@ -32,13 +33,12 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) if (enablePrivilege(L"SeSystemEnvironmentPrivilege") != NULL) return "Failed to enable SeSystemEnvironmentPrivilege"; - uint16_t value; - if (GetFirmwareEnvironmentVariableW(L"BootCurrent", L"{" FF_EFI_GLOBAL_GUID L"}", &value, sizeof(value)) != 2) + if (GetFirmwareEnvironmentVariableW(L"BootCurrent", L"{" FF_EFI_GLOBAL_GUID L"}", &result->order, sizeof(result->order)) != 2) return "GetFirmwareEnvironmentVariableW(BootCurrent) failed"; uint8_t buffer[2048]; wchar_t key[16]; - swprintf(key, ARRAY_SIZE(key), L"Boot%04X", value); + swprintf(key, ARRAY_SIZE(key), L"Boot%04X", result->order); uint32_t size = GetFirmwareEnvironmentVariableW(key, L"{" FF_EFI_GLOBAL_GUID L"}", buffer, sizeof(buffer)); if (size < sizeof(FFEfiLoadOption) || size == ARRAY_SIZE(buffer)) return "GetFirmwareEnvironmentVariableW(Boot####) failed"; diff --git a/src/detection/brightness/brightness_obsd.c b/src/detection/brightness/brightness_obsd.c index bb0bd861b..eb411129d 100644 --- a/src/detection/brightness/brightness_obsd.c +++ b/src/detection/brightness/brightness_obsd.c @@ -8,24 +8,35 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFlist* result) { - FF_AUTO_CLOSE_FD int devfd = open("/dev/ttyC0", O_RDONLY); + char path[] = "/dev/ttyCX"; + for (char i = '0'; i <= '9'; ++i) { + path[strlen("/dev/ttyC")] = i; - if (devfd < 0) return "open(dev/ttyC0, O_RDONLY) failed"; + FF_AUTO_CLOSE_FD int devfd = open(path, O_RDONLY); - struct wsdisplay_param param = { - .param = WSDISPLAYIO_PARAM_BRIGHTNESS, - }; + if (devfd < 0) { + if (errno == EACCES && i == '0') + return "Permission denied when opening tty device"; + if (errno == ENOENT) + break; + continue; + } - if (ioctl(devfd, WSDISPLAYIO_GETPARAM, ¶m) < 0) - return "ioctl(WSDISPLAYIO_GETPARAM) failed"; + struct wsdisplay_param param = { + .param = WSDISPLAYIO_PARAM_BRIGHTNESS, + }; - FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); - ffStrbufInitStatic(&brightness->name, "wsdisplay"); + if (ioctl(devfd, WSDISPLAYIO_GETPARAM, ¶m) < 0) + continue; - brightness->max = param.max; - brightness->min = param.min; - brightness->current = param.curval; - brightness->builtin = true; + FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); + ffStrbufInitF(&brightness->name, "ttyC%c", i); + + brightness->max = param.max; + brightness->min = param.min; + brightness->current = param.curval; + brightness->builtin = true; + } return NULL; } diff --git a/src/detection/brightness/brightness_windows.cpp b/src/detection/brightness/brightness_windows.cpp index 27d53cca8..401a16686 100644 --- a/src/detection/brightness/brightness_windows.cpp +++ b/src/detection/brightness/brightness_windows.cpp @@ -43,6 +43,7 @@ static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, F FF_LIBRARY_LOAD(dxva2, "dlopen dxva2" FF_LIBRARY_EXTENSION " failed", "dxva2" FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(dxva2, GetPhysicalMonitorsFromHMONITOR) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(dxva2, GetMonitorBrightness) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(dxva2, DestroyPhysicalMonitor) FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays) { @@ -64,6 +65,8 @@ static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, F brightness->current = curr; brightness->builtin = false; } + + ffDestroyPhysicalMonitor(physicalMonitor.hPhysicalMonitor); } } return NULL; diff --git a/src/detection/btrfs/btrfs_linux.c b/src/detection/btrfs/btrfs_linux.c index d9aed2586..e3f626717 100644 --- a/src/detection/btrfs/btrfs_linux.c +++ b/src/detection/btrfs/btrfs_linux.c @@ -12,7 +12,10 @@ static const char* enumerateDevices(FFBtrfsResult* item, int dfd, FFstrbuf* buff FF_AUTO_CLOSE_DIR DIR* dirp = fdopendir(subfd); if(dirp == NULL) + { + close(subfd); return "fdopendir(\"/sys/fs/btrfs/UUID/devices\") == NULL"; + } struct dirent* entry; while ((entry = readdir(dirp)) != NULL) diff --git a/src/detection/camera/camera_linux.c b/src/detection/camera/camera_linux.c index 6e9658845..e83f385b0 100644 --- a/src/detection/camera/camera_linux.c +++ b/src/detection/camera/camera_linux.c @@ -37,7 +37,7 @@ const char* ffDetectCamera(FFlist* result) { case V4L2_COLORSPACE_SMPTE170M: ffStrbufInitStatic(&camera->colorspace, "SMPTE 170M"); break; case V4L2_COLORSPACE_SMPTE240M: ffStrbufInitStatic(&camera->colorspace, "SMPTE 240M"); break; - case V4L2_COLORSPACE_BT878: ffStrbufInitStatic(&camera->colorspace, "BT.808"); break; + case V4L2_COLORSPACE_BT878: ffStrbufInitStatic(&camera->colorspace, "BT.878"); break; case V4L2_COLORSPACE_470_SYSTEM_M: ffStrbufInitStatic(&camera->colorspace, "NTSC"); break; case V4L2_COLORSPACE_470_SYSTEM_BG: ffStrbufInitStatic(&camera->colorspace, "EBU 3213"); break; case V4L2_COLORSPACE_JPEG: ffStrbufInitStatic(&camera->colorspace, "JPEG"); break; diff --git a/src/detection/camera/camera_windows.cpp b/src/detection/camera/camera_windows.cpp index 6f19ce932..3da687494 100644 --- a/src/detection/camera/camera_windows.cpp +++ b/src/detection/camera/camera_windows.cpp @@ -48,7 +48,7 @@ const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result) for (uint32_t i = 0; i < count; i++) { - IMFActivate* device = devices[i]; + IMFActivate* FF_AUTO_RELEASE_COM_OBJECT device = devices[i]; wchar_t buffer[256]; uint32_t length = 0; @@ -90,9 +90,11 @@ const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result) continue; // Assume first type is the maximum resolution - IMFMediaType* FF_AUTO_RELEASE_COM_OBJECT type = NULL; + IMFMediaType* type = NULL; for (DWORD idx = 0; SUCCEEDED(handler->GetMediaTypeByIndex(idx, &type)); ++idx) { + on_scope_exit destroyType([=] { type->Release(); }); + GUID majorType; if (FAILED(type->GetMajorType(&majorType)) || majorType != MFMediaType_Video) continue; @@ -123,7 +125,7 @@ const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result) } } - CoTaskMemFree(devices); + if (devices) CoTaskMemFree(devices); return nullptr; } diff --git a/src/detection/chassis/chassis.c b/src/detection/chassis/chassis.c index 9e76bcfc8..b1b44a377 100644 --- a/src/detection/chassis/chassis.c +++ b/src/detection/chassis/chassis.c @@ -34,6 +34,7 @@ const char* ffChassisTypeToString(uint32_t type) case 0x1A: return "Compact PCI"; case 0x1B: return "Advanced TCA"; case 0x1C: return "Blade"; + case 0x1D: return "Mobile Workstation"; case 0x1E: return "Tablet"; case 0x1F: return "Convertible"; case 0x20: return "Detachable"; diff --git a/src/detection/chassis/chassis_apple.c b/src/detection/chassis/chassis_apple.c index 0a649e0c1..956386d08 100644 --- a/src/detection/chassis/chassis_apple.c +++ b/src/detection/chassis/chassis_apple.c @@ -17,10 +17,11 @@ const char* ffDetectChassis(FFChassisResult* result) if (ffStrbufStartsWithS(&host.name, "MacBook ")) ffStrbufSetStatic(&result->type, "Laptop"); - else if (ffStrbufStartsWithS(&host.name, "Mac mini ")) + else if (ffStrbufStartsWithS(&host.name, "Mac mini ") || + ffStrbufStartsWithS(&host.name, "Mac Studio ")) ffStrbufSetStatic(&result->type, "Mini PC"); else if (ffStrbufStartsWithS(&host.name, "iMac ")) - ffStrbufSetStatic(&result->type, "All-in-One"); + ffStrbufSetStatic(&result->type, "All in One"); else ffStrbufSetStatic(&result->type, "Desktop"); diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index a62141817..04b0f00b4 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -430,7 +430,6 @@ FF_MAYBE_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo) while ((p = memmem(p, cpuinfo->length - (uint32_t) (p - cpuinfo->chars), "\nphysical id\t:", strlen("\nphysical id\t:")))) { - if (!p) break; p += strlen("\nphysical id\t:"); char* pend; unsigned long id = strtoul(p, &pend, 10); @@ -586,7 +585,6 @@ FF_MAYBE_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const c while ((p = memmem(p, cpuinfo->length - (uint32_t) (p - cpuinfo->chars), key, keylen))) { - if (!p) break; p += keylen; char* pend; unsigned long id = strtoul(p, &pend, 10); @@ -608,7 +606,7 @@ FF_MAYBE_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, #if __ANDROID__ detectAndroid(cpu); - #else + #elif !__powerpc__ && !__powerpc detectSocName(cpu); #endif diff --git a/src/detection/cpu/cpu_nbsd.c b/src/detection/cpu/cpu_nbsd.c index 118887290..78ec347b2 100644 --- a/src/detection/cpu/cpu_nbsd.c +++ b/src/detection/cpu/cpu_nbsd.c @@ -9,12 +9,19 @@ #include #include +static void freePropDict(prop_dictionary_t* pdict) +{ + assert(pdict != NULL); + if (*pdict == NULL) return; + prop_object_release(*pdict); +} + static const char* detectCpuTemp(double* current) { FF_AUTO_CLOSE_FD int fd = open(_PATH_SYSMON, O_RDONLY); if (fd < 0) return "open(_PATH_SYSMON, O_RDONLY) failed"; - prop_dictionary_t root = NULL; + __attribute__((__cleanup__(freePropDict))) prop_dictionary_t root = NULL; if (prop_dictionary_recv_ioctl(fd, ENVSYS_GETDICTIONARY, &root) < 0) return "prop_dictionary_recv_ioctl(ENVSYS_GETDICTIONARY) failed"; diff --git a/src/detection/cpu/cpu_sunos.c b/src/detection/cpu/cpu_sunos.c index e10dcb898..9553d6a1b 100644 --- a/src/detection/cpu/cpu_sunos.c +++ b/src/detection/cpu/cpu_sunos.c @@ -23,22 +23,24 @@ const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFCPUOptions* options, FFCPURe { kstat_named_t* kn = kstat_data_lookup(ks, "brand"); - ffStrbufSetNS(&cpu->name, KSTAT_NAMED_STR_BUFLEN(kn) - 1, KSTAT_NAMED_STR_PTR(kn)); + if (kn) ffStrbufSetNS(&cpu->name, KSTAT_NAMED_STR_BUFLEN(kn) - 1, KSTAT_NAMED_STR_PTR(kn)); } { kstat_named_t* kn = kstat_data_lookup(ks, "vendor_id"); - ffStrbufSetNS(&cpu->vendor, KSTAT_NAMED_STR_BUFLEN(kn) - 1, KSTAT_NAMED_STR_PTR(kn)); + if (kn) ffStrbufSetNS(&cpu->vendor, KSTAT_NAMED_STR_BUFLEN(kn) - 1, KSTAT_NAMED_STR_PTR(kn)); } ffCPUDetectSpeedByCpuid(cpu); - kstat_named_t* kn = kstat_data_lookup(ks, "clock_MHz"); - if (kn->value.ui32 > cpu->frequencyBase) - cpu->frequencyBase = kn->value.ui32; + { + kstat_named_t* kn = kstat_data_lookup(ks, "clock_MHz"); + if (kn && kn->value.ui32 > cpu->frequencyBase) + cpu->frequencyBase = kn->value.ui32; + } ks = kstat_lookup(kc, "unix", -1, "system_misc"); if (ks && kstat_read(kc, ks, NULL) >= 0) { kstat_named_t* kn = kstat_data_lookup(ks, "ncpus"); - cpu->coresLogical = cpu->coresPhysical = cpu->coresOnline = (uint16_t) kn->value.ui32; + if (kn) cpu->coresLogical = cpu->coresPhysical = cpu->coresOnline = (uint16_t) kn->value.ui32; } return NULL; diff --git a/src/detection/cpu/cpu_windows.c b/src/detection/cpu/cpu_windows.c index 09f422e12..32c31768d 100644 --- a/src/detection/cpu/cpu_windows.c +++ b/src/detection/cpu/cpu_windows.c @@ -128,9 +128,13 @@ static const char* detectByRegistry(FFCPUResult* cpu) if (cpu->coresLogical == 0) { - DWORD cores; - if (RegQueryInfoKeyW(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor", NULL, NULL, &cores, NULL, NULL, NULL, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) - cpu->coresOnline = cpu->coresPhysical = cpu->coresLogical = (uint16_t) cores; + FF_HKEY_AUTO_DESTROY hProcsKey = NULL; + if (ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor", &hProcsKey, NULL)) + { + uint32_t cores; + if (ffRegGetNSubKeys(hProcsKey, &cores, NULL)) + cpu->coresOnline = cpu->coresPhysical = cpu->coresLogical = (uint16_t) cores; + } } uint32_t mhz; diff --git a/src/detection/cpu/cpu_windows.cpp b/src/detection/cpu/cpu_windows.cpp index 4a961d4c5..85b3ee084 100644 --- a/src/detection/cpu/cpu_windows.cpp +++ b/src/detection/cpu/cpu_windows.cpp @@ -26,6 +26,8 @@ const char* detectThermalTemp(double* current, double* critical) else *critical = 0.0/0.0; } + + return NULL; } return "No WMI result returned"; diff --git a/src/detection/cpucache/cpucache_windows.c b/src/detection/cpucache/cpucache_windows.c index ee7bcb8d0..f68c902d2 100644 --- a/src/detection/cpucache/cpucache_windows.c +++ b/src/detection/cpucache/cpucache_windows.c @@ -31,7 +31,7 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) case CacheInstruction: cacheType = FF_CPU_CACHE_TYPE_INSTRUCTION; break; case CacheData: cacheType = FF_CPU_CACHE_TYPE_DATA; break; case CacheTrace: cacheType = FF_CPU_CACHE_TYPE_TRACE; break; - default: __builtin_unreachable(); break; + default: break; } ffCPUCacheAddItem(result, ptr->Cache.Level, ptr->Cache.CacheSize, ptr->Cache.LineSize, cacheType); } diff --git a/src/detection/cpuusage/cpuusage_apple.c b/src/detection/cpuusage/cpuusage_apple.c index 513b5e930..0630072ca 100644 --- a/src/detection/cpuusage/cpuusage_apple.c +++ b/src/detection/cpuusage/cpuusage_apple.c @@ -3,6 +3,7 @@ #include #include +#include const char* ffGetCpuUsageInfo(FFlist* cpuTimes) { @@ -28,5 +29,7 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) .totalAll = (uint64_t)total, }; } + + vm_deallocate(mach_task_self(), (vm_address_t) cpuInfo, numCpuInfo * sizeof(integer_t)); return NULL; } diff --git a/src/detection/disk/disk_bsd.c b/src/detection/disk/disk_bsd.c index b3ddf2e4e..ca6fe1bcc 100644 --- a/src/detection/disk/disk_bsd.c +++ b/src/detection/disk/disk_bsd.c @@ -36,7 +36,7 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) return "geom_gettree() failed"; } - for (cLabels = geomTree.lg_class.lh_first; !ffStrEquals(cLabels->lg_name, "LABEL"); cLabels = cLabels->lg_class.le_next); + for (cLabels = geomTree.lg_class.lh_first; cLabels && !ffStrEquals(cLabels->lg_name, "LABEL"); cLabels = cLabels->lg_class.le_next); if (!cLabels) return "Class LABEL is not found"; } @@ -165,7 +165,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) disk->bytesUsed = 0; // To be filled in ./disk.c disk->filesTotal = (uint32_t) fs->f_files; - disk->filesUsed = (uint32_t) (disk->filesTotal - (uint64_t)fs->f_ffree); + disk->filesUsed = (uint32_t) (fs->f_files - fs->f_ffree); ffStrbufInitS(&disk->mountFrom, fs->f_mntfromname); ffStrbufInitS(&disk->mountpoint, fs->f_mntonname); @@ -185,7 +185,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) #ifndef __DragonFly__ struct stat st; if(stat(fs->f_mntonname, &st) == 0 && st.st_birthtimespec.tv_sec > 0) - disk->createTime = (uint64_t)((st.st_birthtimespec.tv_sec * 1000) + (st.st_birthtimespec.tv_nsec / 1000000)); + disk->createTime = (uint64_t)(((uint64_t) st.st_birthtimespec.tv_sec * 1000) + ((uint64_t) st.st_birthtimespec.tv_nsec / 1000000)); #endif } diff --git a/src/detection/disk/disk_haiku.cpp b/src/detection/disk/disk_haiku.cpp index de867d665..a8e934675 100644 --- a/src/detection/disk/disk_haiku.cpp +++ b/src/detection/disk/disk_haiku.cpp @@ -14,7 +14,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) for (dev_t dev; (dev = next_dev(&pos)) >= B_OK;) { fs_info fs; - if (fs_stat_dev(dev, &fs) < -1) continue; + if (fs_stat_dev(dev, &fs) < 0) continue; node_ref node(fs.dev, fs.root); BDirectory dir(&node); @@ -32,10 +32,10 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) disk->bytesTotal = (uint64_t)fs.total_blocks * (uint64_t) fs.block_size; disk->bytesFree = (uint64_t)fs.free_blocks * (uint64_t) fs.block_size; disk->bytesAvailable = disk->bytesFree; - disk->bytesUsed = 0; // To be filled in ./disk. c + disk->bytesUsed = 0; // To be filled in ./disk.c disk->filesTotal = (uint32_t) fs.total_nodes; - disk->filesUsed = (uint32_t) (disk->filesTotal - (uint64_t)fs.free_nodes); + disk->filesUsed = (uint32_t) (fs.total_nodes - fs.free_nodes); ffStrbufInitS(&disk->mountFrom, fs.device_name); ffStrbufInitS(&disk->mountpoint, path.Path()); diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 4480d4d23..3472c8d30 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -209,7 +209,10 @@ static bool isRemovable(FFDisk* currentDisk) char sysBlockVolume[PATH_MAX]; // /sys/devices/pci0000:00/0000:00:14.0/usb4/4-3/4-3:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 if (realpath(sysBlockPartition, sysBlockVolume) == NULL) return false; - strcpy(strrchr(sysBlockVolume, '/') + 1, "removable"); + char* lastSlash = strrchr(sysBlockVolume, '/'); + if (lastSlash == NULL) + return false; + strcpy(lastSlash + 1, "removable"); char removableChar = '0'; return ffReadFileData(sysBlockVolume, 1, &removableChar) > 0 && removableChar == '1'; diff --git a/src/detection/disk/disk_sunos.c b/src/detection/disk/disk_sunos.c index af19d74d4..82cba50ce 100644 --- a/src/detection/disk/disk_sunos.c +++ b/src/detection/disk/disk_sunos.c @@ -99,9 +99,6 @@ static void detectStats(FFDisk* disk) ffStrbufSetS(&disk->name, fs.f_fstr); disk->createTime = 0; - struct stat deviceStat; - if(stat(disk->mountpoint.chars, &deviceStat) == 0) - disk->createTime = (uint64_t) deviceStat.st_ctim.tv_sec * 1000 + (uint64_t) deviceStat.st_ctim.tv_nsec / 1000000000; } const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) diff --git a/src/detection/diskio/diskio.c b/src/detection/diskio/diskio.c index 1677c5cf2..9413a7125 100644 --- a/src/detection/diskio/diskio.c +++ b/src/detection/diskio/diskio.c @@ -69,10 +69,15 @@ const char* ffDetectDiskIO(FFlist* result, FFDiskIOOptions* options) uint64_t temp = *currValue; *currValue -= *prevValue; *currValue /= (time2 - time1) / 1000 /* seconds */; + + // For next function call *prevValue = temp; } } + + // For next function call time1 = time2; + // Leak ioCounters1 here return NULL; } diff --git a/src/detection/diskio/diskio_bsd.c b/src/detection/diskio/diskio_bsd.c index f8fc1d8c7..abd339e6f 100644 --- a/src/detection/diskio/diskio_bsd.c +++ b/src/detection/diskio/diskio_bsd.c @@ -13,7 +13,8 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { - struct gmesh geomTree; + __attribute__((__cleanup__(geom_deletetree))) + struct gmesh geomTree = {}; if (geom_gettree(&geomTree) < 0) return "geom_gettree() failed"; @@ -21,6 +22,9 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) return "geom_stats_open() failed"; void* snap = geom_stats_snapshot_get(); + if (!snap) + return "geom_stats_snapshot_get() failed"; + struct devstat* snapIter; while ((snapIter = geom_stats_snapshot_next(snap)) != NULL) { diff --git a/src/detection/diskio/diskio_linux.c b/src/detection/diskio/diskio_linux.c index 9bddb27ee..4d8d62241 100644 --- a/src/detection/diskio/diskio_linux.c +++ b/src/detection/diskio/diskio_linux.c @@ -8,10 +8,10 @@ #include #include -static void parseDiskIOCounters(int dfd, const char* devName, FFlist* result, FFDiskIOOptions* options) +static const char* parseDiskIOCounters(int dfd, const char* devName, FFlist* result, FFDiskIOOptions* options) { FF_AUTO_CLOSE_FD int devfd = openat(dfd, "device", O_RDONLY | O_CLOEXEC | O_PATH | O_DIRECTORY); - if (devfd < 0) return; // virtual device + if (devfd < 0) return "virtual device"; FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate(); @@ -49,7 +49,7 @@ static void parseDiskIOCounters(int dfd, const char* devName, FFlist* result, FF } if (options->namePrefix.length && !ffStrbufStartsWith(&name, &options->namePrefix)) - return; + return "ignored"; } // I/Os merges sectors ticks ... @@ -57,10 +57,10 @@ static void parseDiskIOCounters(int dfd, const char* devName, FFlist* result, FF { char sysBlockStat[PROC_FILE_BUFFSIZ]; ssize_t fileSize = ffReadFileDataRelative(dfd, "stat", ARRAY_SIZE(sysBlockStat) - 1, sysBlockStat); - if (fileSize <= 0) return; + if (fileSize <= 0) return "failed to read stat file"; sysBlockStat[fileSize] = '\0'; if (sscanf(sysBlockStat, "%" PRIu64 "%*u%" PRIu64 "%*u%" PRIu64 "%*u%" PRIu64 "%*u", &nRead, §orRead, &nWritten, §orWritten) <= 0) - return; + return "invalid stat file format"; } FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result); @@ -70,6 +70,8 @@ static void parseDiskIOCounters(int dfd, const char* devName, FFlist* result, FF device->bytesWritten = sectorWritten * 512; device->readCount = nRead; device->writeCount = nWritten; + + return NULL; } const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) @@ -83,7 +85,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { const char* const devName = sysBlockEntry->d_name; - if (devName[0] == '.') continue;; + if (devName[0] == '.') continue; FF_AUTO_CLOSE_FD int dfd = openat(dirfd(sysBlockDirp), devName, O_RDONLY | O_CLOEXEC | O_PATH | O_DIRECTORY); if (dfd > 0) parseDiskIOCounters(dfd, devName, result, options); diff --git a/src/detection/diskio/diskio_nbsd.c b/src/detection/diskio/diskio_nbsd.c index 8d537045a..340cd856c 100644 --- a/src/detection/diskio/diskio_nbsd.c +++ b/src/detection/diskio/diskio_nbsd.c @@ -12,12 +12,12 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) if (sysctl(mib, ARRAY_SIZE(mib), NULL, &len, NULL, 0) < 0) return "sysctl({HW_IOSTATS}, NULL) failed"; uint32_t nDrive = (uint32_t) (len / sizeof(struct io_sysctl)); - - struct io_sysctl* stats = malloc(len); + + FF_AUTO_FREE struct io_sysctl* stats = malloc(len); if (sysctl(mib, ARRAY_SIZE(mib), stats, &len, NULL, 0) < 0) return "sysctl({HW_IOSTATS}, stats) failed"; - + for (uint32_t i = 0; i < nDrive; ++i) { struct io_sysctl* st = &stats[i]; diff --git a/src/detection/diskio/diskio_obsd.c b/src/detection/diskio/diskio_obsd.c index 437d93caf..5dbfcd228 100644 --- a/src/detection/diskio/diskio_obsd.c +++ b/src/detection/diskio/diskio_obsd.c @@ -13,7 +13,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) return "sysctl({HW_DISKSTATS}, NULL) failed"; uint32_t nDrive = (uint32_t) (len / sizeof(struct diskstats)); - struct diskstats* stats = malloc(len); + FF_AUTO_FREE struct diskstats* stats = malloc(len); if (sysctl(mib, ARRAY_SIZE(mib), stats, &len, NULL, 0) < 0) return "sysctl({HW_DISKSTATS}, stats) failed"; diff --git a/src/detection/diskio/diskio_sunos.c b/src/detection/diskio/diskio_sunos.c index a6bb0b311..8cc6810bb 100644 --- a/src/detection/diskio/diskio_sunos.c +++ b/src/detection/diskio/diskio_sunos.c @@ -27,7 +27,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) continue; FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result); - ffStrbufInit(&device->devPath); + ffStrbufInit(&device->devPath); // unlike other platforms, `/dev/ks_name` is not available ffStrbufInitS(&device->name, ks->ks_name); device->bytesRead = kio.nread; device->readCount = kio.reads; diff --git a/src/detection/diskio/diskio_windows.c b/src/detection/diskio/diskio_windows.c index da9bf8daf..cf92d32ea 100644 --- a/src/detection/diskio/diskio_windows.c +++ b/src/detection/diskio/diskio_windows.c @@ -56,8 +56,6 @@ static bool detectPhysicalDisk(const wchar_t* szDevice, FFlist* result, FFDiskIO return true; } - ffStrbufInitWS(&device->devPath, szDevice); - DISK_PERFORMANCE dp = {}; if (DeviceIoControl(hDevice, IOCTL_DISK_PERFORMANCE, NULL, 0, &dp, sizeof(dp), &retSize, NULL)) { @@ -72,6 +70,8 @@ static bool detectPhysicalDisk(const wchar_t* szDevice, FFlist* result, FFDiskIO result->length--; } + ffStrbufInitWS(&device->devPath, szDevice); + return true; } diff --git a/src/detection/displayserver/displayserver_android.c b/src/detection/displayserver/displayserver_android.c index d10f394e0..0c7a3c1c9 100644 --- a/src/detection/displayserver/displayserver_android.c +++ b/src/detection/displayserver/displayserver_android.c @@ -4,6 +4,33 @@ #include +static bool checkHdrStatus(FFDisplayResult* display) +{ + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); + + if (ffSettingsGetAndroidProperty("ro.surface_flinger.has_HDR_display", &buffer)) + { + if (ffStrbufIgnCaseEqualS(&buffer, "true")) + { + display->hdrStatus = FF_DISPLAY_HDR_STATUS_SUPPORTED; + + if (ffSettingsGetAndroidProperty("persist.sys.hdr_mode", &buffer) && + ffStrbufToUInt(&buffer, 0) > 0) + display->hdrStatus = FF_DISPLAY_HDR_STATUS_ENABLED; + + return true; + } + else + { + display->hdrStatus = FF_DISPLAY_HDR_STATUS_UNSUPPORTED; + return true; + } + } + + display->hdrStatus = FF_DISPLAY_HDR_STATUS_UNKNOWN; + return false; +} + static void detectWithDumpsys(FFDisplayServerResult* ds) { FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate(); @@ -54,7 +81,7 @@ static void detectWithDumpsys(FFDisplayServerResult* ds) } ffStrbufRecalculateLength(&name); - ffdsAppendDisplay(ds, + FFDisplayResult* display = ffdsAppendDisplay(ds, (uint32_t)width, (uint32_t)height, refreshRate, @@ -72,6 +99,7 @@ static void detectWithDumpsys(FFDisplayServerResult* ds) 0, "dumpsys" ); + if (display) display->hdrStatus = checkHdrStatus(display); } index = nextIndex + 1; @@ -92,7 +120,7 @@ static bool detectWithGetprop(FFDisplayServerResult* ds) uint32_t height = (uint32_t) ffStrbufToUInt(&buffer, 0); ffStrbufSubstrAfterFirstC(&buffer, ','); double scaleFactor = (double) ffStrbufToUInt(&buffer, 0) / 160.; - return ffdsAppendDisplay(ds, + FFDisplayResult* display = ffdsAppendDisplay(ds, width, height, 0, @@ -110,6 +138,8 @@ static bool detectWithGetprop(FFDisplayServerResult* ds) 0, "getprop" ); + if (display) display->hdrStatus = checkHdrStatus(display); + return !!display; } return false; diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index e8eeb9fbf..df6c7cf90 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -68,7 +68,7 @@ static void detectDisplays(FFDisplayServerResult* ds) if(displayInfo) { CFDictionaryRef productNames; - if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames)) + if(ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames) == NULL) ffCfDictGetString(productNames, CFSTR("en_US"), &buffer); // CGDisplayScreenSize reports invalid result for external displays on old Intel MacBook Pro diff --git a/src/detection/displayserver/linux/wayland/wayland.c b/src/detection/displayserver/linux/wayland/wayland.c index b2cdb3da8..f64d18632 100644 --- a/src/detection/displayserver/linux/wayland/wayland.c +++ b/src/detection/displayserver/linux/wayland/wayland.c @@ -273,7 +273,7 @@ const char* ffdsConnectWayland(FFDisplayServerResult* result) FF_LIST_FOR_EACH(FFstrbuf, basePath, instance.state.platform.configDirs) { char path[1024]; - snprintf(path, ARRAY_SIZE(path) - 1, "%s%s", basePath->chars, fileName); + snprintf(path, ARRAY_SIZE(path), "%s%s", basePath->chars, fileName); if (ffReadFileBuffer(path, &monitorsXml)) break; } diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index c8324f789..f735bd40c 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -374,7 +374,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result) ffStrbufAppendS(&procPath, dirent->d_name); uint32_t procFolderPathLength = procPath.length; - //Don't check for processes not owend by the current user. + //Don't check for processes not owned by the current user. ffStrbufAppendS(&procPath, "/loginuid"); ffReadFileBuffer(procPath.chars, &loginuid); if(ffStrbufToUInt(&loginuid, (uint64_t) -1) != userId) diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index 13f8537ae..d71434820 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -26,7 +26,7 @@ typedef struct XcbPropertyData FF_LIBRARY_SYMBOL(xcb_get_atom_name_reply) } XcbPropertyData; -static bool xcbInitPropertyData(void* libraryHandle, XcbPropertyData* propertyData) +static bool xcbInitPropertyData(FF_MAYBE_UNUSED void* libraryHandle, XcbPropertyData* propertyData) { FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_intern_atom, false) FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_intern_atom_reply, false) @@ -333,7 +333,7 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen) const char* ffdsConnectXcbRandr(FFDisplayServerResult* result) { - FF_LIBRARY_LOAD(xcbRandr, "dlopen lbxcb-randr failed", "libxcb-randr" FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD(xcbRandr, "dlopen libxcb-randr failed", "libxcb-randr" FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_connect) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_get_setup) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_setup_roots_iterator) @@ -369,7 +369,7 @@ const char* ffdsConnectXcbRandr(FFDisplayServerResult* result) data.connection = ffxcb_connect(NULL, NULL); if(data.connection == NULL) - return "xcb_connect failed"; + return "xcb_connect() failed"; data.result = result; diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index 0c4d283ed..ab16102be 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -17,7 +17,7 @@ typedef struct X11PropertyData FF_LIBRARY_SYMBOL(XFree) } X11PropertyData; -static bool x11InitPropertyData(void* libraryHandle, X11PropertyData* propertyData) +static bool x11InitPropertyData(FF_MAYBE_UNUSED void* libraryHandle, X11PropertyData* propertyData) { FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, XInternAtom, false) FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, XGetWindowProperty, false) @@ -147,7 +147,7 @@ static bool xrandrHandleCrtc(XrandrData* data, XRROutputInfo* output, FFstrbuf* "xlib-randr-crtc" ); - if (edidLength) + if (item && edidLength) { item->hdrStatus = ffEdidGetHdrCompatible(edidData, edidLength) ? FF_DISPLAY_HDR_STATUS_SUPPORTED : FF_DISPLAY_HDR_STATUS_UNSUPPORTED; ffEdidGetSerialAndManufactureDate(edidData, &item->serial, &item->manufactureYear, &item->manufactureWeek); @@ -231,7 +231,7 @@ static bool xrandrHandleMonitors(XrandrData* data, Screen* screen) if(monitorInfos == NULL) return false; - bool foundAMonitor; + bool foundAMonitor = false; for(int i = 0; i < numberOfMonitors; i++) { @@ -272,7 +272,7 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen) 0, (uint32_t) WidthMMOfScreen(screen), (uint32_t) HeightMMOfScreen(screen), - "xlib_randr_screen" + "xlib-randr-screen" ); } diff --git a/src/detection/dns/dns_apple.c b/src/detection/dns/dns_apple.c new file mode 100644 index 000000000..9568f28b0 --- /dev/null +++ b/src/detection/dns/dns_apple.c @@ -0,0 +1,109 @@ +#include "detection/dns/dns.h" + +#include "common/io/io.h" +#include "util/mallocHelper.h" +#include "util/stringUtils.h" +#include "util/apple/cf_helpers.h" +#include "util/debug.h" + +#include + +static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FFlist* results) +{ + FF_DEBUG("Attempting to read DNS config from %s", path); + + FF_AUTO_CLOSE_FILE FILE* file = fopen(path, "r"); + if (!file) + { + FF_DEBUG("Failed to open %s: %m", path); + return "fopen(path, r) failed"; + } + + if (results->length > 0) + { + FF_DEBUG("Clearing existing DNS entries (%u entries)", results->length); + FF_LIST_FOR_EACH(FFstrbuf, item, *results) + ffStrbufDestroy(item); + ffListClear(results); + } + + FF_AUTO_FREE char* line = NULL; + size_t len = 0; + + while (getline(&line, &len, file) != -1) + { + if (ffStrStartsWith(line, "nameserver")) + { + char* nameserver = line + strlen("nameserver"); + while (*nameserver == ' ' || *nameserver == '\t') + nameserver++; + if (*nameserver == '\0') continue; + + char* comment = strchr(nameserver, '#'); + if (comment) *comment = '\0'; + + if ((ffStrContainsC(nameserver, ':') && !(options->showType & FF_DNS_TYPE_IPV6_BIT)) || + (ffStrContainsC(nameserver, '.') && !(options->showType & FF_DNS_TYPE_IPV4_BIT))) + continue; + + FFstrbuf* item = (FFstrbuf*) ffListAdd(results); + ffStrbufInitS(item, nameserver); + ffStrbufTrimRightSpace(item); + FF_DEBUG("Found DNS server: %s", item->chars); + } + } + + FF_DEBUG("Found %u DNS servers in %s", results->length, path); + return NULL; +} + +const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) +{ + // Handle macOS-specific DNS configurations + FF_DEBUG("Using SystemConfiguration framework for macOS"); + + // Create a reference to the dynamic store + FF_CFTYPE_AUTO_RELEASE SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("fastfetch"), NULL, NULL); + if (store) + { + // Get the network global IPv4 and IPv6 configuration + FF_CFTYPE_AUTO_RELEASE CFStringRef key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, kSCDynamicStoreDomainState, kSCEntNetDNS); + if (key) + { + FF_CFTYPE_AUTO_RELEASE CFDictionaryRef dict = SCDynamicStoreCopyValue(store, key); + if (dict) + { + // Get the DNS server addresses array + CFArrayRef dnsServers = CFDictionaryGetValue(dict, kSCPropNetDNSServerAddresses); + + if (dnsServers) + { + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); + for (CFIndex i = 0; i < CFArrayGetCount(dnsServers); i++) + { + if (ffCfStrGetString(CFArrayGetValueAtIndex(dnsServers, i), &buffer) == NULL) + { + // Check if the address matches our filter + if ((ffStrbufContainC(&buffer, ':') && !(options->showType & FF_DNS_TYPE_IPV6_BIT)) || + (ffStrbufContainC(&buffer, '.') && !(options->showType & FF_DNS_TYPE_IPV4_BIT))) + continue; + + // Add to results + FFstrbuf* item = (FFstrbuf*) ffListAdd(results); + ffStrbufInitMove(item, &buffer); + FF_DEBUG("Found DNS server on macOS: %s", item->chars); + } + } + } + } + } + } + + // If we didn't find any servers, try resolv.conf as fallback + if (results->length > 0) + return NULL; + + FF_DEBUG("No DNS servers found via SystemConfiguration, trying resolv.conf"); + // Try standard resolv.conf location on macOS as a fallback + return detectDnsFromConf("/var/run/resolv.conf", options, results); +} diff --git a/src/detection/dns/dns_linux.c b/src/detection/dns/dns_linux.c index 8bf1da0c2..51c2fd643 100644 --- a/src/detection/dns/dns_linux.c +++ b/src/detection/dns/dns_linux.c @@ -3,6 +3,7 @@ #include "common/io/io.h" #include "util/mallocHelper.h" #include "util/stringUtils.h" +#include "util/debug.h" #ifdef __HAIKU__ #define RESOLV_CONF "/system/settings/network/resolv.conf" @@ -10,11 +11,24 @@ #define RESOLV_CONF "/etc/resolv.conf" #endif -const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) +static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FFlist* results) { - FF_AUTO_CLOSE_FILE FILE* file = fopen(FASTFETCH_TARGET_DIR_ROOT RESOLV_CONF, "r"); + FF_DEBUG("Attempting to read DNS config from %s", path); + + FF_AUTO_CLOSE_FILE FILE* file = fopen(path, "r"); if (!file) - return "fopen (" FASTFETCH_TARGET_DIR_ROOT "/etc/resolv.conf) failed"; + { + FF_DEBUG("Failed to open %s: %m", path); + return "fopen(path, r) failed"; + } + + if (results->length > 0) + { + FF_DEBUG("Clearing existing DNS entries (%u entries)", results->length); + FF_LIST_FOR_EACH(FFstrbuf, item, *results) + ffStrbufDestroy(item); + ffListClear(results); + } FF_AUTO_FREE char* line = NULL; size_t len = 0; @@ -38,7 +52,90 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) FFstrbuf* item = (FFstrbuf*) ffListAdd(results); ffStrbufInitS(item, nameserver); ffStrbufTrimRightSpace(item); + FF_DEBUG("Found DNS server: %s", item->chars); } } + + FF_DEBUG("Found %u DNS servers in %s", results->length, path); + return NULL; +} + +const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) +{ + FF_DEBUG("Starting DNS detection"); + + const char* error = detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT RESOLV_CONF, options, results); + if (error != NULL) + { + FF_DEBUG("Error detecting DNS: %s", error); + return error; + } + + #if __linux__ && !__ANDROID__ + // Handle different DNS management services + if (results->length == 1) + { + const FFstrbuf* firstEntry = FF_LIST_GET(FFstrbuf, *results, 0); + + if (ffStrbufEqualS(firstEntry, "127.0.0.53")) + { + FF_DEBUG("Detected systemd-resolved (127.0.0.53), checking actual DNS servers"); + // Managed by systemd-resolved + if (detectDnsFromConf("/run/systemd/resolve/resolv.conf", options, results) == NULL) + return NULL; + } + else if (ffStrbufEqualS(firstEntry, "127.0.0.1")) + { + FF_DEBUG("Detected possible NetworkManager (127.0.0.1), checking actual DNS servers"); + // Managed by NetworkManager + if (detectDnsFromConf("/var/run/NetworkManager/resolv.conf", options, results) == NULL) + return NULL; + } + } + + // Check other possible DNS configuration files + if (results->length == 0) + { + FF_DEBUG("No DNS servers found, trying alternative config files"); + + // Try resolvconf + FF_DEBUG("Trying resolvconf configuration"); + if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/run/resolvconf/resolv.conf", options, results) == NULL && results->length > 0) + return NULL; + + // Try dnsmasq + FF_DEBUG("Trying dnsmasq configuration"); + if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/dnsmasq/resolv.conf", options, results) == NULL && results->length > 0) + return NULL; + + // Try openresolv + FF_DEBUG("Trying openresolv configuration"); + if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/etc/resolv.conf.openresolv", options, results) == NULL && results->length > 0) + return NULL; + } + #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) + // Handle BSD-specific DNS configurations + if (results->length == 0) + { + FF_DEBUG("No DNS servers found, trying BSD-specific config files"); + + // FreeBSD and other BSDs may use resolvconf service + FF_DEBUG("Trying BSD resolvconf configuration"); + if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/resolvconf/resolv.conf", options, results) == NULL && results->length > 0) + return NULL; + + // Some BSDs store DNS configuration here + FF_DEBUG("Trying BSD nameserver configuration"); + if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/nameserver", options, results) == NULL && results->length > 0) + return NULL; + + // Try common BSD paths + FF_DEBUG("Trying BSD common paths"); + if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/etc/nameserver", options, results) == NULL && results->length > 0) + return NULL; + } + #endif + + FF_DEBUG("DNS detection completed with %u servers found", results->length); return NULL; } diff --git a/src/detection/editor/editor.c b/src/detection/editor/editor.c index 1566cfbb1..b94cadc30 100644 --- a/src/detection/editor/editor.c +++ b/src/detection/editor/editor.c @@ -10,6 +10,7 @@ #ifdef _WIN32 static inline char* realpath(const char* restrict file_name, char* restrict resolved_name) { + assert(resolved_name != NULL); return _fullpath(resolved_name, file_name, _MAX_PATH); } #endif diff --git a/src/detection/gamepad/gamepad_bsd.c b/src/detection/gamepad/gamepad_bsd.c index fa68b46fc..1cc5993ba 100644 --- a/src/detection/gamepad/gamepad_bsd.c +++ b/src/detection/gamepad/gamepad_bsd.c @@ -20,8 +20,12 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { snprintf(path, ARRAY_SIZE(path), "/dev/uhid%d", i); FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY | O_CLOEXEC); - if (fd < 0) continue; - + if (fd < 0) + { + if (errno == ENOENT) + break; // No more devices + continue; // Device not found + } report_desc_t repDesc = hid_get_report_desc(fd); if (!repDesc) continue; @@ -53,6 +57,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) device->battery = 0; } } + hid_end_parse(hData); } hid_dispose_report_desc(repDesc); diff --git a/src/detection/gpu/adl.h b/src/detection/gpu/adl.h new file mode 100644 index 000000000..8b80572d0 --- /dev/null +++ b/src/detection/gpu/adl.h @@ -0,0 +1,73 @@ +#pragma once + +#include "3rdparty/display-library/adl_sdk.h" + +// https://gpuopen-librariesandsdks.github.io/adl/modules.html + +// Function to initialize the ADL2 interface and to obtain client's context handle. +extern int ADL2_Main_Control_Create(ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters, ADL_CONTEXT_HANDLE* context); + +// Destroy client's ADL context. +extern int ADL2_Main_Control_Destroy(ADL_CONTEXT_HANDLE context); + +// Retrieves adapter information for given adapter or all OS-known adapters. +// Return ADL_OK on success, DESPITE THE OFFICIAL DOCUMENT SAYS IT RETURNS 1 FOR SUCCESS! +extern int ADL2_Adapter_AdapterInfoX3_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* numAdapters, AdapterInfo** lppAdapterInfo); + +// Function to retrieve Graphic Core Info. +extern int ADL2_Adapter_Graphic_Core_Info_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLGraphicCoreInfo* pGraphicCoreInfo); + +// Function to retrieve memory information from the adapter. Version 2 +extern int ADL2_Adapter_MemoryInfo2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLMemoryInfo2* lpMemoryInfo2); + +// This function retrieves the VRAM usage of given adapter. +extern int ADL2_Adapter_VRAMUsage_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* iVRAMUsageInMB); + +// This function retrieves the Dedicated VRAM usage of given adapter. +extern int ADL2_Adapter_DedicatedVRAMUsage_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* iVRAMUsageInMB); + +// Function to get the ASICFamilyType from the adapter. +extern int ADL2_Adapter_ASICFamilyType_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpAsicTypes, int* lpValids); + + +// Function to retrieve current power management capabilities. +extern int ADL2_Overdrive_Caps(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* iSupported, int* iEnabled, int* iVersion); + + +/////////// Overdrive 6 functions + +// Function to retrieve current Overdrive and performance-related activity. +extern int ADL2_Overdrive6_CurrentStatus_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLOD6CurrentStatus* lpCurrentStatus); + +// Function to retrieve GPU temperature from the thermal controller. +extern int ADL2_Overdrive6_Temperature_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* lpTemperature); + +// Function to retrieve the current or default Overdrive clock ranges. +extern int ADL2_Overdrive6_StateInfo_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iStateType, ADLOD6StateInfo* lpStateInfo); + + +/// Overdrive N functions + +// Despite the name (N means Next), this is actually Overdrive7 API +// https://github.com/GPUOpen-LibrariesAndSDKs/display-library/blob/master/Sample/OverdriveN/OverdriveN.cpp#L209 + +// Function to retrieve the OverdriveN capabilities. +extern int ADL2_OverdriveN_CapabilitiesX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNCapabilitiesX2* lpODCapabilities); + +// Function to retrieve the current OD performance status. +extern int ADL2_OverdriveN_PerformanceStatus_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPerformanceStatus *lpODPerformanceStatus); + +// Function to retrieve the current temperature. +extern int ADL2_OverdriveN_Temperature_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int iTemperatureType, int *iTemperature); + +// Function to retrieve the current GPU clocks settings. +extern int ADL2_OverdriveN_SystemClocksX2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLODNPerformanceLevelsX2 *lpODPerformanceLevels); + + +/// Overdrive 8 functions + +// Function to retrieve the Overdrive8 current settings. +extern int ADL2_Overdrive8_Current_Setting_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLOD8CurrentSetting *lpCurrentSetting); + +// Function to retrieve the Overdrive8 current settings. +extern int ADL2_New_QueryPMLogData_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLPMLogDataOutput *lpDataOutput); diff --git a/src/detection/gpu/gpu.c b/src/detection/gpu/gpu.c index 1822cb447..bbf83e52d 100644 --- a/src/detection/gpu/gpu.c +++ b/src/detection/gpu/gpu.c @@ -55,6 +55,7 @@ const char* detectByOpenGL(FFlist* gpus) ffStrbufInitMove(&gpu->name, &result.renderer); ffStrbufInit(&gpu->driver); ffStrbufInitF(&gpu->platformApi, "OpenGL %s", result.version.chars); + ffStrbufInit(&gpu->memoryType); gpu->index = FF_GPU_INDEX_UNSET; gpu->temperature = FF_GPU_TEMP_UNSET; gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; diff --git a/src/detection/gpu/gpu.h b/src/detection/gpu/gpu.h index bef90b6d5..a81dd11f1 100644 --- a/src/detection/gpu/gpu.h +++ b/src/detection/gpu/gpu.h @@ -34,6 +34,7 @@ typedef struct FFGPUResult FFstrbuf name; FFstrbuf driver; FFstrbuf platformApi; + FFstrbuf memoryType; double temperature; double coreUsage; int32_t coreCount; diff --git a/src/detection/gpu/gpu_amd.c b/src/detection/gpu/gpu_amd.c index 7bc535382..5ebbeb2ba 100644 --- a/src/detection/gpu/gpu_amd.c +++ b/src/detection/gpu/gpu_amd.c @@ -1,75 +1,545 @@ #include "gpu_driver_specific.h" -// Everything detected in this file is static. -// The real time monitoring requires ADLX, whose interface is much more complicated than AGS -// Whoever has AMD graphic cards interested in this may contribute -// * ADLX (AMD Device Library eXtra): https://github.com/GPUOpen-LibrariesAndSDKs/ADLX - -#include "3rdparty/ags/amd_ags.h" +#include "adl.h" #include "common/library.h" #include "util/mallocHelper.h" +#include "util/debug.h" + +// Helper function to convert ADL status code to string +FF_MAYBE_UNUSED static const char* ffAdlStatusToString(int status) { + switch (status) { + #define FF_ADL_STATUS_CASE(name) case name: return #name; + FF_ADL_STATUS_CASE(ADL_OK) + FF_ADL_STATUS_CASE(ADL_OK_WARNING) + FF_ADL_STATUS_CASE(ADL_OK_MODE_CHANGE) + FF_ADL_STATUS_CASE(ADL_OK_RESTART) + FF_ADL_STATUS_CASE(ADL_OK_WAIT) + FF_ADL_STATUS_CASE(ADL_ERR) + FF_ADL_STATUS_CASE(ADL_ERR_NOT_INIT) + FF_ADL_STATUS_CASE(ADL_ERR_INVALID_PARAM) + FF_ADL_STATUS_CASE(ADL_ERR_INVALID_PARAM_SIZE) + FF_ADL_STATUS_CASE(ADL_ERR_INVALID_ADL_IDX) + FF_ADL_STATUS_CASE(ADL_ERR_INVALID_CONTROLLER_IDX) + FF_ADL_STATUS_CASE(ADL_ERR_INVALID_DIPLAY_IDX) + FF_ADL_STATUS_CASE(ADL_ERR_NOT_SUPPORTED) + FF_ADL_STATUS_CASE(ADL_ERR_NULL_POINTER) + FF_ADL_STATUS_CASE(ADL_ERR_DISABLED_ADAPTER) + FF_ADL_STATUS_CASE(ADL_ERR_INVALID_CALLBACK) + FF_ADL_STATUS_CASE(ADL_ERR_RESOURCE_CONFLICT) + FF_ADL_STATUS_CASE(ADL_ERR_SET_INCOMPLETE) + FF_ADL_STATUS_CASE(ADL_ERR_NO_XDISPLAY) + FF_ADL_STATUS_CASE(ADL_ERR_CALL_TO_INCOMPATIABLE_DRIVER) + FF_ADL_STATUS_CASE(ADL_ERR_NO_ADMINISTRATOR_PRIVILEGES) + FF_ADL_STATUS_CASE(ADL_ERR_FEATURESYNC_NOT_STARTED) + FF_ADL_STATUS_CASE(ADL_ERR_INVALID_POWER_STATE) + #undef FF_ADL_STATUS_CASE + default: return "Unknown ADL error"; + } +} + +// Memory allocation function +static void* __attribute__((__stdcall__)) ffAdlMainMemoryAlloc(int iSize) +{ + return malloc((size_t) iSize); +} + +struct FFAdlData { + FF_LIBRARY_SYMBOL(ADL2_Main_Control_Destroy) + FF_LIBRARY_SYMBOL(ADL2_Adapter_AdapterInfoX3_Get) + FF_LIBRARY_SYMBOL(ADL2_Adapter_Graphic_Core_Info_Get) + FF_LIBRARY_SYMBOL(ADL2_Adapter_MemoryInfo2_Get) + FF_LIBRARY_SYMBOL(ADL2_Adapter_DedicatedVRAMUsage_Get) + FF_LIBRARY_SYMBOL(ADL2_Adapter_VRAMUsage_Get) + FF_LIBRARY_SYMBOL(ADL2_Adapter_ASICFamilyType_Get) + FF_LIBRARY_SYMBOL(ADL2_Overdrive_Caps) + FF_LIBRARY_SYMBOL(ADL2_OverdriveN_CapabilitiesX2_Get) + FF_LIBRARY_SYMBOL(ADL2_OverdriveN_SystemClocksX2_Get) + FF_LIBRARY_SYMBOL(ADL2_OverdriveN_PerformanceStatus_Get) + FF_LIBRARY_SYMBOL(ADL2_OverdriveN_Temperature_Get) + FF_LIBRARY_SYMBOL(ADL2_Overdrive8_Current_Setting_Get) + FF_LIBRARY_SYMBOL(ADL2_New_QueryPMLogData_Get) + FF_LIBRARY_SYMBOL(ADL2_Overdrive6_CurrentStatus_Get) + FF_LIBRARY_SYMBOL(ADL2_Overdrive6_Temperature_Get) + FF_LIBRARY_SYMBOL(ADL2_Overdrive6_StateInfo_Get) + + bool inited; + ADL_CONTEXT_HANDLE apiHandle; +} adlData; + +static void shutdownAdl() +{ + if (adlData.apiHandle) + { + FF_DEBUG("Destroying ADL context"); + adlData.ffADL2_Main_Control_Destroy(adlData.apiHandle); + adlData.apiHandle = NULL; + } +} const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName) { - static bool inited = false; - static AGSGPUInfo gpuInfo; + FF_DEBUG("Attempting to detect AMD GPU info using '%s'", soName); - if (!inited) + if (!adlData.inited) { - inited = true; - FF_LIBRARY_LOAD(libags, "dlopen amd_ags failed", soName , 1); - FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libags, agsInitialize) + adlData.inited = true; + FF_DEBUG("Initializing ADL library"); + FF_LIBRARY_LOAD(atiadl, "dlopen atiadlxx failed", soName , 1); + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(atiadl, ADL2_Main_Control_Create) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Main_Control_Destroy) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Adapter_AdapterInfoX3_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Adapter_Graphic_Core_Info_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Adapter_MemoryInfo2_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Adapter_DedicatedVRAMUsage_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Adapter_VRAMUsage_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Adapter_ASICFamilyType_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Overdrive_Caps) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_OverdriveN_CapabilitiesX2_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_OverdriveN_SystemClocksX2_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_OverdriveN_PerformanceStatus_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Overdrive8_Current_Setting_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_New_QueryPMLogData_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_OverdriveN_Temperature_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Overdrive6_CurrentStatus_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Overdrive6_Temperature_Get) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Overdrive6_StateInfo_Get) + FF_DEBUG("ADL library loaded"); - struct AGSContext* apiHandle; - if (ffagsInitialize(AGS_CURRENT_VERSION, NULL, &apiHandle, &gpuInfo) != AGS_SUCCESS) - return "loading ags library failed"; + int result = ffADL2_Main_Control_Create(ffAdlMainMemoryAlloc, 1 /*iEnumConnectedAdapters*/, &adlData.apiHandle); + FF_DEBUG("ADL2_Main_Control_Create returned %s (%d)", ffAdlStatusToString(result), result); + if (result != ADL_OK) + return "ffADL2_Main_Control_Create() failed"; - // agsDeInitialize will free pointers allocated in gpuInfo. Just leak them. + atexit(shutdownAdl); + atiadl = NULL; // don't close atiadl + FF_DEBUG("ADL initialization complete"); } - if (gpuInfo.numDevices == 0) - return "loading ags library failed or no AMD gpus found"; - - AGSDeviceInfo* device = NULL; - - for (int iDev = 0; iDev < gpuInfo.numDevices; iDev++) + if (!adlData.apiHandle) { - if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID) + FF_DEBUG("ADL context not initialized"); + return "ffADL2_Main_Control_Create() failed"; + } + + FF_AUTO_FREE AdapterInfo* devices = NULL; + int numDevices = 0; + int adapterResult = adlData.ffADL2_Adapter_AdapterInfoX3_Get(adlData.apiHandle, -1, &numDevices, &devices); + FF_DEBUG("ADL2_Adapter_AdapterInfoX3_Get returned %s (%d)", ffAdlStatusToString(adapterResult), adapterResult); + + if (adapterResult == ADL_OK) + { + FF_DEBUG("found %d adapters", numDevices); + } + else + { + FF_DEBUG("ffADL2_Adapter_AdapterInfoX3_Get() failed"); + return "ffADL2_Adapter_AdapterInfoX3_Get() failed"; + } + + const AdapterInfo* device = NULL; + for (int iDev = 0; iDev < numDevices; iDev++) + { + if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID) { + FF_DEBUG("Checking device %d: bus=%d, device=%d, func=%d against requested bus=%u, device=%u, func=%u", + iDev, devices[iDev].iBusNumber, devices[iDev].iDeviceNumber, devices[iDev].iFunctionNumber, + cond->pciBusId.bus, cond->pciBusId.device, cond->pciBusId.func); + if ( - cond->pciDeviceId.deviceId == (uint32_t) gpuInfo.devices[iDev].deviceId && - cond->pciDeviceId.vendorId == (uint32_t) gpuInfo.devices[iDev].vendorId && - cond->pciDeviceId.revId == (uint32_t) gpuInfo.devices[iDev].revisionId) + cond->pciBusId.bus == (uint32_t) devices[iDev].iBusNumber && + cond->pciBusId.device == (uint32_t) devices[iDev].iDeviceNumber && + cond->pciBusId.func == (uint32_t) devices[iDev].iFunctionNumber) { - device = &gpuInfo.devices[iDev]; + device = &devices[iDev]; + FF_DEBUG("Found matching device: %s (index: %d)", device->strAdapterName, device->iAdapterIndex); break; } } } if (!device) + { + FF_DEBUG("Device not found"); return "Device not found"; + } if (result.coreCount) - *result.coreCount = (uint32_t) device->numCUs; + { + ADLGraphicCoreInfo coreInfo; + int status = adlData.ffADL2_Adapter_Graphic_Core_Info_Get(adlData.apiHandle, device->iAdapterIndex, &coreInfo); + FF_DEBUG("ADL2_Adapter_Graphic_Core_Info_Get returned %s (%d)", ffAdlStatusToString(status), status); + + if (status == ADL_OK) + { + FF_DEBUG("Core info - NumCUs: %d, NumPEsPerCU: %d", coreInfo.iNumCUs, coreInfo.iNumPEsPerCU); + *result.coreCount = (uint32_t) coreInfo.iNumCUs * (uint32_t) coreInfo.iNumPEsPerCU; + FF_DEBUG("Got core count: %u", *result.coreCount); + } + else + { + FF_DEBUG("Failed to get core count"); + } + } if (result.memory) { - result.memory->total = device->localMemoryInBytes; - result.memory->used = FF_GPU_VMEM_SIZE_UNSET; + int vramUsage = 0; + int status = adlData.ffADL2_Adapter_DedicatedVRAMUsage_Get(adlData.apiHandle, device->iAdapterIndex, &vramUsage); + FF_DEBUG("ADL2_Adapter_DedicatedVRAMUsage_Get returned %s (%d), usage: %d MB", + ffAdlStatusToString(status), status, vramUsage); + + if (status == ADL_OK) { + result.memory->used = (uint64_t) vramUsage * 1024 * 1024; + FF_DEBUG("Dedicated VRAM usage: %llu bytes (%d MB)", result.memory->used, vramUsage); + } else { + FF_DEBUG("Failed to get dedicated VRAM usage"); + } + + if (result.sharedMemory) + { + vramUsage = 0; + status = adlData.ffADL2_Adapter_VRAMUsage_Get(adlData.apiHandle, device->iAdapterIndex, &vramUsage); + FF_DEBUG("ADL2_Adapter_VRAMUsage_Get returned %s (%d), usage: %d MB", + ffAdlStatusToString(status), status, vramUsage); + + if (status == ADL_OK) { + uint64_t totalUsage = (uint64_t) vramUsage * 1024 * 1024; + result.sharedMemory->used = totalUsage - result.memory->used; + FF_DEBUG("Total VRAM usage: %llu bytes, Shared VRAM usage: %llu bytes (%llu MB)", + totalUsage, result.sharedMemory->used, result.sharedMemory->used / (1024 * 1024)); + } else { + FF_DEBUG("Failed to get total VRAM usage"); + } + } } - if (result.frequency) - *result.frequency = (uint32_t) device->coreClock; // Maximum frequency + if (result.memoryType) + { + ADLMemoryInfo2 memoryInfo; + int status = adlData.ffADL2_Adapter_MemoryInfo2_Get(adlData.apiHandle, device->iAdapterIndex, &memoryInfo); + FF_DEBUG("ADL2_Adapter_MemoryInfo2_Get returned %s (%d)", ffAdlStatusToString(status), status); + + if (status == ADL_OK) + { + FF_DEBUG("Memory info - Type: %s, Size: %lld MB", memoryInfo.strMemoryType, memoryInfo.iMemorySize / 1024 / 1024); + ffStrbufSetS(result.memoryType, memoryInfo.strMemoryType); + FF_DEBUG("Got memory type: %s", memoryInfo.strMemoryType); + } + else + { + FF_DEBUG("Failed to get memory type"); + } + } if (result.type) - *result.type = device->isAPU ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE; + { + int asicTypes = 0; + int valids = 0; + int status = adlData.ffADL2_Adapter_ASICFamilyType_Get(adlData.apiHandle, device->iAdapterIndex, &asicTypes, &valids); + FF_DEBUG("ADL2_Adapter_ASICFamilyType_Get returned %s (%d), asicTypes: 0x%x, valids: 0x%x", + ffAdlStatusToString(status), status, asicTypes, valids); + + if (status == ADL_OK) + { + asicTypes &= valids; // This design is strange + *result.type = asicTypes & ADL_ASIC_INTEGRATED ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE; + FF_DEBUG("GPU type: %s (asicTypes: 0x%x, valids: 0x%x)", + *result.type == FF_GPU_TYPE_INTEGRATED ? "Integrated" : "Discrete", asicTypes, valids); + } + else + { + FF_DEBUG("Failed to get GPU type"); + } + } if (result.index) - *result.index = (uint32_t) device->adlAdapterIndex; + { + *result.index = (uint32_t) device->iAdapterIndex; + FF_DEBUG("Setting adapter index: %u", *result.index); + } if (result.name) - ffStrbufSetS(result.name, device->adapterString); + { + ffStrbufSetS(result.name, device->strAdapterName); + FF_DEBUG("Setting adapter name: %s; UDID: %s, Present: %d, Exist: %d", device->strAdapterName, device->strUDID, device->iPresent, device->iExist); + } + int odVersion = 0; + + { + int odSupported = 0; + int odEnabled = 0; + int status = adlData.ffADL2_Overdrive_Caps(adlData.apiHandle, device->iAdapterIndex, &odSupported, &odEnabled, &odVersion); + FF_DEBUG("ADL2_Overdrive_Caps returned %s (%d); supported %d, enabled %d; version %d", + ffAdlStatusToString(status), status, odSupported, odEnabled, odVersion); + if (status != ADL_OK) + { + FF_DEBUG("Overdrive not supported, results may be inaccurate"); + // Note even if Overdrive is not supported, we can still get the OD version + } + } + + + if (odVersion == 8) + { + FF_DEBUG("Using Overdrive8 API (odVersion=%d)", odVersion); + + if (result.frequency) + { + ADLOD8CurrentSetting currentSetting = { .count = OD8_COUNT }; + int status = adlData.ffADL2_Overdrive8_Current_Setting_Get(adlData.apiHandle, device->iAdapterIndex, ¤tSetting); + FF_DEBUG("ADL2_Overdrive8_Current_Setting_Get returned %s (%d)", ffAdlStatusToString(status), status); + if (status == ADL_OK) + { + FF_DEBUG("OD8 Settings count: %d", currentSetting.count); + + *result.frequency = (uint32_t) currentSetting.Od8SettingTable[OD8_GFXCLK_FMAX]; + FF_DEBUG("Got max engine clock (OD8_GFXCLK_FMAX): %u MHz", *result.frequency); + } + else + { + FF_DEBUG("Failed to get max frequency information"); + } + } + + if (result.temp || result.coreUsage) + { + ADLPMLogDataOutput pmLogDataOutput = {}; + int status = adlData.ffADL2_New_QueryPMLogData_Get(adlData.apiHandle, device->iAdapterIndex, &pmLogDataOutput); + FF_DEBUG("ADL2_New_QueryPMLogData_Get returned %s (%d)", ffAdlStatusToString(status), status); + if (status == ADL_OK) + { + if (result.temp) + { + ADLSingleSensorData* sensor = &pmLogDataOutput.sensors[ADL_PMLOG_TEMPERATURE_HOTSPOT]; + FF_DEBUG("Sensor %d: %s, supported: %d, value: %d", ADL_PMLOG_TEMPERATURE_HOTSPOT, "ADL_PMLOG_TEMPERATURE_HOTSPOT", sensor->supported, sensor->value); + if (sensor->supported) + { + *result.temp = sensor->value; + FF_DEBUG("Temperature: %.1f°C (HOTSPOT)", *result.temp); + } + else + { + sensor = &pmLogDataOutput.sensors[ADL_PMLOG_TEMPERATURE_GFX]; + FF_DEBUG("Sensor %d: %s, supported: %d, value: %d", ADL_PMLOG_TEMPERATURE_GFX, "ADL_PMLOG_TEMPERATURE_GFX", sensor->supported, sensor->value); + if (sensor->supported) + { + *result.temp = sensor->value; + FF_DEBUG("Temperature: %.1f°C (GFX)", *result.temp); + } + else + { + sensor = &pmLogDataOutput.sensors[ADL_PMLOG_TEMPERATURE_SOC]; + FF_DEBUG("Sensor %d: %s, supported: %d, value: %d", ADL_PMLOG_TEMPERATURE_SOC, "ADL_PMLOG_TEMPERATURE_SOC", sensor->supported, sensor->value); + if (sensor->supported) + { + *result.temp = sensor->value; + FF_DEBUG("Temperature: %.1f°C (SOC)", *result.temp); + } + else + { + FF_DEBUG("No supported temp sensor found, temp detection failed"); + } + } + } + } + if (result.coreUsage) + { + ADLSingleSensorData* activity = &pmLogDataOutput.sensors[ADL_PMLOG_INFO_ACTIVITY_GFX]; + FF_DEBUG("Sensor %d: %s, supported: %d, value: %d", ADL_PMLOG_INFO_ACTIVITY_GFX, "ADL_PMLOG_INFO_ACTIVITY_GFX", activity->supported, activity->value); + if (activity->supported) + { + *result.coreUsage = activity->value; + FF_DEBUG("Core usage: %.1f%%", *result.coreUsage); + } + else + { + FF_DEBUG("Sensor %d not supported, GPU usage detection failed", ADL_PMLOG_INFO_ACTIVITY_GFX); + } + } + } + else + { + FF_DEBUG("Failed to get temperature / GPU activity"); + } + } + } + else if (odVersion == 7) + { + FF_DEBUG("Using OverdriveN API (odVersion=%d)", odVersion); + + if (result.frequency) + { + // https://github.com/MaynardMiner/odvii/blob/master/OverdriveN.cpp#L176 + ADLODNCapabilitiesX2 odCapabilities = {}; + int status = adlData.ffADL2_OverdriveN_CapabilitiesX2_Get(adlData.apiHandle, device->iAdapterIndex, &odCapabilities); + FF_DEBUG("ADL2_OverdriveN_CapabilitiesX2_Get returned %s (%d)", ffAdlStatusToString(status), status); + + if (status == ADL_OK) + { + if (odCapabilities.iMaximumNumberOfPerformanceLevels == 0) + { + FF_DEBUG("ADL2_OverdriveN_CapabilitiesX2_Get: no performance levels available"); + } + else + { + FF_DEBUG("ODN Capabilities - MaxPerformanceLevels: %d, GPU Clock Range: [%d - %d]", + odCapabilities.iMaximumNumberOfPerformanceLevels, + odCapabilities.sEngineClockRange.iMin, odCapabilities.sEngineClockRange.iMax); + + size_t size = sizeof(ADLODNPerformanceLevelsX2) + sizeof(ADLODNPerformanceLevelX2) * ((unsigned) odCapabilities.iMaximumNumberOfPerformanceLevels - 1); + FF_AUTO_FREE ADLODNPerformanceLevelsX2* odPerfLevels = calloc(size, 1); + odPerfLevels->iSize = (int) size; + odPerfLevels->iNumberOfPerformanceLevels = odCapabilities.iMaximumNumberOfPerformanceLevels; + odPerfLevels->iMode = ODNControlType_Current; + + int status = adlData.ffADL2_OverdriveN_SystemClocksX2_Get(adlData.apiHandle, device->iAdapterIndex, odPerfLevels); + FF_DEBUG("ADL2_OverdriveN_SystemClocksX2_Get returned %s (%d), levels: %d", + ffAdlStatusToString(status), status, odPerfLevels->iNumberOfPerformanceLevels); + + if (status != ADL_OK) + { + FF_DEBUG("Failed to get frequency information"); + } + else + { + // lowest to highest + for (int i = odPerfLevels->iNumberOfPerformanceLevels - 1; i >= 0 ; i--) + { + ADLODNPerformanceLevelX2* level = &odPerfLevels->aLevels[i]; + FF_DEBUG("Performance level %d: enabled: %d, engine clock = %d", i, level->iEnabled, level->iClock); + if (level->iEnabled) + { + *result.frequency = (uint32_t) level->iClock / 100; // in 10 kHz + FF_DEBUG("Got max engine clock: %u MHz", *result.frequency); + break; + } + } + } + } + } + else + { + FF_DEBUG("Failed to get frequency information"); + } + } + + if (result.coreUsage) + { + ADLODNPerformanceStatus performanceStatus = {}; + int status = adlData.ffADL2_OverdriveN_PerformanceStatus_Get(adlData.apiHandle, device->iAdapterIndex, &performanceStatus); + FF_DEBUG("ADL2_OverdriveN_PerformanceStatus_Get returned %s (%d)", ffAdlStatusToString(status), status); + + if (status == ADL_OK) + { + FF_DEBUG("Performance Status - Activity: %d%%, CoreClock: %dMHz, MemoryClock: %dMHz", + performanceStatus.iGPUActivityPercent, + performanceStatus.iCoreClock, + performanceStatus.iMemoryClock); + + *result.coreUsage = performanceStatus.iGPUActivityPercent; + FF_DEBUG("Got GPU activity: %d%%", performanceStatus.iGPUActivityPercent); + } + else + { + FF_DEBUG("Failed to get GPU activity"); + } + } + + if (result.temp) + { + int milliDegrees = 0; + int status = adlData.ffADL2_OverdriveN_Temperature_Get(adlData.apiHandle, device->iAdapterIndex, 1, &milliDegrees); + FF_DEBUG("ADL2_OverdriveN_Temperature_Get returned %s (%d)", ffAdlStatusToString(status), status); + + if (status == ADL_OK) + { + *result.temp = milliDegrees / 1000.0; + FF_DEBUG("Temperature: %.1f°C (raw: %d milliC)", *result.temp, milliDegrees); + } + else + { + FF_DEBUG("Failed to get temperature"); + } + } + } + else if (odVersion == 6) + { + FF_DEBUG("Using Overdrive6 API (odVersion=%d)", odVersion); + + if (result.frequency) + { + FF_AUTO_FREE ADLOD6StateInfo* stateInfo = calloc(sizeof(ADLOD6StateInfo) + sizeof(ADLOD6PerformanceLevel), 1); + stateInfo->iNumberOfPerformanceLevels = 2; + + int status = adlData.ffADL2_Overdrive6_StateInfo_Get(adlData.apiHandle, device->iAdapterIndex, ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE, stateInfo); + FF_DEBUG("ADL2_Overdrive6_StateInfo_Get returned %s (%d), performance levels: %d", + ffAdlStatusToString(status), status, stateInfo->iNumberOfPerformanceLevels); + + if (status == ADL_OK) + { + // OD6 uses clock ranges instead of discrete performance levels. + // iNumberOfPerformanceLevels is always 2. + // The 1st level indicates the minimum clocks in the range. + // The 2nd level indicates the maximum clocks in the range. + if (stateInfo->iNumberOfPerformanceLevels != 2) + { + FF_DEBUG("ADL2_Overdrive6_StateInfo_Get: unexpected number of performance levels: %d", stateInfo->iNumberOfPerformanceLevels); + } + else + { + FF_DEBUG("OD6 Settings - MinPerformanceLevels: %d, MaxPerformanceLevels: %d", + stateInfo->aLevels[0].iEngineClock, stateInfo->aLevels[1].iEngineClock); + *result.frequency = (uint32_t) stateInfo->aLevels[1].iEngineClock / 100; // in 10 kHz + FF_DEBUG("Got max engine clock: %u MHz", *result.frequency); + } + } + else + { + FF_DEBUG("Failed to get frequency information"); + } + } + + if (result.coreUsage) + { + ADLOD6CurrentStatus status = {}; + int apiStatus = adlData.ffADL2_Overdrive6_CurrentStatus_Get(adlData.apiHandle, device->iAdapterIndex, &status); + FF_DEBUG("ADL2_Overdrive6_CurrentStatus_Get returned %s (%d)", ffAdlStatusToString(apiStatus), apiStatus); + + if (apiStatus == ADL_OK) + { + *result.coreUsage = status.iActivityPercent; + FF_DEBUG("Got GPU activity: %d%%", status.iActivityPercent); + } + else + { + FF_DEBUG("Failed to get GPU activity"); + } + } + + if (result.temp) + { + int milliDegrees = 0; + int status = adlData.ffADL2_Overdrive6_Temperature_Get(adlData.apiHandle, device->iAdapterIndex, &milliDegrees); + FF_DEBUG("ADL2_Overdrive6_Temperature_Get returned %s (%d), temperature: %d milliC", + ffAdlStatusToString(status), status, milliDegrees); + + if (status == ADL_OK) + { + *result.temp = milliDegrees / 1000.0; + FF_DEBUG("Temperature: %.1f°C", *result.temp); + } + else + { + FF_DEBUG("Failed to get temperature"); + } + } + } + else + { + FF_DEBUG("Unknown Overdrive version: %d", odVersion); + return "Unknown Overdrive version"; + } + FF_DEBUG("AMD GPU detection complete - returning success"); return NULL; } diff --git a/src/detection/gpu/gpu_apple.c b/src/detection/gpu/gpu_apple.c index 535b8bc3e..026f9acad 100644 --- a/src/detection/gpu/gpu_apple.c +++ b/src/detection/gpu/gpu_apple.c @@ -18,11 +18,12 @@ static double detectGpuTemp(const FFstrbuf* gpuName) { switch (strtol(gpuName->chars + strlen("Apple M"), NULL, 10)) { + case 0: error = "Invalid Apple Silicon GPU"; break; case 1: error = ffDetectSmcTemps(FF_TEMP_GPU_M1X, &result); break; case 2: error = ffDetectSmcTemps(FF_TEMP_GPU_M2X, &result); break; case 3: error = ffDetectSmcTemps(FF_TEMP_GPU_M3X, &result); break; case 4: error = ffDetectSmcTemps(FF_TEMP_GPU_M4X, &result); break; - default: error = "Unsupported Apple Silicon GPU"; + default: error = "Unsupported Apple Silicon GPU"; break; } } else if (ffStrbufStartsWithS(gpuName, "Intel")) @@ -102,7 +103,8 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) } FFGPUResult* gpu = ffListAdd(gpus); - + gpu->index = FF_GPU_INDEX_UNSET; + ffStrbufInit(&gpu->memoryType); gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; gpu->type = FF_GPU_TYPE_UNKNOWN; gpu->frequency = FF_GPU_FREQUENCY_UNSET; @@ -112,7 +114,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) ffStrbufInit(&gpu->driver); // Ok for both Apple and Intel ffCfDictGetString(properties, CFSTR("CFBundleIdentifier"), &gpu->driver); - if(ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount)) // For Apple + if(ffCfDictGetInt(properties, CFSTR("gpu-core-count"), &gpu->coreCount) != NULL) // For Apple gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET; @@ -131,9 +133,9 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) if (ffCfDictGetInt64(perfStatistics, CFSTR("In use system memory"), (int64_t*) &vramUsed) != NULL) vramTotal = 0; } - else if (ffCfDictGetInt64(perfStatistics, CFSTR("vramUsedBytes"), (int64_t*) &vramTotal) == NULL) + else if (ffCfDictGetInt64(perfStatistics, CFSTR("vramFreeBytes"), (int64_t*) &vramTotal) == NULL) { - if (ffCfDictGetInt64(perfStatistics, CFSTR("vramFreeBytes"), (int64_t*) &vramUsed) == NULL) + if (ffCfDictGetInt64(perfStatistics, CFSTR("vramUsedBytes"), (int64_t*) &vramUsed) == NULL) vramTotal += vramUsed; else vramTotal = 0; @@ -143,15 +145,15 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) ffStrbufInit(&gpu->name); //IOAccelerator returns model / vendor-id properties for Apple Silicon, but not for Intel Iris GPUs. //Still needs testing for AMD's - if(ffCfDictGetString(properties, CFSTR("model"), &gpu->name)) + if(ffCfDictGetString(properties, CFSTR("model"), &gpu->name) != NULL) { CFRelease(properties); + properties = NULL; - io_registry_entry_t parentEntry; - IORegistryEntryGetParentEntry(registryEntry, kIOServicePlane, &parentEntry); - if(IORegistryEntryCreateCFProperties(parentEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) + FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t parentEntry = 0; + if(IORegistryEntryGetParentEntry(registryEntry, kIOServicePlane, &parentEntry) != kIOReturnSuccess || + IORegistryEntryCreateCFProperties(parentEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) { - IOObjectRelease(parentEntry); IOObjectRelease(registryEntry); continue; } @@ -179,7 +181,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) gpu->shared.total = vramTotal; gpu->shared.used = vramUsed; } - else + else if (gpu->type == FF_GPU_TYPE_DISCRETE) { gpu->dedicated.total = vramTotal; gpu->dedicated.used = vramUsed; diff --git a/src/detection/gpu/gpu_apple.m b/src/detection/gpu/gpu_apple.m index 943bd16c5..7adfde58a 100644 --- a/src/detection/gpu/gpu_apple.m +++ b/src/detection/gpu/gpu_apple.m @@ -29,6 +29,7 @@ const char* ffGpuDetectDriverVersion(FFlist* gpus) ffStrbufAppendS(&x->driver, version.UTF8String); } } + return NULL; } return "Unsupported macOS version"; } diff --git a/src/detection/gpu/gpu_bsd.c b/src/detection/gpu/gpu_bsd.c index 1525e9e0e..4dc142c5b 100644 --- a/src/detection/gpu/gpu_bsd.c +++ b/src/detection/gpu/gpu_bsd.c @@ -13,6 +13,9 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { FF_AUTO_CLOSE_FD int fd = open("/dev/pci", O_RDONLY, 0); + if (fd < 0) + return "open(\"/dev/pci\", O_RDONLY, 0) failed"; + struct pci_conf confs[128]; struct pci_match_conf match = { .pc_class = PCIC_DISPLAY, @@ -40,7 +43,8 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(pc->pc_vendor)); ffStrbufInit(&gpu->name); ffStrbufInitS(&gpu->driver, pc->pd_name); - ffStrbufInit(&gpu->platformApi); + ffStrbufInitStatic(&gpu->platformApi, "/dev/pci"); + ffStrbufInit(&gpu->memoryType); gpu->index = FF_GPU_INDEX_UNSET; gpu->temperature = FF_GPU_TEMP_UNSET; gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; @@ -77,7 +81,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD) ffGPUQueryAmdGpuName(pc->pc_device, pc->pc_revid, gpu); if (gpu->name.length == 0) - ffGPUFillVendorAndName(pc->pc_subclass, pc->pc_vendor, pc->pc_device, gpu); + ffGPUFillVendorAndName(pc->pc_subclass, pc->pc_vendor, pc->pc_device, gpu); } if (gpu->type == FF_GPU_TYPE_UNKNOWN) diff --git a/src/detection/gpu/gpu_driver_specific.h b/src/detection/gpu/gpu_driver_specific.h index 258dc68f1..82db3f66b 100644 --- a/src/detection/gpu/gpu_driver_specific.h +++ b/src/detection/gpu/gpu_driver_specific.h @@ -41,6 +41,8 @@ typedef struct FFGpuDriverResult uint32_t* index; double* temp; FFGPUMemory* memory; + FFstrbuf* memoryType; + FFGPUMemory* sharedMemory; uint32_t* coreCount; double* coreUsage; FFGPUType* type; @@ -87,9 +89,9 @@ FF_MAYBE_UNUSED static inline bool getDriverSpecificDetectionFn(const char* vend { *pDetectFn = ffDetectAmdGpuInfo; #ifdef _WIN64 - *pDllName = "amd_ags_x64.dll"; + *pDllName = "atiadlxx.dll"; #else - *pDllName = "amd_ags_x86.dll"; + *pDllName = "atiadlxy.dll"; #endif } #endif diff --git a/src/detection/gpu/gpu_general.c b/src/detection/gpu/gpu_general.c index 703b0b237..7fab697ad 100644 --- a/src/detection/gpu/gpu_general.c +++ b/src/detection/gpu/gpu_general.c @@ -33,7 +33,8 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(dev->vendor_id)); ffStrbufInit(&gpu->name); ffStrbufInit(&gpu->driver); - ffStrbufInit(&gpu->platformApi); + ffStrbufInitStatic(&gpu->platformApi, "libpciaccess"); + ffStrbufInit(&gpu->memoryType); gpu->temperature = FF_GPU_TEMP_UNSET; gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET; @@ -46,9 +47,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* ffGPUQueryAmdGpuName(dev->device_id, dev->revision, gpu); if (gpu->name.length == 0) - { - ffGPUFillVendorAndName((dev->device_class >> 8) & 8, dev->vendor_id, dev->device_id, gpu); - } + ffGPUFillVendorAndName((dev->device_class >> 8) & 0xFF, dev->vendor_id, dev->device_id, gpu); } ffpci_system_cleanup(); diff --git a/src/detection/gpu/gpu_haiku.c b/src/detection/gpu/gpu_haiku.c index 16b40c860..ec1e566f8 100644 --- a/src/detection/gpu/gpu_haiku.c +++ b/src/detection/gpu/gpu_haiku.c @@ -23,7 +23,8 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(dev.vendor_id)); ffStrbufInit(&gpu->name); ffStrbufInit(&gpu->driver); - ffStrbufInit(&gpu->platformApi); + ffStrbufInitStatic(&gpu->platformApi, POKE_DEVICE_FULLNAME); + ffStrbufInit(&gpu->memoryType); gpu->temperature = FF_GPU_TEMP_UNSET; gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET; diff --git a/src/detection/gpu/gpu_intel.c b/src/detection/gpu/gpu_intel.c index c01c80ab4..c440c7207 100644 --- a/src/detection/gpu/gpu_intel.c +++ b/src/detection/gpu/gpu_intel.c @@ -12,6 +12,7 @@ struct FFIgclData { FF_LIBRARY_SYMBOL(ctlEnumTemperatureSensors) FF_LIBRARY_SYMBOL(ctlTemperatureGetState) FF_LIBRARY_SYMBOL(ctlEnumMemoryModules) + FF_LIBRARY_SYMBOL(ctlMemoryGetProperties) FF_LIBRARY_SYMBOL(ctlMemoryGetState) FF_LIBRARY_SYMBOL(ctlEnumFrequencyDomains) FF_LIBRARY_SYMBOL(ctlFrequencyGetProperties) @@ -42,6 +43,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlEnumTemperatureSensors) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlTemperatureGetState) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlEnumMemoryModules) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlMemoryGetProperties) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlMemoryGetState) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlEnumFrequencyDomains) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlFrequencyGetProperties) @@ -135,14 +137,56 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe result.memory->total = 0; for (uint32_t iMem = 0; iMem < memoryCount; iMem++) { - ctl_mem_state_t memoryState = { - .Size = sizeof(ctl_mem_state_t), + ctl_mem_properties_t memoryProperties = { + .Size = sizeof(memoryProperties), .Version = 0, }; - if (igclData.ffctlMemoryGetState(memoryModules[iMem], &memoryState) == CTL_RESULT_SUCCESS) + if (igclData.ffctlMemoryGetProperties(memoryModules[iMem], &memoryProperties) == CTL_RESULT_SUCCESS) { - result.memory->total += memoryState.size; - result.memory->used += memoryState.size - memoryState.free; + if (memoryProperties.location == CTL_MEM_LOC_DEVICE && result.memoryType) + { + switch (memoryProperties.type) + { + #define FF_ICTL_MEM_TYPE_CASE(type) case CTL_MEM_TYPE_##type: ffStrbufSetStatic(result.memoryType, #type); break + FF_ICTL_MEM_TYPE_CASE(HBM); + FF_ICTL_MEM_TYPE_CASE(DDR); + FF_ICTL_MEM_TYPE_CASE(DDR3); + FF_ICTL_MEM_TYPE_CASE(DDR4); + FF_ICTL_MEM_TYPE_CASE(DDR5); + FF_ICTL_MEM_TYPE_CASE(LPDDR); + FF_ICTL_MEM_TYPE_CASE(LPDDR3); + FF_ICTL_MEM_TYPE_CASE(LPDDR4); + FF_ICTL_MEM_TYPE_CASE(LPDDR5); + FF_ICTL_MEM_TYPE_CASE(GDDR4); + FF_ICTL_MEM_TYPE_CASE(GDDR5); + FF_ICTL_MEM_TYPE_CASE(GDDR5X); + FF_ICTL_MEM_TYPE_CASE(GDDR6); + FF_ICTL_MEM_TYPE_CASE(GDDR6X); + FF_ICTL_MEM_TYPE_CASE(GDDR7); + #undef FF_ICTL_MEM_TYPE_CASE + default: + ffStrbufSetF(result.memoryType, "Unknown (%u)", memoryProperties.type); + break; + } + } + + ctl_mem_state_t memoryState = { + .Size = sizeof(ctl_mem_state_t), + .Version = 0, + }; + if (igclData.ffctlMemoryGetState(memoryModules[iMem], &memoryState) == CTL_RESULT_SUCCESS) + { + if (memoryProperties.location == CTL_MEM_LOC_DEVICE) + { + result.memory->total += memoryState.size; + result.memory->used += memoryState.size - memoryState.free; + } + else if (result.sharedMemory && memoryProperties.location == CTL_MEM_LOC_SYSTEM) + { + result.sharedMemory->total += memoryState.size; + result.sharedMemory->used += memoryState.size - memoryState.free; + } + } } } } @@ -171,7 +215,8 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe availableCount++; } } - *result.temp = sumValue / availableCount; + if (availableCount > 0) + *result.temp = sumValue / availableCount; } } diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index f2563917b..f2073a69b 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -426,7 +426,9 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf } else { - pPciPath = memrchr(deviceDir->chars, '/', deviceDir->length) + 1; + pPciPath = memrchr(deviceDir->chars, '/', deviceDir->length); + assert(pPciPath); + pPciPath++; } uint32_t pciDomain, pciBus, pciDevice, pciFunc; @@ -438,6 +440,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf ffStrbufInit(&gpu->name); ffStrbufInit(&gpu->driver); ffStrbufInit(&gpu->platformApi); + ffStrbufInit(&gpu->memoryType); gpu->index = FF_GPU_INDEX_UNSET; gpu->temperature = FF_GPU_TEMP_UNSET; gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET; @@ -632,6 +635,7 @@ static const char* detectOf(FFlist* gpus, FFstrbuf* buffer, FFstrbuf* drmDir, co ffStrbufInit(&gpu->name); ffStrbufInit(&gpu->vendor); ffStrbufInit(&gpu->driver); + ffStrbufInit(&gpu->memoryType); ffStrbufInitF(&gpu->platformApi, "DRM (%s)", drmKey); gpu->temperature = FF_GPU_TEMP_UNSET; gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; diff --git a/src/detection/gpu/gpu_nvidia.c b/src/detection/gpu/gpu_nvidia.c index d9539ba5f..f555eb959 100644 --- a/src/detection/gpu/gpu_nvidia.c +++ b/src/detection/gpu/gpu_nvidia.c @@ -21,6 +21,108 @@ struct FFNvmlData { bool inited; } nvmlData; +#if defined(_WIN32) && !defined(FF_DISABLE_DLOPEN) + +#include "nvapi.h" + +struct FFNvapiData { + FF_LIBRARY_SYMBOL(nvapi_Unload) + FF_LIBRARY_SYMBOL(nvapi_EnumPhysicalGPUs) + FF_LIBRARY_SYMBOL(nvapi_GPU_GetRamType) + + bool inited; +} nvapiData; + +static const char* detectMemTypeByNvapi(FFGpuDriverResult* result) +{ + if (!nvapiData.inited) + { + nvapiData.inited = true; + + FF_LIBRARY_LOAD(libnvapi, "dlopen nvapi failed", + #ifdef _WIN64 + "nvapi64.dll" + #else + "nvapi.dll" + #endif + , 1); + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libnvapi, nvapi_QueryInterface) + #define FF_NVAPI_INTERFACE(iName, iOffset) \ + __typeof__(&iName) ff ## iName = ffnvapi_QueryInterface(iOffset); \ + if (ff ## iName == NULL) return "nvapi_QueryInterface " #iName " failed"; + + FF_NVAPI_INTERFACE(nvapi_Initialize, NVAPI_INTERFACE_OFFSET_INITIALIZE) + FF_NVAPI_INTERFACE(nvapi_Unload, NVAPI_INTERFACE_OFFSET_UNLOAD) + FF_NVAPI_INTERFACE(nvapi_EnumPhysicalGPUs, NVAPI_INTERFACE_OFFSET_ENUM_PHYSICAL_GPUS) + FF_NVAPI_INTERFACE(nvapi_GPU_GetRamType, NVAPI_INTERFACE_OFFSET_GPU_GET_RAM_TYPE) + #undef FF_NVAPI_INTERFACE + + if (ffnvapi_Initialize() < 0) + return "NvAPI_Initialize() failed"; + + nvapiData.ffnvapi_EnumPhysicalGPUs = ffnvapi_EnumPhysicalGPUs; + nvapiData.ffnvapi_GPU_GetRamType = ffnvapi_GPU_GetRamType; + nvapiData.ffnvapi_Unload = ffnvapi_Unload; + + atexit((void*) ffnvapi_Unload); + libnvapi = NULL; // don't close nvapi + } + + if (nvapiData.ffnvapi_EnumPhysicalGPUs == NULL) + return "loading nvapi library failed"; + + NvPhysicalGpuHandle handles[32]; + int gpuCount = 0; + + if (nvapiData.ffnvapi_EnumPhysicalGPUs(handles, &gpuCount) < 0) + return "NvAPI_EnumPhysicalGPUs() failed"; + + uint32_t gpuIndex = *result->index; + + if (gpuIndex >= (uint32_t) gpuCount) + return "GPU index out of range"; + + // Not very sure. Need to check in multi-GPU system + NvPhysicalGpuHandle gpuHandle = handles[gpuIndex]; + + NvApiGPUMemoryType memType; + if (nvapiData.ffnvapi_GPU_GetRamType(gpuHandle, &memType) < 0) + return "NvAPI_GPU_GetRamType() failed"; + + switch (memType) + { + #define FF_NVAPI_MEMORY_TYPE(type) \ + case NVAPI_GPU_MEMORY_TYPE_##type: \ + ffStrbufSetStatic(result->memoryType, #type); \ + break; + FF_NVAPI_MEMORY_TYPE(UNKNOWN) + FF_NVAPI_MEMORY_TYPE(SDRAM) + FF_NVAPI_MEMORY_TYPE(DDR1) + FF_NVAPI_MEMORY_TYPE(DDR2) + FF_NVAPI_MEMORY_TYPE(GDDR2) + FF_NVAPI_MEMORY_TYPE(GDDR3) + FF_NVAPI_MEMORY_TYPE(GDDR4) + FF_NVAPI_MEMORY_TYPE(DDR3) + FF_NVAPI_MEMORY_TYPE(GDDR5) + FF_NVAPI_MEMORY_TYPE(LPDDR2) + FF_NVAPI_MEMORY_TYPE(GDDR5X) + FF_NVAPI_MEMORY_TYPE(LPDDR3) + FF_NVAPI_MEMORY_TYPE(LPDDR4) + FF_NVAPI_MEMORY_TYPE(LPDDR5) + FF_NVAPI_MEMORY_TYPE(GDDR6) + FF_NVAPI_MEMORY_TYPE(GDDR6X) + FF_NVAPI_MEMORY_TYPE(GDDR7) + #undef FF_NVAPI_MEMORY_TYPE + default: + ffStrbufSetF(result->memoryType, "Unknown (%d)", memType); + break; + } + + return NULL; +} + +#endif + const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName) { #ifndef FF_DISABLE_DLOPEN @@ -61,7 +163,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR if (cond->type & FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID) { char pciBusIdStr[32]; - snprintf(pciBusIdStr, ARRAY_SIZE(pciBusIdStr) - 1, "%04x:%02x:%02x.%d", cond->pciBusId.domain, cond->pciBusId.bus, cond->pciBusId.device, cond->pciBusId.func); + snprintf(pciBusIdStr, ARRAY_SIZE(pciBusIdStr), "%04x:%02x:%02x.%d", cond->pciBusId.domain, cond->pciBusId.bus, cond->pciBusId.device, cond->pciBusId.func); nvmlReturn_t ret = nvmlData.ffnvmlDeviceGetHandleByPciBusId_v2(pciBusIdStr, &device); if (ret != NVML_SUCCESS) @@ -88,24 +190,28 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR break; } - if (!device) return "Device not found"; } - nvmlBrandType_t brand; - if (nvmlData.ffnvmlDeviceGetBrand(device, &brand) == NVML_SUCCESS) + if (!device) return "Device not found"; + + if (result.type) { - switch (brand) + nvmlBrandType_t brand; + if (nvmlData.ffnvmlDeviceGetBrand(device, &brand) == NVML_SUCCESS) { - case NVML_BRAND_NVIDIA_RTX: - case NVML_BRAND_QUADRO_RTX: - case NVML_BRAND_GEFORCE: - case NVML_BRAND_TITAN: - case NVML_BRAND_TESLA: - case NVML_BRAND_QUADRO: - *result.type = FF_GPU_TYPE_DISCRETE; - break; - default: - break; + switch (brand) + { + case NVML_BRAND_NVIDIA_RTX: + case NVML_BRAND_QUADRO_RTX: + case NVML_BRAND_GEFORCE: + case NVML_BRAND_TITAN: + case NVML_BRAND_TESLA: + case NVML_BRAND_QUADRO: + *result.type = FF_GPU_TYPE_DISCRETE; + break; + default: + break; + } } } @@ -113,7 +219,13 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR { unsigned int value; if (nvmlData.ffnvmlDeviceGetIndex(device, &value) == NVML_SUCCESS) + { *result.index = value; + #ifdef _WIN32 + if (result.memoryType) + detectMemTypeByNvapi(&result); + #endif + } } diff --git a/src/detection/gpu/gpu_sunos.c b/src/detection/gpu/gpu_sunos.c index 8c59f7dc6..b4d775c4a 100644 --- a/src/detection/gpu/gpu_sunos.c +++ b/src/detection/gpu/gpu_sunos.c @@ -9,7 +9,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); const char* error = ffProcessAppendStdOut(&buffer, (char* const[]) { - "scanpci", + "/usr/bin/scanpci", "-v", NULL, }); @@ -35,8 +35,14 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* { // find the start of device entry const char* pstart = memrchr(buffer.chars, '\n', (size_t) (pclass - buffer.chars)); + if (pstart == NULL) + return "PCI info not found, invalid scanpci result"; while (pstart[1] != 'p') + { pstart = memrchr(buffer.chars, '\n', (size_t) (pstart - buffer.chars - 1)); + if (pstart == NULL) + return "PCI info not found, invalid scanpci result"; + } ++pstart; uint32_t vendorId, deviceId; @@ -51,9 +57,10 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus); ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(vendorId)); + ffStrbufInit(&gpu->memoryType); ffStrbufInit(&gpu->name); ffStrbufInit(&gpu->driver); - ffStrbufInit(&gpu->platformApi); + ffStrbufInitStatic(&gpu->platformApi, "/usr/bin/scanpci"); gpu->index = FF_GPU_INDEX_UNSET; gpu->temperature = FF_GPU_TEMP_UNSET; gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; diff --git a/src/detection/gpu/gpu_windows.c b/src/detection/gpu/gpu_windows.c index 7543392d9..851ef5e4b 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -37,6 +37,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* ffStrbufInit(&gpu->vendor); ffStrbufInit(&gpu->name); ffStrbufInit(&gpu->driver); + ffStrbufInit(&gpu->memoryType); ffStrbufInitStatic(&gpu->platformApi, "SetupAPI"); gpu->index = FF_GPU_INDEX_UNSET; gpu->temperature = FF_GPU_TEMP_UNSET; @@ -47,13 +48,14 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpu->deviceId = 0; gpu->frequency = FF_GPU_FREQUENCY_UNSET; - uint32_t pciBus = 0, pciAddr = UINT32_MAX, pciDev = 0, pciFunc = 0; + uint32_t pciBus = 0, pciAddr = 0, pciDev = 0, pciFunc = 0; if (SetupDiGetDeviceRegistryPropertyW(hdev, &did, SPDRP_BUSNUMBER, NULL, (PBYTE) &pciBus, sizeof(pciBus), NULL) && SetupDiGetDeviceRegistryPropertyW(hdev, &did, SPDRP_ADDRESS, NULL, (PBYTE) &pciAddr, sizeof(pciAddr), NULL)) { pciDev = (pciAddr >> 16) & 0xFFFF; pciFunc = pciAddr & 0xFFFF; gpu->deviceId = (pciBus * 1000ull) + (pciDev * 10ull) + pciFunc; + pciAddr = 1; // Set to 1 to indicate that the device is a PCI device } wchar_t buffer[256]; @@ -173,6 +175,8 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* .index = &gpu->index, .temp = options->temp ? &gpu->temperature : NULL, .memory = options->driverSpecific ? &gpu->dedicated : NULL, + .sharedMemory = options->driverSpecific ? &gpu->shared : NULL, + .memoryType = options->driverSpecific ? &gpu->memoryType : NULL, .coreCount = options->driverSpecific ? (uint32_t*) &gpu->coreCount : NULL, .coreUsage = options->driverSpecific ? &gpu->coreUsage : NULL, .type = &gpu->type, diff --git a/src/detection/gpu/gpu_wsl.cpp b/src/detection/gpu/gpu_wsl.cpp index d8d7700b0..1ab5bb27d 100644 --- a/src/detection/gpu/gpu_wsl.cpp +++ b/src/detection/gpu/gpu_wsl.cpp @@ -70,6 +70,7 @@ const char* ffGPUDetectByDirectX(FF_MAYBE_UNUSED const FFGPUOptions* options, FF FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus); ffStrbufInitS(&gpu->name, desc); + ffStrbufInit(&gpu->memoryType); gpu->index = FF_GPU_INDEX_UNSET; gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET; diff --git a/src/detection/gpu/igcl.h b/src/detection/gpu/igcl.h index 25f342e36..60e5cf22a 100644 --- a/src/detection/gpu/igcl.h +++ b/src/detection/gpu/igcl.h @@ -141,6 +141,50 @@ typedef struct ctl_mem_state_t // https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv417ctlMemoryGetState16ctl_mem_handle_tP15ctl_mem_state_t extern ctl_result_t ctlMemoryGetState(ctl_mem_handle_t hMemory, ctl_mem_state_t *pState); +// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv414ctl_mem_type_t +typedef enum ctl_mem_type_t +{ + CTL_MEM_TYPE_HBM = 0, + CTL_MEM_TYPE_DDR = 1, + CTL_MEM_TYPE_DDR3 = 2, + CTL_MEM_TYPE_DDR4 = 3, + CTL_MEM_TYPE_DDR5 = 4, + CTL_MEM_TYPE_LPDDR = 5, + CTL_MEM_TYPE_LPDDR3 = 6, + CTL_MEM_TYPE_LPDDR4 = 7, + CTL_MEM_TYPE_LPDDR5 = 8, + CTL_MEM_TYPE_GDDR4 = 9, + CTL_MEM_TYPE_GDDR5 = 10, + CTL_MEM_TYPE_GDDR5X = 11, + CTL_MEM_TYPE_GDDR6 = 12, + CTL_MEM_TYPE_GDDR6X = 13, + CTL_MEM_TYPE_GDDR7 = 14, + CTL_MEM_TYPE_MAX +} ctl_mem_type_t; + +// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv413ctl_mem_loc_t +typedef enum ctl_mem_loc_t +{ + CTL_MEM_LOC_SYSTEM = 0, + CTL_MEM_LOC_DEVICE = 1, + CTL_MEM_LOC_MAX +} ctl_mem_loc_t; + +// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv420ctl_mem_properties_t +typedef struct ctl_mem_properties_t +{ + uint32_t Size; + uint8_t Version; + ctl_mem_type_t type; + ctl_mem_loc_t location; + uint64_t physicalSize; + int32_t busWidth; + int32_t numChannels; +} ctl_mem_properties_t; + +// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv422ctlMemoryGetProperties16ctl_mem_handle_tP20ctl_mem_properties_t +extern ctl_result_t ctlMemoryGetProperties(ctl_mem_handle_t hMemory, ctl_mem_properties_t *pProperties); + typedef struct ctl_freq_handle_t* ctl_freq_handle_t; // https://intel.github.io/drivers.gpu.control-library/Control/api.html#ctlenumfrequencydomains diff --git a/src/detection/gpu/nvapi.h b/src/detection/gpu/nvapi.h new file mode 100644 index 000000000..e616d3e5e --- /dev/null +++ b/src/detection/gpu/nvapi.h @@ -0,0 +1,44 @@ +// References: +// https://github.com/NVIDIA/nvapi (MIT License) +// https://github.com/deathcamp/NVOC/blob/master/nvoc.c (Public Domain) + +typedef enum NvApiGPUMemoryType +{ + NVAPI_GPU_MEMORY_TYPE_UNKNOWN = 0, + NVAPI_GPU_MEMORY_TYPE_SDRAM, + NVAPI_GPU_MEMORY_TYPE_DDR1, + NVAPI_GPU_MEMORY_TYPE_DDR2, + NVAPI_GPU_MEMORY_TYPE_GDDR2, + NVAPI_GPU_MEMORY_TYPE_GDDR3, + NVAPI_GPU_MEMORY_TYPE_GDDR4, + NVAPI_GPU_MEMORY_TYPE_DDR3, + NVAPI_GPU_MEMORY_TYPE_GDDR5, + NVAPI_GPU_MEMORY_TYPE_LPDDR2, + NVAPI_GPU_MEMORY_TYPE_GDDR5X, + NVAPI_GPU_MEMORY_TYPE_LPDDR3, + NVAPI_GPU_MEMORY_TYPE_LPDDR4, + NVAPI_GPU_MEMORY_TYPE_LPDDR5, + NVAPI_GPU_MEMORY_TYPE_GDDR6, + NVAPI_GPU_MEMORY_TYPE_GDDR6X, + NVAPI_GPU_MEMORY_TYPE_GDDR7, +} NvApiGPUMemoryType; + +typedef int NvAPI_Status; // 0 = success; < 0 = error +typedef struct NvPhysicalGpuHandle* NvPhysicalGpuHandle; + +typedef enum +{ + NVAPI_INTERFACE_OFFSET_INITIALIZE = 0x0150E828, + NVAPI_INTERFACE_OFFSET_UNLOAD = 0xD22BDD7E, + NVAPI_INTERFACE_OFFSET_ENUM_PHYSICAL_GPUS = 0xE5AC921F, + NVAPI_INTERFACE_OFFSET_GPU_GET_RAM_TYPE = 0x57F7CAAC, + + NVAPI_INTERFACE_OFFSET_FORCE_UINT32 = 0xFFFFFFFF +} NvApiInterfaceOffsets; + +extern void* nvapi_QueryInterface(NvApiInterfaceOffsets offset); + +extern NvAPI_Status nvapi_Initialize(void); +extern NvAPI_Status nvapi_Unload(void); +extern NvAPI_Status nvapi_EnumPhysicalGPUs(NvPhysicalGpuHandle* handles, int* count); +extern NvAPI_Status nvapi_GPU_GetRamType(NvPhysicalGpuHandle handle, NvApiGPUMemoryType* memtype); diff --git a/src/detection/host/host.h b/src/detection/host/host.h index a1e733e01..a8aa16b74 100644 --- a/src/detection/host/host.h +++ b/src/detection/host/host.h @@ -14,7 +14,7 @@ typedef struct FFHostResult } FFHostResult; const char* ffHostGetMacProductNameWithHwModel(const FFstrbuf* hwModel); -#ifdef __x86_64__ +#if __x86_64__ bool ffHostDetectMac(FFHostResult* host); #endif const char* ffDetectHost(FFHostResult* host); diff --git a/src/detection/host/host_mac.c b/src/detection/host/host_mac.c index 20460b4d4..d1703da28 100644 --- a/src/detection/host/host_mac.c +++ b/src/detection/host/host_mac.c @@ -107,6 +107,11 @@ const char* ffHostGetMacProductNameWithHwModel(const FFstrbuf* hwModel) else if(ffStrbufStartsWithS(hwModel, "Mac")) { const char* version = hwModel->chars + strlen("Mac"); + if(ffStrEquals(version, "16,13")) return "MacBook Air (15-inch, M4, 2025)"; + if(ffStrEquals(version, "16,12")) return "MacBook Air (13-inch, M4, 2025)"; + if(ffStrEquals(version, "16,11") || + ffStrEquals(version, "16,10")) return "Mac Mini (2024)"; + if(ffStrEquals(version, "16,9")) return "Mac Studio (M4 Max, 2025)"; if(ffStrEquals(version, "16,3")) return "iMac (24-inch, 2024, Four Thunderbolt / USB 4 ports)"; if(ffStrEquals(version, "16,2")) return "iMac (24-inch, 2024, Two Thunderbolt / USB 4 ports)"; if(ffStrEquals(version, "16,1")) return "MacBook Pro (14-inch, 2024, Three Thunderbolt 4 ports)"; @@ -114,8 +119,7 @@ const char* ffHostGetMacProductNameWithHwModel(const FFstrbuf* hwModel) ffStrEquals(version, "16,8")) return "MacBook Pro (14-inch, 2024, Three Thunderbolt 5 ports)"; if(ffStrEquals(version, "16,7") || ffStrEquals(version, "16,5")) return "MacBook Pro (16-inch, 2024, Three Thunderbolt 5 ports)"; - if(ffStrEquals(version, "16,15") || - ffStrEquals(version, "16,10")) return "Mac mini (2024)"; + if(ffStrEquals(version, "15,14")) return "Mac Studio (M3 Ultra, 2025)"; if(ffStrEquals(version, "15,13")) return "MacBook Air (15-inch, M3, 2024)"; if(ffStrEquals(version, "15,2")) return "MacBook Air (13-inch, M3, 2024)"; if(ffStrEquals(version, "15,3")) return "MacBook Pro (14-inch, Nov 2023, Two Thunderbolt / USB 4 ports)"; diff --git a/src/detection/host/host_windows.c b/src/detection/host/host_windows.c index bc50d6f08..05db2a041 100644 --- a/src/detection/host/host_windows.c +++ b/src/detection/host/host_windows.c @@ -72,7 +72,7 @@ const char* ffDetectHost(FFHostResult* host) ffCleanUpSmbiosValue(&host->family); } - #if _WIN32 && __x86_64__ + #if _WIN64 && __x86_64__ // aarch64 also defines _WIN64 ffHostDetectMac(host); #endif diff --git a/src/detection/initsystem/initsystem_haiku.c b/src/detection/initsystem/initsystem_haiku.c index 7a18a8e25..032de91f6 100644 --- a/src/detection/initsystem/initsystem_haiku.c +++ b/src/detection/initsystem/initsystem_haiku.c @@ -16,6 +16,7 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) ffStrbufSetStatic(&result->exe, path); ffStrbufSetStatic(&result->name, "launch_daemon"); + result->pid = 0; team_info teamInfo; int32 cookie = 0; @@ -28,7 +29,8 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) } } - ffGetFileVersion(path, &result->version); + if (instance.config.general.detectVersion) + ffGetFileVersion(path, &result->version); return NULL; } diff --git a/src/detection/keyboard/keyboard_bsd.c b/src/detection/keyboard/keyboard_bsd.c index 31dc3aa24..727e91b02 100644 --- a/src/detection/keyboard/keyboard_bsd.c +++ b/src/detection/keyboard/keyboard_bsd.c @@ -4,6 +4,7 @@ #include #include #include +#include #if __has_include() #include // FreeBSD @@ -11,16 +12,47 @@ #include // DragonFly #endif -#define MAX_UHID_JOYS 64 +static const char* detectByIoctl(FFlist* devices) +{ + keyboard_info_t kbdInfo; + if (ioctl(STDIN_FILENO, KDGKBINFO, &kbdInfo) != 0) + return "ioctl(KDGKBINFO) failed"; -const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) + FFKeyboardDevice* device = (FFKeyboardDevice*) ffListAdd(devices); + + switch (kbdInfo.kb_type) { + case KB_84: + ffStrbufInitS(&device->name, "AT 84-key keyboard"); + break; + case KB_101: + ffStrbufInitS(&device->name, "AT 101/102-key keyboard"); + break; + default: + ffStrbufInitS(&device->name, "Unknown keyboard"); + break; + } + + ffStrbufAppendF(&device->name, " (kbd%d)", kbdInfo.kb_index); + + ffStrbufInit(&device->serial); + return NULL; +} + +#define MAX_UHID_KBDS 64 + +static const char* detectByUsbhid(FFlist* devices) { char path[16]; - for (int i = 0; i < MAX_UHID_JOYS; i++) + for (int i = 0; i < MAX_UHID_KBDS; i++) { snprintf(path, ARRAY_SIZE(path), "/dev/uhid%d", i); FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY | O_CLOEXEC); - if (fd < 0) continue; + if (fd < 0) + { + if (errno == ENOENT) + break; // No more devices + continue; // Device not found + } report_desc_t repDesc = hid_get_report_desc(fd); if (!repDesc) continue; @@ -43,6 +75,7 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) ffStrbufInitS(&device->name, di.udi_product); } } + hid_end_parse(hData); } hid_dispose_report_desc(repDesc); @@ -50,3 +83,11 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) return NULL; } + +const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) +{ + detectByUsbhid(devices); + if (devices->length > 0) + return NULL; + return detectByIoctl(devices); +} diff --git a/src/detection/media/media_apple.m b/src/detection/media/media_apple.m index c576c7e08..818bf2cbf 100644 --- a/src/detection/media/media_apple.m +++ b/src/detection/media/media_apple.m @@ -11,7 +11,7 @@ extern void MRMediaRemoteGetNowPlayingInfo(dispatch_queue_t dispatcher, void(^ca extern void MRMediaRemoteGetNowPlayingClient(dispatch_queue_t dispatcher, void (^callback)(_Nullable id clientObj)) __attribute__((weak_import)); extern CFStringRef MRNowPlayingClientGetBundleIdentifier(id clientObj) __attribute__((weak_import)); extern CFStringRef MRNowPlayingClientGetParentAppBundleIdentifier(id clientObj) __attribute__((weak_import)); -void MRMediaRemoteGetNowPlayingApplicationIsPlaying(dispatch_queue_t queue, void (^callback)(BOOL playing)); +void MRMediaRemoteGetNowPlayingApplicationIsPlaying(dispatch_queue_t queue, void (^callback)(BOOL playing)) __attribute__((weak_import)); static const char* getMedia(FFMediaResult* result) { @@ -20,6 +20,7 @@ static const char* getMedia(FFMediaResult* result) FF_TEST_FN_EXISTANCE(MRMediaRemoteGetNowPlayingClient); FF_TEST_FN_EXISTANCE(MRNowPlayingClientGetBundleIdentifier); FF_TEST_FN_EXISTANCE(MRNowPlayingClientGetParentAppBundleIdentifier); + FF_TEST_FN_EXISTANCE(MRMediaRemoteGetNowPlayingApplicationIsPlaying); #undef FF_TEST_FN_EXISTANCE dispatch_group_t group = dispatch_group_create(); @@ -63,6 +64,7 @@ static const char* getMedia(FFMediaResult* result) }); dispatch_group_wait(group, DISPATCH_TIME_FOREVER); + // Don't dispatch_release because we are using ARC if(result->playerId.length > 0) { diff --git a/src/detection/media/media_linux.c b/src/detection/media/media_linux.c index d9fbe8ad1..aabf2da3e 100644 --- a/src/detection/media/media_linux.c +++ b/src/detection/media/media_linux.c @@ -129,9 +129,9 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul } else { - char str[] = { fileName[1], fileName[2], 0 }; - if (str[0] == 0 || str[1] == 0) + if (fileName[1] == 0 || fileName[2] == 0) break; + char str[] = { fileName[1], fileName[2], 0 }; ffStrbufAppendC(&result->song, (char) strtoul(str, NULL, 16)); fileName += 2; } diff --git a/src/detection/media/media_windows.dll.cpp b/src/detection/media/media_windows.dll.cpp index 71c3226c4..ff197cf5b 100644 --- a/src/detection/media/media_windows.dll.cpp +++ b/src/detection/media/media_windows.dll.cpp @@ -32,15 +32,15 @@ const char* ffWinrtDetectMedia(FFWinrtMediaResult* result) { switch (playbackInfo.PlaybackStatus()) { - #define FF_MEDIA_SET_STATUS(status_code) \ - case GlobalSystemMediaTransportControlsSessionPlaybackStatus::status_code: result->status = #status_code; break - FF_MEDIA_SET_STATUS(Closed); - FF_MEDIA_SET_STATUS(Opened); - FF_MEDIA_SET_STATUS(Changing); - FF_MEDIA_SET_STATUS(Stopped); - FF_MEDIA_SET_STATUS(Playing); - FF_MEDIA_SET_STATUS(Paused); - #undef FF_MEDIA_SET_STATUS + #define FF_MEDIA_SET_STATUS(status_code) \ + case GlobalSystemMediaTransportControlsSessionPlaybackStatus::status_code: result->status = #status_code; break; + FF_MEDIA_SET_STATUS(Closed) + FF_MEDIA_SET_STATUS(Opened) + FF_MEDIA_SET_STATUS(Changing) + FF_MEDIA_SET_STATUS(Stopped) + FF_MEDIA_SET_STATUS(Playing) + FF_MEDIA_SET_STATUS(Paused) + #undef FF_MEDIA_SET_STATUS } } diff --git a/src/detection/mouse/mouse_bsd.c b/src/detection/mouse/mouse_bsd.c index cb99a47cf..3a1f2eb69 100644 --- a/src/detection/mouse/mouse_bsd.c +++ b/src/detection/mouse/mouse_bsd.c @@ -11,17 +11,21 @@ #include // DragonFly #endif -#define MAX_UHID_JOYS 64 +#define MAX_UHID_MICE 64 const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { char path[16]; - for (int i = 0; i < MAX_UHID_JOYS; i++) + for (int i = 0; i < MAX_UHID_MICE; i++) { snprintf(path, ARRAY_SIZE(path), "/dev/uhid%d", i); FF_AUTO_CLOSE_FD int fd = open(path, O_RDONLY | O_CLOEXEC); - if (fd < 0) continue; - + if (fd < 0) + { + if (errno == ENOENT) + break; // No more devices + continue; // Device not found + } report_desc_t repDesc = hid_get_report_desc(fd); if (!repDesc) continue; @@ -43,6 +47,7 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) ffStrbufInitS(&device->name, di.udi_product); } } + hid_end_parse(hData); } hid_dispose_report_desc(repDesc); diff --git a/src/detection/opencl/opencl.c b/src/detection/opencl/opencl.c index 0c3700023..393202ebe 100644 --- a/src/detection/opencl/opencl.c +++ b/src/detection/opencl/opencl.c @@ -92,6 +92,7 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) ffStrbufInit(&gpu->vendor); ffStrbufInit(&gpu->driver); ffStrbufInit(&gpu->platformApi); + ffStrbufInit(&gpu->memoryType); gpu->index = FF_GPU_INDEX_UNSET; gpu->temperature = FF_GPU_TEMP_UNSET; gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; diff --git a/src/detection/physicalmemory/physicalmemory_linux.c b/src/detection/physicalmemory/physicalmemory_linux.c index cfc18fe30..de9dddad9 100644 --- a/src/detection/physicalmemory/physicalmemory_linux.c +++ b/src/detection/physicalmemory/physicalmemory_linux.c @@ -123,67 +123,73 @@ const char* ffDetectPhysicalMemory(FFlist* result) else if (ldevice) ffStrbufSetS(&device->locator, ldevice); - switch (data->FormFactor) - { - case 0x01: ffStrbufSetStatic(&device->formFactor, "Other"); break; - case 0x02: ffStrbufSetStatic(&device->formFactor, "Unknown"); break; - case 0x03: ffStrbufSetStatic(&device->formFactor, "SIMM"); break; - case 0x04: ffStrbufSetStatic(&device->formFactor, "SIP"); break; - case 0x05: ffStrbufSetStatic(&device->formFactor, "Chip"); break; - case 0x06: ffStrbufSetStatic(&device->formFactor, "DIP"); break; - case 0x07: ffStrbufSetStatic(&device->formFactor, "ZIP"); break; - case 0x08: ffStrbufSetStatic(&device->formFactor, "Proprietary Card"); break; - case 0x09: ffStrbufSetStatic(&device->formFactor, "DIMM"); break; - case 0x0A: ffStrbufSetStatic(&device->formFactor, "TSOP"); break; - case 0x0B: ffStrbufSetStatic(&device->formFactor, "Row of chips"); break; - case 0x0C: ffStrbufSetStatic(&device->formFactor, "RIMM"); break; - case 0x0D: ffStrbufSetStatic(&device->formFactor, "SODIMM"); break; - case 0x0E: ffStrbufSetStatic(&device->formFactor, "SRIMM"); break; - case 0x0F: ffStrbufSetStatic(&device->formFactor, "FBDIMM"); break; - case 0x10: ffStrbufSetStatic(&device->formFactor, "Die"); break; - default: ffStrbufSetF(&device->formFactor, "Unknown (%d)", (int) data->FormFactor); break; - } + const char* formFactorNames[] = { + NULL, // 0x00 (用于索引,实际上没有0x00的类型) + "Other", // 0x01 + "Unknown", // 0x02 + "SIMM", // 0x03 + "SIP", // 0x04 + "Chip", // 0x05 + "DIP", // 0x06 + "ZIP", // 0x07 + "Proprietary Card",// 0x08 + "DIMM", // 0x09 + "TSOP", // 0x0A + "Row of chips", // 0x0B + "RIMM", // 0x0C + "SODIMM", // 0x0D + "SRIMM", // 0x0E + "FBDIMM", // 0x0F + "Die", // 0x10 + }; + if (data->FormFactor > 0 && data->FormFactor < ARRAY_SIZE(formFactorNames)) + ffStrbufSetS(&device->formFactor, formFactorNames[data->FormFactor]); + else + ffStrbufSetF(&device->formFactor, "Unknown (%d)", (int) data->FormFactor); - switch (data->MemoryType) - { - case 0x01: ffStrbufSetStatic(&device->type, "Other"); break; - case 0x02: ffStrbufSetStatic(&device->type, "Unknown"); break; - case 0x03: ffStrbufSetStatic(&device->type, "DRAM"); break; - case 0x04: ffStrbufSetStatic(&device->type, "EDRAM"); break; - case 0x05: ffStrbufSetStatic(&device->type, "VRAM"); break; - case 0x06: ffStrbufSetStatic(&device->type, "SRAM"); break; - case 0x07: ffStrbufSetStatic(&device->type, "RAM"); break; - case 0x08: ffStrbufSetStatic(&device->type, "ROM"); break; - case 0x09: ffStrbufSetStatic(&device->type, "FLASH"); break; - case 0x0A: ffStrbufSetStatic(&device->type, "EEPROM"); break; - case 0x0B: ffStrbufSetStatic(&device->type, "FEPROM"); break; - case 0x0C: ffStrbufSetStatic(&device->type, "EPROM"); break; - case 0x0D: ffStrbufSetStatic(&device->type, "CDRAM"); break; - case 0x0E: ffStrbufSetStatic(&device->type, "3DRAM"); break; - case 0x0F: ffStrbufSetStatic(&device->type, "SDRAM"); break; - case 0x10: ffStrbufSetStatic(&device->type, "SGRAM"); break; - case 0x11: ffStrbufSetStatic(&device->type, "RDRAM"); break; - case 0x12: ffStrbufSetStatic(&device->type, "DDR"); break; - case 0x13: ffStrbufSetStatic(&device->type, "DDR2"); break; - case 0x14: ffStrbufSetStatic(&device->type, "DDR2 FB-DIMM"); break; - case 0x15: - case 0x16: - case 0x17: ffStrbufSetStatic(&device->type, "Reserved"); break; - case 0x18: ffStrbufSetStatic(&device->type, "DDR3"); break; - case 0x19: ffStrbufSetStatic(&device->type, "FBD2"); break; - case 0x1A: ffStrbufSetStatic(&device->type, "DDR4"); break; - case 0x1B: ffStrbufSetStatic(&device->type, "LPDDR"); break; - case 0x1C: ffStrbufSetStatic(&device->type, "LPDDR2"); break; - case 0x1D: ffStrbufSetStatic(&device->type, "LPDDR3"); break; - case 0x1E: ffStrbufSetStatic(&device->type, "LPDDR4"); break; - case 0x1F: ffStrbufSetStatic(&device->type, "Logical non-volatile device"); break; - case 0x20: ffStrbufSetStatic(&device->type, "HBM"); break; - case 0x21: ffStrbufSetStatic(&device->type, "HBM2"); break; - case 0x22: ffStrbufSetStatic(&device->type, "DDR5"); break; - case 0x23: ffStrbufSetStatic(&device->type, "LPDDR5"); break; - case 0x24: ffStrbufSetStatic(&device->type, "HBM3"); break; - default: ffStrbufSetF(&device->type, "Unknown (%d)", (int) data->MemoryType); break; - } + const char* memoryTypeNames[] = { + NULL, // 0x00 (用于索引,实际上没有0x00的类型) + "Other", // 0x01 + "Unknown", // 0x02 + "DRAM", // 0x03 + "EDRAM", // 0x04 + "VRAM", // 0x05 + "SRAM", // 0x06 + "RAM", // 0x07 + "ROM", // 0x08 + "FLASH", // 0x09 + "EEPROM", // 0x0A + "FEPROM", // 0x0B + "EPROM", // 0x0C + "CDRAM", // 0x0D + "3DRAM", // 0x0E + "SDRAM", // 0x0F + "SGRAM", // 0x10 + "RDRAM", // 0x11 + "DDR", // 0x12 + "DDR2", // 0x13 + "DDR2 FB-DIMM", // 0x14 + "Reserved", // 0x15 + "Reserved", // 0x16 + "Reserved", // 0x17 + "DDR3", // 0x18 + "FBD2", // 0x19 + "DDR4", // 0x1A + "LPDDR", // 0x1B + "LPDDR2", // 0x1C + "LPDDR3", // 0x1D + "LPDDR4", // 0x1E + "Logical non-volatile device", // 0x1F + "HBM", // 0x20 + "HBM2", // 0x21 + "DDR5", // 0x22 + "LPDDR5", // 0x23 + "HBM3", // 0x24 + }; + if (data->MemoryType > 0 && data->MemoryType < ARRAY_SIZE(memoryTypeNames)) + ffStrbufSetStatic(&device->type, memoryTypeNames[data->MemoryType]); + else + ffStrbufSetF(&device->type, "Unknown (%d)", (int) data->MemoryType); if (data->Header.Length > offsetof(FFSmbiosMemoryDevice, Speed)) // 2.3+ { diff --git a/src/detection/sound/sound_obsd.c b/src/detection/sound/sound_obsd.c index 2b19d0eb5..5b83f9578 100644 --- a/src/detection/sound/sound_obsd.c +++ b/src/detection/sound/sound_obsd.c @@ -64,7 +64,7 @@ const char* ffDetectSound(FFlist* devices) return "sioctl_ondesc() failed"; if (bundle.iLevel != bundle.iMute || bundle.iLevel == 0) - return "Unexpecd sioctl_ondesc() result"; + return "Unexpected sioctl_ondesc() result"; FFSoundDevice* device = ffListAdd(devices); ffStrbufInitS(&device->name, bundle.name); diff --git a/src/detection/sound/sound_windows.cpp b/src/detection/sound/sound_windows.cpp index fece395f0..4845cac5f 100644 --- a/src/detection/sound/sound_windows.cpp +++ b/src/detection/sound/sound_windows.cpp @@ -9,6 +9,14 @@ extern "C" { #include #include +static void ffCoTaskMemFreeWrapper(void* pptr) +{ + assert(pptr != NULL); + void* ptr = *(void**)pptr; + if (ptr) CoTaskMemFree(ptr); +} +#define FF_COTASK_AUTO_FREE __attribute__((__cleanup__(ffCoTaskMemFreeWrapper))) + const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) { const char* error = ffInitCom(); @@ -20,7 +28,7 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) if (FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void **)&pEnum))) return "CoCreateInstance(CLSID_MMDeviceEnumerator) failed"; - LPWSTR mainDeviceId = NULL; + LPWSTR FF_COTASK_AUTO_FREE mainDeviceId = NULL; { IMMDevice* FF_AUTO_RELEASE_COM_OBJECT pDefaultDevice = NULL; @@ -47,7 +55,7 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) if (FAILED(pDevices->Item(deviceIdx, &immDevice))) continue; - LPWSTR immDeviceId = NULL; + LPWSTR FF_COTASK_AUTO_FREE immDeviceId = NULL; if (FAILED(immDevice->GetId(&immDeviceId))) continue; diff --git a/src/detection/swap/swap_haiku.c b/src/detection/swap/swap_haiku.c index b61f213e7..a9502c915 100644 --- a/src/detection/swap/swap_haiku.c +++ b/src/detection/swap/swap_haiku.c @@ -2,16 +2,14 @@ #include -enum { FFMaxNSwap = 8 }; - const char* ffDetectSwap(FFSwapResult* swap) { system_info info; if (get_system_info(&info) != B_OK) return "Error getting system info"; - swap->bytesTotal = B_PAGE_SIZE * info.max_swap_pages; - swap->bytesUsed = B_PAGE_SIZE * (info.max_swap_pages - info.free_swap_pages); + swap->bytesTotal = B_PAGE_SIZE * (uint64_t) info.max_swap_pages; + swap->bytesUsed = B_PAGE_SIZE * (uint64_t) (info.max_swap_pages - info.free_swap_pages); return NULL; } diff --git a/src/detection/swap/swap_linux.c b/src/detection/swap/swap_linux.c index 15f8fd24d..d86bad19b 100644 --- a/src/detection/swap/swap_linux.c +++ b/src/detection/swap/swap_linux.c @@ -7,7 +7,7 @@ const char* ffDetectSwap(FFSwapResult* swap) { - // #620 + // Ref: #620 char buf[PROC_FILE_BUFFSIZ]; ssize_t nRead = ffReadFileData("/proc/meminfo", ARRAY_SIZE(buf) - 1, buf); if(nRead < 0) diff --git a/src/detection/swap/swap_obsd.c b/src/detection/swap/swap_obsd.c index b64900c9f..414971d39 100644 --- a/src/detection/swap/swap_obsd.c +++ b/src/detection/swap/swap_obsd.c @@ -10,21 +10,24 @@ const char* ffDetectSwap(FFSwapResult* swap) { int nswap = swapctl(SWAP_NSWAP, 0, 0); if (nswap < 0) return "swapctl(SWAP_NSWAP) failed"; - if (nswap == 0) NULL; + if (nswap == 0) return NULL; - struct swapent* swdev = malloc((uint32_t) nswap * sizeof(*swdev)); + FF_AUTO_FREE struct swapent* swdev = malloc((uint32_t) nswap * sizeof(*swdev)); if (swapctl(SWAP_STATS, swdev, nswap) < 0) return "swapctl(SWAP_STATS) failed"; + uint64_t swapTotal = 0, swapUsed = 0; for (int i = 0; i < nswap; i++) { if (swdev[i].se_flags & SWF_ENABLE) { - swap->bytesUsed += (uint64_t) swdev[i].se_inuse * DEV_BSIZE; - swap->bytesTotal += (uint64_t) swdev[i].se_nblks * DEV_BSIZE; + swapUsed += (uint64_t) swdev[i].se_inuse; + swapTotal += (uint64_t) swdev[i].se_nblks; } } + swap->bytesUsed = swapUsed * DEV_BSIZE; + swap->bytesTotal = swapTotal * DEV_BSIZE; return NULL; } diff --git a/src/detection/swap/swap_windows.c b/src/detection/swap/swap_windows.c index 322516fdb..cd6e0d88e 100644 --- a/src/detection/swap/swap_windows.c +++ b/src/detection/swap/swap_windows.c @@ -7,15 +7,22 @@ const char* ffDetectSwap(FFSwapResult* swap) { - uint8_t buffer[1024]; + uint8_t buffer[4096]; ULONG size = sizeof(buffer); SYSTEM_PAGEFILE_INFORMATION* pstart = (SYSTEM_PAGEFILE_INFORMATION*) buffer; if(!NT_SUCCESS(NtQuerySystemInformation(SystemPagefileInformation, pstart, size, &size))) return "NtQuerySystemInformation(SystemPagefileInformation, size) failed"; + for (SYSTEM_PAGEFILE_INFORMATION* current = pstart; ; current = (SYSTEM_PAGEFILE_INFORMATION*)((uint8_t*) current + current->NextEntryOffset)) + { + swap->bytesUsed += current->TotalUsed; + swap->bytesTotal += current->CurrentSize; + if (current->NextEntryOffset == 0) + break; + } uint32_t pageSize = instance.state.platform.sysinfo.pageSize; - swap->bytesUsed = (uint64_t)pstart->TotalUsed * pageSize; - swap->bytesTotal = (uint64_t)pstart->CurrentSize * pageSize; + swap->bytesUsed *= pageSize; + swap->bytesTotal *= pageSize; return NULL; } diff --git a/src/detection/terminalfont/terminalfont_windows.c b/src/detection/terminalfont/terminalfont_windows.c index 3adcd8eaa..3aebf79dc 100644 --- a/src/detection/terminalfont/terminalfont_windows.c +++ b/src/detection/terminalfont/terminalfont_windows.c @@ -4,6 +4,7 @@ #include "common/properties.h" #include "detection/terminalshell/terminalshell.h" #include "util/windows/unicode.h" +#include "util/windows/registry.h" #include "util/stringUtils.h" #include "terminalfont.h" @@ -259,6 +260,22 @@ static void detectConEmu(FFTerminalFontResult* terminalFont) ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); } +static void detectWarp(FFTerminalFontResult* terminalFont) +{ + FF_HKEY_AUTO_DESTROY key = NULL; + if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Warp.dev\\Warp", &key, &terminalFont->error)) + return; + + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); + if (!ffRegReadStrbuf(key, L"FontName", &fontName, NULL)) + ffStrbufSetS(&fontName, "Hack"); + if (!ffRegReadStrbuf(key, L"FontSize", &fontSize, &terminalFont->error)) + ffStrbufSetS(&fontSize, "13"); + + ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); +} + void ffDetectTerminalFontPlatform(const FFTerminalResult* terminal, FFTerminalFontResult* terminalFont) { if(ffStrbufIgnCaseEqualS(&terminal->processName, "Windows Terminal") || @@ -270,4 +287,6 @@ void ffDetectTerminalFontPlatform(const FFTerminalResult* terminal, FFTerminalFo detectConhost(terminalFont); else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "ConEmu")) detectConEmu(terminalFont); + else if(ffStrbufStartsWithIgnCaseS(&terminal->processName, "warp")) + detectWarp(terminalFont); } diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 92bd7294e..f4c8a076e 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -22,9 +22,11 @@ static bool getFileVersion(const FFstrbuf* exePath, const wchar_t* stringName, FFstrbuf* version) { - wchar_t exePathW[PATH_MAX]; + wchar_t exePathW[PATH_MAX + 1]; int len = MultiByteToWideChar(CP_UTF8, 0, exePath->chars, (int)exePath->length, exePathW, ARRAY_SIZE(exePathW)); if (len <= 0) return false; + assert(len < (int) ARRAY_SIZE(exePathW)); + exePathW[len] = L'\0'; return ffGetFileVersion(exePathW, stringName, version); } diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 6a99aefe2..ae5eaf77c 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -170,7 +170,6 @@ static void getTerminalFromEnv(FFTerminalResult* result) #ifdef __APPLE__ !ffStrbufEqualS(&result->processName, "launchd") && - !ffStrbufEqualS(&result->processName, "stable") && //for WarpTerminal #else !ffStrbufEqualS(&result->processName, "systemd") && !ffStrbufEqualS(&result->processName, "init") && @@ -351,11 +350,16 @@ static void setTerminalInfoDetails(FFTerminalResult* result) ffStrbufInitStatic(&result->prettyName, "iTerm"); else if(ffStrbufEndsWithS(&result->exePath, "Terminal.app/Contents/MacOS/Terminal")) { - ffStrbufSetStatic(&result->processName, "Apple_Terminal"); // for terminal font detection + ffStrbufSetStatic(&result->processName, "Apple_Terminal"); // $TERM_PROGRAM, for terminal font detection ffStrbufInitStatic(&result->prettyName, "Apple Terminal"); } else if(ffStrbufEqualS(&result->processName, "Apple_Terminal")) ffStrbufInitStatic(&result->prettyName, "Apple Terminal"); + else if(ffStrbufEndsWithS(&result->exePath, "Warp.app/Contents/MacOS/stable")) + { + ffStrbufSetStatic(&result->processName, "WarpTerminal"); // $TERM_PROGRAM, for terminal font detection + ffStrbufInitStatic(&result->prettyName, "Warp"); + } else if(ffStrbufEqualS(&result->processName, "WarpTerminal")) ffStrbufInitStatic(&result->prettyName, "Warp"); diff --git a/src/detection/tpm/tpm_apple.c b/src/detection/tpm/tpm_apple.c new file mode 100644 index 000000000..8e22d5dc9 --- /dev/null +++ b/src/detection/tpm/tpm_apple.c @@ -0,0 +1,31 @@ +#include "tpm.h" + +#ifndef __aarch64__ + #include "util/apple/cf_helpers.h" + #include +#endif + +const char* ffDetectTPM(FFTPMResult* result) +{ + #ifdef __aarch64__ + + ffStrbufSetStatic(&result->version, "2.0"); + ffStrbufSetStatic(&result->description, "Apple Silicon Security"); + return NULL; + + #else + + FF_IOOBJECT_AUTO_RELEASE io_service_t t2Service = IOServiceGetMatchingService( + kIOMainPortDefault, + IOServiceMatching("AppleT2")); + + if (t2Service) { + ffStrbufSetStatic(&result->version, "2.0"); + ffStrbufSetStatic(&result->description, "Apple T2 Security Chip"); + return NULL; + } + + #endif + + return "No Apple Security hardware detected"; +} diff --git a/src/detection/uptime/uptime_bsd.c b/src/detection/uptime/uptime_bsd.c index 446a95e25..57a17b0d7 100644 --- a/src/detection/uptime/uptime_bsd.c +++ b/src/detection/uptime/uptime_bsd.c @@ -20,7 +20,7 @@ const char* ffDetectUptime(FFUptimeResult* result) return "sysctl({CTL_KERN, KERN_BOOTTIME}) failed"; #if __NetBSD__ - result->bootTime = (uint64_t) bootTime.tv_sec * 1000 + (uint64_t) bootTime.tv_nsec / 10000000; + result->bootTime = (uint64_t) bootTime.tv_sec * 1000 + (uint64_t) bootTime.tv_nsec / 1000000; #else result->bootTime = (uint64_t) bootTime.tv_sec * 1000 + (uint64_t) bootTime.tv_usec / 1000; #endif diff --git a/src/detection/users/users_linux.c b/src/detection/users/users_linux.c index 30c38c2af..99e27627c 100644 --- a/src/detection/users/users_linux.c +++ b/src/detection/users/users_linux.c @@ -39,11 +39,27 @@ next: ffStrbufInitS(&user->name, n->ut_user); ffStrbufInitS(&user->hostName, n->ut_host); ffStrbufInitS(&user->sessionName, n->ut_line); - #ifdef __linux__ - // https://www.linuxquestions.org/questions/programming-9/get-the-ip-addr-out-from-an-int32_t-value-287687/#post1458622 - ffStrbufInitS(&user->clientIp, inet_ntoa((struct in_addr) { .s_addr = (in_addr_t) n->ut_addr_v6[0] })); - #else ffStrbufInit(&user->clientIp); + #ifdef __linux__ + bool isIpv6 = false; + for (int i = 1; i < 4; ++i) { + if (n->ut_addr_v6[i] != 0) { + isIpv6 = true; + break; + } + } + + if (isIpv6) { + char ipv6_str[INET6_ADDRSTRLEN]; + if (inet_ntop(AF_INET6, n->ut_addr_v6, ipv6_str, INET6_ADDRSTRLEN) != NULL) { + ffStrbufSetS(&user->clientIp, ipv6_str); + } + } else if (n->ut_addr_v6[0] != 0) { + char ipv4_str[INET_ADDRSTRLEN]; + if (inet_ntop(AF_INET, n->ut_addr_v6, ipv4_str, INET_ADDRSTRLEN) != NULL) { + ffStrbufSetS(&user->clientIp, ipv4_str); + } + } #endif user->loginTime = (uint64_t) n->ut_tv.tv_sec * 1000 + (uint64_t) n->ut_tv.tv_usec / 1000; } diff --git a/src/detection/users/users_windows.c b/src/detection/users/users_windows.c index b7bdf2721..c2dd961ec 100644 --- a/src/detection/users/users_windows.c +++ b/src/detection/users/users_windows.c @@ -3,6 +3,7 @@ #include #include +#include static inline uint64_t to_ms(uint64_t ret) { @@ -41,8 +42,14 @@ const char* ffDetectUsers(FFUsersOptions* options, FFlist* users) PWTS_CLIENT_ADDRESS address = NULL; if (WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, session->SessionId, WTSClientAddress, (LPWSTR *) &address, &bytes)) { - if (address->AddressFamily == 2 /*AF_INET*/) + if (address->AddressFamily == AF_INET) ffStrbufSetF(&user->clientIp, "%u.%u.%u.%u", address->Address[2], address->Address[3], address->Address[4], address->Address[5]); + else if (address->AddressFamily == AF_INET6) + { + char ipStr[INET6_ADDRSTRLEN]; + if (inet_ntop(AF_INET6, address->Address, ipStr, sizeof(ipStr)) != NULL) + ffStrbufSetS(&user->clientIp, ipStr); + } WTSFreeMemory(address); } diff --git a/src/detection/vulkan/vulkan.c b/src/detection/vulkan/vulkan.c index 3a613ee71..43747d241 100644 --- a/src/detection/vulkan/vulkan.c +++ b/src/detection/vulkan/vulkan.c @@ -220,6 +220,7 @@ static const char* detectVulkan(FFVulkanResult* result) gpu->type = physicalDeviceProperties.properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED; ffStrbufInitS(&gpu->vendor, ffGPUGetVendorString(physicalDeviceProperties.properties.vendorID)); ffStrbufInitS(&gpu->driver, driverProperties.driverInfo); + ffStrbufInit(&gpu->memoryType); VkPhysicalDeviceMemoryProperties memoryProperties = {}; ffvkGetPhysicalDeviceMemoryProperties(physicalDevices[i], &memoryProperties); diff --git a/src/detection/wifi/wifi_apple.m b/src/detection/wifi/wifi_apple.m index 082b9966e..d6377908c 100644 --- a/src/detection/wifi/wifi_apple.m +++ b/src/detection/wifi/wifi_apple.m @@ -38,7 +38,7 @@ static bool getWifiInfoByIpconfig(FFstrbuf* ipconfig, const char* prefix, FFstrb const char* end = strchr(start, '\n'); if (!end) return false; ffStrbufSetNS(result, (uint32_t) (end - start), start); - return false; + return true; } const char* ffDetectWifi(FFlist* result) diff --git a/src/detection/wifi/wifi_bsd.c b/src/detection/wifi/wifi_bsd.c index e070b1e50..ca42a7ed8 100644 --- a/src/detection/wifi/wifi_bsd.c +++ b/src/detection/wifi/wifi_bsd.c @@ -1,81 +1,156 @@ #include "wifi.h" -#include "common/processing.h" -#include "common/properties.h" +#include "common/io/io.h" #include "util/stringUtils.h" -#include #include #include +#include +#include +#include +#include +#include +#include +#include const char* ffDetectWifi(FFlist* result) { struct if_nameindex* infs = if_nameindex(); - if(!infs) + if(!infs) { return "if_nameindex() failed"; + } + + FF_AUTO_CLOSE_FD int sock = socket(AF_INET, SOCK_DGRAM, 0); + if(sock < 0) { + return "socket() failed"; + } for(struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i) { - if (!ffStrStartsWith(i->if_name, "wlan")) continue; - FF_STRBUF_AUTO_DESTROY ifconfig = ffStrbufCreate(); - if (ffProcessAppendStdOut(&ifconfig, (char* const[]) { - "ifconfig", - i->if_name, - NULL - }) == NULL) - { - FFWifiResult* item = (FFWifiResult*) ffListAdd(result); - ffStrbufInitS(&item->inf.description, i->if_name); - ffStrbufInit(&item->inf.status); - ffStrbufInit(&item->conn.status); - ffStrbufInit(&item->conn.ssid); - ffStrbufInit(&item->conn.bssid); - ffStrbufInit(&item->conn.protocol); - ffStrbufInit(&item->conn.security); - item->conn.signalQuality = 0.0/0.0; - item->conn.rxRate = 0.0/0.0; - item->conn.txRate = 0.0/0.0; - item->conn.channel = 0; - item->conn.frequency = 0; + if (!ffStrStartsWith(i->if_name, "wlan")) { + continue; + } - ffParsePropLines(ifconfig.chars, "status: ", &item->conn.status); - if (!ffStrbufEqualS(&item->conn.status, "associated")) - continue; + FFWifiResult* item = (FFWifiResult*) ffListAdd(result); + ffStrbufInitS(&item->inf.description, i->if_name); + ffStrbufInit(&item->inf.status); + ffStrbufInit(&item->conn.status); + ffStrbufInit(&item->conn.ssid); + ffStrbufInit(&item->conn.bssid); + ffStrbufInit(&item->conn.protocol); + ffStrbufInit(&item->conn.security); + item->conn.signalQuality = 0.0/0.0; + item->conn.rxRate = 0.0/0.0; + item->conn.txRate = 0.0/0.0; + item->conn.channel = 0; + item->conn.frequency = 0; - ffParsePropLines(ifconfig.chars, "ssid ", &item->conn.ssid); - if (item->conn.ssid.length) - { - // This doesn't work for quoted SSID values - uint32_t idx = ffStrbufFirstIndexS(&item->conn.ssid, " bssid "); - if (idx < item->conn.ssid.length) - { - ffStrbufSetS(&item->conn.bssid, item->conn.ssid.chars + idx + (uint32_t) strlen(" bssid ")); - ffStrbufSubstrBefore(&item->conn.ssid, idx); - } + char ssid[IEEE80211_NWID_LEN + 1] = {}; + struct ieee80211req ireq = {}; + strlcpy(ireq.i_name, i->if_name, sizeof(ireq.i_name)); + ireq.i_type = IEEE80211_IOC_SSID; + ireq.i_data = ssid; + ireq.i_len = sizeof(ssid) - 1; - idx = ffStrbufFirstIndexS(&item->conn.ssid, " channel "); - if (idx < item->conn.ssid.length) - { - const char* pchannel = item->conn.ssid.chars + idx + strlen(" channel "); - sscanf(pchannel, "%hu (%hu MHz %*s)", &item->conn.channel, &item->conn.frequency); - } - - ffStrbufSubstrBefore(&item->conn.ssid, idx); + if (ioctl(sock, SIOCG80211, &ireq) < 0 || ireq.i_len == 0) { + struct ifreq ifr; + strlcpy(ifr.ifr_name, i->if_name, sizeof(ifr.ifr_name)); + if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) { + ffStrbufSetStatic(&item->inf.status, "Unknown"); + } else { + ffStrbufSetStatic(&item->inf.status, ifr.ifr_flags & IFF_UP ? "Up" : "Down"); } + ffStrbufAppendS(&item->conn.status, "Not associated"); + continue; + } - ffParsePropLines(ifconfig.chars, "media: ", &item->conn.protocol); - if (item->conn.protocol.length) - { - uint32_t index = ffStrbufFirstIndexS(&item->conn.protocol, " mode "); - if (index == item->conn.protocol.length) - ffStrbufClear(&item->conn.protocol); - else - { - ffStrbufSubstrAfter(&item->conn.protocol, index + strlen(" mode ") - 1); - ffStrbufPrependS(&item->conn.protocol, "802."); - } + ffStrbufSetStatic(&item->inf.status, "Up"); + ffStrbufSetStatic(&item->conn.status, "Associated"); + ffStrbufAppendNS(&item->conn.ssid, ireq.i_len, ssid); + + uint8_t bssid[IEEE80211_ADDR_LEN] = {}; + ireq.i_type = IEEE80211_IOC_BSSID; + ireq.i_data = bssid; + ireq.i_len = sizeof(bssid); + + if (ioctl(sock, SIOCG80211, &ireq) >= 0) { + ffStrbufSetF(&item->conn.bssid, "%02X:%02X:%02X:%02X:%02X:%02X", + bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); + } + + struct ieee80211_channel curchan = {}; + ireq.i_type = IEEE80211_IOC_CURCHAN; + ireq.i_data = &curchan; + ireq.i_len = sizeof(curchan); + + if (ioctl(sock, SIOCG80211, &ireq) >= 0) { + item->conn.channel = curchan.ic_ieee; + item->conn.frequency = curchan.ic_freq; + + if (IEEE80211_IS_CHAN_FHSS(&curchan)) + ffStrbufSetStatic(&item->conn.protocol, "802.11 (FHSS)"); + if (IEEE80211_IS_CHAN_A(&curchan)) + ffStrbufSetStatic(&item->conn.protocol, "802.11a"); + if (IEEE80211_IS_CHAN_B(&curchan)) + ffStrbufSetStatic(&item->conn.protocol, "802.11b"); + if (IEEE80211_IS_CHAN_ANYG(&curchan)) + ffStrbufSetStatic(&item->conn.protocol, "802.11g"); + if (IEEE80211_IS_CHAN_HT(&curchan)) + ffStrbufSetStatic(&item->conn.protocol, "802.11n (Wi-Fi 4)"); + if (IEEE80211_IS_CHAN_VHT(&curchan)) + ffStrbufSetStatic(&item->conn.protocol, "802.11ac (Wi-Fi 5)"); + #ifdef IEEE80211_IS_CHAN_HE // for future use + if (IEEE80211_IS_CHAN_HE(&curchan)) + ffStrbufSetStatic(&item->conn.protocol, "802.11ax (Wi-Fi 6)"); + #endif + } + + union { + struct ieee80211req_sta_req req; + uint8_t buf[1024]; + } stareq = {}; + memcpy(stareq.req.is_u.macaddr, bssid, sizeof(bssid)); + ireq.i_type = IEEE80211_IOC_STA_INFO; + ireq.i_data = &stareq; + ireq.i_len = sizeof(stareq); + + if (ioctl(sock, SIOCG80211, &ireq) >= 0) { + struct ieee80211req_sta_info* sta = stareq.req.info; + if (sta->isi_len != 0) { + item->conn.signalQuality = (sta->isi_rssi >= -50 ? 100 : sta->isi_rssi <= -100 ? 0 : (sta->isi_rssi + 100) * 2); + item->conn.rxRate = sta->isi_txmbps * 0.5; + } + } + + ireq.i_type = IEEE80211_IOC_AUTHMODE; + ireq.i_data = NULL; + ireq.i_len = 0; + if (ioctl(sock, SIOCG80211, &ireq) >= 0) { + switch (ireq.i_val) { + case IEEE80211_AUTH_NONE: + ffStrbufSetStatic(&item->conn.security, "Insecure"); + break; + case IEEE80211_AUTH_OPEN: + ffStrbufSetStatic(&item->conn.security, "Open"); + break; + case IEEE80211_AUTH_SHARED: + ffStrbufSetStatic(&item->conn.security, "Shared"); + break; + case IEEE80211_AUTH_8021X: + ffStrbufSetStatic(&item->conn.security, "8021X"); + break; + case IEEE80211_AUTH_AUTO: + ffStrbufSetStatic(&item->conn.security, "Auto"); + break; + case IEEE80211_AUTH_WPA: + ffStrbufSetStatic(&item->conn.security, "WPA"); + break; + default: + ffStrbufSetF(&item->conn.security, "Unknown (%d)", ireq.i_val); + break; } } } + if_freenameindex(infs); return NULL; } diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index b9dafc001..deadf6dcc 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -4,6 +4,7 @@ #include "common/processing.h" #include "common/properties.h" #include "util/stringUtils.h" +#include "util/debug.h" #include @@ -45,48 +46,77 @@ typedef enum { static const char* detectWifiWithNm(FFWifiResult* item, FFstrbuf* buffer) { + FF_DEBUG("Starting NetworkManager wifi detection for interface %s", item->inf.description.chars); FFDBusData dbus; const char* error = ffDBusLoadData(DBUS_BUS_SYSTEM, &dbus); if(error) + { + FF_DEBUG("Failed to load DBus data: %s", error); return error; + } { + FF_DEBUG("Getting device by IP interface name"); DBusMessage* device = ffDBusGetMethodReply(&dbus, "org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager", "org.freedesktop.NetworkManager", "GetDeviceByIpIface", item->inf.description.chars); if(!device) + { + FF_DEBUG("GetDeviceByIpIface failed for interface %s", item->inf.description.chars); return "Failed to call GetDeviceByIpIface"; + } ffStrbufClear(buffer); DBusMessageIter rootIter; if(!dbus.lib->ffdbus_message_iter_init(device, &rootIter) || !ffDBusGetString(&dbus, &rootIter, buffer)) { + FF_DEBUG("Failed to initialize message iterator or get device path"); dbus.lib->ffdbus_message_unref(device); return "Failed to get device path"; } + FF_DEBUG("Got device path: %s", buffer->chars); dbus.lib->ffdbus_message_unref(device); } if (item->conn.txRate != item->conn.txRate) { + FF_DEBUG("Getting bitrate from NetworkManager"); uint32_t bitrate; if (ffDBusGetPropertyUint(&dbus, "org.freedesktop.NetworkManager", buffer->chars, "org.freedesktop.NetworkManager.Device.Wireless", "Bitrate", &bitrate)) + { item->conn.txRate = bitrate / 1000.; + FF_DEBUG("Got bitrate: %.2f Mbps", item->conn.txRate); + } + else + FF_DEBUG("Failed to get bitrate"); } + FF_DEBUG("Getting active access point path"); FF_STRBUF_AUTO_DESTROY apPath = ffStrbufCreate(); if (!ffDBusGetPropertyString(&dbus, "org.freedesktop.NetworkManager", buffer->chars, "org.freedesktop.NetworkManager.Device.Wireless", "ActiveAccessPoint", &apPath)) + { + FF_DEBUG("Failed to get active access point path"); return "Failed to get active access point path"; + } + FF_DEBUG("Got access point path: %s", apPath.chars); if (!item->conn.status.length) + { ffStrbufSetStatic(&item->conn.status, "connected"); + FF_DEBUG("Setting connection status to 'connected'"); + } + FF_DEBUG("Getting access point properties"); DBusMessage* reply = ffDBusGetAllProperties(&dbus, "org.freedesktop.NetworkManager", apPath.chars, "org.freedesktop.NetworkManager.AccessPoint"); if(reply == NULL) + { + FF_DEBUG("Failed to get access point properties"); return "Failed to get access point properties"; + } DBusMessageIter rootIterator; if(!dbus.lib->ffdbus_message_iter_init(reply, &rootIterator) && dbus.lib->ffdbus_message_iter_get_arg_type(&rootIterator) != DBUS_TYPE_ARRAY) { + FF_DEBUG("Invalid type of access point properties"); dbus.lib->ffdbus_message_unref(reply); return "Invalid type of access point properties"; } @@ -98,6 +128,7 @@ static const char* detectWifiWithNm(FFWifiResult* item, FFstrbuf* buffer) NM80211ApSecurityFlags wpaFlags, rsnFlags; int flagCount = 0; + FF_DEBUG("Parsing access point properties"); while(true) { if(dbus.lib->ffdbus_message_iter_get_arg_type(&arrayIterator) != DBUS_TYPE_DICT_ENTRY) @@ -114,32 +145,49 @@ static const char* detectWifiWithNm(FFWifiResult* item, FFstrbuf* buffer) if (ffStrEquals(key, "Ssid")) { if (!item->conn.ssid.length) + { + FF_DEBUG("Found SSID property"); ffDBusGetString(&dbus, &dictIterator, &item->conn.ssid); + FF_DEBUG("SSID: %s", item->conn.ssid.chars); + } } else if (ffStrEquals(key, "HwAddress")) { if (!item->conn.bssid.length) + { + FF_DEBUG("Found HwAddress property"); ffDBusGetString(&dbus, &dictIterator, &item->conn.bssid); + FF_DEBUG("BSSID: %s", item->conn.bssid.chars); + } } else if (ffStrEquals(key, "Strength")) { if (item->conn.signalQuality != item->conn.signalQuality) { + FF_DEBUG("Found Strength property"); uint32_t strengthPercent; if (ffDBusGetUint(&dbus, &dictIterator, &strengthPercent)) + { item->conn.signalQuality = strengthPercent; + FF_DEBUG("Signal quality: %u%%", strengthPercent); + } } } else if (ffStrEquals(key, "Frequency")) { if (item->conn.frequency == 0) { + FF_DEBUG("Found Frequency property"); uint32_t frequency; if (ffDBusGetUint(&dbus, &dictIterator, &frequency)) { item->conn.frequency = (uint16_t) frequency; + FF_DEBUG("Frequency: %u MHz", item->conn.frequency); if (item->conn.channel == 0) + { item->conn.channel = ffWifiFreqToChannel(item->conn.frequency); + FF_DEBUG("Calculated channel: %u", item->conn.channel); + } } } } @@ -154,40 +202,68 @@ static const char* detectWifiWithNm(FFWifiResult* item, FFstrbuf* buffer) if (flagCount == 3) { + FF_DEBUG("Determining security type from flags (Flags: 0x%08x, WPA: 0x%08x, RSN: 0x%08x)", + flags, wpaFlags, rsnFlags); if ((flags & NM_802_11_AP_FLAGS_PRIVACY) && (wpaFlags == NM_802_11_AP_SEC_NONE) && (rsnFlags == NM_802_11_AP_SEC_NONE)) + { ffStrbufAppendS(&item->conn.security, "WEP/"); + FF_DEBUG("Adding security: WEP"); + } if (wpaFlags != NM_802_11_AP_SEC_NONE) + { ffStrbufAppendS(&item->conn.security, "WPA/"); + FF_DEBUG("Adding security: WPA"); + } if ((rsnFlags & NM_802_11_AP_SEC_KEY_MGMT_PSK) || (rsnFlags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { ffStrbufAppendS(&item->conn.security, "WPA2/"); + FF_DEBUG("Adding security: WPA2"); } if (rsnFlags & NM_802_11_AP_SEC_KEY_MGMT_SAE) { ffStrbufAppendS(&item->conn.security, "WPA3/"); + FF_DEBUG("Adding security: WPA3"); } if ((rsnFlags & NM_802_11_AP_SEC_KEY_MGMT_OWE) || (rsnFlags & NM_802_11_AP_SEC_KEY_MGMT_OWE_TM)) { ffStrbufAppendS(&item->conn.security, "OWE/"); + FF_DEBUG("Adding security: OWE"); } if ((wpaFlags & NM_802_11_AP_SEC_KEY_MGMT_802_1X) || (rsnFlags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { ffStrbufAppendS(&item->conn.security, "802.1X/"); + FF_DEBUG("Adding security: 802.1X"); } if (!item->conn.security.length) + { ffStrbufAppendS(&item->conn.security, "Insecure"); + FF_DEBUG("No security detected, marking as 'Insecure'"); + } else + { ffStrbufTrimRight(&item->conn.security, '/'); + FF_DEBUG("Final security string: %s", item->conn.security.chars); + } + + if (wpaFlags & NM_802_11_AP_SEC_PAIR_TKIP || rsnFlags & NM_802_11_AP_SEC_PAIR_TKIP) { + FF_DEBUG("Detected TKIP encryption"); + } + if (wpaFlags & NM_802_11_AP_SEC_PAIR_CCMP || rsnFlags & NM_802_11_AP_SEC_PAIR_CCMP) { + FF_DEBUG("Detected CCMP/AES encryption"); + } } + FF_DEBUG("NetworkManager wifi detection completed successfully"); return NULL; } #endif // FF_HAVE_DBUS static const char* detectWifiWithIw(FFWifiResult* item, FFstrbuf* buffer) { + FF_DEBUG("Starting iw wifi detection for interface %s", item->inf.description.chars); const char* error = NULL; FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate(); + FF_DEBUG("Executing 'iw dev %s link'", item->inf.description.chars); if((error = ffProcessAppendStdOut(&output, (char* const[]){ "iw", "dev", @@ -195,48 +271,79 @@ static const char* detectWifiWithIw(FFWifiResult* item, FFstrbuf* buffer) "link", NULL }))) + { + FF_DEBUG("iw command execution failed: %s", error); return error; + } if(output.length == 0) + { + FF_DEBUG("iw command output is empty"); return "iw command execution failed"; + } if(!ffParsePropLines(output.chars, "Connected to ", &item->conn.bssid)) { + FF_DEBUG("Not connected to any access point"); ffStrbufAppendS(&item->conn.status, "disconnected"); return NULL; } + FF_DEBUG("Connected to an access point"); ffStrbufAppendS(&item->conn.status, "connected"); ffStrbufSubstrBeforeFirstC(&item->conn.bssid, ' '); ffStrbufUpperCase(&item->conn.bssid); + FF_DEBUG("BSSID: %s", item->conn.bssid.chars); - ffParsePropLines(output.chars, "SSID: ", &item->conn.ssid); + if(ffParsePropLines(output.chars, "SSID: ", &item->conn.ssid)) + FF_DEBUG("SSID: %s", item->conn.ssid.chars); + else + FF_DEBUG("SSID not found in iw output"); ffStrbufClear(buffer); if(ffParsePropLines(output.chars, "signal: ", buffer)) { int level = (int) ffStrbufToSInt(buffer, INT_MAX); if (level != INT_MAX) + { item->conn.signalQuality = level >= -50 ? 100 : level <= -100 ? 0 : (level + 100) * 2; + FF_DEBUG("Signal level: %d dBm, quality: %.0f%%", level, item->conn.signalQuality); + } } ffStrbufClear(buffer); if(ffParsePropLines(output.chars, "rx bitrate: ", buffer)) + { item->conn.rxRate = ffStrbufToDouble(buffer); + FF_DEBUG("RX bitrate: %.2f Mbps", item->conn.rxRate); + } ffStrbufClear(buffer); if(ffParsePropLines(output.chars, "tx bitrate: ", buffer)) { item->conn.txRate = ffStrbufToDouble(buffer); + FF_DEBUG("TX bitrate: %.2f Mbps (raw: %s)", item->conn.txRate, buffer->chars); if(ffStrbufContainS(buffer, " EHT-MCS ")) + { ffStrbufSetStatic(&item->conn.protocol, "802.11be (Wi-Fi 7)"); + FF_DEBUG("Detected protocol: Wi-Fi 7"); + } else if(ffStrbufContainS(buffer, " HE-MCS ")) + { ffStrbufSetStatic(&item->conn.protocol, "802.11ax (Wi-Fi 6)"); + FF_DEBUG("Detected protocol: Wi-Fi 6"); + } else if(ffStrbufContainS(buffer, " VHT-MCS ")) + { ffStrbufSetStatic(&item->conn.protocol, "802.11ac (Wi-Fi 5)"); + FF_DEBUG("Detected protocol: Wi-Fi 5"); + } else if(ffStrbufContainS(buffer, " MCS ")) + { ffStrbufSetStatic(&item->conn.protocol, "802.11n (Wi-Fi 4)"); + FF_DEBUG("Detected protocol: Wi-Fi 4"); + } } ffStrbufClear(buffer); @@ -244,8 +351,10 @@ static const char* detectWifiWithIw(FFWifiResult* item, FFstrbuf* buffer) { item->conn.frequency = (uint16_t) ffStrbufToUInt(buffer, 0); item->conn.channel = ffWifiFreqToChannel(item->conn.frequency); + FF_DEBUG("Frequency: %u MHz, Channel: %u", item->conn.frequency, item->conn.channel); } + FF_DEBUG("iw wifi detection completed successfully"); return NULL; } @@ -257,12 +366,19 @@ static const char* detectWifiWithIw(FFWifiResult* item, FFstrbuf* buffer) static const char* detectWifiWithIoctls(FFWifiResult* item) { + FF_DEBUG("Starting ioctl wifi detection for interface %s", item->inf.description.chars); FF_AUTO_CLOSE_FD int sock = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); if(sock < 0) + { + FF_DEBUG("Failed to create socket: %m"); return "socket() failed"; + } struct iwreq iwr; ffStrCopy(iwr.ifr_name, item->inf.description.chars, IFNAMSIZ); + + // Get SSID + FF_DEBUG("Getting SSID via ioctl"); ffStrbufEnsureFree(&item->conn.ssid, IW_ESSID_MAX_SIZE); iwr.u.essid.pointer = (caddr_t) item->conn.ssid.chars; iwr.u.essid.length = IW_ESSID_MAX_SIZE + 1; @@ -271,31 +387,54 @@ static const char* detectWifiWithIoctls(FFWifiResult* item) { ffStrbufSetStatic(&item->conn.status, "connected"); ffStrbufRecalculateLength(&item->conn.ssid); + FF_DEBUG("SSID: %s", item->conn.ssid.chars); } + else + FF_DEBUG("Failed to get SSID via ioctl: %m"); + // Get protocol name + FF_DEBUG("Getting protocol name via ioctl"); if(ioctl(sock, SIOCGIWNAME, &iwr) >= 0 && !ffStrEqualsIgnCase(iwr.u.name, "IEEE 802.11")) { if(ffStrStartsWithIgnCase(iwr.u.name, "IEEE ")) ffStrbufSetS(&item->conn.protocol, iwr.u.name + strlen("IEEE ")); else ffStrbufSetS(&item->conn.protocol, iwr.u.name); + FF_DEBUG("Protocol: %s", item->conn.protocol.chars); } + else + FF_DEBUG("Failed to get protocol name via ioctl: %m"); + // Get BSSID + FF_DEBUG("Getting BSSID via ioctl"); if(ioctl(sock, SIOCGIWAP, &iwr) >= 0) { for(int i = 0; i < 6; ++i) ffStrbufAppendF(&item->conn.bssid, "%.2X:", (uint8_t) iwr.u.ap_addr.sa_data[i]); ffStrbufTrimRight(&item->conn.bssid, ':'); + FF_DEBUG("BSSID: %s", item->conn.bssid.chars); } + else + FF_DEBUG("Failed to get BSSID via ioctl: %m"); + // Get bitrate + FF_DEBUG("Getting bitrate via ioctl"); if(ioctl(sock, SIOCGIWRATE, &iwr) >= 0) + { item->conn.txRate = iwr.u.bitrate.value / 1000000.; + FF_DEBUG("TX bitrate: %.2f Mbps", item->conn.txRate); + } + else + FF_DEBUG("Failed to get bitrate via ioctl: %m"); + // Get frequency/channel + FF_DEBUG("Getting frequency via ioctl"); if(ioctl(sock, SIOCGIWFREQ, &iwr) >= 0) { if (iwr.u.freq.e == 0 && iwr.u.freq.m <= 1000) { item->conn.channel = (uint16_t) iwr.u.freq.m; + FF_DEBUG("Direct channel value: %u", item->conn.channel); } else { @@ -312,9 +451,14 @@ static const char* detectWifiWithIoctls(FFWifiResult* item) } item->conn.frequency = (uint16_t) iwr.u.freq.m; item->conn.channel = ffWifiFreqToChannel(item->conn.frequency); + FF_DEBUG("Frequency: %u MHz, Channel: %u", item->conn.frequency, item->conn.channel); } } + else + FF_DEBUG("Failed to get frequency via ioctl: %m"); + // Get signal strength + FF_DEBUG("Getting signal stats via ioctl"); struct iw_statistics stats; iwr.u.data.pointer = &stats; iwr.u.data.length = sizeof(stats); @@ -322,11 +466,15 @@ static const char* detectWifiWithIoctls(FFWifiResult* item) if(ioctl(sock, SIOCGIWSTATS, &iwr) >= 0) { - int8_t level = (int8_t) stats.qual.level; // https://stackoverflow.com/questions/18079771/wireless-h-how-do-i-print-out-the-signal-level + int8_t level = (int8_t) stats.qual.level; item->conn.signalQuality = level >= -50 ? 100 : level <= -100 ? 0 : (level + 100) * 2; + FF_DEBUG("Signal level: %d dBm, quality: %.0f%%", level, item->conn.signalQuality); } + else + FF_DEBUG("Failed to get signal stats via ioctl: %m"); - //FIXME: doesn't work + // Get security info + FF_DEBUG("Getting security info via ioctl"); struct iw_encode_ext iwe; iwr.u.data.pointer = &iwe; iwr.u.data.length = sizeof(iwe); @@ -337,43 +485,61 @@ static const char* detectWifiWithIoctls(FFWifiResult* item) { case IW_ENCODE_ALG_WEP: ffStrbufAppendS(&item->conn.security, "WEP"); + FF_DEBUG("Security: WEP"); break; case IW_ENCODE_ALG_TKIP: ffStrbufAppendS(&item->conn.security, "TKIP"); + FF_DEBUG("Security: TKIP"); break; case IW_ENCODE_ALG_CCMP: ffStrbufAppendS(&item->conn.security, "CCMP"); + FF_DEBUG("Security: CCMP"); break; case IW_ENCODE_ALG_PMK: ffStrbufAppendS(&item->conn.security, "PMK"); + FF_DEBUG("Security: PMK"); break; case IW_ENCODE_ALG_AES_CMAC: ffStrbufAppendS(&item->conn.security, "CMAC"); + FF_DEBUG("Security: CMAC"); break; default: ffStrbufAppendF(&item->conn.security, "Unknown (%d)", (int) iwe.alg); + FF_DEBUG("Security: Unknown (%d)", (int) iwe.alg); break; } } + else + FF_DEBUG("Failed to get security info via ioctl: %m"); + FF_DEBUG("ioctl wifi detection completed"); return NULL; } #endif // FF_HAVE_LINUX_WIRELESS const char* ffDetectWifi(FF_MAYBE_UNUSED FFlist* result) { + FF_DEBUG("Starting wifi detection"); struct if_nameindex* infs = if_nameindex(); if(!infs) + { + FF_DEBUG("if_nameindex() failed: %m"); return "if_nameindex() failed"; + } FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); for(struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i) { + FF_DEBUG("Checking interface: %s (index: %u)", i->if_name, i->if_index); ffStrbufSetF(&buffer, "/sys/class/net/%s/phy80211/", i->if_name); if(!ffPathExists(buffer.chars, FF_PATHTYPE_DIRECTORY)) + { + FF_DEBUG("Not a wifi interface (no phy80211 directory)"); continue; + } + FF_DEBUG("Found wifi interface: %s", i->if_name); FFWifiResult* item = (FFWifiResult*)ffListAdd(result); ffStrbufInitS(&item->inf.description, i->if_name); ffStrbufInit(&item->inf.status); @@ -390,24 +556,36 @@ const char* ffDetectWifi(FF_MAYBE_UNUSED FFlist* result) ffStrbufSetF(&buffer, "/sys/class/net/%s/operstate", i->if_name); if (!ffAppendFileBuffer(buffer.chars, &item->inf.status)) + { + FF_DEBUG("Failed to read operstate file"); continue; + } ffStrbufTrimRightSpace(&item->inf.status); + FF_DEBUG("Interface status: %s", item->inf.status.chars); if (!ffStrbufEqualS(&item->inf.status, "up")) + { + FF_DEBUG("Skipping interface as it's not up"); continue; + } + FF_DEBUG("Trying to detect wifi with iw"); if (detectWifiWithIw(item, &buffer) != NULL) { + FF_DEBUG("iw detection failed, trying fallback methods"); #ifdef FF_HAVE_LINUX_WIRELESS + FF_DEBUG("Trying to detect wifi with ioctls"); detectWifiWithIoctls(item); #endif } #ifdef FF_HAVE_DBUS + FF_DEBUG("Enhancing wifi info with NetworkManager"); detectWifiWithNm(item, &buffer); #endif } if_freenameindex(infs); + FF_DEBUG("Wifi detection completed, found %u wifi interfaces", result->length); return NULL; } diff --git a/src/detection/wm/wm_apple.m b/src/detection/wm/wm_apple.m index c2395d811..fba7b3f22 100644 --- a/src/detection/wm/wm_apple.m +++ b/src/detection/wm/wm_apple.m @@ -16,6 +16,7 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) FF_AUTO_FREE struct kinfo_proc* processes = ffSysctlGetData(request, requestLength, &length); if(processes == NULL) return "sysctl(CTL_KERN, KERN_PROC, KERN_PROC_ALL) failed"; + assert(length % sizeof(struct kinfo_proc) == 0); for(size_t i = 0; i < length / sizeof(struct kinfo_proc); i++) { diff --git a/src/detection/wm/wm_linux.c b/src/detection/wm/wm_linux.c index 2c249484a..42c205dce 100644 --- a/src/detection/wm/wm_linux.c +++ b/src/detection/wm/wm_linux.c @@ -6,42 +6,90 @@ #include "util/binary.h" #include "util/path.h" #include "util/stringUtils.h" +#include "util/debug.h" const char* ffDetectWMPlugin(FF_MAYBE_UNUSED FFstrbuf* pluginName) { return "Not supported on this platform"; } -static bool extractHyprlandVersion(const char* line, FF_MAYBE_UNUSED uint32_t len, void *userdata) +static bool extractHyprlandVersion(const char* line, uint32_t len, void *userdata) { if (line[0] != 'v') return true; + ++line; --len; int count = 0; - sscanf(line + 1, "%*d.%*d.%*d%n", &count); + sscanf(line, "%*d.%*d.%*d%n", &count); if (count == 0) return true; - ffStrbufSetNS((FFstrbuf*) userdata, len - 1, line + 1); + ffStrbufSetNS((FFstrbuf*) userdata, len, line); return false; } static const char* getHyprland(FFstrbuf* result) { - FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); - const char* error = ffFindExecutableInPath("Hyprland", &path); - if (error) return "Failed to find Hyprland executable path"; + FF_DEBUG("Detecting Hyprland version"); + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); - if (ffBinaryExtractStrings(path.chars, extractHyprlandVersion, result, (uint32_t) strlen("v0.0.0")) == NULL) + FF_DEBUG("Checking for " FASTFETCH_TARGET_DIR_USR "/include/hyprland/src/version.h" " file"); + if (ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/include/hyprland/src/version.h", result)) + { + FF_DEBUG("Found version.h file, extracting version"); + if (ffStrbufSubstrAfterFirstS(result, "\n#define GIT_TAG ")) + { + ffStrbufSubstrAfterFirstC(result, '"'); + ffStrbufSubstrBeforeFirstC(result, '"'); + FF_DEBUG("Extracted version from version.h: %s", result->chars); + return NULL; + } + FF_DEBUG("Failed to extract version from version.h"); + ffStrbufClear(result); + } + else + { + FF_DEBUG("version.h file not found, trying Hyprland executable"); + } + + const char* error = ffFindExecutableInPath("Hyprland", &buffer); + if (error) { + FF_DEBUG("Error finding Hyprland executable: %s", error); + return "Failed to find Hyprland executable path"; + } + FF_DEBUG("Found Hyprland executable at: %s", buffer.chars); + + ffBinaryExtractStrings(buffer.chars, extractHyprlandVersion, result, (uint32_t) strlen("v0.0.0")); + if (result->length > 0) { + FF_DEBUG("Extracted version from binary strings: %s", result->chars); return NULL; + } + FF_DEBUG("Failed to extract version from binary strings, trying --version option"); if (ffProcessAppendStdOut(result, (char* const[]){ - path.chars, + buffer.chars, "--version", NULL }) == NULL) - { // Hyprland 0.46.2 built from branch v0.46.2-b at... long and multi line - ffStrbufSubstrAfterFirstC(result, ' '); - ffStrbufSubstrBeforeFirstC(result, ' '); + { + // Hyprland 0.48.1 built from branch at commit 29e2e59... + // Date: ... + // Tag: v0.48.1, commits: 5937 + // ... + + FF_DEBUG("Raw version output: %s", result->chars); + // Use tag if available + if (ffStrbufSubstrAfterFirstS(result, "\nTag: v")) + { + ffStrbufSubstrBeforeFirstC(result, ','); + FF_DEBUG("Extracted version from Tag: %s", result->chars); + } + else + { + ffStrbufSubstrAfterFirstC(result, ' '); + ffStrbufSubstrBeforeFirstC(result, ' '); + FF_DEBUG("Extracted version from output: %s", result->chars); + } return NULL; } + FF_DEBUG("Failed to run Hyprland --version command"); return "Failed to run command `Hyprland --version`"; } @@ -50,7 +98,9 @@ static bool extractSwayVersion(const char* line, FF_MAYBE_UNUSED uint32_t len, v { if (!ffStrStartsWith(line, "sway version ")) return true; - ffStrbufSetNS((FFstrbuf*) userdata, len - (uint32_t) strlen("sway version "), line + strlen("sway version ")); + FFstrbuf* result = (FFstrbuf*) userdata; + ffStrbufSetNS(result, len - (uint32_t) strlen("sway version "), line + strlen("sway version ")); + ffStrbufTrimRightSpace(result); return false; } @@ -60,11 +110,8 @@ static const char* getSway(FFstrbuf* result) const char* error = ffFindExecutableInPath("sway", &path); if (error) return "Failed to find sway executable path"; - if (ffBinaryExtractStrings(path.chars, extractSwayVersion, result, (uint32_t) strlen("v0.0.0")) == NULL) - { - ffStrbufTrimRightSpace(result); - return NULL; - } + ffBinaryExtractStrings(path.chars, extractSwayVersion, result, (uint32_t) strlen("v0.0.0")); + if (result->length > 0) return NULL; if (ffProcessAppendStdOut(result, (char* const[]){ path.chars, diff --git a/src/fastfetch.c b/src/fastfetch.c index 3c8245abe..32cebc613 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -472,9 +472,22 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val if (parseJsoncFile(value)) return; + FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(128); + + //Try to load as a relative path with the directory of fastfetch binary + if (instance.state.platform.exePath.length) + { + ffStrbufSet(&absolutePath, &instance.state.platform.exePath); + ffStrbufSubstrBeforeLastC(&absolutePath, '/'); + ffStrbufAppendS(&absolutePath, "/"); + ffStrbufAppendS(&absolutePath, value); + + if (parseJsoncFile(absolutePath.chars)) return; + ffStrbufClear(&absolutePath); + } + //Try to load as a relative path - FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(128); FF_LIST_FOR_EACH(FFstrbuf, path, instance.state.platform.dataDirs) { //We need to copy it, because if a config file loads a config file, the value of path must be unchanged @@ -492,23 +505,6 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val if (success) return; } - { - //Try exe path - ffStrbufSet(&absolutePath, &instance.state.platform.exePath); - ffStrbufSubstrBeforeLastC(&absolutePath, '/'); - ffStrbufAppendS(&absolutePath, "/presets/"); - ffStrbufAppendS(&absolutePath, value); - - bool success = parseJsoncFile(absolutePath.chars); - if (!success) - { - ffStrbufAppendS(&absolutePath, ".jsonc"); - success = parseJsoncFile(absolutePath.chars); - } - - if (success) return; - } - //File not found fprintf(stderr, "Error: couldn't find config: %s\n", value); diff --git a/src/logo/ascii/xray_os.txt b/src/logo/ascii/ada.txt similarity index 100% rename from src/logo/ascii/xray_os.txt rename to src/logo/ascii/ada.txt diff --git a/src/logo/ascii/nexalinux.txt b/src/logo/ascii/nexalinux.txt index 4372a7507..c1ff9cf63 100644 --- a/src/logo/ascii/nexalinux.txt +++ b/src/logo/ascii/nexalinux.txt @@ -1,19 +1,19 @@ - ******** - ***************** - ********************** - ************************** -********** ********** -******* ********* -****** ******** -******* ******* -********* ****** ******* - ***************** ****** - *************** ******* - *********** ******* - ******** - ******** - ********* - ********** - ********* - ******* - *** + + **** + ********** + ****************** + ************************ + ****************************** + *************** *************** + ************ **** #*********** + ********* ********** ********* + ****** #****************# #***** + * ************************ *# + ****************************** + #************** **************# + ************ **** ************ + ********* ********** ********* + *** **************** *** + ********************** + ******************** + ***** ***** \ No newline at end of file diff --git a/src/logo/ascii/wii_linux_ngx.txt b/src/logo/ascii/wii_linux.txt similarity index 100% rename from src/logo/ascii/wii_linux_ngx.txt rename to src/logo/ascii/wii_linux.txt diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 19dffec73..b60a94b80 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -13,6 +13,17 @@ const FFlogo ffLogoUnknown = { }; static const FFlogo A[] = { + //Ada + { + .names = {"Ada"}, + .lines = FASTFETCH_DATATEXT_LOGO_ADA, + .colors = { + FF_COLOR_FG_256 "15", + FF_COLOR_FG_256 "14", + FF_COLOR_FG_256 "16", + FF_COLOR_FG_256 "24", + } + }, // Adélie { .names = {"Adélie", "Adelie"}, @@ -3395,7 +3406,7 @@ static const FFlogo O[] = { // OpenSuseTumbleweedSmall { .names = {"opensuse-tumbleweed_small"}, - .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED, + .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED_SMALL, .type = FF_LOGO_LINE_TYPE_SMALL_BIT, .colors = { FF_COLOR_FG_WHITE, @@ -4995,10 +5006,10 @@ static const FFlogo V[] = { }; static const FFlogo W[] = { - // WiiLinuxNgx + // WiiLinux { - .names = {"WiiLinuxNgx"}, - .lines = FASTFETCH_DATATEXT_LOGO_WII_LINUX_NGX, + .names = {"WiiLinuxNgx", "WiiLinux", "Wii-Linux", "Wii Linux"}, + .lines = FASTFETCH_DATATEXT_LOGO_WII_LINUX, .colors = { FF_COLOR_FG_CYAN, FF_COLOR_FG_WHITE, @@ -5144,17 +5155,6 @@ static const FFlogo X[] = { FF_COLOR_FG_256 "15", } }, - //Xray_OS - { - .names = {"Xray_OS"}, - .lines = FASTFETCH_DATATEXT_LOGO_XRAY_OS, - .colors = { - FF_COLOR_FG_256 "15", - FF_COLOR_FG_256 "14", - FF_COLOR_FG_256 "16", - FF_COLOR_FG_256 "24", - } - }, // LAST {}, }; diff --git a/src/modules/bootmgr/bootmgr.c b/src/modules/bootmgr/bootmgr.c index 70e081e00..19162f15a 100644 --- a/src/modules/bootmgr/bootmgr.c +++ b/src/modules/bootmgr/bootmgr.c @@ -42,6 +42,7 @@ void ffPrintBootmgr(FFBootmgrOptions* options) FF_FORMAT_ARG(bootmgr.firmware, "firmware-path"), FF_FORMAT_ARG(firmwareName, "firmware-name"), FF_FORMAT_ARG(bootmgr.secureBoot, "secure-boot"), + FF_FORMAT_ARG(bootmgr.order, "order"), })); } @@ -102,6 +103,7 @@ void ffGenerateBootmgrJsonResult(FF_MAYBE_UNUSED FFBootmgrOptions* options, yyjs yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result"); yyjson_mut_obj_add_strbuf(doc, obj, "name", &bootmgr.name); yyjson_mut_obj_add_strbuf(doc, obj, "firmware", &bootmgr.firmware); + yyjson_mut_obj_add_uint(doc, obj, "order", bootmgr.order); yyjson_mut_obj_add_bool(doc, obj, "secureBoot", bootmgr.secureBoot); exit: @@ -122,6 +124,7 @@ static FFModuleBaseInfo ffModuleInfo = { {"Firmware file path", "firmware-path"}, {"Firmware file name", "firmware-name"}, {"Is secure boot enabled", "secure-boot"}, + {"Boot order", "order"}, })) }; diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index e8cf55cae..9049e7afb 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -153,6 +153,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu FF_FORMAT_ARG(sPercentBar, "shared-percentage-bar"), FF_FORMAT_ARG(coreUsageNum, "core-usage-num"), FF_FORMAT_ARG(coreUsageBar, "core-usage-bar"), + FF_FORMAT_ARG(gpu->memoryType, "memory-type"), })); } } @@ -193,6 +194,7 @@ void ffPrintGPU(FFGPUOptions* options) ffStrbufDestroy(&gpu->name); ffStrbufDestroy(&gpu->driver); ffStrbufDestroy(&gpu->platformApi); + ffStrbufDestroy(&gpu->memoryType); } } @@ -398,9 +400,6 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_ else yyjson_mut_obj_add_null(doc, dedicatedObj, "used"); - yyjson_mut_obj_add_strbuf(doc, obj, "driver", &gpu->driver); - yyjson_mut_obj_add_strbuf(doc, obj, "name", &gpu->name); - yyjson_mut_val* sharedObj = yyjson_mut_obj_add_obj(doc, memoryObj, "shared"); if (gpu->shared.total != FF_GPU_VMEM_SIZE_UNSET) yyjson_mut_obj_add_uint(doc, sharedObj, "total", gpu->shared.total); @@ -411,6 +410,14 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_ else yyjson_mut_obj_add_null(doc, sharedObj, "used"); + if (gpu->memoryType.length) + yyjson_mut_obj_add_strbuf(doc, memoryObj, "type", &gpu->memoryType); + else + yyjson_mut_obj_add_null(doc, memoryObj, "type"); + + yyjson_mut_obj_add_strbuf(doc, obj, "driver", &gpu->driver); + yyjson_mut_obj_add_strbuf(doc, obj, "name", &gpu->name); + if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET yyjson_mut_obj_add_real(doc, obj, "temperature", gpu->temperature); else @@ -440,6 +447,7 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_ ffStrbufDestroy(&gpu->name); ffStrbufDestroy(&gpu->driver); ffStrbufDestroy(&gpu->platformApi); + ffStrbufDestroy(&gpu->memoryType); } } @@ -469,8 +477,9 @@ static FFModuleBaseInfo ffModuleInfo = { {"Dedicated memory usage percentage bar", "dedicated-percentage-bar"}, {"Shared memory usage percentage num", "shared-percentage-num"}, {"Shared memory usage percentage bar", "shared-percentage-bar"}, - {"Core usage percentage num (supports Nvidia & Apple GPU only)", "core-usage-num"}, - {"Core usage percentage bar (supports Nvidia & Apple GPU only)", "core-usage-bar"}, + {"Core usage percentage num", "core-usage-num"}, + {"Core usage percentage bar", "core-usage-bar"}, + {"Memory type (Windows only)", "memory-type"}, })), }; diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index 2500ab32d..e1a5d1b30 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -26,7 +26,7 @@ static void formatKey(const FFLocalIpOptions* options, FFLocalIpResult* ip, uint ffStrbufClear(key); FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, ((FFformatarg[]) { FF_FORMAT_ARG(index, "index"), - FF_FORMAT_ARG(ip->name, "name"), + FF_FORMAT_ARG(ip->name, "ifname"), FF_FORMAT_ARG(ip->mac, "mac"), FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index 28ecdac8a..29dd5db41 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -36,6 +36,9 @@ void ffPrintSeparator(FFSeparatorOptions* options) { ffLogoPrintLine(); + if(options->outputColor.length && !instance.config.display.pipe) + ffPrintColor(&options->outputColor); + if (options->length > 0) { if(__builtin_expect(options->string.length == 1, 1)) @@ -47,68 +50,67 @@ void ffPrintSeparator(FFSeparatorOptions* options) fputs(options->string.chars, stdout); } } - putchar('\n'); - return; - } - - setlocale(LC_CTYPE, ""); - mbstate_t state = {}; - bool fqdn = instance.config.modules.title.fqdn; - const FFPlatform* platform = &instance.state.platform; - - FF_AUTO_FREE wchar_t* wstr = malloc((max( - platform->userName.length, options->string.length) + 1) * sizeof(*wstr)); - - uint32_t titleLength = 1 // @ - + getWcsWidth(&platform->userName, wstr, &state) // user name - + (fqdn ? platform->hostName.length : ffStrbufFirstIndexC(&platform->hostName, '.')); // host name - - if(options->outputColor.length && !instance.config.display.pipe) - ffPrintColor(&options->outputColor); - if(__builtin_expect(options->string.length == 1, 1)) - { - ffPrintCharTimes(options->string.chars[0], titleLength); } else { - uint32_t wcsLength = getWcsWidth(&options->string, wstr, &state); + setlocale(LC_CTYPE, ""); + mbstate_t state = {}; + bool fqdn = instance.config.modules.title.fqdn; + const FFPlatform* platform = &instance.state.platform; - int remaining = (int) titleLength; - //Write the whole separator as often as it fits fully into titleLength - for (; remaining >= (int) wcsLength; remaining -= (int) wcsLength) - ffStrbufWriteTo(&options->string, stdout); + FF_AUTO_FREE wchar_t* wstr = malloc((max( + platform->userName.length, options->string.length) + 1) * sizeof(*wstr)); - if (remaining > 0) + uint32_t titleLength = 1 // @ + + getWcsWidth(&platform->userName, wstr, &state) // user name + + (fqdn ? platform->hostName.length : ffStrbufFirstIndexC(&platform->hostName, '.')); // host name + + if(__builtin_expect(options->string.length == 1, 1)) { - //Write as much of the separator as needed to fill titleLength - if (wcsLength != options->string.length) + ffPrintCharTimes(options->string.chars[0], titleLength); + } + else + { + uint32_t wcsLength = getWcsWidth(&options->string, wstr, &state); + + int remaining = (int) titleLength; + //Write the whole separator as often as it fits fully into titleLength + for (; remaining >= (int) wcsLength; remaining -= (int) wcsLength) + ffStrbufWriteTo(&options->string, stdout); + + if (remaining > 0) { - // Unicode chars - for(int i = 0; remaining > 0; ++i) + //Write as much of the separator as needed to fill titleLength + if (wcsLength != options->string.length) { - #ifdef __linux__ - // https://stackoverflow.com/questions/75126743/i-have-difficulties-with-putwchar-in-c#answer-75137784 - char wch[16] = ""; - uint32_t wchLength = (uint32_t) wcrtomb(wch, wstr[i], &state); - fwrite(wch, wchLength, 1, stdout); - #else - putwchar(wstr[i]); - #endif - int width = mk_wcwidth(wstr[i]); - remaining -= width < 0 ? 0 : width; + // Unicode chars + for(int i = 0; remaining > 0; ++i) + { + #ifdef __linux__ + // https://stackoverflow.com/questions/75126743/i-have-difficulties-with-putwchar-in-c#answer-75137784 + char wch[16] = ""; + uint32_t wchLength = (uint32_t) wcrtomb(wch, wstr[i], &state); + fwrite(wch, wchLength, 1, stdout); + #else + putwchar(wstr[i]); + #endif + int width = mk_wcwidth(wstr[i]); + remaining -= width < 0 ? 0 : width; + } + } + else + { + for(int i = 0; i < remaining; i++) + putchar(options->string.chars[i]); } } - else - { - for(int i = 0; i < remaining; i++) - putchar(options->string.chars[i]); - } } + setlocale(LC_CTYPE, "C"); } + if(options->outputColor.length && !instance.config.display.pipe) fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); putchar('\n'); - setlocale(LC_CTYPE, "C"); } bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key, const char* value) diff --git a/src/util/FFlist.h b/src/util/FFlist.h index a4b2f64c4..d15f14f80 100644 --- a/src/util/FFlist.h +++ b/src/util/FFlist.h @@ -11,7 +11,7 @@ typedef struct FFlist { - char* data; + uint8_t* data; uint32_t elementSize; uint32_t length; uint32_t capacity; @@ -37,7 +37,7 @@ static inline void ffListInitA(FFlist* list, uint32_t elementSize, uint32_t capa { ffListInit(list, elementSize); list->capacity = capacity; - list->data = __builtin_expect(capacity == 0, 0) ? NULL : (char*) malloc((size_t)list->capacity * list->elementSize); + list->data = __builtin_expect(capacity == 0, 0) ? NULL : (uint8_t*) malloc((size_t)list->capacity * list->elementSize); } static inline FFlist ffListCreate(uint32_t elementSize) diff --git a/src/util/apple/cf_helpers.h b/src/util/apple/cf_helpers.h index c509bd574..5f6cb291c 100644 --- a/src/util/apple/cf_helpers.h +++ b/src/util/apple/cf_helpers.h @@ -28,7 +28,7 @@ static inline void cfReleaseWrapper(void* type) #define FF_CFTYPE_AUTO_RELEASE __attribute__((__cleanup__(cfReleaseWrapper))) -static inline void wrapIoObjectRelease(io_service_t* service) +static inline void wrapIoObjectRelease(io_object_t* service) { assert(service); if (*service) diff --git a/src/util/binary.h b/src/util/binary.h index 9ef0ac7e1..2d2d7849b 100644 --- a/src/util/binary.h +++ b/src/util/binary.h @@ -2,4 +2,17 @@ #include "fastfetch.h" +/** + * Extracts string literals from a binary file + * + * @param file Path to the binary file to extract strings from + * @param cb Callback function that will be called for each string found + * Return false from callback to stop extraction + * @param userdata User-provided data passed to the callback function + * @param minLength Minimum length of strings to extract + * + * @return NULL on success, error message on failure. + * @note This function won't return an error if no strings are found. + * Always check if strings are correctly extracted after this function all. + */ const char* ffBinaryExtractStrings(const char* file, bool (*cb)(const char* str, uint32_t len, void* userdata), void* userdata, uint32_t minLength); diff --git a/src/util/binary_apple.c b/src/util/binary_apple.c index 6efeb5d5a..9ee0ace96 100644 --- a/src/util/binary_apple.c +++ b/src/util/binary_apple.c @@ -14,12 +14,28 @@ // Ref: https://github.com/AlexDenisov/segment_dumper/blob/master/main.c +/** + * Helper function to read data from a file at a specific offset + */ static inline bool readData(FILE *objFile, void *buf, size_t size, off_t offset) { fseek(objFile, offset, SEEK_SET); return fread(buf, 1, size, objFile) == size; } +/** + * Handles a Mach-O section by extracting strings from the __cstring section + * + * @param objFile File handle to the Mach-O object file + * @param name Section name to check + * @param offset Offset of the section in the file + * @param size Size of the section + * @param cb Callback function to process strings + * @param userdata User data for the callback + * @param minLength Minimum string length to extract + * + * @return true to continue processing, false to stop + */ static bool handleMachSection(FILE *objFile, const char *name, off_t offset, size_t size, bool (*cb)(const char *str, uint32_t len, void *userdata), void *userdata, uint32_t minLength) { if (!ffStrEquals(name, "__cstring")) return true; @@ -43,6 +59,22 @@ static bool handleMachSection(FILE *objFile, const char *name, off_t offset, siz return true; } +/** + * Processes a Mach-O header (32-bit or 64-bit) + * + * This function parses the load commands in a Mach-O header, looking for + * LC_SEGMENT or LC_SEGMENT_64 commands that contain the __TEXT segment. + * It then processes the sections within that segment to extract strings. + * + * @param objFile File handle to the Mach-O object file + * @param offset Offset of the Mach header in the file + * @param is_64 Whether this is a 64-bit Mach-O header + * @param cb Callback function to process strings + * @param userdata User data for the callback + * @param minLength Minimum string length to extract + * + * @return NULL on success, error message on failure + */ static const char* dumpMachHeader(FILE *objFile, off_t offset, bool is_64, bool (*cb)(const char *str, uint32_t len, void *userdata), void *userdata, uint32_t minLength) { uint32_t ncmds; @@ -117,6 +149,20 @@ static const char* dumpMachHeader(FILE *objFile, off_t offset, bool is_64, bool return NULL; } +/** + * Processes a Fat binary header (Universal binary) + * + * This function handles the fat header of a universal binary, which can contain + * multiple Mach-O binaries for different architectures. It extracts and processes + * each embedded Mach-O file. + * + * @param objFile File handle to the universal binary + * @param cb Callback function to process strings + * @param userdata User data for the callback + * @param minLength Minimum string length to extract + * + * @return NULL on success, error message on failure + */ static const char* dumpFatHeader(FILE *objFile, bool (*cb)(const char *str, uint32_t len, void *userdata), void *userdata, uint32_t minLength) { struct fat_header header; @@ -165,21 +211,32 @@ static const char* dumpFatHeader(FILE *objFile, bool (*cb)(const char *str, uint return "Unsupported fat header"; } +/** + * Extracts string literals from a Mach-O (Apple) binary file + * + * This function supports both single-architecture Mach-O files and + * universal binaries (fat binaries) containing multiple architectures. + * It locates the __cstring section in the __TEXT segment which contains + * the string literals used in the program. + */ const char *ffBinaryExtractStrings(const char *machoFile, bool (*cb)(const char *str, uint32_t len, void *userdata), void *userdata, uint32_t minLength) { FF_AUTO_CLOSE_FILE FILE *objFile = fopen(machoFile, "rb"); if (objFile == NULL) return "File could not be opened"; + // Read the magic number to determine the type of binary uint32_t magic; if (!readData(objFile, &magic, sizeof(magic), 0)) return "read magic number failed"; + // Check for supported formats // MH_CIGAM and MH_CIGAM_64 seem to be no longer used, as `swap_mach_header` is marked as deprecated. // However FAT_CIGAM and FAT_CIGAM_64 are still used (/usr/bin/vim). if (magic != MH_MAGIC && magic != MH_MAGIC_64 && magic != FAT_CIGAM && magic != FAT_CIGAM_64 && magic != FAT_MAGIC && magic != FAT_MAGIC_64) return "Unsupported format or big endian mach-o file"; + // Process either a fat binary or a regular Mach-O binary if (magic == FAT_MAGIC || magic == FAT_MAGIC_64 || magic == FAT_CIGAM || magic == FAT_CIGAM_64) return dumpFatHeader(objFile, cb, userdata, minLength); else diff --git a/src/util/binary_linux.c b/src/util/binary_linux.c index 3b6ccca35..df89e160d 100644 --- a/src/util/binary_linux.c +++ b/src/util/binary_linux.c @@ -9,6 +9,9 @@ #include // #1254 #include +/** + * Structure to hold dynamically loaded libelf function pointers + */ struct FFElfData { FF_LIBRARY_SYMBOL(elf_version) FF_LIBRARY_SYMBOL(elf_begin) @@ -23,8 +26,19 @@ struct FFElfData { bool inited; } elfData; +/** + * Extracts string literals from an ELF (Linux/Unix) binary file + * + * This function loads the libelf library dynamically, opens the ELF file, + * locates the .rodata section (which contains string literals), and + * scans it for valid strings. Each string found is passed to the + * callback function for processing. + * + * The function supports both 32-bit and 64-bit ELF formats. + */ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* str, uint32_t len, void* userdata), void* userdata, uint32_t minLength) { + // Initialize libelf if not already done if (!elfData.inited) { elfData.inited = true; @@ -32,6 +46,7 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libelf, elfData, elf_version) if (elfData.ffelf_version(EV_CURRENT) == EV_NONE) return "elf_version() failed"; + // Load all required libelf functions FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libelf, elfData, elf_begin) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libelf, elfData, elf_getshdrstrndx) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libelf, elfData, elf_nextscn) @@ -47,12 +62,14 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s if (elfData.ffelf_end == NULL) return "load libelf failed"; + // Open the ELF file FF_AUTO_CLOSE_FD int fd = open(elfFile, O_RDONLY, 0); if (fd < 0) return "open() failed"; Elf* elf = elfData.ffelf_begin(fd, ELF_C_READ, NULL); if (elf == NULL) return "elf_begin() failed"; + // Get the section header string table index size_t shstrndx = 0; if (elfData.ffelf_getshdrstrndx(elf, &shstrndx) < 0) { @@ -60,9 +77,11 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s return "elf_getshdrstrndx() failed"; } + // Iterate through all sections, looking for .rodata which contains string literals Elf_Scn* scn = NULL; while ((scn = elfData.ffelf_nextscn(elf, scn)) != NULL) { + // Try 64-bit section header first, then 32-bit if that fails Elf64_Shdr* shdr64 = elfData.ffelf64_getshdr(scn); Elf32_Shdr* shdr32 = NULL; if (shdr64 == NULL) @@ -71,18 +90,22 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s if (shdr32 == NULL) continue; } + // Get the section name and check if it's .rodata const char* name = elfData.ffelf_strptr(elf, shstrndx, shdr64 ? shdr64->sh_name : shdr32->sh_name); if (name == NULL || !ffStrEquals(name, ".rodata")) continue; + // Get the section data Elf_Data* data = elfData.ffelf_getdata(scn, NULL); if (data == NULL) continue; + // Scan the section for string literals for (size_t off = 0; off < data->d_size; ++off) { const char* p = (const char*) data->d_buf + off; if (*p == '\0') continue; uint32_t len = (uint32_t) strlen(p); if (len < minLength) continue; + // Only process printable ASCII characters if (*p >= ' ' && *p <= '~') // Ignore control characters { if (!cb(p, len, userdata)) break; @@ -99,6 +122,9 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s #else +/** + * Fallback implementation when libelf is not available + */ const char* ffBinaryExtractStrings(const char* file, bool (*cb)(const char* str, uint32_t len, void* userdata), void* userdata, uint32_t minLength) { FF_UNUSED(file, cb, userdata, minLength); diff --git a/src/util/binary_windows.c b/src/util/binary_windows.c index 7f9d842f1..e86cd5e5c 100644 --- a/src/util/binary_windows.c +++ b/src/util/binary_windows.c @@ -8,25 +8,37 @@ #include #include +/** + * Extracts string literals from a PE (Windows) executable + * + * This function maps the PE file into memory, locates the .rdata section + * (which typically contains string literals), and scans it for valid strings. + * Each string found is passed to the callback function for processing. + */ const char* ffBinaryExtractStrings(const char *peFile, bool (*cb)(const char *str, uint32_t len, void *userdata), void *userdata, uint32_t minLength) { + // Use MapAndLoad with cleanup attribute to ensure proper unloading __attribute__((__cleanup__(UnMapAndLoad))) LOADED_IMAGE loadedImage = {}; if (!MapAndLoad(peFile, NULL, &loadedImage, FALSE, TRUE)) return "File could not be loaded"; + // Iterate through all sections in the PE file for (ULONG i = 0; i < loadedImage.NumberOfSections; ++i) { PIMAGE_SECTION_HEADER section = &loadedImage.Sections[i]; + // Look for initialized data sections with the name ".rdata" which typically contains string literals if ((section->Characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA) && ffStrEquals((const char*) section->Name, ".rdata")) { uint8_t *data = (uint8_t *) loadedImage.MappedAddress + section->PointerToRawData; + // Scan the section for string literals for (size_t off = 0; off < section->SizeOfRawData; ++off) { const char* p = (const char*) data + off; if (*p == '\0') continue; uint32_t len = (uint32_t) strlen(p); if (len < minLength) continue; + // Only process printable ASCII characters if (*p >= ' ' && *p <= '~') // Ignore control characters { if (!cb(p, len, userdata)) break; diff --git a/src/util/debug.h b/src/util/debug.h index 9e6bf7228..0f6d8b821 100644 --- a/src/util/debug.h +++ b/src/util/debug.h @@ -1,3 +1,6 @@ +#pragma once + +#include "fastfetch.h" #include "common/time.h" static inline const char* ffFindFileName(const char* file) diff --git a/src/util/path.c b/src/util/path.c index 5a0b5964e..e61de1163 100644 --- a/src/util/path.c +++ b/src/util/path.c @@ -38,8 +38,7 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) if (!ffPathExists(result->chars, FF_PATHTYPE_FILE)) continue; #else - struct stat st; - if (stat(result->chars, &st) < 0 || !(st.st_mode & S_IXUSR)) + if (access(result->chars, X_OK) != 0) continue; #endif @@ -52,7 +51,8 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) bool ffIsAbsolutePath(const char* path) { #ifdef _WIN32 - return ffCharIsEnglishAlphabet(path[0]) && path[1] == ':' && (path[2] == '\\' || path[2] == '/'); + return (ffCharIsEnglishAlphabet(path[0]) && path[1] == ':' && (path[2] == '\\' || path[2] == '/')) // drive letter path + || (path[0] == '\\' && path[1] == '\\'); // UNC path #else return path[0] == '/'; #endif diff --git a/src/util/platform/FFPlatform_unix.c b/src/util/platform/FFPlatform_unix.c index fbf59d85f..a6d5321d6 100644 --- a/src/util/platform/FFPlatform_unix.c +++ b/src/util/platform/FFPlatform_unix.c @@ -172,6 +172,14 @@ static void getDataDirs(FFPlatform* platform) #endif ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/local/share/"); ffPlatformPathAddAbsolute(&platform->dataDirs, FASTFETCH_TARGET_DIR_USR "/share/"); + + if (platform->exePath.length > 0) + { + // Add ${currentExePath} + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateCopy(&platform->exePath); + ffStrbufSubstrBeforeLastC(&path, '/'); + ffPlatformPathAddAbsolute(&platform->dataDirs, path.chars); + } } static void getUserName(FFPlatform* platform, const struct passwd* pwd) diff --git a/src/util/platform/FFPlatform_windows.c b/src/util/platform/FFPlatform_windows.c index 71feae3f3..d95c9443f 100644 --- a/src/util/platform/FFPlatform_windows.c +++ b/src/util/platform/FFPlatform_windows.c @@ -129,6 +129,14 @@ static void getDataDirs(FFPlatform* platform) platformPathAddKnownFolder(&platform->dataDirs, &FOLDERID_RoamingAppData); platformPathAddKnownFolder(&platform->dataDirs, &FOLDERID_LocalAppData); ffPlatformPathAddHome(&platform->dataDirs, platform, ""); + + if (platform->exePath.length > 0) + { + // Add ${currentExePath} + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateCopy(&platform->exePath); + ffStrbufSubstrBeforeLastC(&path, '/'); + ffPlatformPathAddAbsolute(&platform->dataDirs, path.chars); + } } static void getUserName(FFPlatform* platform) diff --git a/src/util/smbiosHelper.c b/src/util/smbiosHelper.c index fd5d29484..62fed285d 100644 --- a/src/util/smbiosHelper.c +++ b/src/util/smbiosHelper.c @@ -2,6 +2,7 @@ #include "common/io/io.h" #include "util/unused.h" #include "util/mallocHelper.h" +#include "util/debug.h" bool ffIsSmbiosValueSet(FFstrbuf* value) { @@ -50,7 +51,7 @@ const FFSmbiosHeader* ffSmbiosNextEntry(const FFSmbiosHeader* header) return (const FFSmbiosHeader*) (p + 1); } -#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun) || defined(__HAIKU__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun) || defined(__HAIKU__) || defined(__OpenBSD__) #include #include #include @@ -138,55 +139,112 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() if (buffer.chars == NULL) { + FF_DEBUG("Initializing SMBIOS buffer"); ffStrbufInit(&buffer); - #ifndef __HAIKU__ + #if !__HAIKU__ && !__OpenBSD__ #ifdef __linux__ + FF_DEBUG("Using Linux implementation - trying /sys/firmware/dmi/tables/DMI"); if (!ffAppendFileBuffer("/sys/firmware/dmi/tables/DMI", &buffer)) #endif { #if !defined(__sun) && !defined(__NetBSD__) + FF_DEBUG("Using memory-mapped implementation"); FF_STRBUF_AUTO_DESTROY strEntryAddress = ffStrbufCreate(); #ifdef __FreeBSD__ - if (!ffSettingsGetFreeBSDKenv("hint.smbios.0.mem", &strEntryAddress)) + FF_DEBUG("Using FreeBSD kenv implementation"); + if (!ffSettingsGetFreeBSDKenv("hint.smbios.0.mem", &strEntryAddress)) { + FF_DEBUG("Failed to get SMBIOS address from FreeBSD kenv"); return NULL; + } + FF_DEBUG("Got SMBIOS address from kenv: %s", strEntryAddress.chars); #elif defined(__linux__) { + FF_DEBUG("Using Linux EFI systab implementation"); FF_STRBUF_AUTO_DESTROY systab = ffStrbufCreate(); - if (!ffAppendFileBuffer("/sys/firmware/efi/systab", &systab)) + if (!ffAppendFileBuffer("/sys/firmware/efi/systab", &systab)) { + FF_DEBUG("Failed to read /sys/firmware/efi/systab"); return NULL; + } if (!ffParsePropLines(systab.chars, "SMBIOS3=", &strEntryAddress) && - !ffParsePropLines(systab.chars, "SMBIOS=", &strEntryAddress)) + !ffParsePropLines(systab.chars, "SMBIOS=", &strEntryAddress)) { + FF_DEBUG("Failed to find SMBIOS entry in systab"); return NULL; + } + FF_DEBUG("Found SMBIOS entry in systab: %s", strEntryAddress.chars); } #endif loff_t entryAddress = (loff_t) strtol(strEntryAddress.chars, NULL, 16); - if (entryAddress == 0) return NULL; + if (entryAddress == 0) { + FF_DEBUG("Invalid SMBIOS entry address: 0"); + return NULL; + } + FF_DEBUG("Parsed SMBIOS entry address: 0x%lx", (unsigned long)entryAddress); FF_AUTO_CLOSE_FD int fd = open("/dev/mem", O_RDONLY); - if (fd < 0) return NULL; + if (fd < 0) { + FF_DEBUG("Failed to open /dev/mem: %s", strerror(errno)); + return NULL; + } + FF_DEBUG("/dev/mem opened successfully with fd=%d", fd); FFSmbiosEntryPoint entryPoint; + FF_DEBUG("Attempting to read %zu bytes from physical address 0x%lx", + sizeof(entryPoint), (unsigned long)entryAddress); if (pread(fd, &entryPoint, sizeof(entryPoint), entryAddress) < 0x10) { + FF_DEBUG("pread failed, trying mmap"); // `pread /dev/mem` returns EFAULT in FreeBSD // https://stackoverflow.com/questions/69372330/how-to-read-dev-mem-using-read void* p = mmap(NULL, sizeof(entryPoint), PROT_READ, MAP_SHARED, fd, entryAddress); - if (p == MAP_FAILED) return NULL; + if (p == MAP_FAILED) { + FF_DEBUG("mmap failed: %s", strerror(errno)); + return NULL; + } memcpy(&entryPoint, p, sizeof(entryPoint)); munmap(p, sizeof(entryPoint)); + FF_DEBUG("Successfully read entry point data via mmap"); + } else { + FF_DEBUG("Successfully read entry point data via pread"); } #else + // Sun or NetBSD + FF_DEBUG("Using %s specific implementation", + #ifdef __NetBSD__ + "NetBSD" + #else + "SunOS" + #endif + ); + FF_AUTO_CLOSE_FD int fd = open("/dev/smbios", O_RDONLY); - if (fd < 0) return NULL; + if (fd < 0) { + FF_DEBUG("Failed to open /dev/smbios: %s", strerror(errno)); + return NULL; + } + FF_DEBUG("/dev/smbios opened successfully with fd=%d", fd); FFSmbiosEntryPoint entryPoint; #ifdef __NetBSD__ off_t addr = (off_t) ffSysctlGetInt64("machdep.smbios", 0); - if (addr == 0) return NULL; - if (pread(fd, &entryPoint, sizeof(entryPoint), addr) < 1) return NULL; + if (addr == 0) { + FF_DEBUG("Failed to get SMBIOS address from sysctl"); + return NULL; + } + FF_DEBUG("Got SMBIOS address from sysctl: 0x%lx", (unsigned long)addr); + + if (pread(fd, &entryPoint, sizeof(entryPoint), addr) < 1) { + FF_DEBUG("Failed to read SMBIOS entry point: %s", strerror(errno)); + return NULL; + } + FF_DEBUG("Successfully read SMBIOS entry point"); #else - if (ffReadFDData(fd, sizeof(entryPoint), &entryPoint) < 1) return NULL; + FF_DEBUG("Reading SMBIOS entry point from /dev/smbios"); + if (ffReadFDData(fd, sizeof(entryPoint), &entryPoint) < 1) { + FF_DEBUG("Failed to read SMBIOS entry point: %s", strerror(errno)); + return NULL; + } + FF_DEBUG("Successfully read SMBIOS entry point"); #endif #endif @@ -194,89 +252,155 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() loff_t tableAddress = 0; if (memcmp(entryPoint.Smbios20.AnchorString, "_SM_", sizeof(entryPoint.Smbios20.AnchorString)) == 0) { - if (entryPoint.Smbios20.EntryPointLength != sizeof(entryPoint.Smbios20)) + FF_DEBUG("Found SMBIOS 2.0 entry point"); + if (entryPoint.Smbios20.EntryPointLength != sizeof(entryPoint.Smbios20)) { + FF_DEBUG("Invalid SMBIOS 2.0 entry point length: %u (expected %zu)", + entryPoint.Smbios20.EntryPointLength, sizeof(entryPoint.Smbios20)); return NULL; + } tableLength = entryPoint.Smbios20.StructureTableLength; tableAddress = (loff_t) entryPoint.Smbios20.StructureTableAddress; + FF_DEBUG("SMBIOS 2.0: tableLength=0x%x, tableAddress=0x%lx, version=%u.%u", + tableLength, (unsigned long)tableAddress, + entryPoint.Smbios20.SmbiosMajorVersion, entryPoint.Smbios20.SmbiosMinorVersion); } else if (memcmp(entryPoint.Smbios30.AnchorString, "_SM3_", sizeof(entryPoint.Smbios30.AnchorString)) == 0) { - if (entryPoint.Smbios30.EntryPointLength != sizeof(entryPoint.Smbios30)) + FF_DEBUG("Found SMBIOS 3.0 entry point"); + if (entryPoint.Smbios30.EntryPointLength != sizeof(entryPoint.Smbios30)) { + FF_DEBUG("Invalid SMBIOS 3.0 entry point length: %u (expected %zu)", + entryPoint.Smbios30.EntryPointLength, sizeof(entryPoint.Smbios30)); return NULL; + } tableLength = entryPoint.Smbios30.StructureTableMaximumSize; tableAddress = (loff_t) entryPoint.Smbios30.StructureTableAddress; + FF_DEBUG("SMBIOS 3.0: tableLength=0x%x, tableAddress=0x%lx, version=%u.%u.%u", + tableLength, (unsigned long)tableAddress, + entryPoint.Smbios30.SmbiosMajorVersion, entryPoint.Smbios30.SmbiosMinorVersion, entryPoint.Smbios30.SmbiosDocrev); } - else + else { + FF_DEBUG("Unknown SMBIOS entry point format"); return NULL; + } ffStrbufEnsureFixedLengthFree(&buffer, tableLength); + FF_DEBUG("Attempting to read SMBIOS table data: %u bytes at 0x%lx", tableLength, (unsigned long)tableAddress); if (pread(fd, buffer.chars, tableLength, tableAddress) == (ssize_t) tableLength) { buffer.length = tableLength; buffer.chars[buffer.length] = '\0'; + FF_DEBUG("Successfully read SMBIOS table data: %u bytes", tableLength); } else { + FF_DEBUG("pread failed, trying mmap"); // entryPoint.StructureTableAddress must be page aligned. // Unaligned physical memory access results in all kinds of crashes. void* p = mmap(NULL, tableLength, PROT_READ, MAP_SHARED, fd, tableAddress); if (p == MAP_FAILED) { + FF_DEBUG("mmap failed: %s", strerror(errno)); ffStrbufDestroy(&buffer); // free buffer and reset state return NULL; } ffStrbufSetNS(&buffer, tableLength, (char*) p); munmap(p, tableLength); + FF_DEBUG("Successfully read SMBIOS table data via mmap: %u bytes", tableLength); } } #else { + FF_DEBUG("Using %s implementation", + #if __HAIKU__ + "Haiku" + #else + "OpenBSD" + #endif + ); + uint32_t tableLength = 0; off_t tableAddress = 0; - FF_AUTO_CLOSE_FD int fd = open("/dev/misc/mem", O_RDONLY); - if (fd < 0) + FF_AUTO_CLOSE_FD int fd = open( + #if __HAIKU__ + "/dev/misc/mem" + #else + "/dev/mem" // kern.securelevel must be -1 + #endif + , O_RDONLY); + if (fd < 0) { + FF_DEBUG("Failed to open memory device: %s", strerror(errno)); return NULL; + } + FF_DEBUG("Memory device opened successfully with fd=%d", fd); // Works on legacy BIOS only // See: https://wiki.osdev.org/System_Management_BIOS#UEFI_systems + // On BSD systems, we can get EFI system resource table (ESRT) via EFIIOC_GET_TABLE + // However, to acquire SMBIOS entry point, we need EFI configuration table (provided by EFI system table) + // which is not available via EFIIOC_GET_TABLE. FF_AUTO_FREE uint8_t* smBiosBase = malloc(0x10000); - if (pread(fd, smBiosBase, 0x10000, 0xF0000) != 0x10000) + if (pread(fd, smBiosBase, 0x10000, 0xF0000) != 0x10000) { + FF_DEBUG("Failed to read SMBIOS memory region: %s", strerror(errno)); return NULL; + } + FF_DEBUG("Successfully read 0x10000 bytes from physical address 0xF0000"); for (off_t offset = 0; offset <= 0xffe0; offset += 0x10) { FFSmbiosEntryPoint* p = (void*)(smBiosBase + offset); if (memcmp(p, "_SM3_", sizeof(p->Smbios30.AnchorString)) == 0) { - if (p->Smbios30.EntryPointLength != sizeof(p->Smbios30)) + FF_DEBUG("Found SMBIOS 3.0 entry point at offset 0x%lx", (unsigned long)offset); + if (p->Smbios30.EntryPointLength != sizeof(p->Smbios30)) { + FF_DEBUG("Invalid SMBIOS 3.0 entry point length: %u (expected %zu)", + p->Smbios30.EntryPointLength, sizeof(p->Smbios30)); return NULL; + } tableLength = p->Smbios30.StructureTableMaximumSize; tableAddress = (off_t) p->Smbios30.StructureTableAddress; + FF_DEBUG("SMBIOS 3.0: tableLength=0x%x, tableAddress=0x%lx, version=%u.%u.%u", + tableLength, (unsigned long)tableAddress, + p->Smbios30.SmbiosMajorVersion, p->Smbios30.SmbiosMinorVersion, p->Smbios30.SmbiosDocrev); break; } else if (memcmp(p, "_SM_", sizeof(p->Smbios20.AnchorString)) == 0) { - if (p->Smbios20.EntryPointLength != sizeof(p->Smbios20)) + FF_DEBUG("Found SMBIOS 2.0 entry point at offset 0x%lx", (unsigned long)offset); + if (p->Smbios20.EntryPointLength != sizeof(p->Smbios20)) { + FF_DEBUG("Invalid SMBIOS 2.0 entry point length: %u (expected %zu)", + p->Smbios20.EntryPointLength, sizeof(p->Smbios20)); return NULL; + } tableLength = p->Smbios20.StructureTableLength; tableAddress = (off_t) p->Smbios20.StructureTableAddress; + FF_DEBUG("SMBIOS 2.0: tableLength=0x%x, tableAddress=0x%lx, version=%u.%u", + tableLength, (unsigned long)tableAddress, + p->Smbios20.SmbiosMajorVersion, p->Smbios20.SmbiosMinorVersion); break; } } - if (tableLength == 0) + if (tableLength == 0) { + FF_DEBUG("No valid SMBIOS entry point found in memory region"); return NULL; + } ffStrbufEnsureFixedLengthFree(&buffer, tableLength); + FF_DEBUG("Attempting to read SMBIOS table data: %u bytes at 0x%lx", tableLength, (unsigned long)tableAddress); if (pread(fd, buffer.chars, tableLength, tableAddress) == tableLength) { buffer.length = tableLength; buffer.chars[buffer.length] = '\0'; + FF_DEBUG("Successfully read SMBIOS table data: %u bytes", tableLength); } - else + else { + FF_DEBUG("Failed to read SMBIOS table data: %s", strerror(errno)); return NULL; + } } #endif + FF_DEBUG("Parsing SMBIOS table structures"); + int structureCount = 0; for ( const FFSmbiosHeader* header = (const FFSmbiosHeader*) buffer.chars; (const uint8_t*) header < (const uint8_t*) buffer.chars + buffer.length; @@ -285,16 +409,25 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() { if (header->Type < FF_SMBIOS_TYPE_END_OF_TABLE) { - if (!table[header->Type]) + if (!table[header->Type]) { table[header->Type] = header; + FF_DEBUG("Found SMBIOS structure type %u, handle 0x%04X, length %u", + header->Type, header->Handle, header->Length); + structureCount++; + } } - else if (header->Type == FF_SMBIOS_TYPE_END_OF_TABLE) + else if (header->Type == FF_SMBIOS_TYPE_END_OF_TABLE) { + FF_DEBUG("Reached end-of-table marker"); break; + } } + FF_DEBUG("Parsed %d SMBIOS structures", structureCount); } - if (buffer.length == 0) + if (buffer.length == 0) { + FF_DEBUG("No valid SMBIOS data available"); return NULL; + } return &table; } @@ -320,16 +453,28 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() if (!buffer) { + FF_DEBUG("Initializing Windows SMBIOS buffer"); const DWORD signature = 'RSMB'; + FF_DEBUG("Querying system firmware table size with signature 'RSMB'"); uint32_t bufSize = GetSystemFirmwareTable(signature, 0, NULL, 0); - if (bufSize <= sizeof(FFRawSmbiosData)) + if (bufSize <= sizeof(FFRawSmbiosData)) { + FF_DEBUG("Invalid firmware table size: %u (must be > %zu)", + bufSize, sizeof(FFRawSmbiosData)); return NULL; + } + FF_DEBUG("Firmware table size: %u bytes", bufSize); buffer = (FFRawSmbiosData*) malloc(bufSize); assert(buffer); + FF_DEBUG("Allocated buffer for SMBIOS data"); + FF_MAYBE_UNUSED uint32_t resultSize = GetSystemFirmwareTable(signature, 0, buffer, bufSize); assert(resultSize == bufSize); + FF_DEBUG("Successfully retrieved SMBIOS data: version %u.%u, length %u bytes", + buffer->SMBIOSMajorVersion, buffer->SMBIOSMinorVersion, buffer->Length); + FF_DEBUG("Parsing SMBIOS table structures"); + FF_MAYBE_UNUSED int structureCount = 0; for ( const FFSmbiosHeader* header = (const FFSmbiosHeader*) buffer->SMBIOSTableData; (const uint8_t*) header < buffer->SMBIOSTableData + buffer->Length; @@ -338,12 +483,19 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() { if (header->Type < FF_SMBIOS_TYPE_END_OF_TABLE) { - if (!table[header->Type]) + if (!table[header->Type]) { table[header->Type] = header; + FF_DEBUG("Found SMBIOS structure type %u, handle 0x%04X, length %u", + header->Type, header->Handle, header->Length); + structureCount++; + } } - else if (header->Type == FF_SMBIOS_TYPE_END_OF_TABLE) + else if (header->Type == FF_SMBIOS_TYPE_END_OF_TABLE) { + FF_DEBUG("Reached end-of-table marker"); break; + } } + FF_DEBUG("Parsed %d SMBIOS structures", structureCount); } return &table; diff --git a/src/util/windows/unicode.c b/src/util/windows/unicode.c index cf75a071c..a6d758ff3 100644 --- a/src/util/windows/unicode.c +++ b/src/util/windows/unicode.c @@ -11,22 +11,12 @@ void ffStrbufSetNWS(FFstrbuf* result, uint32_t length, const wchar_t* source) } int size_needed = WideCharToMultiByte(CP_UTF8, 0, source, (int)length, NULL, 0, NULL, NULL); - ffStrbufEnsureFree(result, (uint32_t)size_needed); - WideCharToMultiByte(CP_UTF8, 0, source, (int)length, result->chars, size_needed, NULL, NULL); - result->length = (uint32_t)size_needed; - result->chars[size_needed] = '\0'; -} - -void ffStrbufInitNWS(FFstrbuf* result, uint32_t length, const wchar_t* source) -{ - if(!length) + if (size_needed < 0) { - ffStrbufInit(result); + ffStrbufSetF(result, "WCTMB failed: %u", (unsigned) GetLastError()); return; } - - int size_needed = WideCharToMultiByte(CP_UTF8, 0, source, (int)length, NULL, 0, NULL, NULL); - ffStrbufInitA(result, (uint32_t)size_needed + 1); + ffStrbufEnsureFixedLengthFree(result, (uint32_t)size_needed); WideCharToMultiByte(CP_UTF8, 0, source, (int)length, result->chars, size_needed, NULL, NULL); result->length = (uint32_t)size_needed; result->chars[size_needed] = '\0'; diff --git a/src/util/windows/unicode.h b/src/util/windows/unicode.h index 783cf6787..b34c3ffca 100644 --- a/src/util/windows/unicode.h +++ b/src/util/windows/unicode.h @@ -11,7 +11,11 @@ static inline void ffStrbufSetWS(FFstrbuf* result, const wchar_t* source) return ffStrbufSetNWS(result, (uint32_t)wcslen(source), source); } -void ffStrbufInitNWS(FFstrbuf* result, uint32_t length, const wchar_t* source); +static inline void ffStrbufInitNWS(FFstrbuf* result, uint32_t length, const wchar_t* source) +{ + ffStrbufInit(result); + return ffStrbufSetNWS(result, length, source); +} static inline void ffStrbufInitWS(FFstrbuf* result, const wchar_t* source) { diff --git a/src/util/windows/wmi.cpp b/src/util/windows/wmi.cpp index 34cfb06d6..9f9a4384f 100644 --- a/src/util/windows/wmi.cpp +++ b/src/util/windows/wmi.cpp @@ -107,7 +107,7 @@ bool FFWmiRecord::getString(const wchar_t* key, FFstrbuf* strbuf) case VT_BSTR: if(type == CIM_DATETIME) { - ISWbemDateTime *pDateTime; + FF_AUTO_RELEASE_COM_OBJECT ISWbemDateTime *pDateTime = nullptr; BSTR dateStr; if(FAILED(CoCreateInstance(__uuidof(SWbemDateTime), 0, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pDateTime)))) result = false;