libcamera: camera_sensor: Use active area size as resolution
When a sensor can upscale the image, the native sensor resolution isn't equal to the largest size reported by the sensor. Use the active area size instead, and default it to the largest enumerated size if the crop rectangle targets are not supported. 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
87194982eb
commit
96aecfe365
2 changed files with 13 additions and 13 deletions
|
@ -53,7 +53,7 @@ public:
|
|||
const MediaEntity *entity() const { return entity_; }
|
||||
const std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }
|
||||
const std::vector<Size> &sizes() const { return sizes_; }
|
||||
const Size &resolution() const { return resolution_; }
|
||||
Size resolution() const { return activeArea_.size(); }
|
||||
|
||||
V4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,
|
||||
const Size &size) const;
|
||||
|
@ -87,7 +87,6 @@ private:
|
|||
std::string id_;
|
||||
|
||||
V4L2Subdevice::Formats formats_;
|
||||
Size resolution_;
|
||||
std::vector<unsigned int> mbusCodes_;
|
||||
std::vector<Size> sizes_;
|
||||
|
||||
|
|
|
@ -233,12 +233,6 @@ int CameraSensor::init()
|
|||
auto last = std::unique(sizes_.begin(), sizes_.end());
|
||||
sizes_.erase(last, sizes_.end());
|
||||
|
||||
/*
|
||||
* The sizes_ vector is sorted in ascending order, the resolution is
|
||||
* thus the last element of the vector.
|
||||
*/
|
||||
resolution_ = sizes_.back();
|
||||
|
||||
/*
|
||||
* VIMC is a bit special, as it does not yet support all the mandatory
|
||||
* requirements regular sensors have to respect.
|
||||
|
@ -324,14 +318,20 @@ int CameraSensor::validateSensorDriver()
|
|||
Rectangle rect;
|
||||
int ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_BOUNDS, &rect);
|
||||
if (ret) {
|
||||
rect = Rectangle(resolution());
|
||||
/*
|
||||
* Default the pixel array size to the largest size supported
|
||||
* by the sensor. The sizes_ vector is sorted in ascending
|
||||
* order, the largest size is thus the last element.
|
||||
*/
|
||||
pixelArraySize_ = sizes_.back();
|
||||
|
||||
LOG(CameraSensor, Warning)
|
||||
<< "The PixelArraySize property has been defaulted to "
|
||||
<< rect.toString();
|
||||
<< pixelArraySize_.toString();
|
||||
err = -EINVAL;
|
||||
} else {
|
||||
pixelArraySize_ = rect.size();
|
||||
}
|
||||
pixelArraySize_.width = rect.width;
|
||||
pixelArraySize_.height = rect.height;
|
||||
|
||||
ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_DEFAULT, &activeArea_);
|
||||
if (ret) {
|
||||
|
@ -397,7 +397,8 @@ int CameraSensor::validateSensorDriver()
|
|||
*/
|
||||
void CameraSensor::initVimcDefaultProperties()
|
||||
{
|
||||
pixelArraySize_ = resolution();
|
||||
/* Use the largest supported size. */
|
||||
pixelArraySize_ = sizes_.back();
|
||||
activeArea_ = Rectangle(pixelArraySize_);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue