Monado OpenXR Runtime
rift_s.h
Go to the documentation of this file.
1/*
2 * Copyright 2013, Fredrik Hultin.
3 * Copyright 2013, Jakob Bornecrantz.
4 * Copyright 2016 Philipp Zabel
5 * Copyright 2019-2022 Jan Schmidt
6 * SPDX-License-Identifier: BSL-1.0
7 *
8 * OpenHMD - Free and Open Source API and drivers for immersive technology.
9 */
10
11/*!
12 * @file
13 * @brief Oculus Rift S Driver Internal Interface
14 * @author Jan Schmidt <jan@centricular.com>
15 * @ingroup drv_rift_s
16 */
17
18#pragma once
19
20#include "os/os_threading.h"
21#include "util/u_logging.h"
22#include "xrt/xrt_defines.h"
23#include "xrt/xrt_frame.h"
24#include "xrt/xrt_frameserver.h"
25#include "xrt/xrt_prober.h"
26#include "xrt/xrt_tracking.h"
27
28#include "rift_s_firmware.h"
29#include "rift_s_protocol.h"
30#include "rift_s_radio.h"
31#include "rift_s_tracker.h"
32
33#ifndef RIFT_S_H
34#define RIFT_S_H
35
36struct rift_s_hmd;
38struct rift_s_camera;
39
40extern enum u_logging_level rift_s_log_level;
41
42#define RIFT_S_TRACE(...) U_LOG_IFL_T(rift_s_log_level, __VA_ARGS__)
43#define RIFT_S_DEBUG(...) U_LOG_IFL_D(rift_s_log_level, __VA_ARGS__)
44#define RIFT_S_INFO(...) U_LOG_IFL_I(rift_s_log_level, __VA_ARGS__)
45#define RIFT_S_WARN(...) U_LOG_IFL_W(rift_s_log_level, __VA_ARGS__)
46#define RIFT_S_ERROR(...) U_LOG_IFL_E(rift_s_log_level, __VA_ARGS__)
47
48#define MAX_TRACKED_DEVICES 2
49
50#define HMD_HID 0
51#define STATUS_HID 1
52#define CONTROLLER_HID 2
53
54/* All HMD Configuration / calibration info */
56{
57 rift_s_panel_info_t panel_info;
58 int proximity_threshold;
59
60 /* Camera calibration block from firmware */
61 struct rift_s_camera_calibration_block camera_calibration;
62
63 struct rift_s_imu_config_info_t imu_config_info;
64 struct rift_s_imu_calibration imu_calibration;
65};
66
67/* Structure to track online devices and type */
69{
70 uint64_t device_id;
71 rift_s_device_type device_type;
72};
73
75{
76 struct xrt_tracking_origin base;
77 struct xrt_reference ref;
78
79 /* Packet processing thread */
80 struct os_thread_helper oth;
81 struct os_hid_device *handles[3];
82 uint64_t last_keep_alive;
83
84 /* state tracking for tracked devices on our radio link */
85 int num_active_tracked_devices;
86 struct rift_s_tracked_device tracked_device[MAX_TRACKED_DEVICES];
87
88 /* Radio comms manager */
89 rift_s_radio_state radio_state;
90
91 /* Device lock protects device access */
92 struct os_mutex dev_mutex;
93
94 /* All configuration data for the HMD, stored
95 * here for sharing to child objects */
96 struct rift_s_hmd_config hmd_config;
97
98 /* 3dof/SLAM tracker that provides HMD pose */
99 struct rift_s_tracker *tracker;
100
101 /* HMD device */
102 struct rift_s_hmd *hmd;
103
104 /* Controller devices */
105 struct rift_s_controller *controllers[MAX_TRACKED_DEVICES];
106
107 /* Video feed handling */
108 struct xrt_frame_context xfctx;
109 struct rift_s_camera *cam;
110};
111
112struct rift_s_system *
113rift_s_system_create(struct xrt_prober *xp,
114 const unsigned char *hmd_serial_no,
115 struct os_hid_device *hid_hmd,
116 struct os_hid_device *hid_status,
117 struct os_hid_device *hid_controllers);
118
119struct os_hid_device *
120rift_s_system_hid_handle(struct rift_s_system *sys);
122rift_s_system_radio(struct rift_s_system *sys);
123
124struct rift_s_tracker *
125rift_s_system_get_tracker(struct rift_s_system *sys);
126
127struct xrt_device *
128rift_s_system_get_hmd(struct rift_s_system *sys);
129void
130rift_s_system_remove_hmd(struct rift_s_system *sys);
131
132struct xrt_device *
133rift_s_system_get_controller(struct rift_s_system *sys, int index);
134void
135rift_s_system_remove_controller(struct rift_s_system *sys, struct rift_s_controller *ctrl);
136
137struct xrt_device *
138rift_s_system_get_hand_tracking_device(struct rift_s_system *sys);
139
140void
141rift_s_system_reference(struct rift_s_system **dst, struct rift_s_system *src);
142
143#endif
u_logging_level
Logging level enum.
Definition: u_logging.h:43
Wrapper around OS threading native functions.
Oculus Rift S firmware parsing interface.
Oculus Rift S USB protocol implementation interface.
Oculus Rift S HMD Radio management interface.
HMD tracker handling.
Representing a single hid interface on a device.
Definition: os_hid.h:29
A wrapper around a native mutex.
Definition: os_threading.h:55
All in one helper that handles locking, waiting for change and starting a thread.
Definition: os_threading.h:453
Definition: rift_s_firmware.h:90
Specifies whether the user wants to enable autoexposure from the start.
Definition: rift_s_camera.c:50
Definition: rift_s_controller.h:39
Definition: rift_s.h:56
Definition: rift_s_hmd.h:30
Definition: rift_s_firmware.h:51
Definition: rift_s_protocol.h:224
Definition: rift_s_protocol.h:213
Definition: rift_s_radio.h:41
Definition: rift_s.h:75
Definition: rift_s.h:69
Definition: rift_s_tracker.h:42
A single HMD or input device.
Definition: xrt_device.h:241
Object used to track all sinks and frame producers in a graph.
Definition: xrt_frame.h:108
The main prober that probes and manages found but not opened HMD devices that are connected to the sy...
Definition: xrt_prober.h:132
A base class for reference counted objects.
Definition: xrt_defines.h:96
A tracking system or device origin.
Definition: xrt_tracking.h:71
Basic logging functionality.
Common defines and enums for XRT.
Data frame header.
Frameserver interface for video drivers.
Common interface to probe for devices.
Header defining the tracking system integration in Monado.