mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 04:36:07 +00:00
d/psvr: Switch to logging API
This commit is contained in:
parent
6fd1e7b36c
commit
d72776b82c
|
@ -42,6 +42,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEBUG_GET_ONCE_BOOL_OPTION(psvr_disco, "PSVR_DISCO", false)
|
DEBUG_GET_ONCE_BOOL_OPTION(psvr_disco, "PSVR_DISCO", false)
|
||||||
|
#define PSVR_DEBUG(p, ...) U_LOG_XDEV_IFL_D(&p->base, p->log_level, __VA_ARGS__)
|
||||||
|
#define PSVR_ERROR(p, ...) U_LOG_XDEV_IFL_E(&p->base, p->log_level, __VA_ARGS__)
|
||||||
|
|
||||||
#define FEATURE_BUFFER_SIZE 256
|
#define FEATURE_BUFFER_SIZE 256
|
||||||
|
|
||||||
|
@ -85,8 +87,7 @@ struct psvr_device
|
||||||
bool powered_on;
|
bool powered_on;
|
||||||
bool in_vr_mode;
|
bool in_vr_mode;
|
||||||
|
|
||||||
bool print_spew;
|
enum u_logging_level log_level;
|
||||||
bool print_debug;
|
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -1010,8 +1011,7 @@ struct xrt_device *
|
||||||
psvr_device_create(struct hid_device_info *hmd_handle_info,
|
psvr_device_create(struct hid_device_info *hmd_handle_info,
|
||||||
struct hid_device_info *hmd_control_info,
|
struct hid_device_info *hmd_control_info,
|
||||||
struct xrt_prober *xp,
|
struct xrt_prober *xp,
|
||||||
bool print_spew,
|
enum u_logging_level log_level)
|
||||||
bool print_debug)
|
|
||||||
{
|
{
|
||||||
enum u_device_alloc_flags flags = (enum u_device_alloc_flags)(
|
enum u_device_alloc_flags flags = (enum u_device_alloc_flags)(
|
||||||
U_DEVICE_ALLOC_HMD | U_DEVICE_ALLOC_TRACKING_NONE);
|
U_DEVICE_ALLOC_HMD | U_DEVICE_ALLOC_TRACKING_NONE);
|
||||||
|
@ -1019,8 +1019,7 @@ psvr_device_create(struct hid_device_info *hmd_handle_info,
|
||||||
U_DEVICE_ALLOCATE(struct psvr_device, flags, 1, 0);
|
U_DEVICE_ALLOCATE(struct psvr_device, flags, 1, 0);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
psvr->print_spew = print_spew;
|
psvr->log_level = log_level;
|
||||||
psvr->print_debug = print_debug;
|
|
||||||
psvr->base.update_inputs = psvr_device_update_inputs;
|
psvr->base.update_inputs = psvr_device_update_inputs;
|
||||||
psvr->base.get_tracked_pose = psvr_device_get_tracked_pose;
|
psvr->base.get_tracked_pose = psvr_device_get_tracked_pose;
|
||||||
psvr->base.get_view_pose = psvr_device_get_view_pose;
|
psvr->base.get_view_pose = psvr_device_get_view_pose;
|
||||||
|
@ -1136,15 +1135,14 @@ psvr_device_create(struct hid_device_info *hmd_handle_info,
|
||||||
u_var_add_u8(psvr, &psvr->wants.leds[6], "Led G");
|
u_var_add_u8(psvr, &psvr->wants.leds[6], "Led G");
|
||||||
u_var_add_u8(psvr, &psvr->wants.leds[7], "Led H");
|
u_var_add_u8(psvr, &psvr->wants.leds[7], "Led H");
|
||||||
u_var_add_u8(psvr, &psvr->wants.leds[8], "Led I");
|
u_var_add_u8(psvr, &psvr->wants.leds[8], "Led I");
|
||||||
u_var_add_bool(psvr, &psvr->print_debug, "Debug");
|
u_var_add_log_level(psvr, &psvr->log_level, "Log level");
|
||||||
u_var_add_bool(psvr, &psvr->print_spew, "Spew");
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finishing touches.
|
* Finishing touches.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (psvr->print_debug) {
|
if (psvr->log_level <= U_LOGGING_DEBUG) {
|
||||||
u_device_dump_config(&psvr->base, __func__, "Sony PSVR");
|
u_device_dump_config(&psvr->base, __func__, "Sony PSVR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include "xrt/xrt_device.h"
|
#include "xrt/xrt_device.h"
|
||||||
#include "xrt/xrt_prober.h"
|
#include "xrt/xrt_prober.h"
|
||||||
|
|
||||||
|
#include "util/u_logging.h"
|
||||||
|
|
||||||
#include <hidapi.h>
|
#include <hidapi.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,8 +127,7 @@ struct xrt_device *
|
||||||
psvr_device_create(struct hid_device_info *hmd_handle_info,
|
psvr_device_create(struct hid_device_info *hmd_handle_info,
|
||||||
struct hid_device_info *hmd_control_info,
|
struct hid_device_info *hmd_control_info,
|
||||||
struct xrt_prober *xp,
|
struct xrt_prober *xp,
|
||||||
bool print_spew,
|
enum u_logging_level log_level);
|
||||||
bool print_debug);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
psvr_parse_sensor_packet(struct psvr_parsed_sensor *sensor,
|
psvr_parse_sensor_packet(struct psvr_parsed_sensor *sensor,
|
||||||
|
@ -139,37 +140,6 @@ psvr_parse_status_packet(struct psvr_parsed_status *status,
|
||||||
int size);
|
int size);
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Printing functions.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define PSVR_SPEW(p, ...) \
|
|
||||||
do { \
|
|
||||||
if (p->print_spew) { \
|
|
||||||
fprintf(stderr, "%s - ", __func__); \
|
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
|
||||||
fprintf(stderr, "\n"); \
|
|
||||||
} \
|
|
||||||
} while (false)
|
|
||||||
#define PSVR_DEBUG(p, ...) \
|
|
||||||
do { \
|
|
||||||
if (p->print_debug) { \
|
|
||||||
fprintf(stderr, "%s - ", __func__); \
|
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
|
||||||
fprintf(stderr, "\n"); \
|
|
||||||
} \
|
|
||||||
} while (false)
|
|
||||||
|
|
||||||
#define PSVR_ERROR(p, ...) \
|
|
||||||
do { \
|
|
||||||
fprintf(stderr, "%s - ", __func__); \
|
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
|
||||||
fprintf(stderr, "\n"); \
|
|
||||||
} while (false)
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "util/u_misc.h"
|
#include "util/u_misc.h"
|
||||||
#include "util/u_debug.h"
|
#include "util/u_debug.h"
|
||||||
|
#include "util/u_logging.h"
|
||||||
|
|
||||||
#include "psvr_interface.h"
|
#include "psvr_interface.h"
|
||||||
#include "psvr_device.h"
|
#include "psvr_device.h"
|
||||||
|
@ -30,8 +31,9 @@
|
||||||
|
|
||||||
// Should the experimental PSVR driver be enabled.
|
// Should the experimental PSVR driver be enabled.
|
||||||
DEBUG_GET_ONCE_BOOL_OPTION(psvr_enable, "PSVR_ENABLE", true)
|
DEBUG_GET_ONCE_BOOL_OPTION(psvr_enable, "PSVR_ENABLE", true)
|
||||||
DEBUG_GET_ONCE_BOOL_OPTION(psvr_spew, "PSVR_PRINT_SPEW", false)
|
DEBUG_GET_ONCE_LOG_OPTION(psvr_log, "DUMMY_LOG", U_LOGGING_WARN)
|
||||||
DEBUG_GET_ONCE_BOOL_OPTION(psvr_debug, "PSVR_PRINT_DEBUG", false)
|
|
||||||
|
#define PSVR_DEBUG(p, ...) U_LOG_IFL_D(p->log_level, __VA_ARGS__)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* PSVR prober struct.
|
* PSVR prober struct.
|
||||||
|
@ -43,9 +45,9 @@ struct psvr_prober
|
||||||
{
|
{
|
||||||
struct xrt_auto_prober base;
|
struct xrt_auto_prober base;
|
||||||
|
|
||||||
bool print_spew;
|
|
||||||
bool print_debug;
|
|
||||||
bool enabled;
|
bool enabled;
|
||||||
|
|
||||||
|
enum u_logging_level log_level;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,8 +106,7 @@ psvr_prober_autoprobe(struct xrt_auto_prober *xap,
|
||||||
if (info_control != NULL && info_handle != NULL) {
|
if (info_control != NULL && info_handle != NULL) {
|
||||||
if (ppsvr->enabled) {
|
if (ppsvr->enabled) {
|
||||||
dev = psvr_device_create(info_handle, info_control, xp,
|
dev = psvr_device_create(info_handle, info_control, xp,
|
||||||
ppsvr->print_spew,
|
ppsvr->log_level);
|
||||||
ppsvr->print_debug);
|
|
||||||
} else {
|
} else {
|
||||||
PSVR_DEBUG(ppsvr,
|
PSVR_DEBUG(ppsvr,
|
||||||
"Found a PSVR hmd but driver is disabled");
|
"Found a PSVR hmd but driver is disabled");
|
||||||
|
@ -132,8 +133,7 @@ psvr_create_auto_prober(void)
|
||||||
ppsvr->base.destroy = psvr_prober_destroy;
|
ppsvr->base.destroy = psvr_prober_destroy;
|
||||||
ppsvr->base.lelo_dallas_autoprobe = psvr_prober_autoprobe;
|
ppsvr->base.lelo_dallas_autoprobe = psvr_prober_autoprobe;
|
||||||
ppsvr->enabled = debug_get_bool_option_psvr_enable();
|
ppsvr->enabled = debug_get_bool_option_psvr_enable();
|
||||||
ppsvr->print_spew = debug_get_bool_option_psvr_spew();
|
ppsvr->log_level = debug_get_log_option_psvr_log();
|
||||||
ppsvr->print_debug = debug_get_bool_option_psvr_debug();
|
|
||||||
|
|
||||||
return &ppsvr->base;
|
return &ppsvr->base;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue