Difference between revisions of "Display services"

From Nintendo Switch Brew
Jump to navigation Jump to search
Line 36: Line 36:
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
! Cmd || Name || Notes
+
! Cmd || Name
 
|-
 
|-
| 0 || GetDisplayService ||
+
| 0 || [[#GetDisplayService]]
 
|-
 
|-
 
|}
 
|}
Line 52: Line 52:
 
! Cmd || Name
 
! Cmd || Name
 
|-
 
|-
| 1 || GetDisplayService || Returns an [[#IApplicationDisplayService]]. Same input as vi:u.
+
| 1 || [[#GetDisplayService]]
 
|-
 
|-
| 3 || GetDisplayServiceWithProxyNameExchange || Returns an [[#IApplicationDisplayService]].
+
| 3 || [[#GetDisplayServiceWithProxyNameExchange]]
 
|-
 
|-
 
|}
 
|}
 +
 +
== GetDisplayService ==
 +
Returns an [[#IApplicationDisplayService]]. Same input as vi:u.
 +
 +
== GetDisplayServiceWithProxyNameExchange ==
 +
Returns an [[#IApplicationDisplayService]].
  
 
= vi:m =
 
= vi:m =
Line 63: Line 69:
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
! Cmd || Name || Notes
+
! Cmd || Name
 
|-
 
|-
| 2 || GetDisplayService || Returns an [[#IApplicationDisplayService]]. Same input as vi:u.
+
| 2 || [[#GetDisplayService]]
 
|-
 
|-
| 3 || GetDisplayServiceWithProxyNameExchange || Takes an input u64 and u32. Returns an [[#IApplicationDisplayService]].
+
| 3 || [[#GetDisplayServiceWithProxyNameExchange]]
 
|-
 
|-
 
|}
 
|}
 +
 +
== GetDisplayService ==
 +
Returns an [[#IApplicationDisplayService]]. Same input as vi:u.
 +
 +
== GetDisplayServiceWithProxyNameExchange ==
 +
Takes an input u64 and u32. Returns an [[#IApplicationDisplayService]].
  
 
= IApplicationDisplayService =
 
= IApplicationDisplayService =
Line 76: Line 88:
 
! Cmd || Name || Notes
 
! Cmd || Name || Notes
 
|-
 
|-
| 100 || GetRelayService || Returns an [[#IHOSBinderDriver]].
+
| 100 || [[#GetRelayService]]
 
|-
 
|-
| 101 || GetSystemDisplayService || Returns an [[#ISystemDisplayService]].
+
| 101 || [[#GetSystemDisplayService]]
 
|-
 
|-
| 102 || GetManagerDisplayService || Returns an [[#IManagerDisplayService]].
+
| 102 || [[#GetManagerDisplayService]]
 
|-
 
|-
| 103 || GetIndirectDisplayTransactionService || Returns an [[#IHOSBinderDriver]].
+
| 103 || [[#GetIndirectDisplayTransactionService]]
 
|-
 
|-
| 1000 || ListDisplays ||
+
| 1000 || [[#ListDisplays]]
 
|-
 
|-
| 1010 || OpenDisplay ||
+
| 1010 || [[#OpenDisplay]]
 
|-
 
|-
| 1011 || OpenDefaultDisplay ||
+
| 1011 || [[#OpenDefaultDisplay]]
 
|-
 
|-
| 1020 || CloseDisplay ||
+
| 1020 || [[#CloseDisplay]]
 
|-
 
|-
| 1101 || SetDisplayEnabled ||
+
| 1101 || [[#SetDisplayEnabled]]
 
|-
 
|-
| 1102 || GetDisplayResolution ||
+
| 1102 || [[#GetDisplayResolution]]
 
|-
 
|-
| 2020 || OpenLayer ||
+
| 2020 || [[#OpenLayer]]
 
|-
 
|-
| 2021 || CloseLayer ||
+
| 2021 || [[#CloseLayer]]
 
|-
 
|-
| 2030 || CreateStrayLayer ||
+
| 2030 || [[#CreateStrayLayer]]
 
|-
 
|-
| 2031 || DestroyStrayLayer ||
+
| 2031 || [[#DestroyStrayLayer]]
 
|-
 
|-
| 2101 || SetLayerScalingMode ||
+
| 2101 || [[#SetLayerScalingMode]]
 
|-
 
|-
| 2450 || GetIndirectLayerImageMap ||
+
| 2450 || [[#GetIndirectLayerImageMap]]
 
|-
 
|-
| 2451 || GetIndirectLayerImageCropMap ||
+
| 2451 || [[#GetIndirectLayerImageCropMap]]
 
|-
 
|-
| 2460 || GetIndirectLayerImageRequiredMemoryInfo ||
+
| 2460 || [[#GetIndirectLayerImageRequiredMemoryInfo]]
 
|-
 
|-
| 5202 || GetDisplayVsyncEvent ||
+
| 5202 || [[#GetDisplayVsyncEvent]]
 
|-
 
|-
| 5203 || GetDisplayVsyncEventForDebug ||
+
| 5203 || [[#GetDisplayVsyncEventForDebug]]
 
|-
 
|-
 
|}
 
|}
Line 126: Line 138:
  
 
These commands using PIDs have AppletResourceUserId as the last input u64, hence AppletResourceUserId must [[IPC_Marshalling|match]] the user-process PID(no special handling for value 0).
 
These commands using PIDs have AppletResourceUserId as the last input u64, hence AppletResourceUserId must [[IPC_Marshalling|match]] the user-process PID(no special handling for value 0).
 +
 +
== GetRelayService ==
 +
Returns an [[Nvnflinger_services#dispdrv|IHOSBinderDriver]] interface which abstracts "nn::visrv::service::RelayServiceImpl".
 +
 +
== GetIndirectDisplayTransactionService ==
 +
Returns an [[Nvnflinger_services#dispdrv|IHOSBinderDriver]] interface which abstracts "nn::visrv::service::IndirectDisplayTransactionServiceImpl".
 +
 +
== GetSystemDisplayService ==
 +
Returns an [[#ISystemDisplayService]].
 +
 +
== GetManagerDisplayService ==
 +
Returns an [[#IManagerDisplayService]].
  
 
== ListDisplays ==
 
== ListDisplays ==
Line 186: Line 210:
 
== GetDisplayVsyncEventForDebug ==
 
== GetDisplayVsyncEventForDebug ==
 
Takes an input u64 DisplayId and returns a handle.
 
Takes an input u64 DisplayId and returns a handle.
 
== IHOSBinderDriver ==
 
{| class="wikitable" border="1"
 
|-
 
! Cmd || Name
 
|-
 
| 0 || [[#TransactParcel]]
 
|-
 
| 1 || [[#AdjustRefcount]]
 
|-
 
| 2 || [[#GetNativeHandle]]
 
|-
 
| 3 || [[#TransactParcelAuto]]
 
|}
 
 
This uses Android code.
 
 
Command(s) from here are constantly used while displaying gfx.
 
 
TransactParcel is used by 1.0.0 official user-processes, while starting with {unknown version} TransactParcelAuto is used instead.
 
 
=== TransactParcel ===
 
Takes a s32, an u32, a type-0x5 input buffer, a type-0x6 output buffer, and an input u32. Each word is immediately after the previous word.
 
 
=== AdjustRefcount ===
 
Takes 3 input s32s, with each word immediately following the previous word. No additional output.
 
 
=== GetNativeHandle ===
 
Takes an input s32 and u32, with the latter immediately following the previous word. Returns an output event handle.
 
 
=== TransactParcelAuto ===
 
Takes a s32, an u32, a type-0x21 input buffer, a type-0x22 output buffer, and an input u32. Each word is immediately after the previous word.
 
  
 
== ISystemDisplayService ==
 
== ISystemDisplayService ==
Line 342: Line 334:
 
|}
 
|}
  
=DisplayInfo=
+
= DisplayInfo =
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
Line 362: Line 354:
 
The width/height for the "Default" Display is the resolution for 1080p even when in handheld-mode.
 
The width/height for the "Default" Display is the resolution for 1080p even when in handheld-mode.
  
=DisplayName=
+
= DisplayName =
 
This is a 0x40-byte block: a NUL-terminated string.
 
This is a 0x40-byte block: a NUL-terminated string.
 +
 +
Can be "Default", "External", "Edid", "Internal" or "Null".
  
 
= NativeWindow =
 
= NativeWindow =

Revision as of 20:27, 30 October 2017

The only image data contained in this sysmodule is basically a saved display framebuffer, no image data for actively-used layers/framebuffers.

caps:sc

caps:ss

cec-mgr

mm:u

NVIDIA multimedia (NvMM) platform service.

Cmd Name
0 ?
1 ?
2 ?
3 ?
4 module_init_clk
5 module_deinit_clk
6 module_set_clk_rate
7 module_get_clk_rate

vi:u

This is "nn::visrv::sf::IApplicationRootService".

Cmd Name
0 #GetDisplayService

GetDisplayService

Returns an #IApplicationDisplayService. Takes an input u32, user-processes use 0 or 1, with 0 for regular-applications normally. 0 = user-service(vi:u), 1 = non-user-service? Returns an error when using value 1 with vi:u(same error listed below for IApplicationDisplayService for unavailable commands).

vi:s

This is "nn::visrv::sf::ISystemRootService".

Cmd Name
1 #GetDisplayService
3 #GetDisplayServiceWithProxyNameExchange

GetDisplayService

Returns an #IApplicationDisplayService. Same input as vi:u.

GetDisplayServiceWithProxyNameExchange

Returns an #IApplicationDisplayService.

vi:m

This is "nn::visrv::sf::IManagerRootService".

Cmd Name
2 #GetDisplayService
3 #GetDisplayServiceWithProxyNameExchange

GetDisplayService

Returns an #IApplicationDisplayService. Same input as vi:u.

GetDisplayServiceWithProxyNameExchange

Takes an input u64 and u32. Returns an #IApplicationDisplayService.

IApplicationDisplayService

Cmd Name Notes
100 #GetRelayService
101 #GetSystemDisplayService
102 #GetManagerDisplayService
103 #GetIndirectDisplayTransactionService
1000 #ListDisplays
1010 #OpenDisplay
1011 #OpenDefaultDisplay
1020 #CloseDisplay
1101 #SetDisplayEnabled
1102 #GetDisplayResolution
2020 #OpenLayer
2021 #CloseLayer
2030 #CreateStrayLayer
2031 #DestroyStrayLayer
2101 #SetLayerScalingMode
2450 #GetIndirectLayerImageMap
2451 #GetIndirectLayerImageCropMap
2460 #GetIndirectLayerImageRequiredMemoryInfo
5202 #GetDisplayVsyncEvent
5203 #GetDisplayVsyncEventForDebug

Available sessions for each service:

  • "vi:u": Only GetRelayService.
  • "vi:s": Everything except GetManagerDisplayService.
  • "vi:m": All.

When attempting to use a get-session cmd with a service it's not available with, error 0xA72 is returned.

These commands using PIDs have AppletResourceUserId as the last input u64, hence AppletResourceUserId must match the user-process PID(no special handling for value 0).

GetRelayService

Returns an IHOSBinderDriver interface which abstracts "nn::visrv::service::RelayServiceImpl".

GetIndirectDisplayTransactionService

Returns an IHOSBinderDriver interface which abstracts "nn::visrv::service::IndirectDisplayTransactionServiceImpl".

GetSystemDisplayService

Returns an #ISystemDisplayService.

GetManagerDisplayService

Returns an #IManagerDisplayService.

ListDisplays

Takes a type-0x6 output buffer containing the array of #DisplayInfo output entries. Returns an output u64: total number of output entries.

Normally(?) this only returns the "Default" display.

OpenDisplay

Takes a #DisplayName as input. Returns an output u64, the DisplayId.

To open the default display, input string "Default" can be used.

OpenDefaultDisplay

Returns an output u64.

Probably not (?) used by newer official user-processes, since those use OpenDisplay with the default string instead.

CloseDisplay

Takes an input u64, DisplayId.

SetDisplayEnabled

Takes an input u32 boolean, and an u64(DisplayId?).

GetDisplayResolution

Takes an input u64 DisplayId and returns two output u64s.

OpenLayer

Takes a PID-descriptor, a type-0x6 buffer for the output #NativeWindow, a #DisplayName(which was previously used with #OpenDisplay), an u64 LayerId, and an u64 AppletResourceUserId. Returns an output u64 NativeWindow_Size.

Official user-processes use a LayerId stored in a global state field("...ExternalLayerId") if non-zero, otherwise:

This OpenLayer command returns error 0x272 when the AppletResourceUserId is invalid.

CloseLayer

Takes an input u64: LayerId which was used with #OpenLayer.

CreateStrayLayer

Takes a type-0x6 buffer for the output #NativeWindow, an u32(LayerFlags bitmask), and an u64 DisplayId. Returns two output u64s: LayerId and NativeWindow_Size.

DestroyStrayLayer

Takes an input u64: LayerId from #CreateStrayLayer.

SetLayerScalingMode

Takes an input u32("ScalingMode") and u64.

GetIndirectLayerImageMap

Takes a PID-descriptor, an type-0x46 buffer, and four u64s: width(s32), height(s32), <output from AM GetIndirectLayerConsumerHandle>, and AppletResourceUserId. Returns two output u64s.

GetIndirectLayerImageCropMap

Takes a PID-descriptor, an type-0x46 buffer, four floats, four u64s(last u64 is AppletResourceUserId). Returns two output u64s. The floats are stored immediately after each other(32bits).

GetIndirectLayerImageRequiredMemoryInfo

Takes two input u64s: with and height. Returns two output u64s. First u64 is the buffer size to use with the ImageMap cmds.

GetDisplayVsyncEvent

Takes an input u64 DisplayId and returns a handle.

GetDisplayVsyncEventForDebug

Takes an input u64 DisplayId and returns a handle.

ISystemDisplayService

Cmd Name
1200 GetZOrderCountMin
1202 GetZOrderCountMax
1203 GetDisplayLogicalResolution
1204 SetDisplayMagnification
2201 SetLayerPosition
2203 SetLayerSize
2204 GetLayerZ
2205 SetLayerZ
2207 SetLayerVisibility
2209 SetLayerAlpha
2312 CreateStrayLayer
2400 OpenIndirectLayer
2401 CloseIndirectLayer
2402 FlipIndirectLayer
3000 ListDisplayModes
3001 ListDisplayRgbRanges
3002 ListDisplayContentTypes
3200 GetDisplayMode
3201 SetDisplayMode
3202 GetDisplayUnderscan
3203 SetDisplayUnderscan
3204 GetDisplayContentType
3205 SetDisplayContentType
3206 GetDisplayRgbRange
3207 SetDisplayRgbRange
3208 GetDisplayCmuMode
3209 SetDisplayCmuMode
3210 GetDisplayContrastRatio
3211 SetDisplayContrastRatio
3214 GetDisplayGamma
3215 SetDisplayGamma
3216 GetDisplayCmuLuma
3217 SetDisplayCmuLuma

IManagerDisplayService

Cmd Name
1102 GetDisplayResolution
2010 CreateManagedLayer
2011 DestroyManagedLayer
2050 CreateIndirectLayer
2051 DestroyIndirectLayer
2052 CreateIndirectProducerEndPoint
2053 DestroyIndirectProducerEndPoint
2054 CreateIndirectConsumerEndPoint
2055 DestroyIndirectConsumerEndPoint
2300 AcquireLayerTexturePresentingEvent
2301 ReleaseLayerTexturePresentingEvent
2302 GetDisplayHotplugEvent
2402 GetDisplayHotplugState
4201 SetDisplayAlpha
4203 SetDisplayLayerStack
4205 SetDisplayPowerState
6000 AddToLayerStack
6001 RemoveFromLayerStack
6002 SetLayerVisibility
7000 SetContentVisibility
8000 SetConductorLayer
8100 SetIndirectProducerFlipOffset

DisplayInfo

Offset Size Description
0x0 0x40 #DisplayName
0x40 0x8? Normally 0x1 for the "Default" Display?
0x48 0x8? Normally 0x1 for the "Default" Display?
0x50 0x8? Width
0x58 0x8? Height

This is a 0x60-byte structure.

The width/height for the "Default" Display is the resolution for 1080p even when in handheld-mode.

DisplayName

This is a 0x40-byte block: a NUL-terminated string.

Can be "Default", "External", "Edid", "Internal" or "Null".

NativeWindow

Offset Size Description
0x0 0x4 ParcelDataSize
0x4 0x4 ParcelDataOffset
0x8 0x4 ParcelObjectsSize
0xC 0x4 ParcelObjectsOffset
0x10 ? FlattenedBinder

Max size of this buffer is 0x100-bytes(outbuf size used by official user-processes). Parsed("Deserialize...") by a function called by the code described under #OpenLayer, which executes code with Android symbols.