libcamera: Make libudev optional
libcamera depends on libudev for device enumeration. It is however useful to allow building documentation without requiring the dependency to be installed. Make the libudev dependency optional and compile the udev-based device enumerator out when libudev is not present. Note that while libcamera will compile without libudev, it will not be able to enumerate devices. A sysfs-based device enumerator is planned as a fallback but not implemented yet. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
@@ -7,19 +7,14 @@
|
||||
#ifndef __LIBCAMERA_DEVICE_ENUMERATOR_H__
|
||||
#define __LIBCAMERA_DEVICE_ENUMERATOR_H__
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <linux/media.h>
|
||||
|
||||
struct udev;
|
||||
struct udev_monitor;
|
||||
|
||||
namespace libcamera {
|
||||
|
||||
class EventNotifier;
|
||||
class MediaDevice;
|
||||
|
||||
class DeviceMatch
|
||||
@@ -58,25 +53,6 @@ private:
|
||||
virtual std::string lookupDeviceNode(int major, int minor) = 0;
|
||||
};
|
||||
|
||||
class DeviceEnumeratorUdev: public DeviceEnumerator
|
||||
{
|
||||
public:
|
||||
DeviceEnumeratorUdev();
|
||||
~DeviceEnumeratorUdev();
|
||||
|
||||
int init() final;
|
||||
int enumerate() final;
|
||||
|
||||
private:
|
||||
struct udev *udev_;
|
||||
struct udev_monitor *monitor_;
|
||||
EventNotifier *notifier_;
|
||||
|
||||
std::string lookupDeviceNode(int major, int minor) final;
|
||||
|
||||
void udevNotify(EventNotifier *notifier);
|
||||
};
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
#endif /* __LIBCAMERA_DEVICE_ENUMERATOR_H__ */
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
/*
|
||||
* Copyright (C) 2018-2019, Google Inc.
|
||||
*
|
||||
* device_enumerator_udev.h - udev-based device enumerator
|
||||
*/
|
||||
#ifndef __LIBCAMERA_DEVICE_ENUMERATOR_UDEV_H__
|
||||
#define __LIBCAMERA_DEVICE_ENUMERATOR_UDEV_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "device_enumerator.h"
|
||||
|
||||
struct udev;
|
||||
struct udev_monitor;
|
||||
|
||||
namespace libcamera {
|
||||
|
||||
class EventNotifier;
|
||||
|
||||
class DeviceEnumeratorUdev : public DeviceEnumerator
|
||||
{
|
||||
public:
|
||||
DeviceEnumeratorUdev();
|
||||
~DeviceEnumeratorUdev();
|
||||
|
||||
int init() final;
|
||||
int enumerate() final;
|
||||
|
||||
private:
|
||||
struct udev *udev_;
|
||||
struct udev_monitor *monitor_;
|
||||
EventNotifier *notifier_;
|
||||
|
||||
std::string lookupDeviceNode(int major, int minor) final;
|
||||
|
||||
void udevNotify(EventNotifier *notifier);
|
||||
};
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
#endif /* __LIBCAMERA_DEVICE_ENUMERATOR_UDEV_H__ */
|
||||
Reference in New Issue
Block a user