libcamera: Global s/devnode/deviceNode rename
Do not use the abreviated version for members, variables and getter methods. Library-wise rename, no intended functional changes. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
d18d25bde3
commit
1af83ca6df
11 changed files with 55 additions and 55 deletions
|
@ -189,18 +189,18 @@ DeviceEnumerator::~DeviceEnumerator()
|
|||
|
||||
/**
|
||||
* \brief Add a media device to the enumerator
|
||||
* \param[in] devnode path to the media device to add
|
||||
* \param[in] deviceNode path to the media device to add
|
||||
*
|
||||
* Create a media device for the \a devnode, open it, populate its media graph,
|
||||
* Create a media device for the \a deviceNode, open it, populate its media graph,
|
||||
* and look up device nodes associated with all entities. Store the media device
|
||||
* in the internal list for later matching with pipeline handlers.
|
||||
*
|
||||
* \return 0 on success, or a negative error code if the media device can't be
|
||||
* created or populated
|
||||
*/
|
||||
int DeviceEnumerator::addDevice(const std::string &devnode)
|
||||
int DeviceEnumerator::addDevice(const std::string &deviceNode)
|
||||
{
|
||||
MediaDevice *media = new MediaDevice(devnode);
|
||||
MediaDevice *media = new MediaDevice(deviceNode);
|
||||
|
||||
int ret = media->open();
|
||||
if (ret < 0)
|
||||
|
@ -209,25 +209,25 @@ int DeviceEnumerator::addDevice(const std::string &devnode)
|
|||
ret = media->populate();
|
||||
if (ret < 0) {
|
||||
LOG(DeviceEnumerator, Info)
|
||||
<< "Unable to populate media device " << devnode
|
||||
<< "Unable to populate media device " << deviceNode
|
||||
<< " (" << strerror(-ret) << "), skipping";
|
||||
return ret;
|
||||
}
|
||||
|
||||
LOG(DeviceEnumerator, Debug)
|
||||
<< "New media device \"" << media->driver()
|
||||
<< "\" created from " << devnode;
|
||||
<< "\" created from " << deviceNode;
|
||||
|
||||
/* Associate entities to device node paths. */
|
||||
for (MediaEntity *entity : media->entities()) {
|
||||
if (entity->deviceMajor() == 0 && entity->deviceMinor() == 0)
|
||||
continue;
|
||||
|
||||
std::string devnode = lookupDevnode(entity->deviceMajor(), entity->deviceMinor());
|
||||
if (devnode.empty())
|
||||
std::string deviceNode = lookupDeviceNode(entity->deviceMajor(), entity->deviceMinor());
|
||||
if (deviceNode.empty())
|
||||
return -EINVAL;
|
||||
|
||||
ret = entity->setDeviceNode(devnode);
|
||||
ret = entity->setDeviceNode(deviceNode);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ MediaDevice *DeviceEnumerator::search(const DeviceMatch &dm)
|
|||
}
|
||||
|
||||
/**
|
||||
* \fn DeviceEnumerator::lookupDevnode(int major, int minor)
|
||||
* \fn DeviceEnumerator::lookupDeviceNode(int major, int minor)
|
||||
* \brief Lookup device node path from device number
|
||||
* \param major The device major number
|
||||
* \param minor The device minor number
|
||||
|
@ -358,12 +358,12 @@ done:
|
|||
return ret >= 0 ? 0 : ret;
|
||||
}
|
||||
|
||||
std::string DeviceEnumeratorUdev::lookupDevnode(int major, int minor)
|
||||
std::string DeviceEnumeratorUdev::lookupDeviceNode(int major, int minor)
|
||||
{
|
||||
struct udev_device *device;
|
||||
const char *name;
|
||||
dev_t devnum;
|
||||
std::string devnode = std::string();
|
||||
std::string deviceNode = std::string();
|
||||
|
||||
devnum = makedev(major, minor);
|
||||
device = udev_device_new_from_devnum(udev_, 'c', devnum);
|
||||
|
@ -372,11 +372,11 @@ std::string DeviceEnumeratorUdev::lookupDevnode(int major, int minor)
|
|||
|
||||
name = udev_device_get_devnode(device);
|
||||
if (name)
|
||||
devnode = name;
|
||||
deviceNode = name;
|
||||
|
||||
udev_device_unref(device);
|
||||
|
||||
return devnode;
|
||||
return deviceNode;
|
||||
}
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
|
|
@ -45,12 +45,12 @@ public:
|
|||
MediaDevice *search(const DeviceMatch &dm);
|
||||
|
||||
protected:
|
||||
int addDevice(const std::string &devnode);
|
||||
int addDevice(const std::string &deviceNode);
|
||||
|
||||
private:
|
||||
std::vector<MediaDevice *> devices_;
|
||||
|
||||
virtual std::string lookupDevnode(int major, int minor) = 0;
|
||||
virtual std::string lookupDeviceNode(int major, int minor) = 0;
|
||||
};
|
||||
|
||||
class DeviceEnumeratorUdev: public DeviceEnumerator
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
private:
|
||||
struct udev *udev_;
|
||||
|
||||
std::string lookupDevnode(int major, int minor) final;
|
||||
std::string lookupDeviceNode(int major, int minor) final;
|
||||
};
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace libcamera {
|
|||
class MediaDevice
|
||||
{
|
||||
public:
|
||||
MediaDevice(const std::string &devnode);
|
||||
MediaDevice(const std::string &deviceNode);
|
||||
~MediaDevice();
|
||||
|
||||
bool acquire();
|
||||
|
@ -35,7 +35,7 @@ public:
|
|||
bool valid() const { return valid_; }
|
||||
|
||||
const std::string driver() const { return driver_; }
|
||||
const std::string devnode() const { return devnode_; }
|
||||
const std::string deviceNode() const { return deviceNode_; }
|
||||
|
||||
const std::vector<MediaEntity *> &entities() const { return entities_; }
|
||||
MediaEntity *getEntityByName(const std::string &name) const;
|
||||
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
private:
|
||||
std::string driver_;
|
||||
std::string devnode_;
|
||||
std::string deviceNode_;
|
||||
int fd_;
|
||||
bool valid_;
|
||||
bool acquired_;
|
||||
|
|
|
@ -85,7 +85,7 @@ class MediaEntity : public MediaObject
|
|||
public:
|
||||
const std::string &name() const { return name_; }
|
||||
unsigned int function() const { return function_; }
|
||||
const std::string &devnode() const { return devnode_; }
|
||||
const std::string &deviceNode() const { return deviceNode_; }
|
||||
unsigned int deviceMajor() const { return major_; }
|
||||
unsigned int deviceMinor() const { return minor_; }
|
||||
|
||||
|
@ -94,7 +94,7 @@ public:
|
|||
const MediaPad *getPadByIndex(unsigned int index) const;
|
||||
const MediaPad *getPadById(unsigned int id) const;
|
||||
|
||||
int setDeviceNode(const std::string &devnode);
|
||||
int setDeviceNode(const std::string &deviceNode);
|
||||
|
||||
private:
|
||||
friend class MediaDevice;
|
||||
|
@ -106,7 +106,7 @@ private:
|
|||
|
||||
std::string name_;
|
||||
unsigned int function_;
|
||||
std::string devnode_;
|
||||
std::string deviceNode_;
|
||||
unsigned int major_;
|
||||
unsigned int minor_;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class MediaEntity;
|
|||
class V4L2Device
|
||||
{
|
||||
public:
|
||||
explicit V4L2Device(const std::string &devnode);
|
||||
explicit V4L2Device(const std::string &deviceNode);
|
||||
explicit V4L2Device(const MediaEntity &entity);
|
||||
V4L2Device(const V4L2Device &) = delete;
|
||||
~V4L2Device();
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
const char *busName() const { return caps_.bus_info(); }
|
||||
|
||||
private:
|
||||
std::string devnode_;
|
||||
std::string deviceNode_;
|
||||
int fd_;
|
||||
V4L2Capability caps_;
|
||||
};
|
||||
|
|
|
@ -63,13 +63,13 @@ LOG_DEFINE_CATEGORY(MediaDevice)
|
|||
|
||||
/**
|
||||
* \brief Construct a MediaDevice
|
||||
* \param devnode The media device node path
|
||||
* \param deviceNode The media device node path
|
||||
*
|
||||
* Once constructed the media device is invalid, and must be opened and
|
||||
* populated with open() and populate() before the media graph can be queried.
|
||||
*/
|
||||
MediaDevice::MediaDevice(const std::string &devnode)
|
||||
: devnode_(devnode), fd_(-1), valid_(false), acquired_(false)
|
||||
MediaDevice::MediaDevice(const std::string &deviceNode)
|
||||
: deviceNode_(deviceNode), fd_(-1), valid_(false), acquired_(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -145,12 +145,12 @@ int MediaDevice::open()
|
|||
return -EBUSY;
|
||||
}
|
||||
|
||||
int ret = ::open(devnode_.c_str(), O_RDWR);
|
||||
int ret = ::open(deviceNode_.c_str(), O_RDWR);
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
LOG(MediaDevice, Error)
|
||||
<< "Failed to open media device at "
|
||||
<< devnode_ << ": " << strerror(-ret);
|
||||
<< deviceNode_ << ": " << strerror(-ret);
|
||||
return ret;
|
||||
}
|
||||
fd_ = ret;
|
||||
|
@ -285,9 +285,9 @@ int MediaDevice::populate()
|
|||
*/
|
||||
|
||||
/**
|
||||
* \fn MediaDevice::devnode()
|
||||
* \fn MediaDevice::deviceNode()
|
||||
* \brief Retrieve the media device device node path
|
||||
* \return The MediaDevice devnode path
|
||||
* \return The MediaDevice deviceNode path
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -246,7 +246,7 @@ void MediaPad::addLink(MediaLink *link)
|
|||
*
|
||||
* In addition to their graph id, media graph entities are identified by a
|
||||
* name() unique in the media device context. They implement a function() and
|
||||
* may expose a devnode().
|
||||
* may expose a deviceNode().
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -266,7 +266,7 @@ void MediaPad::addLink(MediaLink *link)
|
|||
*/
|
||||
|
||||
/**
|
||||
* \fn MediaEntity::devnode()
|
||||
* \fn MediaEntity::deviceNode()
|
||||
* \brief Retrieve the entity's device node path, if any
|
||||
*
|
||||
* \sa int setDeviceNode()
|
||||
|
@ -326,23 +326,23 @@ const MediaPad *MediaEntity::getPadById(unsigned int id) const
|
|||
|
||||
/**
|
||||
* \brief Set the path to the device node for the associated interface
|
||||
* \param devnode The interface device node path associated with this entity
|
||||
* \param deviceNode The interface device node path associated with this entity
|
||||
* \return 0 on success, or a negative error code if the device node can't be
|
||||
* accessed
|
||||
*/
|
||||
int MediaEntity::setDeviceNode(const std::string &devnode)
|
||||
int MediaEntity::setDeviceNode(const std::string &deviceNode)
|
||||
{
|
||||
/* Make sure the device node can be accessed. */
|
||||
int ret = ::access(devnode.c_str(), R_OK | W_OK);
|
||||
int ret = ::access(deviceNode.c_str(), R_OK | W_OK);
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
LOG(MediaDevice, Error)
|
||||
<< "Device node " << devnode << " can't be accessed: "
|
||||
<< "Device node " << deviceNode << " can't be accessed: "
|
||||
<< strerror(-ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
devnode_ = devnode;
|
||||
deviceNode_ = deviceNode;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -88,10 +88,10 @@ LOG_DEFINE_CATEGORY(V4L2)
|
|||
|
||||
/**
|
||||
* \brief Construct a V4L2Device
|
||||
* \param devnode The file-system path to the video device node
|
||||
* \param deviceNode The file-system path to the video device node
|
||||
*/
|
||||
V4L2Device::V4L2Device(const std::string &devnode)
|
||||
: devnode_(devnode), fd_(-1)
|
||||
V4L2Device::V4L2Device(const std::string &deviceNode)
|
||||
: deviceNode_(deviceNode), fd_(-1)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ V4L2Device::V4L2Device(const std::string &devnode)
|
|||
* Construct a V4L2Device from a MediaEntity's device node path.
|
||||
*/
|
||||
V4L2Device::V4L2Device(const MediaEntity &entity)
|
||||
: V4L2Device(entity.devnode())
|
||||
: V4L2Device(entity.deviceNode())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -124,11 +124,11 @@ int V4L2Device::open()
|
|||
return -EBUSY;
|
||||
}
|
||||
|
||||
ret = ::open(devnode_.c_str(), O_RDWR);
|
||||
ret = ::open(deviceNode_.c_str(), O_RDWR);
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
LOG(V4L2, Error)
|
||||
<< "Failed to open V4L2 device '" << devnode_
|
||||
<< "Failed to open V4L2 device '" << deviceNode_
|
||||
<< "': " << strerror(-ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ int V4L2Device::open()
|
|||
}
|
||||
|
||||
LOG(V4L2, Debug)
|
||||
<< "Opened '" << devnode_ << "' "
|
||||
<< "Opened '" << deviceNode_ << "' "
|
||||
<< caps_.bus_info() << ": " << caps_.driver()
|
||||
<< ": " << caps_.card();
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class MediaDeviceLinkTest : public Test
|
|||
|
||||
if (dev_->open()) {
|
||||
cerr << "Failed to open media device at "
|
||||
<< dev_->devnode() << endl;
|
||||
<< dev_->deviceNode() << endl;
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ protected:
|
|||
void cleanup() { }
|
||||
|
||||
private:
|
||||
int testMediaDevice(string devnode);
|
||||
int testMediaDevice(string deviceNode);
|
||||
|
||||
void printMediaGraph(const MediaDevice &media, ostream &os);
|
||||
void printLinkFlags(const MediaLink *link, ostream &os);
|
||||
|
@ -68,7 +68,7 @@ void MediaDevicePrintTest::printLinkFlags(const MediaLink *link, ostream &os)
|
|||
*/
|
||||
void MediaDevicePrintTest::printMediaGraph(const MediaDevice &media, ostream &os)
|
||||
{
|
||||
os << "\n" << media.driver() << " - " << media.devnode() << "\n\n";
|
||||
os << "\n" << media.driver() << " - " << media.deviceNode() << "\n\n";
|
||||
|
||||
for (auto const &entity : media.entities()) {
|
||||
os << "\"" << entity->name() << "\"\n";
|
||||
|
@ -108,9 +108,9 @@ void MediaDevicePrintTest::printMediaGraph(const MediaDevice &media, ostream &os
|
|||
}
|
||||
|
||||
/* Test a single media device. */
|
||||
int MediaDevicePrintTest::testMediaDevice(const string devnode)
|
||||
int MediaDevicePrintTest::testMediaDevice(const string deviceNode)
|
||||
{
|
||||
MediaDevice dev(devnode);
|
||||
MediaDevice dev(deviceNode);
|
||||
int ret;
|
||||
|
||||
/* Fuzzy open/close sequence. */
|
||||
|
@ -144,7 +144,7 @@ int MediaDevicePrintTest::testMediaDevice(const string devnode)
|
|||
#define MAX_MEDIA_DEV 256
|
||||
int MediaDevicePrintTest::run()
|
||||
{
|
||||
const string devnode("/dev/media");
|
||||
const string deviceNode("/dev/media");
|
||||
unsigned int i;
|
||||
int ret = 77; /* skip test exit code */
|
||||
|
||||
|
@ -153,7 +153,7 @@ int MediaDevicePrintTest::run()
|
|||
* system, if any.
|
||||
*/
|
||||
for (i = 0; i < MAX_MEDIA_DEV; i++) {
|
||||
string mediadev = devnode + to_string(i);
|
||||
string mediadev = deviceNode + to_string(i);
|
||||
struct stat pstat = { };
|
||||
|
||||
if (stat(mediadev.c_str(), &pstat))
|
||||
|
|
|
@ -72,7 +72,7 @@ int IPU3PipelineTest::init()
|
|||
}
|
||||
|
||||
if (cio2->open()) {
|
||||
cerr << "Failed to open media device " << cio2->devnode() << endl;
|
||||
cerr << "Failed to open media device " << cio2->deviceNode() << endl;
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ int IPU3PipelineTest::init()
|
|||
*/
|
||||
int ret = cio2->populate();
|
||||
if (ret) {
|
||||
cerr << "Failed to populate media device " << cio2->devnode() << endl;
|
||||
cerr << "Failed to populate media device " << cio2->deviceNode() << endl;
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue