nvapi_sys/gpu/
display.rs

1use status::NvAPI_Status;
2use handles::NvPhysicalGpuHandle;
3
4nvenum! {
5    pub enum NV_MONITOR_CONN_TYPE / MonitorConnectorType {
6        NV_MONITOR_CONN_TYPE_UNINITIALIZED / Uninitialized = 0,
7        NV_MONITOR_CONN_TYPE_VGA / Vga = 2,
8        NV_MONITOR_CONN_TYPE_COMPONENT / Component = 3,
9        NV_MONITOR_CONN_TYPE_SVIDEO / SVideo = 4,
10        NV_MONITOR_CONN_TYPE_HDMI / Hdmi = 5,
11        NV_MONITOR_CONN_TYPE_DVI / Dvi = 6,
12        NV_MONITOR_CONN_TYPE_LVDS / Lvds = 7,
13        NV_MONITOR_CONN_TYPE_DP / DisplayPort = 8,
14        NV_MONITOR_CONN_TYPE_COMPOSITE / Composite = 9,
15        NV_MONITOR_CONN_TYPE_UNKNOWN / Unknown = -1,
16    }
17}
18
19nvenum_display! {
20    MonitorConnectorType => _
21}
22
23nvbits! {
24    /// Argument to `NvAPI_GPU_GetConnectedDisplayIds`
25    pub enum NV_GPU_CONNECTED_IDS_FLAG / ConnectedIdsFlags {
26        /// Get uncached connected devices
27        NV_GPU_CONNECTED_IDS_FLAG_UNCACHED / UNCACHED = 0x01,
28        /// Get devices such that those can be selected in an SLI configuration
29        NV_GPU_CONNECTED_IDS_FLAG_SLI / SLI = 0x02,
30        /// Get devices such that to reflect the Lid State
31        NV_GPU_CONNECTED_IDS_FLAG_LIDSTATE / LID_STATE = 0x04,
32        /// Get devices that includes the fake connected monitors
33        NV_GPU_CONNECTED_IDS_FLAG_FAKE / FAKE = 0x08,
34        /// Excludes devices that are part of the multi stream topology.
35        NV_GPU_CONNECTED_IDS_FLAG_EXCLUDE_MST / EXCLUDE_MST = 0x10,
36    }
37}
38
39nvbits! {
40    /// Bitfield in `NV_GPU_DISPLAYIDS`
41    pub enum NV_GPU_DISPLAYIDS_FLAGS / DisplayIdsFlags {
42        /// This display is part of MST topology and it's a dynamic
43        NV_GPU_DISPLAYIDS_FLAGS_DYNAMIC / DYNAMIC = 0x01,
44        /// This displayID belongs to a multi stream enabled connector(root node).
45        /// Note that when multi stream is enabled and
46        /// a single multi stream capable monitor is connected to it, the monitor will share the
47        /// display id with the RootNode.
48        NV_GPU_DISPLAYIDS_FLAGS_MST_ROOT_NODE / MST_ROOT_NODE = 0x02,
49        /// This display is being actively driven
50        NV_GPU_DISPLAYIDS_FLAGS_ACTIVE / ACTIVE = 0x04,
51        /// This display is the representative display
52        NV_GPU_DISPLAYIDS_FLAGS_CLUSTER / CLUSTER = 0x08,
53        /// This display is reported to the OS
54        NV_GPU_DISPLAYIDS_FLAGS_OS_VISIBLE / OS_VISIBLE = 0x10,
55        /// This display is wireless
56        NV_GPU_DISPLAYIDS_FLAGS_WIRELESS / WIRELESS = 0x20,
57        /// This display is connected
58        NV_GPU_DISPLAYIDS_FLAGS_CONNECTED / CONNECTED = 0x40,
59        /// Do not use
60        NV_GPU_DISPLAYIDS_FLAGS_RESERVED_INTERNAL / RESERVED_INTERNAL = 0x1ff80,
61        /// this display is a phycially connected display; Valid only when is
62        /// Connected bit is set
63        NV_GPU_DISPLAYIDS_FLAGS_PHYSICALLY_CONNECTED / PHYSICALLY_CONNECTED = 0x20000,
64        /// must be zero
65        NV_GPU_DISPLAYIDS_FLAGS_RESERVED / RESERVED = 0xfffc0000u32,
66    }
67}
68
69nvstruct! {
70    pub struct NV_GPU_DISPLAYIDS {
71        pub version: u32,
72        /// out: vga, tv, dvi, hdmi and dp. This is reserved for future use and clients should not
73        /// rely on this information. Instead get the
74        /// GPU connector type from `NvAPI_GPU_GetConnectorInfo`/`NvAPI_GPU_GetConnectorInfoEx`
75        pub connectorType: NV_MONITOR_CONN_TYPE,
76        /// this is a unique identifier for each device
77        pub displayId: u32,
78        /// if bit is set then this display is part of MST topology and it's a dynamic
79        pub flags: NV_GPU_DISPLAYIDS_FLAGS,
80    }
81}
82
83nvversion! { NV_GPU_DISPLAYIDS_VER1(NV_GPU_DISPLAYIDS = 4 * 4, 1) }
84nvversion! { NV_GPU_DISPLAYIDS_VER2(NV_GPU_DISPLAYIDS = 4 * 4, 3) }
85nvversion! { NV_GPU_DISPLAYIDS_VER = NV_GPU_DISPLAYIDS_VER2 }
86
87nvapi! {
88    pub type GPU_GetConnectedDisplayIds = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, pDisplayIds: *mut NV_GPU_DISPLAYIDS, pDisplayIdCount: *mut u32, flags: NV_GPU_CONNECTED_IDS_FLAG) -> NvAPI_Status;
89
90    /// Due to space limitation NvAPI_GPU_GetConnectedOutputs can return maximum 32 devices, but
91    /// this is no longer true for DPMST. NvAPI_GPU_GetConnectedDisplayIds will return all
92    /// the connected display devices in the form of displayIds for the associated hPhysicalGpu.
93    /// This function can accept set of flags to request cached, uncached, sli and lid to get the connected devices.
94    /// Default value for flags will be cached.
95    ///
96    /// # HOW TO USE
97    ///
98    /// 1. for each PhysicalGpu, make a call to get the number of connected displayId's
99    ///    using NvAPI_GPU_GetConnectedDisplayIds by passing the pDisplayIds as NULL
100    /// 2. On call success:
101    ///    Allocate memory based on pDisplayIdCount then make a call NvAPI_GPU_GetConnectedDisplayIds to populate DisplayIds
102    ///
103    /// # RETURN STATUS
104    ///
105    /// - `NVAPI_INVALID_ARGUMENT`: hPhysicalGpu or pDisplayIds or pDisplayIdCount is NULL
106    /// - `NVAPI_OK`: *pDisplayIds contains a set of GPU-output identifiers
107    /// - `NVAPI_NVIDIA_DEVICE_NOT_FOUND`: no NVIDIA GPU driving a display was found
108    /// - `NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE`: hPhysicalGpu was not a physical GPU handle
109    pub unsafe fn NvAPI_GPU_GetConnectedDisplayIds;
110}
111
112nvapi! {
113    pub type GPU_GetAllDisplayIds = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, pDisplayIds: *mut NV_GPU_DISPLAYIDS, pDisplayIdCount: *mut u32) -> NvAPI_Status;
114
115    /// This API returns display IDs for all possible outputs on the GPU.
116    /// For DPMST connector, it will return display IDs for all the video sinks in the topology.
117    ///
118    /// # Returns
119    ///
120    /// - `NVAPI_INSUFFICIENT_BUFFER`: When the input buffer(pDisplayIds) is less than the actual number of display IDs
121    pub unsafe fn NvAPI_GPU_GetAllDisplayIds;
122}