Many signals used in internal and public APIs carry the emitter pointer as a signal argument. This was done to allow slots connected to multiple signal instances to differentiate between emitters. While starting from a good intention of facilitating the implementation of slots, it turned out to be a bad API design as the signal isn't meant to know what it will be connected to, and thus shouldn't carry parameters that are solely meant to support a use case specific to the connected slot. These pointers turn out to be unused in all slots but one. In the only case where it is needed, it can be obtained by wrapping the slot in a lambda function when connecting the signal. Do so, and drop the emitter pointer from all signals. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
76 lines
1.6 KiB
C++
76 lines
1.6 KiB
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2018-2019, Google Inc.
|
|
*
|
|
* device_enumerator_udev.h - udev-based device enumerator
|
|
*/
|
|
#ifndef __LIBCAMERA_INTERNAL_DEVICE_ENUMERATOR_UDEV_H__
|
|
#define __LIBCAMERA_INTERNAL_DEVICE_ENUMERATOR_UDEV_H__
|
|
|
|
#include <list>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <set>
|
|
#include <string>
|
|
#include <sys/types.h>
|
|
|
|
#include "libcamera/internal/device_enumerator.h"
|
|
|
|
struct udev;
|
|
struct udev_device;
|
|
struct udev_monitor;
|
|
|
|
namespace libcamera {
|
|
|
|
class EventNotifier;
|
|
class MediaDevice;
|
|
class MediaEntity;
|
|
|
|
class DeviceEnumeratorUdev final : public DeviceEnumerator
|
|
{
|
|
public:
|
|
DeviceEnumeratorUdev();
|
|
~DeviceEnumeratorUdev();
|
|
|
|
int init();
|
|
int enumerate();
|
|
|
|
private:
|
|
using DependencyMap = std::map<dev_t, std::list<MediaEntity *>>;
|
|
|
|
struct MediaDeviceDeps {
|
|
MediaDeviceDeps(std::unique_ptr<MediaDevice> media,
|
|
DependencyMap deps)
|
|
: media_(std::move(media)), deps_(std::move(deps))
|
|
{
|
|
}
|
|
|
|
bool operator==(const MediaDeviceDeps &other) const
|
|
{
|
|
return media_ == other.media_;
|
|
}
|
|
|
|
std::unique_ptr<MediaDevice> media_;
|
|
DependencyMap deps_;
|
|
};
|
|
|
|
int addUdevDevice(struct udev_device *dev);
|
|
int populateMediaDevice(MediaDevice *media, DependencyMap *deps);
|
|
std::string lookupDeviceNode(dev_t devnum);
|
|
|
|
int addV4L2Device(dev_t devnum);
|
|
void udevNotify();
|
|
|
|
struct udev *udev_;
|
|
struct udev_monitor *monitor_;
|
|
EventNotifier *notifier_;
|
|
|
|
std::set<dev_t> orphans_;
|
|
std::list<MediaDeviceDeps> pending_;
|
|
std::map<dev_t, MediaDeviceDeps *> devMap_;
|
|
};
|
|
|
|
} /* namespace libcamera */
|
|
|
|
#endif /* __LIBCAMERA_INTERNAL_DEVICE_ENUMERATOR_UDEV_H__ */
|