libcamera: v4l2_device: Inherit from Loggable to print device node name
Automate printing of device node name in log messages by inheriting from the Loggable class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
8a401ed411
commit
04d5be7f76
2 changed files with 15 additions and 8 deletions
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
#include <libcamera/signal.h>
|
#include <libcamera/signal.h>
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
namespace libcamera {
|
namespace libcamera {
|
||||||
|
|
||||||
class Buffer;
|
class Buffer;
|
||||||
|
@ -76,7 +78,7 @@ public:
|
||||||
unsigned int planesCount;
|
unsigned int planesCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
class V4L2Device
|
class V4L2Device : protected Loggable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit V4L2Device(const std::string &deviceNode);
|
explicit V4L2Device(const std::string &deviceNode);
|
||||||
|
@ -106,6 +108,9 @@ public:
|
||||||
int streamOn();
|
int streamOn();
|
||||||
int streamOff();
|
int streamOff();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::string logPrefix() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int getFormatSingleplane(V4L2DeviceFormat *format);
|
int getFormatSingleplane(V4L2DeviceFormat *format);
|
||||||
int setFormatSingleplane(V4L2DeviceFormat *format);
|
int setFormatSingleplane(V4L2DeviceFormat *format);
|
||||||
|
|
|
@ -262,8 +262,7 @@ int V4L2Device::open()
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
LOG(V4L2, Error)
|
LOG(V4L2, Error)
|
||||||
<< "Failed to open V4L2 device '" << deviceNode_
|
<< "Failed to open V4L2 device: " << strerror(-ret);
|
||||||
<< "': " << strerror(-ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
fd_ = ret;
|
fd_ = ret;
|
||||||
|
@ -278,9 +277,8 @@ int V4L2Device::open()
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(V4L2, Debug)
|
LOG(V4L2, Debug)
|
||||||
<< "Opened '" << deviceNode_ << "' "
|
<< "Opened device " << caps_.bus_info() << ": "
|
||||||
<< caps_.bus_info() << ": " << caps_.driver()
|
<< caps_.driver() << ": " << caps_.card();
|
||||||
<< ": " << caps_.card();
|
|
||||||
|
|
||||||
if (!caps_.isCapture() && !caps_.isOutput()) {
|
if (!caps_.isCapture() && !caps_.isOutput()) {
|
||||||
LOG(V4L2, Debug) << "Device is not a supported type";
|
LOG(V4L2, Debug) << "Device is not a supported type";
|
||||||
|
@ -350,6 +348,11 @@ void V4L2Device::close()
|
||||||
* \return The string containing the device location
|
* \return The string containing the device location
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
std::string V4L2Device::logPrefix() const
|
||||||
|
{
|
||||||
|
return deviceNode_;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retrieve the image format set on the V4L2 device
|
* \brief Retrieve the image format set on the V4L2 device
|
||||||
* \param[out] format The image format applied on the device
|
* \param[out] format The image format applied on the device
|
||||||
|
@ -519,8 +522,7 @@ int V4L2Device::requestBuffers(unsigned int count)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(V4L2, Debug)
|
LOG(V4L2, Debug) << rb.count << " buffers requested.";
|
||||||
<< deviceNode_ << ":" << rb.count << " buffers requested.";
|
|
||||||
|
|
||||||
return rb.count;
|
return rb.count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue