v4l2: v4l2_camera_proxy: Use stream config in tryFormat
For handling try_fmt, the values should be filled in by validating the stream configuration, and not by recalculating them or manually checking against the cached list of formats and sizes. Add a new V4L2Camera::validateConfiguration() function to validate a configuration and use it to obtain size, format, stride, and frameSize values. If the format negotiation fails, return error from try_fmt and s_fmt. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
a3b5ee998e
commit
323a53c232
4 changed files with 48 additions and 18 deletions
|
@ -138,6 +138,26 @@ int V4L2Camera::configure(StreamConfiguration *streamConfigOut,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int V4L2Camera::validateConfiguration(const PixelFormat &pixelFormat,
|
||||
const Size &size,
|
||||
StreamConfiguration *streamConfigOut)
|
||||
{
|
||||
std::unique_ptr<CameraConfiguration> config =
|
||||
camera_->generateConfiguration({ StreamRole::Viewfinder });
|
||||
StreamConfiguration &cfg = config->at(0);
|
||||
cfg.size = size;
|
||||
cfg.pixelFormat = pixelFormat;
|
||||
cfg.bufferCount = 1;
|
||||
|
||||
CameraConfiguration::Status validation = config->validate();
|
||||
if (validation == CameraConfiguration::Invalid)
|
||||
return -EINVAL;
|
||||
|
||||
*streamConfigOut = cfg;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int V4L2Camera::allocBuffers(unsigned int count)
|
||||
{
|
||||
Stream *stream = config_->at(0).stream();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue