@@ -964,6 +964,7 @@ V4L2SubdeviceFormat CameraData::findBestFormat(const Size &req, unsigned int bit
constexpr float penaltyAr = 1500.0;
constexpr float penaltyBitDepth = 500.0;
+ constexpr float penaltyNonGeneric = 1.0;
/* Calculate the closest/best mode from the user requested size. */
for (const auto &[mbusCode, sizes] : sensorFormats_) {
@@ -987,14 +988,19 @@ V4L2SubdeviceFormat CameraData::findBestFormat(const Size &req, unsigned int bit
/* Add any penalties... this is not an exact science! */
score += utils::abs_diff(info.bitsPerPixel, bitDepth) * penaltyBitDepth;
+ /* Break ties when sensor advertises both legacy and generic codes */
+ if (MediaBusFormatInfo::info(mbusCode).genericRaw == false)
+ score += penaltyNonGeneric;
+
if (score <= bestScore) {
bestScore = score;
bestFormat.code = mbusCode;
bestFormat.size = size;
}
- LOG(RPI, Debug) << "Format: " << size
- << " fmt " << *format
+ LOG(RPI, Debug) << "Format: " << *format
+ << "_" << utils::hex(mbusCode, 4)
+ << "_" << size
<< " Score: " << score
<< " (best " << bestScore << ")";
}
Most sensors that support the new common raw sensor model advertise both generic raw formats, and legacy bayer-specific formats. Break the tie by preferring the generic formats by a smidge, as all the Raspberry Pi drivers involved in the capture path (unicam, bcm2835-isp, cfe and pisp) can work with the newer media bus codes. Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com> --- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)