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:
Jacopo Mondi 2019-01-21 17:53:28 +01:00
parent d18d25bde3
commit 1af83ca6df
11 changed files with 55 additions and 55 deletions

View file

@ -189,18 +189,18 @@ DeviceEnumerator::~DeviceEnumerator()
/** /**
* \brief Add a media device to the enumerator * \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 * and look up device nodes associated with all entities. Store the media device
* in the internal list for later matching with pipeline handlers. * 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 * \return 0 on success, or a negative error code if the media device can't be
* created or populated * 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(); int ret = media->open();
if (ret < 0) if (ret < 0)
@ -209,25 +209,25 @@ int DeviceEnumerator::addDevice(const std::string &devnode)
ret = media->populate(); ret = media->populate();
if (ret < 0) { if (ret < 0) {
LOG(DeviceEnumerator, Info) LOG(DeviceEnumerator, Info)
<< "Unable to populate media device " << devnode << "Unable to populate media device " << deviceNode
<< " (" << strerror(-ret) << "), skipping"; << " (" << strerror(-ret) << "), skipping";
return ret; return ret;
} }
LOG(DeviceEnumerator, Debug) LOG(DeviceEnumerator, Debug)
<< "New media device \"" << media->driver() << "New media device \"" << media->driver()
<< "\" created from " << devnode; << "\" created from " << deviceNode;
/* Associate entities to device node paths. */ /* Associate entities to device node paths. */
for (MediaEntity *entity : media->entities()) { for (MediaEntity *entity : media->entities()) {
if (entity->deviceMajor() == 0 && entity->deviceMinor() == 0) if (entity->deviceMajor() == 0 && entity->deviceMinor() == 0)
continue; continue;
std::string devnode = lookupDevnode(entity->deviceMajor(), entity->deviceMinor()); std::string deviceNode = lookupDeviceNode(entity->deviceMajor(), entity->deviceMinor());
if (devnode.empty()) if (deviceNode.empty())
return -EINVAL; return -EINVAL;
ret = entity->setDeviceNode(devnode); ret = entity->setDeviceNode(deviceNode);
if (ret) if (ret)
return 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 * \brief Lookup device node path from device number
* \param major The device major number * \param major The device major number
* \param minor The device minor number * \param minor The device minor number
@ -358,12 +358,12 @@ done:
return ret >= 0 ? 0 : ret; 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; struct udev_device *device;
const char *name; const char *name;
dev_t devnum; dev_t devnum;
std::string devnode = std::string(); std::string deviceNode = std::string();
devnum = makedev(major, minor); devnum = makedev(major, minor);
device = udev_device_new_from_devnum(udev_, 'c', devnum); 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); name = udev_device_get_devnode(device);
if (name) if (name)
devnode = name; deviceNode = name;
udev_device_unref(device); udev_device_unref(device);
return devnode; return deviceNode;
} }
} /* namespace libcamera */ } /* namespace libcamera */

View file

@ -45,12 +45,12 @@ public:
MediaDevice *search(const DeviceMatch &dm); MediaDevice *search(const DeviceMatch &dm);
protected: protected:
int addDevice(const std::string &devnode); int addDevice(const std::string &deviceNode);
private: private:
std::vector<MediaDevice *> devices_; 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 class DeviceEnumeratorUdev: public DeviceEnumerator
@ -65,7 +65,7 @@ public:
private: private:
struct udev *udev_; struct udev *udev_;
std::string lookupDevnode(int major, int minor) final; std::string lookupDeviceNode(int major, int minor) final;
}; };
} /* namespace libcamera */ } /* namespace libcamera */

View file

@ -21,7 +21,7 @@ namespace libcamera {
class MediaDevice class MediaDevice
{ {
public: public:
MediaDevice(const std::string &devnode); MediaDevice(const std::string &deviceNode);
~MediaDevice(); ~MediaDevice();
bool acquire(); bool acquire();
@ -35,7 +35,7 @@ public:
bool valid() const { return valid_; } bool valid() const { return valid_; }
const std::string driver() const { return driver_; } 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_; } const std::vector<MediaEntity *> &entities() const { return entities_; }
MediaEntity *getEntityByName(const std::string &name) const; MediaEntity *getEntityByName(const std::string &name) const;
@ -49,7 +49,7 @@ public:
private: private:
std::string driver_; std::string driver_;
std::string devnode_; std::string deviceNode_;
int fd_; int fd_;
bool valid_; bool valid_;
bool acquired_; bool acquired_;

View file

@ -85,7 +85,7 @@ class MediaEntity : public MediaObject
public: public:
const std::string &name() const { return name_; } const std::string &name() const { return name_; }
unsigned int function() const { return function_; } 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 deviceMajor() const { return major_; }
unsigned int deviceMinor() const { return minor_; } unsigned int deviceMinor() const { return minor_; }
@ -94,7 +94,7 @@ public:
const MediaPad *getPadByIndex(unsigned int index) const; const MediaPad *getPadByIndex(unsigned int index) const;
const MediaPad *getPadById(unsigned int id) const; const MediaPad *getPadById(unsigned int id) const;
int setDeviceNode(const std::string &devnode); int setDeviceNode(const std::string &deviceNode);
private: private:
friend class MediaDevice; friend class MediaDevice;
@ -106,7 +106,7 @@ private:
std::string name_; std::string name_;
unsigned int function_; unsigned int function_;
std::string devnode_; std::string deviceNode_;
unsigned int major_; unsigned int major_;
unsigned int minor_; unsigned int minor_;

View file

@ -36,7 +36,7 @@ class MediaEntity;
class V4L2Device class V4L2Device
{ {
public: public:
explicit V4L2Device(const std::string &devnode); explicit V4L2Device(const std::string &deviceNode);
explicit V4L2Device(const MediaEntity &entity); explicit V4L2Device(const MediaEntity &entity);
V4L2Device(const V4L2Device &) = delete; V4L2Device(const V4L2Device &) = delete;
~V4L2Device(); ~V4L2Device();
@ -52,7 +52,7 @@ public:
const char *busName() const { return caps_.bus_info(); } const char *busName() const { return caps_.bus_info(); }
private: private:
std::string devnode_; std::string deviceNode_;
int fd_; int fd_;
V4L2Capability caps_; V4L2Capability caps_;
}; };

View file

@ -63,13 +63,13 @@ LOG_DEFINE_CATEGORY(MediaDevice)
/** /**
* \brief Construct a 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 * Once constructed the media device is invalid, and must be opened and
* populated with open() and populate() before the media graph can be queried. * populated with open() and populate() before the media graph can be queried.
*/ */
MediaDevice::MediaDevice(const std::string &devnode) MediaDevice::MediaDevice(const std::string &deviceNode)
: devnode_(devnode), fd_(-1), valid_(false), acquired_(false) : deviceNode_(deviceNode), fd_(-1), valid_(false), acquired_(false)
{ {
} }
@ -145,12 +145,12 @@ int MediaDevice::open()
return -EBUSY; return -EBUSY;
} }
int ret = ::open(devnode_.c_str(), O_RDWR); int ret = ::open(deviceNode_.c_str(), O_RDWR);
if (ret < 0) { if (ret < 0) {
ret = -errno; ret = -errno;
LOG(MediaDevice, Error) LOG(MediaDevice, Error)
<< "Failed to open media device at " << "Failed to open media device at "
<< devnode_ << ": " << strerror(-ret); << deviceNode_ << ": " << strerror(-ret);
return ret; return ret;
} }
fd_ = ret; fd_ = ret;
@ -285,9 +285,9 @@ int MediaDevice::populate()
*/ */
/** /**
* \fn MediaDevice::devnode() * \fn MediaDevice::deviceNode()
* \brief Retrieve the media device device node path * \brief Retrieve the media device device node path
* \return The MediaDevice devnode path * \return The MediaDevice deviceNode path
*/ */
/** /**

View file

@ -246,7 +246,7 @@ void MediaPad::addLink(MediaLink *link)
* *
* In addition to their graph id, media graph entities are identified by a * 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 * 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 * \brief Retrieve the entity's device node path, if any
* *
* \sa int setDeviceNode() * \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 * \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 * \return 0 on success, or a negative error code if the device node can't be
* accessed * accessed
*/ */
int MediaEntity::setDeviceNode(const std::string &devnode) int MediaEntity::setDeviceNode(const std::string &deviceNode)
{ {
/* Make sure the device node can be accessed. */ /* 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) { if (ret < 0) {
ret = -errno; ret = -errno;
LOG(MediaDevice, Error) LOG(MediaDevice, Error)
<< "Device node " << devnode << " can't be accessed: " << "Device node " << deviceNode << " can't be accessed: "
<< strerror(-ret); << strerror(-ret);
return ret; return ret;
} }
devnode_ = devnode; deviceNode_ = deviceNode;
return 0; return 0;
} }

View file

@ -88,10 +88,10 @@ LOG_DEFINE_CATEGORY(V4L2)
/** /**
* \brief Construct a V4L2Device * \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) V4L2Device::V4L2Device(const std::string &deviceNode)
: devnode_(devnode), fd_(-1) : deviceNode_(deviceNode), fd_(-1)
{ {
} }
@ -102,7 +102,7 @@ V4L2Device::V4L2Device(const std::string &devnode)
* Construct a V4L2Device from a MediaEntity's device node path. * Construct a V4L2Device from a MediaEntity's device node path.
*/ */
V4L2Device::V4L2Device(const MediaEntity &entity) V4L2Device::V4L2Device(const MediaEntity &entity)
: V4L2Device(entity.devnode()) : V4L2Device(entity.deviceNode())
{ {
} }
@ -124,11 +124,11 @@ int V4L2Device::open()
return -EBUSY; return -EBUSY;
} }
ret = ::open(devnode_.c_str(), O_RDWR); ret = ::open(deviceNode_.c_str(), O_RDWR);
if (ret < 0) { if (ret < 0) {
ret = -errno; ret = -errno;
LOG(V4L2, Error) LOG(V4L2, Error)
<< "Failed to open V4L2 device '" << devnode_ << "Failed to open V4L2 device '" << deviceNode_
<< "': " << strerror(-ret); << "': " << strerror(-ret);
return ret; return ret;
} }
@ -144,7 +144,7 @@ int V4L2Device::open()
} }
LOG(V4L2, Debug) LOG(V4L2, Debug)
<< "Opened '" << devnode_ << "' " << "Opened '" << deviceNode_ << "' "
<< caps_.bus_info() << ": " << caps_.driver() << caps_.bus_info() << ": " << caps_.driver()
<< ": " << caps_.card(); << ": " << caps_.card();

View file

@ -55,7 +55,7 @@ class MediaDeviceLinkTest : public Test
if (dev_->open()) { if (dev_->open()) {
cerr << "Failed to open media device at " cerr << "Failed to open media device at "
<< dev_->devnode() << endl; << dev_->deviceNode() << endl;
return TestFail; return TestFail;
} }

View file

@ -35,7 +35,7 @@ protected:
void cleanup() { } void cleanup() { }
private: private:
int testMediaDevice(string devnode); int testMediaDevice(string deviceNode);
void printMediaGraph(const MediaDevice &media, ostream &os); void printMediaGraph(const MediaDevice &media, ostream &os);
void printLinkFlags(const MediaLink *link, 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) 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()) { for (auto const &entity : media.entities()) {
os << "\"" << entity->name() << "\"\n"; os << "\"" << entity->name() << "\"\n";
@ -108,9 +108,9 @@ void MediaDevicePrintTest::printMediaGraph(const MediaDevice &media, ostream &os
} }
/* Test a single media device. */ /* 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; int ret;
/* Fuzzy open/close sequence. */ /* Fuzzy open/close sequence. */
@ -144,7 +144,7 @@ int MediaDevicePrintTest::testMediaDevice(const string devnode)
#define MAX_MEDIA_DEV 256 #define MAX_MEDIA_DEV 256
int MediaDevicePrintTest::run() int MediaDevicePrintTest::run()
{ {
const string devnode("/dev/media"); const string deviceNode("/dev/media");
unsigned int i; unsigned int i;
int ret = 77; /* skip test exit code */ int ret = 77; /* skip test exit code */
@ -153,7 +153,7 @@ int MediaDevicePrintTest::run()
* system, if any. * system, if any.
*/ */
for (i = 0; i < MAX_MEDIA_DEV; i++) { for (i = 0; i < MAX_MEDIA_DEV; i++) {
string mediadev = devnode + to_string(i); string mediadev = deviceNode + to_string(i);
struct stat pstat = { }; struct stat pstat = { };
if (stat(mediadev.c_str(), &pstat)) if (stat(mediadev.c_str(), &pstat))

View file

@ -72,7 +72,7 @@ int IPU3PipelineTest::init()
} }
if (cio2->open()) { if (cio2->open()) {
cerr << "Failed to open media device " << cio2->devnode() << endl; cerr << "Failed to open media device " << cio2->deviceNode() << endl;
return TestFail; return TestFail;
} }
@ -84,7 +84,7 @@ int IPU3PipelineTest::init()
*/ */
int ret = cio2->populate(); int ret = cio2->populate();
if (ret) { if (ret) {
cerr << "Failed to populate media device " << cio2->devnode() << endl; cerr << "Failed to populate media device " << cio2->deviceNode() << endl;
return TestFail; return TestFail;
} }