d/wmr: Document camera start and constify argument

This commit is contained in:
Jakob Bornecrantz 2021-11-20 13:50:54 +00:00
parent 16c75e7cc7
commit 4329b755a9
2 changed files with 14 additions and 9 deletions

View file

@ -66,8 +66,8 @@ struct wmr_camera
struct os_thread_helper usb_thread;
int usb_complete;
struct wmr_camera_config *configs;
int n_configs;
const struct wmr_camera_config *configs;
int config_count;
size_t xfer_size;
uint32_t frame_width, frame_height;
@ -116,8 +116,8 @@ compute_frame_size(struct wmr_camera *cam)
F = 26;
for (i = 0; i < cam->n_configs; i++) {
struct wmr_camera_config *config = cam->configs + i;
for (i = 0; i < cam->config_count; i++) {
const struct wmr_camera_config *config = &cam->configs[i];
if (config->purpose != WMR_CAMERA_PURPOSE_HEAD_TRACKING)
continue;
@ -364,12 +364,12 @@ out:
}
bool
wmr_camera_start(struct wmr_camera *cam, struct wmr_camera_config *cam_configs, int n_configs)
wmr_camera_start(struct wmr_camera *cam, const struct wmr_camera_config *cam_configs, int config_count)
{
int res, i;
cam->configs = cam_configs;
cam->n_configs = n_configs;
cam->config_count = config_count;
if (!compute_frame_size(cam)) {
WMR_CAM_WARN(cam, "Invalid config or no head tracking cameras found");
goto fail;
@ -383,8 +383,8 @@ wmr_camera_start(struct wmr_camera *cam, struct wmr_camera_config *cam_configs,
if (res < 0)
goto fail;
for (i = 0; i < cam->n_configs; i++) {
struct wmr_camera_config *config = cam->configs + i;
for (i = 0; i < cam->config_count; i++) {
const struct wmr_camera_config *config = &cam->configs[i];
if (config->purpose != WMR_CAMERA_PURPOSE_HEAD_TRACKING)
continue;

View file

@ -27,8 +27,13 @@ wmr_camera_open(struct xrt_prober_device *dev_holo, enum u_logging_level ll);
void
wmr_camera_free(struct wmr_camera *cam);
/*!
* Starts the cameras.
*
* The data pointed to by @p configs must be kept alive for as long as the camera is kept alive.
*/
bool
wmr_camera_start(struct wmr_camera *cam, struct wmr_camera_config *cam_configs, int n_configs);
wmr_camera_start(struct wmr_camera *cam, const struct wmr_camera_config *configs, int config_count);
bool
wmr_camera_stop(struct wmr_camera *cam);
int