@@ -523,6 +523,15 @@ c2_status_t MfxC2EncoderComponent::Init()
523523
524524 if (mfx_res == MFX_ERR_NONE) mfx_res = InitSession ();
525525
526+ // Need to reset the RateControlMethod according to HW Capability
527+ // Here is a WA to set RateControlMethod depend on iGPU or dGPU
528+ if (mfx_res == MFX_ERR_NONE) {
529+ if (isdGPU ())
530+ mfx_set_RateControlMethod (MFX_RATECONTROL_CQP, &m_mfxVideoParamsConfig);
531+ else
532+ mfx_set_RateControlMethod (MFX_RATECONTROL_CBR, &m_mfxVideoParamsConfig);
533+ }
534+
526535 return MfxStatusToC2 (mfx_res);
527536}
528537
@@ -678,8 +687,8 @@ mfxStatus MfxC2EncoderComponent::InitSession()
678687 MFX_DEBUG_TRACE_FUNC;
679688
680689 mfxStatus mfx_res = MFX_ERR_NONE;
681- mfxConfig cfg[2 ];
682- mfxVariant cfgVal[2 ];
690+ mfxConfig cfg[3 ];
691+ mfxVariant cfgVal[3 ];
683692
684693 if (nullptr == m_mfxLoader)
685694 m_mfxLoader = MFXLoad ();
@@ -722,6 +731,22 @@ mfxStatus MfxC2EncoderComponent::InitSession()
722731 return MFX_ERR_UNKNOWN;
723732 }
724733
734+ cfg[2 ] = MFXCreateConfig (m_mfxLoader);
735+ if (!cfg[2 ]) {
736+ ALOGE (" Failed to create a MFX configuration" );
737+ MFXUnload (m_mfxLoader);
738+ return MFX_ERR_UNKNOWN;
739+ }
740+
741+ cfgVal[2 ].Type = MFX_VARIANT_TYPE_U32;
742+ cfgVal[2 ].Data .U32 = DRM_RENDER_NODE_NUM;
743+ mfx_res = MFXSetConfigFilterProperty (cfg[2 ], (const mfxU8 *) " mfxExtendedDeviceId.DRMRenderNodeNum" , cfgVal[2 ]);
744+ if (MFX_ERR_NONE != mfx_res) {
745+ ALOGE (" Failed to add an additional MFX configuration (%d)" , mfx_res);
746+ MFXUnload (m_mfxLoader);
747+ return MFX_ERR_UNKNOWN;
748+ }
749+
725750 while (1 ) {
726751 /* Enumerate all implementations */
727752 uint32_t idx = 0 ;
@@ -744,8 +769,58 @@ mfxStatus MfxC2EncoderComponent::InitSession()
744769
745770 mfx_res = MFXCreateSession (m_mfxLoader, idx, &m_mfxSession);
746771
772+ MFX_LOG_INFO (" ApiVersion: %hu.%hu " ,
773+ idesc->ApiVersion .Major ,
774+ idesc->ApiVersion .Minor );
775+ MFX_LOG_INFO (" Implementation type: %s\n " ,
776+ (idesc->Impl == MFX_IMPL_TYPE_SOFTWARE) ? " SW" : " HW" );
777+ MFX_LOG_INFO (" %2sApiVersion.Major: 0x%04X\n " , " " , idesc->ApiVersion .Major );
778+ MFX_LOG_INFO (" %2sApiVersion.Minor: 0x%04X\n " , " " , idesc->ApiVersion .Minor );
779+ MFX_LOG_INFO (" %2sImplementation Name: %s\n " , " " , idesc->ImplName );
780+ MFX_LOG_INFO (" %2sLicense: %s\n " , " " , idesc->License );
781+ MFX_LOG_INFO (" %2sKeywords: %s\n " , " " , idesc->Keywords );
782+ MFX_LOG_INFO (" %2sVendorID: 0x%04X\n " , " " , idesc->VendorID );
783+ MFX_LOG_INFO (" %2sVendorImplID: 0x%04X\n " , " " , idesc->VendorImplID );
784+
747785 MFXDispReleaseImplDescription (m_mfxLoader, idesc);
748786
787+ #ifdef ONEVPL_EXPERIMENTAL
788+ mfxExtendedDeviceId* idescDevice;
789+
790+ mfx_res = MFXEnumImplementations (m_mfxLoader,
791+ 0 ,
792+ MFX_IMPLCAPS_DEVICE_ID_EXTENDED,
793+ reinterpret_cast <mfxHDL*>(&idescDevice));
794+ if (MFX_ERR_NONE != mfx_res) {
795+ ALOGE (" MFXEnumImplementations MFX_IMPLCAPS_DEVICE_ID_EXTENDED error=%d\n " , mfx_res);
796+ }
797+ else {
798+ MFX_LOG_INFO (" %6sDeviceName: %s\n " , " " , idescDevice->DeviceName );
799+ MFX_LOG_INFO (" %6sExtended DeviceID's:\n " , " " );
800+ MFX_LOG_INFO (" %6sVendorID: 0x%04X\n " , " " , idescDevice->VendorID );
801+ MFX_LOG_INFO (" %6sDeviceID: 0x%04X\n " , " " , idescDevice->DeviceID );
802+ MFX_LOG_INFO (" %6sPCIDomain: 0x%08X\n " , " " , idescDevice->PCIDomain );
803+ MFX_LOG_INFO (" %6sPCIBus: 0x%08X\n " , " " , idescDevice->PCIBus );
804+ MFX_LOG_INFO (" %6sPCIdevice: 0x%08X\n " , " " , idescDevice->PCIDevice );
805+ MFX_LOG_INFO (" %6sPCIFunction: 0x%08X\n " , " " , idescDevice->PCIFunction );
806+ MFX_LOG_INFO (" %6sDRMRenderNodeNum: %d\n " , " " , idescDevice->DRMRenderNodeNum );
807+ MFX_LOG_INFO (" %6sDRMPrimaryNodeNum: 0x%04X\n " , " " , idescDevice->DRMPrimaryNodeNum );
808+ MFX_LOG_INFO (" %6sLUIDValid: 0x%04X\n " , " " , idescDevice->LUIDValid );
809+
810+ detectdGPU (idescDevice->DeviceID );
811+
812+ if (idescDevice->LUIDValid ) {
813+ MFX_LOG_INFO (" %6sDeviceLUID: " , " " );
814+ for (mfxU32 idx = 0 ; idx < 8 ; idx++) {
815+ MFX_LOG_INFO (" %02x" , idescDevice->DeviceLUID [7 - idx]);
816+ }
817+ MFX_LOG_INFO (" %6sLUIDDeviceNodeMask: 0x%04X\n " , " " , idescDevice->LUIDDeviceNodeMask );
818+ }
819+ }
820+
821+ MFXDispReleaseImplDescription (m_mfxLoader, idescDevice);
822+ #endif
823+
749824 if (MFX_ERR_NONE == mfx_res)
750825 break ;
751826
@@ -760,6 +835,9 @@ mfxStatus MfxC2EncoderComponent::InitSession()
760835 return mfx_res;
761836 }
762837
838+ #ifdef ONEVPL_EXPERIMENTAL
839+ m_device->setDedicated (isdGPU ());
840+ #endif
763841 mfx_res = m_device->InitMfxSession (m_mfxSession);
764842
765843 MFX_DEBUG_TRACE__mfxStatus (mfx_res);
0 commit comments