mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 18:46:18 +00:00
xrt: Add interface to prober to open video devices
This commit is contained in:
parent
3b1abffa2d
commit
c021199b98
|
@ -24,6 +24,8 @@ extern "C" {
|
|||
*
|
||||
*/
|
||||
|
||||
struct xrt_fs;
|
||||
struct xrt_frame_context;
|
||||
struct xrt_prober;
|
||||
struct xrt_prober_device;
|
||||
|
||||
|
@ -144,6 +146,10 @@ struct xrt_prober
|
|||
struct xrt_prober_device *xpdev,
|
||||
int interface,
|
||||
struct os_hid_device **out_hid_dev);
|
||||
int (*open_video_device)(struct xrt_prober *xp,
|
||||
struct xrt_prober_device *xpdev,
|
||||
struct xrt_frame_context *xfctx,
|
||||
struct xrt_fs **out_xfs);
|
||||
int (*list_video_devices)(struct xrt_prober *xp,
|
||||
xrt_prober_list_video_cb cb,
|
||||
void *ptr);
|
||||
|
@ -220,6 +226,20 @@ xrt_prober_get_string_descriptor(struct xrt_prober *xp,
|
|||
length);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Helper function for @ref xrt_prober::xrt_prober_open_video_device.
|
||||
*
|
||||
* @ingroup xrt_iface
|
||||
*/
|
||||
XRT_MAYBE_UNUSED static inline int
|
||||
xrt_prober_open_video_device(struct xrt_prober *xp,
|
||||
struct xrt_prober_device *xpdev,
|
||||
struct xrt_frame_context *xfctx,
|
||||
struct xrt_fs **out_xfs)
|
||||
{
|
||||
return xp->open_video_device(xp, xpdev, xfctx, out_xfs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Helper function for @ref xrt_prober::list_video_devices.
|
||||
*
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../auxiliary
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../drivers
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../../external
|
||||
)
|
||||
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
#include "util/u_debug.h"
|
||||
#include "p_prober.h"
|
||||
|
||||
#ifdef XRT_OS_LINUX
|
||||
#include "v4l2/v4l2_interface.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -54,6 +58,12 @@ open_hid_interface(struct xrt_prober* xp,
|
|||
int interface,
|
||||
struct os_hid_device** out_hid_dev);
|
||||
|
||||
static int
|
||||
open_video_device(struct xrt_prober* xp,
|
||||
struct xrt_prober_device* xpdev,
|
||||
struct xrt_frame_context* xfctx,
|
||||
struct xrt_fs** out_xfs);
|
||||
|
||||
static int
|
||||
list_video_devices(struct xrt_prober* xp,
|
||||
xrt_prober_list_video_cb cb,
|
||||
|
@ -235,6 +245,7 @@ initialize(struct prober* p, struct xrt_prober_entry_lists* lists)
|
|||
p->base.dump = dump;
|
||||
p->base.select = select_device;
|
||||
p->base.open_hid_interface = open_hid_interface;
|
||||
p->base.open_video_device = open_video_device;
|
||||
p->base.list_video_devices = list_video_devices;
|
||||
p->base.get_string_descriptor = get_string_descriptor;
|
||||
p->base.destroy = destroy;
|
||||
|
@ -567,6 +578,32 @@ open_hid_interface(struct xrt_prober* xp,
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
open_video_device(struct xrt_prober* xp,
|
||||
struct xrt_prober_device* xpdev,
|
||||
struct xrt_frame_context* xfctx,
|
||||
struct xrt_fs** out_xfs)
|
||||
{
|
||||
struct prober_device* pdev = (struct prober_device*)xpdev;
|
||||
|
||||
#ifdef XRT_OS_LINUX
|
||||
if (pdev->num_v4ls == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct xrt_fs* xfs = v4l2_fs_create(xfctx, pdev->v4ls[0].path);
|
||||
if (xfs == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*out_xfs = xfs;
|
||||
return 0;
|
||||
#else
|
||||
(void)pdev;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
list_video_devices(struct xrt_prober* xp,
|
||||
xrt_prober_list_video_cb cb,
|
||||
|
|
Loading…
Reference in a new issue