@@ -410,6 +410,30 @@ void RkISP1CameraData::metadataReady(unsigned int frame, const ControlList &meta
410
410
pipe ()->tryCompleteRequest (info);
411
411
}
412
412
413
+ /* -----------------------------------------------------------------------------
414
+ * Camera Configuration
415
+ */
416
+
417
+ namespace {
418
+
419
+ /* Keep in sync with the supported raw formats in rkisp1_path.cpp. */
420
+ const std::map<PixelFormat, uint32_t > rawFormats = {
421
+ { formats::SBGGR8, MEDIA_BUS_FMT_SBGGR8_1X8 },
422
+ { formats::SGBRG8, MEDIA_BUS_FMT_SGBRG8_1X8 },
423
+ { formats::SGRBG8, MEDIA_BUS_FMT_SGRBG8_1X8 },
424
+ { formats::SRGGB8, MEDIA_BUS_FMT_SRGGB8_1X8 },
425
+ { formats::SBGGR10, MEDIA_BUS_FMT_SBGGR10_1X10 },
426
+ { formats::SGBRG10, MEDIA_BUS_FMT_SGBRG10_1X10 },
427
+ { formats::SGRBG10, MEDIA_BUS_FMT_SGRBG10_1X10 },
428
+ { formats::SRGGB10, MEDIA_BUS_FMT_SRGGB10_1X10 },
429
+ { formats::SBGGR12, MEDIA_BUS_FMT_SBGGR12_1X12 },
430
+ { formats::SGBRG12, MEDIA_BUS_FMT_SGBRG12_1X12 },
431
+ { formats::SGRBG12, MEDIA_BUS_FMT_SGRBG12_1X12 },
432
+ { formats::SRGGB12, MEDIA_BUS_FMT_SRGGB12_1X12 },
433
+ };
434
+
435
+ } /* namespace */
436
+
413
437
RkISP1CameraConfiguration::RkISP1CameraConfiguration (Camera *camera,
414
438
RkISP1CameraData *data)
415
439
: CameraConfiguration()
@@ -456,6 +480,21 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()
456
480
status = Adjusted;
457
481
}
458
482
483
+ /*
484
+ * Simultaneous capture of raw and processed streams isn't possible. If
485
+ * there is any raw stream, cap the number of streams to one.
486
+ */
487
+ if (config_.size () > 1 ) {
488
+ for (const auto &cfg : config_) {
489
+ if (PixelFormatInfo::info (cfg.pixelFormat ).colourEncoding ==
490
+ PixelFormatInfo::ColourEncodingRAW) {
491
+ config_.resize (1 );
492
+ status = Adjusted;
493
+ break ;
494
+ }
495
+ }
496
+ }
497
+
459
498
/*
460
499
* If there are more than one stream in the configuration figure out the
461
500
* order to evaluate the streams. The first stream has the highest
@@ -517,45 +556,51 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()
517
556
}
518
557
}
519
558
520
- /* All paths rejected configuraiton . */
559
+ /* All paths rejected configuration . */
521
560
LOG (RkISP1, Debug) << " Camera configuration not supported "
522
561
<< cfg.toString ();
523
562
return Invalid;
524
563
}
525
564
526
565
/* Select the sensor format. */
566
+ PixelFormat rawFormat;
527
567
Size maxSize;
528
- for (const StreamConfiguration &cfg : config_)
568
+
569
+ for (const StreamConfiguration &cfg : config_) {
570
+ const PixelFormatInfo &info = PixelFormatInfo::info (cfg.pixelFormat );
571
+ if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW)
572
+ rawFormat = cfg.pixelFormat ;
573
+
529
574
maxSize = std::max (maxSize, cfg.size );
575
+ }
576
+
577
+ std::vector<unsigned int > mbusCodes;
578
+
579
+ if (rawFormat.isValid ()) {
580
+ mbusCodes = { rawFormats.at (rawFormat) };
581
+ } else {
582
+ std::transform (rawFormats.begin (), rawFormats.end (),
583
+ std::back_inserter (mbusCodes),
584
+ [](const auto &value) { return value.second ; });
585
+ }
586
+
587
+ sensorFormat_ = sensor->getFormat (mbusCodes, maxSize);
530
588
531
- sensorFormat_ = sensor->getFormat ({ MEDIA_BUS_FMT_SBGGR12_1X12,
532
- MEDIA_BUS_FMT_SGBRG12_1X12,
533
- MEDIA_BUS_FMT_SGRBG12_1X12,
534
- MEDIA_BUS_FMT_SRGGB12_1X12,
535
- MEDIA_BUS_FMT_SBGGR10_1X10,
536
- MEDIA_BUS_FMT_SGBRG10_1X10,
537
- MEDIA_BUS_FMT_SGRBG10_1X10,
538
- MEDIA_BUS_FMT_SRGGB10_1X10,
539
- MEDIA_BUS_FMT_SBGGR8_1X8,
540
- MEDIA_BUS_FMT_SGBRG8_1X8,
541
- MEDIA_BUS_FMT_SGRBG8_1X8,
542
- MEDIA_BUS_FMT_SRGGB8_1X8 },
543
- maxSize);
544
589
if (sensorFormat_.size .isNull ())
545
590
sensorFormat_.size = sensor->resolution ();
546
591
547
592
return status;
548
593
}
549
594
595
+ /* -----------------------------------------------------------------------------
596
+ * Pipeline Operations
597
+ */
598
+
550
599
PipelineHandlerRkISP1::PipelineHandlerRkISP1 (CameraManager *manager)
551
600
: PipelineHandler(manager), hasSelfPath_(true )
552
601
{
553
602
}
554
603
555
- /* -----------------------------------------------------------------------------
556
- * Pipeline Operations
557
- */
558
-
559
604
std::unique_ptr<CameraConfiguration>
560
605
PipelineHandlerRkISP1::generateConfiguration (Camera *camera,
561
606
const StreamRoles &roles)
@@ -611,23 +656,38 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
611
656
colorSpace = ColorSpace::Rec709;
612
657
break ;
613
658
659
+ case StreamRole::Raw:
660
+ if (roles.size () > 1 ) {
661
+ LOG (RkISP1, Error)
662
+ << " Can't capture both raw and processed streams" ;
663
+ return nullptr ;
664
+ }
665
+
666
+ useMainPath = true ;
667
+ colorSpace = ColorSpace::Raw;
668
+ break ;
669
+
614
670
default :
615
671
LOG (RkISP1, Warning)
616
672
<< " Requested stream role not supported: " << role;
617
673
return nullptr ;
618
674
}
619
675
620
- StreamConfiguration cfg;
676
+ RkISP1Path *path;
677
+
621
678
if (useMainPath) {
622
- cfg = data->mainPath_ ->generateConfiguration (
623
- data->sensor_ .get ());
679
+ path = data->mainPath_ ;
624
680
mainPathAvailable = false ;
625
681
} else {
626
- cfg = data->selfPath_ ->generateConfiguration (
627
- data->sensor_ .get ());
682
+ path = data->selfPath_ ;
628
683
selfPathAvailable = false ;
629
684
}
630
685
686
+ StreamConfiguration cfg =
687
+ path->generateConfiguration (data->sensor_ .get (), role);
688
+ if (!cfg.pixelFormat .isValid ())
689
+ return nullptr ;
690
+
631
691
cfg.colorSpace = colorSpace;
632
692
config->addConfiguration (cfg);
633
693
}
@@ -681,10 +741,14 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
681
741
<< " ISP input pad configured with " << format
682
742
<< " crop " << rect;
683
743
684
- isRaw_ = false ;
744
+ const PixelFormat &streamFormat = config->at (0 ).pixelFormat ;
745
+ const PixelFormatInfo &info = PixelFormatInfo::info (streamFormat);
746
+ isRaw_ = info.colourEncoding == PixelFormatInfo::ColourEncodingRAW;
685
747
686
748
/* YUYV8_2X8 is required on the ISP source path pad for YUV output. */
687
- format.mbus_code = MEDIA_BUS_FMT_YUYV8_2X8;
749
+ if (!isRaw_)
750
+ format.mbus_code = MEDIA_BUS_FMT_YUYV8_2X8;
751
+
688
752
LOG (RkISP1, Debug)
689
753
<< " Configuring ISP output pad with " << format
690
754
<< " crop " << rect;
0 commit comments