Monado OpenXR Runtime
wmr_camera.c File Reference

WMR camera interface. More...

#include <asm/byteorder.h>
#include <libusb.h>
#include <stdlib.h>
#include <assert.h>
#include <inttypes.h>
#include "math/m_api.h"
#include "os/os_threading.h"
#include "util/u_autoexpgain.h"
#include "util/u_debug.h"
#include "util/u_var.h"
#include "util/u_sink.h"
#include "util/u_frame.h"
#include "util/u_trace_marker.h"
#include "wmr_config.h"
#include "wmr_protocol.h"
#include "wmr_camera.h"
Include dependency graph for wmr_camera.c:

Data Structures

struct  wmr_camera_active_cmd
 
struct  wmr_camera_gain_cmd
 
struct  wmr_camera
 
struct  wmr_camera::wmr_camera_expgain
 

Macros

#define WMR_CAM_TRACE(c, ...)   U_LOG_IFL_T((c)->log_level, __VA_ARGS__)
 
#define WMR_CAM_DEBUG(c, ...)   U_LOG_IFL_D((c)->log_level, __VA_ARGS__)
 
#define WMR_CAM_INFO(c, ...)   U_LOG_IFL_I((c)->log_level, __VA_ARGS__)
 
#define WMR_CAM_WARN(c, ...)   U_LOG_IFL_W((c)->log_level, __VA_ARGS__)
 
#define WMR_CAM_ERROR(c, ...)   U_LOG_IFL_E((c)->log_level, __VA_ARGS__)
 
#define CAM_ENDPOINT   0x05
 
#define NUM_XFERS   4
 
#define WMR_CAMERA_CMD_GAIN   0x80
 
#define WMR_CAMERA_CMD_ON   0x81
 
#define WMR_CAMERA_CMD_OFF   0x82
 
#define DEFAULT_EXPOSURE   6000
 
#define DEFAULT_GAIN   127
 
#define WMR_FRAMETYPE_SLAM   0x0
 
#define WMR_FRAMETYPE_CONTROLLER   0x2
 
#define WMR_DEBUG_SINK_SLAM   0
 
#define WMR_DEBUG_SINK_CONTROLLER   1
 

Functions

static int update_expgain (struct wmr_camera *cam, struct xrt_frame **frames)
 Specifies whether the user wants to enable autoexposure from the start. More...
 
struct wmr_camera_active_cmd __attribute__ ((packed))
 
static bool compute_frame_size (struct wmr_camera *cam)
 
static void * wmr_cam_usb_thread (void *ptr)
 
static int send_buffer_to_device (struct wmr_camera *cam, uint8_t *buf, uint8_t len)
 
static int set_active (struct wmr_camera *cam, bool active)
 
static void LIBUSB_CALL img_xfer_cb (struct libusb_transfer *xfer)
 
struct wmr_camerawmr_camera_open (struct wmr_camera_open_config *config)
 
void wmr_camera_free (struct wmr_camera *cam)
 
bool wmr_camera_start (struct wmr_camera *cam)
 Starts the cameras. More...
 
bool wmr_camera_stop (struct wmr_camera *cam)
 
int wmr_camera_set_exposure_gain (struct wmr_camera *cam, uint8_t camera_id, uint16_t exposure, uint8_t gain)
 Set manual exposure and gain values. More...
 

Variables

__le32 magic
 
__le32 len
 
__le32 cmd
 
__le16 camera_id
 
__le16 exposure
 observed 60 to 6000 (but supports up to ~9000) More...
 
__le16 gain
 observed 16 to 255 More...
 
__le16 camera_id2
 same as camera_id More...
 
struct wmr_camera __attribute__
 

Detailed Description

Function Documentation

◆ update_expgain()

static int update_expgain ( struct wmr_camera cam,
struct xrt_frame **  frames 
)
static

Specifies whether the user wants to enable autoexposure from the start.

Specifies whether the user wants to use the same exp/gain values for all cameras

References wmr_camera::ceg, wmr_camera::tcam_confs, wmr_camera::tcam_count, u_autoexpgain_get_exposure(), u_autoexpgain_get_gain(), u_autoexpgain_update(), wmr_camera::unify_expgains, and wmr_camera_set_exposure_gain().

◆ wmr_cam_usb_thread()

static void* wmr_cam_usb_thread ( void *  ptr)
static
Todo:
Think this is not needed? what condition are we waiting for?

◆ wmr_camera_set_exposure_gain()

int wmr_camera_set_exposure_gain ( struct wmr_camera cam,
uint8_t  camera_id,
uint16_t  exposure,
uint8_t  gain 
)

Set manual exposure and gain values.

Parameters
camCamera container
camera_idWhich camera to affect
exposureTime the shutter is open, observed values 60-6000.
gainAmplification of the analog signal, observed values: 16-255.

Referenced by update_expgain().

◆ wmr_camera_start()

bool wmr_camera_start ( struct wmr_camera cam)

Starts the cameras.

Variable Documentation

◆ camera_id2

__le16 camera_id2

same as camera_id

◆ exposure

__le16 exposure

observed 60 to 6000 (but supports up to ~9000)

◆ gain

__le16 gain

observed 16 to 255