libcamera: rkisp1: Assign sizes to roles
Currently each RkISP1 path (main and self) generate a configuration by bounding the sensor's resolution to their respective maximum output aspect ratio and size. Size maxResolution = maxResolution_.boundedToAspectRatio(resolution) .boundedTo(resolution); In the case of self path, whose maximum size is 1920x1920, the generated configuration could get assigned unusual sizes, as the result of the above operation. As an example, with the imx258 sensor whose resolution is 4208x3118, the resulting size for the Viewfinder use case is an unusual 1920x1423. Fix this by assigning to each role a desired output size: - Use the sensor's resolution for StillCapture and Raw - Use 1080p for Viewfinder and VideoRecording Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
311e5bc1a8
commit
d45da036a4
3 changed files with 19 additions and 3 deletions
|
@ -162,6 +162,8 @@ public:
|
|||
bool match(DeviceEnumerator *enumerator) override;
|
||||
|
||||
private:
|
||||
static constexpr Size kRkISP1PreviewSize = { 1920, 1080 };
|
||||
|
||||
RkISP1CameraData *cameraData(Camera *camera)
|
||||
{
|
||||
return static_cast<RkISP1CameraData *>(camera->_d());
|
||||
|
@ -633,12 +635,15 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
|
|||
bool mainPathAvailable = true;
|
||||
|
||||
for (const StreamRole role : roles) {
|
||||
Size size;
|
||||
|
||||
switch (role) {
|
||||
case StreamRole::StillCapture:
|
||||
/* JPEG encoders typically expect sYCC. */
|
||||
if (!colorSpace)
|
||||
colorSpace = ColorSpace::Sycc;
|
||||
|
||||
size = data->sensor_->resolution();
|
||||
break;
|
||||
|
||||
case StreamRole::Viewfinder:
|
||||
|
@ -648,12 +653,16 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
|
|||
*/
|
||||
if (!colorSpace)
|
||||
colorSpace = ColorSpace::Sycc;
|
||||
|
||||
size = kRkISP1PreviewSize;
|
||||
break;
|
||||
|
||||
case StreamRole::VideoRecording:
|
||||
/* Rec. 709 is a good default for HD video recording. */
|
||||
if (!colorSpace)
|
||||
colorSpace = ColorSpace::Rec709;
|
||||
|
||||
size = kRkISP1PreviewSize;
|
||||
break;
|
||||
|
||||
case StreamRole::Raw:
|
||||
|
@ -664,6 +673,7 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
|
|||
}
|
||||
|
||||
colorSpace = ColorSpace::Raw;
|
||||
size = data->sensor_->resolution();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -690,7 +700,7 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
|
|||
}
|
||||
|
||||
StreamConfiguration cfg =
|
||||
path->generateConfiguration(data->sensor_.get(), role);
|
||||
path->generateConfiguration(data->sensor_.get(), size, role);
|
||||
if (!cfg.pixelFormat.isValid())
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -127,15 +127,20 @@ void RkISP1Path::populateFormats()
|
|||
}
|
||||
|
||||
StreamConfiguration
|
||||
RkISP1Path::generateConfiguration(const CameraSensor *sensor, StreamRole role)
|
||||
RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size,
|
||||
StreamRole role)
|
||||
{
|
||||
const std::vector<unsigned int> &mbusCodes = sensor->mbusCodes();
|
||||
const Size &resolution = sensor->resolution();
|
||||
|
||||
/* Min and max resolutions to populate the available stream formats. */
|
||||
Size maxResolution = maxResolution_.boundedToAspectRatio(resolution)
|
||||
.boundedTo(resolution);
|
||||
Size minResolution = minResolution_.expandedToAspectRatio(resolution);
|
||||
|
||||
/* The desired stream size, bound to the max resolution. */
|
||||
Size streamSize = size.boundedTo(maxResolution);
|
||||
|
||||
/* Create the list of supported stream formats. */
|
||||
std::map<PixelFormat, std::vector<SizeRange>> streamFormats;
|
||||
unsigned int rawBitsPerPixel = 0;
|
||||
|
@ -189,7 +194,7 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, StreamRole role)
|
|||
StreamFormats formats(streamFormats);
|
||||
StreamConfiguration cfg(formats);
|
||||
cfg.pixelFormat = format;
|
||||
cfg.size = maxResolution;
|
||||
cfg.size = streamSize;
|
||||
cfg.bufferCount = RKISP1_BUFFER_COUNT;
|
||||
|
||||
return cfg;
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
bool isEnabled() const { return link_->flags() & MEDIA_LNK_FL_ENABLED; }
|
||||
|
||||
StreamConfiguration generateConfiguration(const CameraSensor *sensor,
|
||||
const Size &resolution,
|
||||
StreamRole role);
|
||||
CameraConfiguration::Status validate(const CameraSensor *sensor,
|
||||
StreamConfiguration *cfg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue