mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-25 17:45:06 +03:00
libcamera: v4l2_subdevice: Rework enumPadSizes()
Align the enumPadSizes() interface and implementation with that of enumPadCodes(). There is no functional change. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
3e51cc30bf
commit
be78ffbe9a
2 changed files with 22 additions and 20 deletions
|
@ -58,8 +58,8 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<unsigned int> enumPadCodes(unsigned int pad);
|
std::vector<unsigned int> enumPadCodes(unsigned int pad);
|
||||||
int enumPadSizes(unsigned int pad, unsigned int code,
|
std::vector<SizeRange> enumPadSizes(unsigned int pad,
|
||||||
std::vector<SizeRange> *size);
|
unsigned int code);
|
||||||
|
|
||||||
int setSelection(unsigned int pad, unsigned int target,
|
int setSelection(unsigned int pad, unsigned int target,
|
||||||
Rectangle *rect);
|
Rectangle *rect);
|
||||||
|
|
|
@ -209,10 +209,14 @@ FormatEnum V4L2Subdevice::formats(unsigned int pad)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int code : enumPadCodes(pad))
|
for (unsigned int code : enumPadCodes(pad)) {
|
||||||
if (enumPadSizes(pad, code, &formatMap[code]))
|
std::vector<SizeRange> sizes = enumPadSizes(pad, code);
|
||||||
|
if (sizes.empty())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
formatMap[code] = sizes;
|
||||||
|
}
|
||||||
|
|
||||||
return formatMap;
|
return formatMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,25 +339,25 @@ std::vector<unsigned int> V4L2Subdevice::enumPadCodes(unsigned int pad)
|
||||||
return codes;
|
return codes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int V4L2Subdevice::enumPadSizes(unsigned int pad,unsigned int code,
|
std::vector<SizeRange> V4L2Subdevice::enumPadSizes(unsigned int pad,
|
||||||
std::vector<SizeRange> *sizes)
|
unsigned int code)
|
||||||
{
|
{
|
||||||
struct v4l2_subdev_frame_size_enum sizeEnum = {};
|
std::vector<SizeRange> sizes;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
sizeEnum.index = 0;
|
for (unsigned int index = 0;; index++) {
|
||||||
sizeEnum.pad = pad;
|
struct v4l2_subdev_frame_size_enum sizeEnum = {};
|
||||||
sizeEnum.code = code;
|
sizeEnum.index = index;
|
||||||
sizeEnum.which = V4L2_SUBDEV_FORMAT_ACTIVE;
|
sizeEnum.pad = pad;
|
||||||
while (true) {
|
sizeEnum.code = code;
|
||||||
|
sizeEnum.which = V4L2_SUBDEV_FORMAT_ACTIVE;
|
||||||
|
|
||||||
ret = ioctl(fd_, VIDIOC_SUBDEV_ENUM_FRAME_SIZE, &sizeEnum);
|
ret = ioctl(fd_, VIDIOC_SUBDEV_ENUM_FRAME_SIZE, &sizeEnum);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
sizes->emplace_back(sizeEnum.min_width, sizeEnum.min_height,
|
sizes.emplace_back(sizeEnum.min_width, sizeEnum.min_height,
|
||||||
sizeEnum.max_width, sizeEnum.max_height);
|
sizeEnum.max_width, sizeEnum.max_height);
|
||||||
|
|
||||||
sizeEnum.index++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret && (errno != EINVAL && errno != ENOTTY)) {
|
if (ret && (errno != EINVAL && errno != ENOTTY)) {
|
||||||
|
@ -361,12 +365,10 @@ int V4L2Subdevice::enumPadSizes(unsigned int pad,unsigned int code,
|
||||||
LOG(V4L2Subdev, Error)
|
LOG(V4L2Subdev, Error)
|
||||||
<< "Unable to enumerate sizes on pad " << pad
|
<< "Unable to enumerate sizes on pad " << pad
|
||||||
<< ": " << strerror(-ret);
|
<< ": " << strerror(-ret);
|
||||||
sizes->clear();
|
return {};
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return sizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,
|
int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue