@@ -393,6 +393,17 @@ namespace Plugin {
393
393
registerMethod (" setMEMC" , &AVOutputTV::setMEMC, this );
394
394
registerMethod (" resetMEMC" , &AVOutputTV::resetMEMC, this );
395
395
registerMethod (" getMEMCCaps" , &AVOutputTV::getMEMCCaps, this );
396
+
397
+ registerMethod (" getBacklightCapsV2" , &AVOutputTV::getBacklightCapsV2, this );
398
+ registerMethod (" getBrightnessCapsV2" , &AVOutputTV::getBrightnessCapsV2, this );
399
+ registerMethod (" getContrastCapsV2" , &AVOutputTV::getContrastCapsV2, this );
400
+ registerMethod (" getSharpnessCapsV2" , &AVOutputTV::getSharpnessCapsV2, this );
401
+ registerMethod (" getSaturationCapsV2" , &AVOutputTV::getSaturationCapsV2, this );
402
+ registerMethod (" getHueCapsV2" , &AVOutputTV::getHueCapsV2, this );
403
+ registerMethod (" getPrecisionDetailCapsV2" , &AVOutputTV::getPrecisionDetailCapsV2, this );
404
+ registerMethod (" getColorTemperatureCapsV2" , &AVOutputTV::getColorTemperatureCapsV2, this );
405
+ registerMethod (" getSdrGammaCapsV2" , &AVOutputTV::getSdrGammaCapsV2, this );
406
+ registerMethod (" getDVCalibrationCapsV2" , &AVOutputTV::getDVCalibrationCapsV2, this );
396
407
397
408
LOGINFO (" Exit\n " );
398
409
}
@@ -495,6 +506,186 @@ namespace Plugin {
495
506
LOGINFO (" Exit\n " );
496
507
}
497
508
509
+ uint32_t AVOutputTV::getCapsV2 (
510
+ const std::function<tvError_t(int *, tvContextCaps_t**, std::vector<std::string>&)>& getCapsFunc,
511
+ const char* key,
512
+ const JsonObject& parameters,
513
+ JsonObject& response)
514
+ {
515
+ int max_value = 0 ;
516
+ tvContextCaps_t* context_caps = nullptr ;
517
+ std::vector<std::string> options;
518
+ // Call the HAL function
519
+ tvError_t result = getCapsFunc (&max_value, &context_caps, options);
520
+ LOGWARN (" AVOutputPlugins: %s: result: %d" , __FUNCTION__, result);
521
+ if (result != tvERROR_NONE) {
522
+ returnResponse (false );
523
+ }
524
+ JsonObject capsInfo;
525
+ JsonObject rangeInfo;
526
+ if (!options.empty ()) {
527
+ JsonArray optionsArray;
528
+ for (const auto & option : options) {
529
+ optionsArray.Add (option);
530
+ }
531
+ rangeInfo[" options" ] = optionsArray;
532
+ } else {
533
+ rangeInfo[" from" ] = 0 ;
534
+ rangeInfo[" to" ] = max_value;
535
+ }
536
+ capsInfo[" rangeInfo" ] = rangeInfo;
537
+ capsInfo[" platformSupport" ] = true ;
538
+ capsInfo[" context" ] = parseContextCaps (context_caps);
539
+ response[key] = capsInfo;
540
+ returnResponse (true );
541
+ }
542
+
543
+ JsonObject AVOutputTV::parseContextCaps (tvContextCaps_t* context_caps) {
544
+ JsonObject contextObj;
545
+ if (context_caps && context_caps->num_contexts > 0 ) {
546
+ for (size_t i = 0 ; i < context_caps->num_contexts ; ++i) {
547
+ int pqMode = context_caps->contexts [i].pq_mode ;
548
+ int videoFormat = context_caps->contexts [i].videoFormatType ;
549
+ int videoSource = context_caps->contexts [i].videoSrcType ;
550
+
551
+ auto pqModeIt = AVOutputTV::pqModeMap.find (pqMode);
552
+ auto videoFormatIt = AVOutputTV::videoFormatMap.find (videoFormat);
553
+ auto videoSrcIt = AVOutputTV::videoSrcMap.find (videoSource);
554
+
555
+ if (pqModeIt != AVOutputTV::pqModeMap.end () &&
556
+ videoFormatIt != AVOutputTV::videoFormatMap.end () &&
557
+ videoSrcIt != AVOutputTV::videoSrcMap.end ()) {
558
+
559
+ const char * pqModeStr = pqModeIt->second .c_str ();
560
+ const char * videoFormatStr = videoFormatIt->second .c_str ();
561
+ const char * videoSrcStr = videoSrcIt->second .c_str ();
562
+
563
+ if (!contextObj.HasLabel (pqModeStr)) {
564
+ contextObj[pqModeStr] = JsonObject ();
565
+ }
566
+ JsonObject pqModeObj = contextObj[pqModeStr].Object ();
567
+
568
+ if (!pqModeObj.HasLabel (videoFormatStr)) {
569
+ pqModeObj[videoFormatStr] = JsonArray ();
570
+ }
571
+ JsonArray formatArray = pqModeObj[videoFormatStr].Array ();
572
+ // **Manually check for existence before adding**
573
+ bool exists = false ;
574
+ for (size_t j = 0 ; j < formatArray.Length (); ++j) {
575
+ if (strcmp (formatArray[j].String ().c_str (), videoSrcStr) == 0 ) {
576
+ exists = true ;
577
+ break ;
578
+ }
579
+ }
580
+ if (!exists) {
581
+ formatArray.Add (videoSrcStr);
582
+ }
583
+ // Update objects
584
+ pqModeObj[videoFormatStr] = formatArray;
585
+ contextObj[pqModeStr] = pqModeObj;
586
+ }
587
+ }
588
+ }
589
+ return contextObj;
590
+ }
591
+
592
+ uint32_t AVOutputTV::getBacklightCapsV2 (const JsonObject& parameters, JsonObject& response) {
593
+ return getCapsV2 ([this ](int * max_backlight, tvContextCaps_t** context_caps, std::vector<std::string>&) {
594
+ return this ->GetBacklightCaps (max_backlight, context_caps);
595
+ }, " Backlight" , parameters, response);
596
+ }
597
+
598
+ uint32_t AVOutputTV::getBrightnessCapsV2 (const JsonObject& parameters, JsonObject& response) {
599
+ return getCapsV2 ([this ](int * max_brightness, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
600
+ return this ->GetBrightnessCaps (max_brightness, context_caps);
601
+ },
602
+ " Brightness" , parameters, response);
603
+ }
604
+
605
+ uint32_t AVOutputTV::getContrastCapsV2 (const JsonObject& parameters, JsonObject& response) {
606
+ return getCapsV2 ([this ](int * max_contrast, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
607
+ return this ->GetContrastCaps (max_contrast, context_caps);
608
+ },
609
+ " Contrast" , parameters, response);
610
+ }
611
+
612
+ uint32_t AVOutputTV::getSharpnessCapsV2 (const JsonObject& parameters, JsonObject& response) {
613
+ return getCapsV2 ([this ](int * max_sharpness, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
614
+ return this ->GetSharpnessCaps (max_sharpness, context_caps);
615
+ },
616
+ " Sharpness" , parameters, response);
617
+ }
618
+
619
+ uint32_t AVOutputTV::getSaturationCapsV2 (const JsonObject& parameters, JsonObject& response) {
620
+ return getCapsV2 ([this ](int * max_saturation, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
621
+ return this ->GetSaturationCaps (max_saturation, context_caps);
622
+ },
623
+ " Saturation" , parameters, response);
624
+ }
625
+
626
+ uint32_t AVOutputTV::getHueCapsV2 (const JsonObject& parameters, JsonObject& response) {
627
+ return getCapsV2 ([this ](int * max_hue, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
628
+ return this ->GetHueCaps (max_hue, context_caps);
629
+ },
630
+ " Hue" , parameters, response);
631
+ }
632
+
633
+ uint32_t AVOutputTV::getPrecisionDetailCapsV2 (const JsonObject& parameters, JsonObject& response) {
634
+ return getCapsV2 ([this ](int * max_precision, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
635
+ return this ->GetPrecisionDetailCaps (max_precision, context_caps);
636
+ },
637
+ " PrecisionDetails" , parameters, response);
638
+ }
639
+
640
+ uint32_t AVOutputTV::getColorTemperatureCapsV2 (const JsonObject& parameters, JsonObject& response) {
641
+ return getCapsV2 ([this ](int * options_count, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
642
+ return this ->GetColorTemperatureCaps (options_count, context_caps, options);
643
+ },
644
+ " ColorTemperature" , parameters, response);
645
+ }
646
+
647
+ uint32_t AVOutputTV::getSdrGammaCapsV2 (const JsonObject& parameters, JsonObject& response) {
648
+ return getCapsV2 ([this ](int * options_count, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
649
+ return this ->GetSdrGammaCaps (options_count, context_caps, options);
650
+ },
651
+ " SDRGamma" , parameters, response);
652
+ }
653
+
654
+ uint32_t AVOutputTV::getDVCalibrationCapsV2 (const JsonObject& parameters, JsonObject& response) {
655
+ tvDVCalibrationSettings_t *min_values = nullptr ;
656
+ tvDVCalibrationSettings_t *max_values = nullptr ;
657
+ tvContextCaps_t *context_caps = nullptr ;
658
+
659
+ if (GetDVCalibrationCaps (&min_values, &max_values, &context_caps) != tvERROR_NONE) {
660
+ returnResponse (false );
661
+ }
662
+
663
+ JsonObject capsInfo;
664
+ JsonObject rangeInfo;
665
+
666
+ rangeInfo[" Tmax" ] = JsonObject ({{" from" , min_values->Tmax }, {" to" , max_values->Tmax }});
667
+ rangeInfo[" Tmin" ] = JsonObject ({{" from" , min_values->Tmin }, {" to" , max_values->Tmin }});
668
+ rangeInfo[" Tgamma" ] = JsonObject ({{" from" , min_values->Tgamma }, {" to" , max_values->Tgamma }});
669
+ rangeInfo[" Rx" ] = JsonObject ({{" from" , min_values->Rx }, {" to" , max_values->Rx }});
670
+ rangeInfo[" Ry" ] = JsonObject ({{" from" , min_values->Ry }, {" to" , max_values->Ry }});
671
+ rangeInfo[" Gx" ] = JsonObject ({{" from" , min_values->Gx }, {" to" , max_values->Gx }});
672
+ rangeInfo[" Gy" ] = JsonObject ({{" from" , min_values->Gy }, {" to" , max_values->Gy }});
673
+ rangeInfo[" Bx" ] = JsonObject ({{" from" , min_values->Bx }, {" to" , max_values->Bx }});
674
+ rangeInfo[" By" ] = JsonObject ({{" from" , min_values->By }, {" to" , max_values->By }});
675
+ rangeInfo[" Wx" ] = JsonObject ({{" from" , min_values->Wx }, {" to" , max_values->Wx }});
676
+ rangeInfo[" Wy" ] = JsonObject ({{" from" , min_values->Wy }, {" to" , max_values->Wy }});
677
+
678
+ capsInfo[" rangeInfo" ] = rangeInfo;
679
+ capsInfo[" platformSupport" ] = true ;
680
+ capsInfo[" context" ] = parseContextCaps (context_caps);
681
+
682
+ response[" DolbyVisionCalibration" ] = capsInfo;
683
+
684
+ delete min_values;
685
+ delete max_values;
686
+ returnResponse (true );
687
+ }
688
+
498
689
uint32_t AVOutputTV::getZoomModeCaps (const JsonObject& parameters, JsonObject& response)
499
690
{
500
691
LOGINFO (" Entry" );
0 commit comments