libnx  v4.2.0
vi.h
Go to the documentation of this file.
1 /**
2  * @file vi.h
3  * @brief Display (vi:*) service IPC wrapper.
4  * @author yellows8
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 #include "../kernel/event.h"
10 #include "../sf/service.h"
11 
12 typedef struct {
13  char data[0x40];
15 
16 typedef struct {
17  u64 display_id;
18  ViDisplayName display_name;
19  bool initialized;
20 } ViDisplay;
21 
22 typedef struct {
23  u64 layer_id;
24  u32 igbp_binder_obj_id;
25  bool initialized : 1;
26  bool stray_layer : 1;
27 } ViLayer;
28 
29 typedef enum {
30  ViServiceType_Default = -1,
31  ViServiceType_Application = 0,
32  ViServiceType_System = 1,
33  ViServiceType_Manager = 2,
34 } ViServiceType;
35 
36 /// Used by viCreateLayer when CreateStrayLayer is used internally.
37 typedef enum {
38  ViLayerFlags_Default = 0x1,
39 } ViLayerFlags;
40 
41 /// Used with viSetLayerScalingMode.
42 typedef enum {
43  ViScalingMode_None = 0x0,
44  ViScalingMode_FitToLayer = 0x2,
45  ViScalingMode_PreserveAspectRatio = 0x4,
46 
47  ViScalingMode_Default = ViScalingMode_FitToLayer,
49 
50 /// Used with viSetDisplayPowerState.
51 typedef enum {
52  ViPowerState_Off = 0, ///< Screen is off.
53  ViPowerState_NotScanning = 1, ///< [3.0.0+] Screen is on, but not scanning content.
54  ViPowerState_On = 2, ///< [3.0.0+] Screen is on.
55 
56  ViPowerState_On_Deprecated = 1, ///< [1.0.0 - 2.3.0] Screen is on.
57 } ViPowerState;
58 
59 /// Used as argument to many capture functions.
60 typedef enum {
61  ViLayerStack_Default = 0, ///< Default layer stack, includes all layers.
62  ViLayerStack_Lcd = 1, ///< Includes only layers for the LCD.
63  ViLayerStack_Screenshot = 2, ///< Includes only layers for user screenshots.
64  ViLayerStack_Recording = 3, ///< Includes only layers for recording videos.
65  ViLayerStack_LastFrame = 4, ///< Includes only layers for the last applet-transition frame.
66  ViLayerStack_Arbitrary = 5, ///< Captures some arbitrary layer. This is normally only for am.
67  ViLayerStack_ApplicationForDebug = 6, ///< Captures layers for the current application. This is normally used by creport/debugging tools.
68  ViLayerStack_Null = 10, ///< Layer stack for the empty display.
69 } ViLayerStack;
70 
71 Result viInitialize(ViServiceType service_type);
72 void viExit(void);
73 
74 Service* viGetSession_IApplicationDisplayService(void);
75 Service* viGetSession_IHOSBinderDriverRelay(void);
76 Service* viGetSession_ISystemDisplayService(void);
77 Service* viGetSession_IManagerDisplayService(void);
78 Service* viGetSession_IHOSBinderDriverIndirect(void);
79 
80 // Misc functions
81 Result viSetContentVisibility(bool v);
82 
83 // Display functions
84 
85 Result viOpenDisplay(const char *display_name, ViDisplay *display);
86 Result viCloseDisplay(ViDisplay *display);
87 
88 static inline Result viOpenDefaultDisplay(ViDisplay *display)
89 {
90  return viOpenDisplay("Default", display);
91 }
92 
93 Result viGetDisplayResolution(ViDisplay *display, s32 *width, s32 *height);
94 Result viGetDisplayLogicalResolution(ViDisplay *display, s32 *width, s32 *height);
95 /// Only available on [3.0.0+].
96 Result viSetDisplayMagnification(ViDisplay *display, s32 x, s32 y, s32 width, s32 height);
97 Result viGetDisplayVsyncEvent(ViDisplay *display, Event *event_out);
98 Result viSetDisplayPowerState(ViDisplay *display, ViPowerState state);
99 Result viSetDisplayAlpha(ViDisplay *display, float alpha);
100 Result viGetZOrderCountMin(ViDisplay *display, s32 *z);
101 Result viGetZOrderCountMax(ViDisplay *display, s32 *z);
102 
103 // Layer functions
104 
105 Result viCreateLayer(const ViDisplay *display, ViLayer *layer);
106 Result viCreateManagedLayer(const ViDisplay *display, ViLayerFlags layer_flags, u64 aruid, u64 *layer_id);
107 Result viSetLayerSize(ViLayer *layer, s32 width, s32 height);
108 Result viSetLayerZ(ViLayer *layer, s32 z);
109 Result viSetLayerPosition(ViLayer *layer, float x, float y);
110 Result viCloseLayer(ViLayer *layer);
111 Result viDestroyManagedLayer(ViLayer *layer);
112 
113 Result viSetLayerScalingMode(ViLayer *layer, ViScalingMode scaling_mode);
114 
115 // IndirectLayer functions
116 
117 Result viGetIndirectLayerImageMap(void* buffer, size_t size, s32 width, s32 height, u64 IndirectLayerConsumerHandle, u64 *out_size, u64 *out_stride);
118 Result viGetIndirectLayerImageRequiredMemoryInfo(s32 width, s32 height, u64 *out_size, u64 *out_alignment);
ViLayerStack_Default
@ ViLayerStack_Default
Default layer stack, includes all layers.
Definition: vi.h:61
ViDisplayName
Definition: vi.h:12
ViPowerState_Off
@ ViPowerState_Off
Screen is off.
Definition: vi.h:52
ViLayerStack
ViLayerStack
Used as argument to many capture functions.
Definition: vi.h:60
Event
Kernel-mode event structure.
Definition: event.h:13
s32
int32_t s32
32-bit signed integer.
Definition: types.h:27
ViPowerState_NotScanning
@ ViPowerState_NotScanning
[3.0.0+] Screen is on, but not scanning content.
Definition: vi.h:53
ViLayerStack_Screenshot
@ ViLayerStack_Screenshot
Includes only layers for user screenshots.
Definition: vi.h:63
ViLayerStack_ApplicationForDebug
@ ViLayerStack_ApplicationForDebug
Captures layers for the current application. This is normally used by creport/debugging tools.
Definition: vi.h:67
ViLayerStack_Arbitrary
@ ViLayerStack_Arbitrary
Captures some arbitrary layer. This is normally only for am.
Definition: vi.h:66
viSetDisplayMagnification
Result viSetDisplayMagnification(ViDisplay *display, s32 x, s32 y, s32 width, s32 height)
Only available on [3.0.0+].
u32
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21
u64
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
ViLayerStack_Recording
@ ViLayerStack_Recording
Includes only layers for recording videos.
Definition: vi.h:64
ViLayerFlags
ViLayerFlags
Used by viCreateLayer when CreateStrayLayer is used internally.
Definition: vi.h:37
Result
u32 Result
Function error code result type.
Definition: types.h:44
ViScalingMode
ViScalingMode
Used with viSetLayerScalingMode.
Definition: vi.h:42
ViLayer
Definition: vi.h:22
ViPowerState_On_Deprecated
@ ViPowerState_On_Deprecated
[1.0.0 - 2.3.0] Screen is on.
Definition: vi.h:56
ViDisplay
Definition: vi.h:16
Service
Service object structure.
Definition: service.h:13
ViPowerState_On
@ ViPowerState_On
[3.0.0+] Screen is on.
Definition: vi.h:54
ViLayerStack_LastFrame
@ ViLayerStack_LastFrame
Includes only layers for the last applet-transition frame.
Definition: vi.h:65
ViLayerStack_Lcd
@ ViLayerStack_Lcd
Includes only layers for the LCD.
Definition: vi.h:62
ViPowerState
ViPowerState
Used with viSetDisplayPowerState.
Definition: vi.h:51
ViLayerStack_Null
@ ViLayerStack_Null
Layer stack for the empty display.
Definition: vi.h:68