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 SERIAL_LENGTH 14
48
49#define GYRO_SCALE (2000.0 / 32767.0)
50#define ACCEL_SCALE (4.0 * MATH_GRAVITY_M_S2 / 32767.0)
51
52#define IMU_FREQ 2000.0f
53#define IMU_PERIOD_NS ((time_duration_ns)(1000000000.0f / IMU_FREQ))
54
55enum psvr2_report_id
56{
57 PSVR2_REPORT_ID_SET_PERIPHERAL = 0x8,
58 PSVR2_REPORT_ID_SET_CAMERA_MODE = 0xB,
59 PSVR2_REPORT_ID_SET_GAZE_STREAM = 0xC,
60 PSVR2_REPORT_ID_SET_GAZE_USER_CALIBRATION = 0xD,
61 PSVR2_REPORT_ID_SET_BRIGHTNESS = 0x12,
62};
63
64enum psvr2_gaze_stream_subcommand
65{
66 PSVR2_GAZE_STREAM_SUBCMD_ENABLE = 0x01,
67 PSVR2_GAZE_STREAM_SUBCMD_DISABLE = 0x02,
68};
69
70enum psvr2_set_peripheral_subcommand
71{
72 PSVR2_SET_PERIPHERAL_SUBCMD_MOTOR = 0x01,
73};
74
75enum psvr2_camera_mode
76{
77 PSVR2_CAMERA_MODE_OFF = 0,
78 // 819456 byte 640x640x2 SBS bottom cameras
79 PSVR2_CAMERA_MODE_BOTTOM_SBS_CROPPED = 1,
80 // 819456 byte 640x640x2 SBS (mode 1) + 409856 byte 640x640 frames (from top cameras alternately) interleaved
81 PSVR2_CAMERA_MODE_2 = 2,
82 // 819456 byte 640x640x2 SBS interleaved bottom and top camera paired images
83 PSVR2_CAMERA_MODE_3 = 3,
84 // 520448 byte 512x508x2 Top-Bottom fisheye, *Controller Tracking* interleaved top and bottom camera pairs
85 PSVR2_CAMERA_MODE_4 = 4,
86 // 80256 byte 400x200 nearly black (no value higher than 0x0f)
87 PSVR2_CAMERA_MODE_400_200_DARK = 5,
88 // no packets / off
89 PSVR2_CAMERA_MODE_EYE_CAMERAS = 6,
90 // 819456 byte 640x640x2 + 520448 byte 512x508x2 fisheye *Controller Tracking* alternating bottom camera
91 PSVR2_CAMERA_MODE_7 = 7,
92 // 819456 byte 640x640x2 SBS bottom cameras + 80256 byte 400x200 nearly black packets like mode 5
93 PSVR2_CAMERA_MODE_8 = 8,
94 // interleaved mode 2 + mode 5 packets
95 PSVR2_CAMERA_MODE_9 = 9,
96 // 640x640x2 SBS interleaved bottom and top cameras + 80256 byte mode 5 packets
97 PSVR2_CAMERA_MODE_10 = 0xa,
98 // Mode 4 + Mode 5 packets interleaved
99 PSVR2_CAMERA_MODE_11 = 0xb,
100 // 409856 byte 320x640x4 vertical stack of all 4 cameras + 260352 byte 256x254x4 vertical stack fisheye
101 // controller-tracking all-4-cameras packets interleaved
102 PSVR2_CAMERA_MODE_12 = 0xc,
103 // mode 1, but upside down
104 PSVR2_CAMERA_MODE_13 = 0xd,
105 // mode 1 upside down + mode 4 bottom cameras only
106 PSVR2_CAMERA_MODE_14 = 0xe,
107 // mode 0xc + mode 5
108 PSVR2_CAMERA_MODE_15 = 0xf,
109 // 1024x1024x2 BC4 compressed images (really 1000x1000, with 24 padding pixels you can ignore on the
110 // right/bottom)
111 PSVR2_CAMERA_MODE_BOTTOM_SBS_BC4 = 0x10,
112};
113
114#pragma pack(push, 1)
115
117{
118 __le32 vts_us;
119 __le16 accel[3];
120 __le16 gyro[3];
121 __le16 dp_frame_cnt;
122 __le16 dp_line_cnt;
123 __le16 imu_ts_us;
124 __le16 status;
125};
126
128{
129 uint8_t dprx_status; //< 0 = not ready. 2 = cinematic? and 1 = unknown. HDCP? Other?
130 uint8_t prox_sensor_flag; //< 0 = not triggered. 1 = triggered?
131 uint8_t function_button; //< 0 = not pressed, 1 = pressed
132 uint8_t empty0[2];
133 uint8_t ipd_dial_mm; //< 59 to 72mm
134
135 uint8_t remainder[26];
136};
137
139{
140 char SLAhdr[3]; //< "SLA"
141 uint8_t const1; //< Constant 0x01?
142 __le32 pkt_size; //< 0x0200 = 512 bytes;
143 __le32 vts_ts_us; //< Timestamp
144 __le32 unknown1; //< Unknown. Constant 3?
145 __lef32 pos[3]; //< 32-bit floats
146 __lef32 orient[4]; //< Orientation quaternion
147 uint8_t remainder[468];
148};
149
151{
152 __le16 report_id;
153 __le16 subcmd;
154 __le32 len;
155 uint8_t data[512 - 8];
156};
157
158typedef uint32_t psvr2_eye_bool;
159
161{
162 psvr2_eye_bool gaze_point_mm_valid;
163 struct __levec3 gaze_point_mm;
164
165 psvr2_eye_bool gaze_direction_valid;
166 struct __levec3 gaze_direction;
167
168 psvr2_eye_bool pupil_diameter_valid;
169 __lef32 pupil_diameter_mm;
170
171 psvr2_eye_bool unk_bool_2;
172 struct __levec2 unk_float_2;
173
174 psvr2_eye_bool unk_bool_3;
175 struct __levec2 unk_float_4;
176
177 psvr2_eye_bool blink_valid;
178 psvr2_eye_bool blink;
179};
180
182{
183 psvr2_eye_bool gaze_point_valid;
184 struct __levec3 gaze_point_3d; // unclear what this denotes precisely
185
186 psvr2_eye_bool normalized_gaze_valid;
187 struct __levec3 normalized_gaze;
188
189 psvr2_eye_bool is_valid;
190 __le32 timestamp;
191
192 psvr2_eye_bool unk_bool_7;
193 __lef32 unk_float_8;
194
195 psvr2_eye_bool unk_bool_9;
196 struct __levec3 unk_float_12;
197 struct __levec3 unk_float_15;
198 struct __levec3 unk_float_18;
199};
200
202{
203 __le32 size;
204 __le32 unk_1;
205 __le32 unk_2;
206 __le32 unk_3_const;
207
208 __le32 timestamp_1;
209 __le32 timestamp_2;
210 __le32 timestamp_3;
211
212 // unknown garbage
213 psvr2_eye_bool unk_bool_1;
214 __lef32 unk_float_1;
215 psvr2_eye_bool unk_bool_2;
216 psvr2_eye_bool unk_bool_3;
217 __lef32 unk_float_2;
218 psvr2_eye_bool unk_bool_4;
219 psvr2_eye_bool unk_bool_5;
220 psvr2_eye_bool unk_bool_6;
221 psvr2_eye_bool unk_bool_7;
222 psvr2_eye_bool unk_bool_8;
223 __lef32 unk_float_3;
224
225 // openness?
226 psvr2_eye_bool unk_bool_9;
227 __lef32 unk_float_4;
228
229 psvr2_eye_bool unk_bool_10;
230 __lef32 unk_float_5;
231
232 struct pkt_eye_gaze left;
233 struct pkt_eye_gaze right;
234 struct pkt_gaze_combined combined;
235};
236
238{
239 uint8_t header[2]; // 0000
240 __le16 version; // 0002
241
242 struct pkt_gaze_packet_data packet_data;
243};
244
245#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:117
Definition psvr2_protocol.h:161
Definition psvr2_protocol.h:182
Definition psvr2_protocol.h:202
Definition psvr2_protocol.h:238
Definition psvr2_protocol.h:151
Definition psvr2_protocol.h:139
Definition psvr2_protocol.h:128