From bd257500b8ae3333a4a5c8c059ff6d796d078e86 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 6 Sep 2020 13:31:10 +0100 Subject: [PATCH] d/v4l2: Expose more information --- doc/changes/drivers/mr.665.1.md | 1 + src/xrt/drivers/v4l2/v4l2_driver.c | 10 +++++++++- src/xrt/drivers/v4l2/v4l2_interface.h | 8 +++++++- src/xrt/state_trackers/prober/p_prober.c | 3 ++- 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 doc/changes/drivers/mr.665.1.md diff --git a/doc/changes/drivers/mr.665.1.md b/doc/changes/drivers/mr.665.1.md new file mode 100644 index 000000000..cf68d1b8f --- /dev/null +++ b/doc/changes/drivers/mr.665.1.md @@ -0,0 +1 @@ +v4l2: Expose more information through new fields in XRT interface. diff --git a/src/xrt/drivers/v4l2/v4l2_driver.c b/src/xrt/drivers/v4l2/v4l2_driver.c index 691231ea4..cbf6dd826 100644 --- a/src/xrt/drivers/v4l2/v4l2_driver.c +++ b/src/xrt/drivers/v4l2/v4l2_driver.c @@ -740,7 +740,11 @@ v4l2_fs_node_destroy(struct xrt_frame_node *node) } struct xrt_fs * -v4l2_fs_create(struct xrt_frame_context *xfctx, const char *path) +v4l2_fs_create(struct xrt_frame_context *xfctx, + const char *path, + const char *product, + const char *manufacturer, + const char *serial) { struct v4l2_fs *vid = U_TYPED_CALLOC(struct v4l2_fs); vid->base.enumerate_modes = v4l2_fs_enumerate_modes; @@ -753,6 +757,10 @@ v4l2_fs_create(struct xrt_frame_context *xfctx, const char *path) vid->ll = debug_get_log_option_v4l2_log(); vid->fd = -1; + snprintf(vid->base.product, sizeof(vid->base.product), "%s", product); + snprintf(vid->base.manufacturer, sizeof(vid->base.manufacturer), "%s", manufacturer); + snprintf(vid->base.serial, sizeof(vid->base.serial), "%s", serial); + int fd = open(path, O_RDWR, 0); if (fd < 0) { V4L2_ERROR(vid, "Can not open '%s'", path); diff --git a/src/xrt/drivers/v4l2/v4l2_interface.h b/src/xrt/drivers/v4l2/v4l2_interface.h index f2cdf2be9..4ff37dfc4 100644 --- a/src/xrt/drivers/v4l2/v4l2_interface.h +++ b/src/xrt/drivers/v4l2/v4l2_interface.h @@ -58,13 +58,19 @@ struct v4l2_source_descriptor uint32_t rate; }; + + /*! * Create a v4l2 frameserver * * @ingroup drv_v4l2 */ struct xrt_fs * -v4l2_fs_create(struct xrt_frame_context *xfctx, const char *path); +v4l2_fs_create(struct xrt_frame_context *xfctx, + const char *path, + const char *product, + const char *manufacturer, + const char *serial); #ifdef __cplusplus diff --git a/src/xrt/state_trackers/prober/p_prober.c b/src/xrt/state_trackers/prober/p_prober.c index d0b73da1b..1fc0f2455 100644 --- a/src/xrt/state_trackers/prober/p_prober.c +++ b/src/xrt/state_trackers/prober/p_prober.c @@ -758,7 +758,8 @@ open_video_device(struct xrt_prober *xp, return -1; } - struct xrt_fs *xfs = v4l2_fs_create(xfctx, pdev->v4ls[0].path); + struct xrt_fs *xfs = + v4l2_fs_create(xfctx, pdev->v4ls[0].path, pdev->usb.product, pdev->usb.manufacturer, pdev->usb.serial); if (xfs == NULL) { return -1; }