Monado OpenXR Runtime
Loading...
Searching...
No Matches
psvr2_protocol.h
Go to the documentation of this file.
1// Copyright 2023, Jan Schmidt
2// Copyright 2024, Joel Valenciano
3// Copyright 2025, Beyley Cardellio
4// SPDX-License-Identifier: BSL-1.0
5/*!
6 * @file
7 * @brief PSVR2 HMD protocol defines
8 *
9 * @author Jan Schmidt <jan@centricular.com>
10 * @author Joel Valenciano <joelv1907@gmail.com>
11 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
12 * @ingroup drv_psvr2
13 */
14#pragma once
15
16
17#define PSVR2_SLAM_INTERFACE 3
18#define PSVR2_SLAM_ENDPOINT 3
19
20#define PSVR2_GAZE_INTERFACE 5
21#define PSVR2_GAZE_ENDPOINT 0x85
22
23#define PSVR2_CAMERA_INTERFACE 6
24#define PSVR2_CAMERA_ENDPOINT 7
25
26#define PSVR2_STATUS_INTERFACE 7
27#define PSVR2_STATUS_ENDPOINT 8
28
29#define PSVR2_LD_INTERFACE 8
30#define PSVR2_LD_ENDPOINT 9
31
32#define PSVR2_RP_INTERFACE 9
33#define PSVR2_RP_ENDPOINT 10
34
35#define PSVR2_VD_INTERFACE 10
36#define PSVR2_VD_ENDPOINT 11
37
38#define USB_SLAM_XFER_SIZE 1024
39#define USB_STATUS_XFER_SIZE 1024
40#define USB_GAZE_XFER_SIZE 32768
41#define USB_CAM_MODE10_XFER_SIZE 1040640
42#define USB_CAM_MODE1_XFER_SIZE 819456
43#define USB_LD_XFER_SIZE 36944
44#define USB_RP_XFER_SIZE 821120
45#define USB_VD_XFER_SIZE 32768
46
47#define GYRO_SCALE (2000.0 / 32767.0)
48#define ACCEL_SCALE (4.0 * MATH_GRAVITY_M_S2 / 32767.0)
49
50#define IMU_FREQ 2000.0f
51#define IMU_PERIOD_NS ((time_duration_ns)(1000000000.0f / IMU_FREQ))
52
53enum psvr2_report_id
54{
55 PSVR2_REPORT_ID_SET_PERIPHERAL = 0x8,
56 PSVR2_REPORT_ID_SET_CAMERA_MODE = 0xB,
57 PSVR2_REPORT_ID_SET_GAZE_STREAM = 0xC,
58 PSVR2_REPORT_ID_SET_GAZE_USER_CALIBRATION = 0xD,
59 PSVR2_REPORT_ID_SET_BRIGHTNESS = 0x12,
60};
61
62enum psvr2_gaze_stream_subcommand
63{
64 PSVR2_GAZE_STREAM_SUBCMD_ENABLE = 0x01,
65 PSVR2_GAZE_STREAM_SUBCMD_DISABLE = 0x02,
66};
67
68enum psvr2_set_peripheral_subcommand
69{
70 PSVR2_SET_PERIPHERAL_SUBCMD_MOTOR = 0x01,
71};
72
73enum psvr2_camera_mode
74{
75 PSVR2_CAMERA_MODE_OFF = 0,
76 // 819456 byte 640x640x2 SBS bottom cameras
77 PSVR2_CAMERA_MODE_BOTTOM_SBS_CROPPED = 1,
78 // 819456 byte 640x640x2 SBS (mode 1) + 409856 byte 640x640 frames (from top cameras alternately) interleaved
79 PSVR2_CAMERA_MODE_2 = 2,
80 // 819456 byte 640x640x2 SBS interleaved bottom and top camera paired images
81 PSVR2_CAMERA_MODE_3 = 3,
82 // 520448 byte 512x508x2 Top-Bottom fisheye, *Controller Tracking* interleaved top and bottom camera pairs
83 PSVR2_CAMERA_MODE_4 = 4,
84 // 80256 byte 400x200 nearly black (no value higher than 0x0f)
85 PSVR2_CAMERA_MODE_400_200_DARK = 5,
86 // no packets / off
87 PSVR2_CAMERA_MODE_EYE_CAMERAS = 6,
88 // 819456 byte 640x640x2 + 520448 byte 512x508x2 fisheye *Controller Tracking* alternating bottom camera
89 PSVR2_CAMERA_MODE_7 = 7,
90 // 819456 byte 640x640x2 SBS bottom cameras + 80256 byte 400x200 nearly black packets like mode 5
91 PSVR2_CAMERA_MODE_8 = 8,
92 // interleaved mode 2 + mode 5 packets
93 PSVR2_CAMERA_MODE_9 = 9,
94 // 640x640x2 SBS interleaved bottom and top cameras + 80256 byte mode 5 packets
95 PSVR2_CAMERA_MODE_10 = 0xa,
96 // Mode 4 + Mode 5 packets interleaved
97 PSVR2_CAMERA_MODE_11 = 0xb,
98 // 409856 byte 320x640x4 vertical stack of all 4 cameras + 260352 byte 256x254x4 vertical stack fisheye
99 // controller-tracking all-4-cameras packets interleaved
100 PSVR2_CAMERA_MODE_12 = 0xc,
101 // mode 1, but upside down
102 PSVR2_CAMERA_MODE_13 = 0xd,
103 // mode 1 upside down + mode 4 bottom cameras only
104 PSVR2_CAMERA_MODE_14 = 0xe,
105 // mode 0xc + mode 5
106 PSVR2_CAMERA_MODE_15 = 0xf,
107 // 1024x1024x2 BC4 compressed images (really 1000x1000, with 24 padding pixels you can ignore on the
108 // right/bottom)
109 PSVR2_CAMERA_MODE_BOTTOM_SBS_BC4 = 0x10,
110};
111
112#pragma pack(push, 1)
113
115{
116 __le32 vts_us;
117 __le16 accel[3];
118 __le16 gyro[3];
119 __le16 dp_frame_cnt;
120 __le16 dp_line_cnt;
121 __le16 imu_ts_us;
122 __le16 status;
123};
124
126{
127 uint8_t dprx_status; //< 0 = not ready. 2 = cinematic? and 1 = unknown. HDCP? Other?
128 uint8_t prox_sensor_flag; //< 0 = not triggered. 1 = triggered?
129 uint8_t function_button; //< 0 = not pressed, 1 = pressed
130 uint8_t empty0[2];
131 uint8_t ipd_dial_mm; //< 59 to 72mm
132
133 uint8_t remainder[26];
134};
135
137{
138 char SLAhdr[3]; //< "SLA"
139 uint8_t const1; //< Constant 0x01?
140 __le32 pkt_size; //< 0x0200 = 512 bytes;
141 __le32 vts_ts_us; //< Timestamp
142 __le32 unknown1; //< Unknown. Constant 3?
143 __lef32 pos[3]; //< 32-bit floats
144 __lef32 orient[4]; //< Orientation quaternion
145 uint8_t remainder[468];
146};
147
149{
150 __le16 report_id;
151 __le16 subcmd;
152 __le32 len;
153 uint8_t data[512 - 8];
154};
155
156typedef uint32_t psvr2_eye_bool;
157
159{
160 psvr2_eye_bool gaze_point_mm_valid;
161 struct __levec3 gaze_point_mm;
162
163 psvr2_eye_bool gaze_direction_valid;
164 struct __levec3 gaze_direction;
165
166 psvr2_eye_bool pupil_diameter_valid;
167 __lef32 pupil_diameter_mm;
168
169 psvr2_eye_bool unk_bool_2;
170 struct __levec2 unk_float_2;
171
172 psvr2_eye_bool unk_bool_3;
173 struct __levec2 unk_float_4;
174
175 psvr2_eye_bool blink_valid;
176 psvr2_eye_bool blink;
177};
178
180{
181 psvr2_eye_bool gaze_point_valid;
182 struct __levec3 gaze_point_3d; // unclear what this denotes precisely
183
184 psvr2_eye_bool normalized_gaze_valid;
185 struct __levec3 normalized_gaze;
186
187 psvr2_eye_bool is_valid;
188 __le32 timestamp;
189
190 psvr2_eye_bool unk_bool_7;
191 __lef32 unk_float_8;
192
193 psvr2_eye_bool unk_bool_9;
194 struct __levec3 unk_float_12;
195 struct __levec3 unk_float_15;
196 struct __levec3 unk_float_18;
197};
198
200{
201 __le32 size;
202 __le32 unk_1;
203 __le32 unk_2;
204 __le32 unk_3_const;
205
206 __le32 timestamp_1;
207 __le32 timestamp_2;
208 __le32 timestamp_3;
209
210 // unknown garbage
211 psvr2_eye_bool unk_bool_1;
212 __lef32 unk_float_1;
213 psvr2_eye_bool unk_bool_2;
214 psvr2_eye_bool unk_bool_3;
215 __lef32 unk_float_2;
216 psvr2_eye_bool unk_bool_4;
217 psvr2_eye_bool unk_bool_5;
218 psvr2_eye_bool unk_bool_6;
219 psvr2_eye_bool unk_bool_7;
220 psvr2_eye_bool unk_bool_8;
221 __lef32 unk_float_3;
222
223 // openness?
224 psvr2_eye_bool unk_bool_9;
225 __lef32 unk_float_4;
226
227 psvr2_eye_bool unk_bool_10;
228 __lef32 unk_float_5;
229
230 struct pkt_eye_gaze left;
231 struct pkt_eye_gaze right;
232 struct pkt_gaze_combined combined;
233};
234
236{
237 uint8_t header[2]; // 0000
238 __le16 version; // 0002
239
240 struct pkt_gaze_packet_data packet_data;
241};
242
244{
245 __le32 version;
246 __le32 reserved_0;
247 uint8_t commit_hash[40];
248 __le32 unknown_0;
249 __le32 unknown_1;
250 char pcb_id[16];
251 __le32 unknown_2;
252 __le32 reserved_1;
253 __le32 recovery_version;
254};
255
256#pragma pack(pop)
Little endian 32-bit float wrapper struct.
Definition xrt_byte_order.h:73
Definition xrt_byte_order.h:210
Definition xrt_byte_order.h:240
Definition psvr2_protocol.h:115
Definition psvr2_protocol.h:159
Definition psvr2_protocol.h:244
Definition psvr2_protocol.h:180
Definition psvr2_protocol.h:200
Definition psvr2_protocol.h:236
Definition psvr2_protocol.h:149
Definition psvr2_protocol.h:137
Definition psvr2_protocol.h:126