mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-10 15:58:06 +00:00
d/daydream: Port to u_logging.
Port static printfs to u_logging.
This commit is contained in:
parent
1ba7d803a0
commit
2dbb6a6bb8
src/xrt/drivers/daydream
|
@ -29,6 +29,7 @@
|
|||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
DEBUG_GET_ONCE_LOG_OPTION(daydream_log, "DAYDREAM_LOG", U_LOGGING_WARN)
|
||||
|
||||
/*!
|
||||
* Indices where each input is in the input list.
|
||||
|
@ -174,7 +175,7 @@ daydream_read_one_packet(struct daydream_device *daydream,
|
|||
retries--;
|
||||
}
|
||||
if (ret == 0) {
|
||||
fprintf(stderr, "%s\n", __func__);
|
||||
U_LOG_W("Retrying Bluetooth read.");
|
||||
// Must lock thread before check in while.
|
||||
os_thread_helper_lock(&daydream->oth);
|
||||
continue;
|
||||
|
@ -363,9 +364,7 @@ static struct xrt_binding_profile binding_profiles[1] = {
|
|||
*/
|
||||
|
||||
struct daydream_device *
|
||||
daydream_device_create(struct os_ble_device *ble,
|
||||
bool print_spew,
|
||||
bool print_debug)
|
||||
daydream_device_create(struct os_ble_device *ble)
|
||||
{
|
||||
enum u_device_alloc_flags flags =
|
||||
(enum u_device_alloc_flags)(U_DEVICE_ALLOC_TRACKING_NONE);
|
||||
|
@ -387,8 +386,7 @@ daydream_device_create(struct os_ble_device *ble,
|
|||
dd->base.num_binding_profiles = ARRAY_SIZE(binding_profiles);
|
||||
|
||||
dd->ble = ble;
|
||||
dd->print_spew = print_spew;
|
||||
dd->print_debug = print_debug;
|
||||
dd->ll = debug_get_log_option_daydream_log();
|
||||
|
||||
float accel_ticks_to_float = MATH_GRAVITY_M_S2 / 520.0;
|
||||
float gyro_ticks_to_float = 1.0 / 120.0;
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include "os/os_threading.h"
|
||||
#include "os/os_ble.h"
|
||||
|
||||
#include "util/u_logging.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -84,8 +86,7 @@ struct daydream_device
|
|||
struct m_imu_3dof fusion;
|
||||
};
|
||||
|
||||
bool print_spew;
|
||||
bool print_debug;
|
||||
enum u_logging_level ll;
|
||||
|
||||
struct
|
||||
{
|
||||
|
@ -95,35 +96,14 @@ struct daydream_device
|
|||
|
||||
|
||||
struct daydream_device *
|
||||
daydream_device_create(struct os_ble_device *ble,
|
||||
bool print_spew,
|
||||
bool print_debug);
|
||||
daydream_device_create(struct os_ble_device *ble);
|
||||
|
||||
|
||||
#define DAYDREAM_SPEW(c, ...) \
|
||||
do { \
|
||||
if (c->print_spew) { \
|
||||
fprintf(stderr, "%s - ", __func__); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define DAYDREAM_DEBUG(c, ...) \
|
||||
do { \
|
||||
if (c->print_debug) { \
|
||||
fprintf(stderr, "%s - ", __func__); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define DAYDREAM_ERROR(c, ...) \
|
||||
do { \
|
||||
fprintf(stderr, "%s - ", __func__); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
} while (false)
|
||||
#define DAYDREAM_TRACE(d, ...) U_LOG_XDEV_IFL_T(&d->base, d->ll, __VA_ARGS__)
|
||||
#define DAYDREAM_DEBUG(d, ...) U_LOG_XDEV_IFL_D(&d->base, d->ll, __VA_ARGS__)
|
||||
#define DAYDREAM_INFO(d, ...) U_LOG_XDEV_IFL_I(&d->base, d->ll, __VA_ARGS__)
|
||||
#define DAYDREAM_WARN(d, ...) U_LOG_XDEV_IFL_W(&d->base, d->ll, __VA_ARGS__)
|
||||
#define DAYDREAM_ERROR(d, ...) U_LOG_XDEV_IFL_E(&d->base, d->ll, __VA_ARGS__)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
|
||||
// Should the experimental Daydream driver be enabled.
|
||||
DEBUG_GET_ONCE_BOOL_OPTION(daydream_enable, "DAYDREAM_ENABLE", true)
|
||||
DEBUG_GET_ONCE_BOOL_OPTION(daydream_spew, "DAYDREAM_PRINT_SPEW", false)
|
||||
DEBUG_GET_ONCE_BOOL_OPTION(daydream_debug, "DAYDREAM_PRINT_DEBUG", false)
|
||||
|
||||
/*!
|
||||
* Daydream prober struct.
|
||||
|
@ -41,9 +39,6 @@ DEBUG_GET_ONCE_BOOL_OPTION(daydream_debug, "DAYDREAM_PRINT_DEBUG", false)
|
|||
struct daydream_prober
|
||||
{
|
||||
struct xrt_auto_prober base;
|
||||
|
||||
bool print_spew;
|
||||
bool print_debug;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
|
@ -91,8 +86,7 @@ daydream_prober_autoprobe(struct xrt_auto_prober *xap,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct daydream_device *dd = daydream_device_create(
|
||||
ble, pdaydream->print_spew, pdaydream->print_debug);
|
||||
struct daydream_device *dd = daydream_device_create(ble);
|
||||
|
||||
return &dd->base;
|
||||
}
|
||||
|
@ -113,8 +107,6 @@ daydream_create_auto_prober()
|
|||
pdaydream->base.destroy = daydream_prober_destroy;
|
||||
pdaydream->base.lelo_dallas_autoprobe = daydream_prober_autoprobe;
|
||||
pdaydream->enabled = debug_get_bool_option_daydream_enable();
|
||||
pdaydream->print_spew = debug_get_bool_option_daydream_spew();
|
||||
pdaydream->print_debug = debug_get_bool_option_daydream_debug();
|
||||
|
||||
return &pdaydream->base;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue