libcamera: v4l2_subdevice: Add method to retrieve the media entity
Add a method to retrieve the media entity associated with a subdevice. The entityName() and deviceNode() methods are not needed anymore as they can be accessed through the media entity, remove them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
d97cafdf3c
commit
05b0e5ed53
5 changed files with 14 additions and 23 deletions
|
@ -41,8 +41,7 @@ public:
|
||||||
bool isOpen() const;
|
bool isOpen() const;
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
const std::string &deviceNode() const { return entity_->deviceNode(); }
|
const MediaEntity *entity() const { return entity_; }
|
||||||
const std::string &entityName() const { return entity_->name(); }
|
|
||||||
|
|
||||||
int setCrop(unsigned int pad, Rectangle *rect);
|
int setCrop(unsigned int pad, Rectangle *rect);
|
||||||
int setCompose(unsigned int pad, Rectangle *rect);
|
int setCompose(unsigned int pad, Rectangle *rect);
|
||||||
|
|
|
@ -590,7 +590,7 @@ int PipelineHandlerIPU3::registerCameras()
|
||||||
&IPU3CameraData::imguOutputBufferReady);
|
&IPU3CameraData::imguOutputBufferReady);
|
||||||
|
|
||||||
/* Create and register the Camera instance. */
|
/* Create and register the Camera instance. */
|
||||||
std::string cameraName = cio2->sensor_->entityName() + " "
|
std::string cameraName = cio2->sensor_->entity()->name() + " "
|
||||||
+ std::to_string(id);
|
+ std::to_string(id);
|
||||||
std::shared_ptr<Camera> camera = Camera::create(this,
|
std::shared_ptr<Camera> camera = Camera::create(this,
|
||||||
cameraName,
|
cameraName,
|
||||||
|
@ -1066,7 +1066,7 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (maxSize_.width == 0) {
|
if (maxSize_.width == 0) {
|
||||||
LOG(IPU3, Info) << "Sensor '" << sensor_->entityName()
|
LOG(IPU3, Info) << "Sensor '" << sensor_->entity()->name()
|
||||||
<< "' detected, but no supported image format "
|
<< "' detected, but no supported image format "
|
||||||
<< " found: skip camera creation";
|
<< " found: skip camera creation";
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
|
@ -131,12 +131,12 @@ int V4L2Subdevice::open()
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ::open(deviceNode().c_str(), O_RDWR);
|
ret = ::open(entity_->deviceNode().c_str(), O_RDWR);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
LOG(V4L2Subdev, Error)
|
LOG(V4L2Subdev, Error)
|
||||||
<< "Failed to open V4L2 subdevice '" << deviceNode()
|
<< "Failed to open V4L2 subdevice '"
|
||||||
<< "': " << strerror(-ret);
|
<< entity_->deviceNode() << "': " << strerror(-ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
fd_ = ret;
|
fd_ = ret;
|
||||||
|
@ -166,17 +166,9 @@ void V4L2Subdevice::close()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn V4L2Subdevice::deviceNode()
|
* \fn V4L2Subdevice::entity()
|
||||||
* \brief Retrieve the path of the device node associated with the subdevice
|
* \brief Retrieve the media entity associated with the subdevice
|
||||||
*
|
* \return The subdevice's associated media entity.
|
||||||
* \return The subdevice's device node system path
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn V4L2Subdevice::entityName()
|
|
||||||
* \brief Retrieve the name of the media entity associated with the subdevice
|
|
||||||
*
|
|
||||||
* \return The name of the media entity the subdevice is associated to
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -343,7 +335,7 @@ V4L2Subdevice *V4L2Subdevice::fromEntityName(const MediaDevice *media,
|
||||||
|
|
||||||
std::string V4L2Subdevice::logPrefix() const
|
std::string V4L2Subdevice::logPrefix() const
|
||||||
{
|
{
|
||||||
return "'" + entityName() + "'";
|
return "'" + entity_->name() + "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
int V4L2Subdevice::enumPadSizes(unsigned int pad,unsigned int code,
|
int V4L2Subdevice::enumPadSizes(unsigned int pad,unsigned int code,
|
||||||
|
|
|
@ -52,7 +52,7 @@ int ListFormatsTest::run()
|
||||||
formats = scaler_->formats(0);
|
formats = scaler_->formats(0);
|
||||||
if (formats.empty()) {
|
if (formats.empty()) {
|
||||||
cerr << "Failed to list formats on pad 0 of subdevice "
|
cerr << "Failed to list formats on pad 0 of subdevice "
|
||||||
<< scaler_->entityName() << endl;
|
<< scaler_->entity()->name() << endl;
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
for (auto it = formats.begin(); it != formats.end(); ++it)
|
for (auto it = formats.begin(); it != formats.end(); ++it)
|
||||||
|
@ -61,7 +61,7 @@ int ListFormatsTest::run()
|
||||||
formats = scaler_->formats(1);
|
formats = scaler_->formats(1);
|
||||||
if (formats.empty()) {
|
if (formats.empty()) {
|
||||||
cerr << "Failed to list formats on pad 1 of subdevice "
|
cerr << "Failed to list formats on pad 1 of subdevice "
|
||||||
<< scaler_->entityName() << endl;
|
<< scaler_->entity()->name() << endl;
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
for (auto it = formats.begin(); it != formats.end(); ++it)
|
for (auto it = formats.begin(); it != formats.end(); ++it)
|
||||||
|
@ -71,7 +71,7 @@ int ListFormatsTest::run()
|
||||||
formats = scaler_->formats(2);
|
formats = scaler_->formats(2);
|
||||||
if (!formats.empty()) {
|
if (!formats.empty()) {
|
||||||
cerr << "Listing formats on non-existing pad 2 of subdevice "
|
cerr << "Listing formats on non-existing pad 2 of subdevice "
|
||||||
<< scaler_->entityName()
|
<< scaler_->entity()->name()
|
||||||
<< " should return an empty format list" << endl;
|
<< " should return an empty format list" << endl;
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ int V4L2SubdeviceTest::init()
|
||||||
ret = scaler_->open();
|
ret = scaler_->open();
|
||||||
if (ret) {
|
if (ret) {
|
||||||
cerr << "Unable to open video subdevice "
|
cerr << "Unable to open video subdevice "
|
||||||
<< scaler_->deviceNode() << endl;
|
<< scaler_->entity()->deviceNode() << endl;
|
||||||
media_->release();
|
media_->release();
|
||||||
return TestSkip;
|
return TestSkip;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue