mirror of
https://github.com/lbgos/rift-s-linux.git
synced 2026-10-28 12:01:23 +01:00
xrt: Add byte order constants and conversion functions
Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2477>
This commit is contained in:
1 parent
dcf8aebad1
commit
682d16db18
9 files changed
+102
-12
No files matched your search
@@ -22,6 +22,7 @@
|
||||
#include "os/os_hid.h"
|
||||
#include "os/os_time.h"
|
||||
#include "os/os_threading.h"
|
||||
#include "xrt/xrt_byte_order.h"
|
||||
|
||||
#include "math/m_api.h"
|
||||
#include "math/m_relation_history.h"
|
||||
@@ -275,7 +276,6 @@ static inline int16_t
|
||||
hydra_read_int16_le(uint8_t **bufptr)
|
||||
{
|
||||
uint8_t *buf = *bufptr;
|
||||
//! @todo nothing actually defines XRT_BIG_ENDIAN when needed!
|
||||
#ifdef XRT_BIG_ENDIAN
|
||||
uint8_t bytes[2] = {buf[1], buf[0]};
|
||||
#else
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
* @author Jan Schmidt <jan@centricular.com>
|
||||
* @ingroup drv_rift_s
|
||||
*/
|
||||
#include <asm/byteorder.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "rift_s.h"
|
||||
#include "rift_s_camera.h"
|
||||
|
||||
#include "os/os_threading.h"
|
||||
#include "xrt/xrt_byte_order.h"
|
||||
|
||||
#include "xrt/xrt_defines.h"
|
||||
#include "xrt/xrt_frame.h"
|
||||
|
||||
@@ -10,12 +10,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <asm/byteorder.h>
|
||||
#include "xrt/xrt_byte_order.h"
|
||||
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_time.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
*
|
||||
* Printing functions.
|
||||
|
||||
@@ -10,13 +10,15 @@
|
||||
// IWYU pragma: no_include <asm/int-ll64.h>
|
||||
// IWYU pragma: no_include <linux/byteorder/little_endian.h>
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <zlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "math/m_api.h"
|
||||
|
||||
#include "xrt/xrt_byte_order.h"
|
||||
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_logging.h"
|
||||
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <stdint.h>
|
||||
#include "os/os_hid.h"
|
||||
#include "xrt/xrt_byte_order.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define VIVE_CONTROLLER_BUTTON_REPORT_ID 0x01
|
||||
|
||||
|
||||
@@ -10,13 +10,12 @@
|
||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||
* @ingroup drv_wmr
|
||||
*/
|
||||
#include <asm/byteorder.h>
|
||||
#include <libusb.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "math/m_api.h"
|
||||
|
||||
#include "os/os_threading.h"
|
||||
#include "xrt/xrt_byte_order.h"
|
||||
|
||||
#include "util/u_autoexpgain.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_var.h"
|
||||
@@ -28,6 +27,10 @@
|
||||
#include "wmr_protocol.h"
|
||||
#include "wmr_camera.h"
|
||||
|
||||
#include <libusb.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
//! Specifies whether the user wants to enable autoexposure from the start.
|
||||
DEBUG_GET_ONCE_BOOL_OPTION(wmr_autoexposure, "WMR_AUTOEXPOSURE", true)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include "xrt/xrt_byte_order.h"
|
||||
|
||||
#include "wmr_protocol.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
// Copyright 2025, Beyley Cardellio
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief Endian-specific byte order defines.
|
||||
* @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
|
||||
* @ingroup aux_os
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "xrt_compiler.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
// On Linux, all these conversion functions are defined for both endians
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#elif defined(XRT_BIG_ENDIAN)
|
||||
|
||||
#error "@todo: Add byte order constants and functions for this OS or big endian machines."
|
||||
|
||||
#else
|
||||
|
||||
#define __be64 uint64_t
|
||||
#define __be32 uint32_t
|
||||
#define __be16 uint16_t
|
||||
|
||||
#define __be16_to_cpu(x) ((((uint16_t)x & (uint16_t)0x00FFU) << 8) | (((uint16_t)x & (uint16_t)0xFF00U) >> 8))
|
||||
#define __cpu_to_be16(x) __be16_to_cpu(x)
|
||||
|
||||
#define __be32_to_cpu(x) \
|
||||
((((uint32_t)x & (uint32_t)0x000000FFUL) << 24) | (((uint32_t)x & (uint32_t)0x0000FF00UL) << 8) | \
|
||||
(((uint32_t)x & (uint32_t)0x00FF0000UL) >> 8) | (((uint32_t)x & (uint32_t)0xFF000000UL) >> 24))
|
||||
#define __cpu_to_be32(x) __be32_to_cpu(x)
|
||||
|
||||
#define __be64_to_cpu(x) \
|
||||
((((uint64_t)x & (uint64_t)0x00000000000000FFULL) << 56) | \
|
||||
(((uint64_t)x & (uint64_t)0x000000000000FF00ULL) << 40) | \
|
||||
(((uint64_t)x & (uint64_t)0x0000000000FF0000ULL) << 24) | \
|
||||
(((uint64_t)x & (uint64_t)0x00000000FF000000ULL) << 8) | \
|
||||
(((uint64_t)x & (uint64_t)0x000000FF00000000ULL) >> 8) | \
|
||||
(((uint64_t)x & (uint64_t)0x0000FF0000000000ULL) >> 24) | \
|
||||
(((uint64_t)x & (uint64_t)0x00FF000000000000ULL) >> 40) | \
|
||||
(((uint64_t)x & (uint64_t)0xFF00000000000000ULL) >> 56)) |
|
||||
#define __cpu_to_be64(x) __be64_to_cpu(x)
|
||||
|
||||
#define __le64 uint64_t
|
||||
#define __le32 uint32_t
|
||||
#define __le16 uint16_t
|
||||
#define __u8 uint8_t
|
||||
#define __s8 int8_t
|
||||
#define __cpu_to_le16
|
||||
#define __le16_to_cpu
|
||||
#define __cpu_to_le32
|
||||
#define __le32_to_cpu
|
||||
#define __cpu_to_le64
|
||||
#define __le64_to_cpu
|
||||
|
||||
#endif
|
||||
@@ -24,6 +24,27 @@
|
||||
#include "xrt_windows.h"
|
||||
#endif // _MSC_VER
|
||||
|
||||
#if (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN) || \
|
||||
(defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || \
|
||||
(defined(__STDC_ENDIAN_NATIVE__) && __STDC_ENDIAN_NATIVE__ == __STDC_ENDIAN_BIG__) || defined(__BIG_ENDIAN__) || \
|
||||
defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || \
|
||||
defined(__MIBSEB__)
|
||||
|
||||
#define XRT_BIG_ENDIAN
|
||||
|
||||
#elif (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || \
|
||||
(defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
|
||||
(defined(__STDC_ENDIAN_NATIVE__) && __STDC_ENDIAN_NATIVE__ == __STDC_ENDIAN_LITTLE__) || \
|
||||
defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || \
|
||||
defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || defined(__x86_64__) || defined(_M_X64) || \
|
||||
defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86)
|
||||
|
||||
#undef XRT_BIG_ENDIAN
|
||||
|
||||
#else
|
||||
#error "@todo: Unable to determine current architecture."
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Array size helper.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user