62 if( SDIoutGpu == NULL || SDIoutGpu->
IsSDIoutput() != true )
67 if ( NvAPI_Initialize() != NVAPI_OK )
74 NVVIOTOPOLOGY l_vioTopologies;
75 memset( &l_vioTopologies, 0,
sizeof( l_vioTopologies ) );
76 l_vioTopologies.version = NVVIOTOPOLOGY_VER;
78 if ( NvAPI_VIO_QueryTopology( &l_vioTopologies ) != NVAPI_OK )
83 if ( l_vioTopologies.vioTotalDeviceCount == 0 )
93 while ( (
i < l_vioTopologies.vioTotalDeviceCount ) && ( !l_bFound ) )
96 memset( &l_vioCaps, 0,
sizeof( l_vioCaps ) );
97 l_vioCaps.version = NVVIOCAPS_VER;
98 if ( NvAPI_VIO_GetCapabilities( l_vioTopologies.vioTarget[
i].hVioHandle,
99 &l_vioCaps ) != NVAPI_OK )
101 LOG_ERROR(
"Video I/O Unsupported." );
106 if ( l_vioCaps.adapterCaps & NVVIOCAPS_VIDOUT_SDI )
108 m_vioHandle = l_vioTopologies.vioTarget[
i].hVioHandle;
120 LOG_ERROR(
"No SDI video output devices found." );
129 if ( NvAPI_VIO_Open( m_vioHandle, NVVIOCLASS_SDI, NVVIOOWNERTYPE_APPLICATION ) != NVAPI_OK )
135 NVVIOCONFIG_V1 l_vioConfig;
136 memset( &l_vioConfig, 0,
sizeof( l_vioConfig ) );
137 l_vioConfig.version = NVVIOCONFIG_VER1;
138 l_vioConfig.fields = 0;
139 l_vioConfig.nvvioConfigType = NVVIOCONFIGTYPE_OUT;
142 l_vioConfig.fields = NVVIOCONFIG_SIGNALFORMAT;
143 l_vioConfig.vioConfig.outConfig.signalFormat = options->
videoFormat;
144 l_vioConfig.fields |= NVVIOCONFIG_DATAFORMAT;
145 l_vioConfig.vioConfig.outConfig.dataFormat = options->
dataFormat;
152 l_vioConfig.vioConfig.outConfig.dataFormat = NVVIODATAFORMAT_DUAL_X8X8X8_TO_DUAL_422_PASSTHRU;
159 l_vioConfig.vioConfig.outConfig.dataFormat = NVVIODATAFORMAT_X10X10X10_444_PASSTHRU;
165 l_vioConfig.vioConfig.outConfig.dataFormat = NVVIODATAFORMAT_R8G8B8A8_TO_YCRCBA4224;
171 l_vioConfig.vioConfig.outConfig.dataFormat = NVVIODATAFORMAT_R10G10B10_TO_YCRCB422;
178 l_vioConfig.vioConfig.outConfig.syncEnable = options->
syncEnable;
179 l_vioConfig.vioConfig.outConfig.syncSource = options->
syncSource;
183 case NVVIOSYNCSOURCE_SDISYNC:
184 l_vioConfig.fields |= NVVIOCONFIG_SYNCSOURCEENABLE;
186 case NVVIOSYNCSOURCE_COMPSYNC:
187 l_vioConfig.vioConfig.outConfig.compositeSyncType = NVVIOCOMPSYNCTYPE_AUTO;
188 l_vioConfig.fields |= ( NVVIOCONFIG_SYNCSOURCEENABLE | NVVIOCONFIG_COMPOSITESYNCTYPE );
196 l_vioConfig.fields |= NVVIOCONFIG_CSCOVERRIDE;
197 l_vioConfig.vioConfig.outConfig.cscOverride =
TRUE;
198 l_vioConfig.fields |= NVVIOCONFIG_COLORCONVERSION;
201 l_vioConfig.vioConfig.outConfig.colorConversion.colorOffset[0] = options->
cscOffset[0];
202 l_vioConfig.vioConfig.outConfig.colorConversion.colorOffset[1] = options->
cscOffset[1];
203 l_vioConfig.vioConfig.outConfig.colorConversion.colorOffset[2] = options->
cscOffset[2];
206 l_vioConfig.vioConfig.outConfig.colorConversion.colorScale[0] = options->
cscScale[0];
207 l_vioConfig.vioConfig.outConfig.colorConversion.colorScale[1] = options->
cscScale[1];
208 l_vioConfig.vioConfig.outConfig.colorConversion.colorScale[2] = options->
cscScale[2];
209 l_vioConfig.vioConfig.outConfig.colorConversion.compositeSafe =
TRUE;
212 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[0][0] = options->
cscMatrix[0][0];
213 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[0][1] = options->
cscMatrix[0][1];
214 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[0][2] = options->
cscMatrix[0][2];
215 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[1][0] = options->
cscMatrix[1][0];
216 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[1][1] = options->
cscMatrix[1][1];
217 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[1][2] = options->
cscMatrix[1][2];
218 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[2][0] = options->
cscMatrix[2][0];
219 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[2][1] = options->
cscMatrix[2][1];
220 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[2][2] = options->
cscMatrix[2][2];
224 l_vioConfig.fields |= NVVIOCONFIG_CSCOVERRIDE;
225 l_vioConfig.vioConfig.outConfig.cscOverride =
FALSE;
229 l_vioConfig.vioConfig.outConfig.gammaCorrection.version = NVVIOGAMMACORRECTION_VER;
230 l_vioConfig.vioConfig.outConfig.gammaCorrection.fGammaValueR = options->
gamma[0];
231 l_vioConfig.vioConfig.outConfig.gammaCorrection.fGammaValueG = options->
gamma[1];
232 l_vioConfig.vioConfig.outConfig.gammaCorrection.fGammaValueB = options->
gamma[2];
233 l_vioConfig.fields |= NVVIOCONFIG_GAMMACORRECTION;
236 l_vioConfig.fields |= NVVIOCONFIG_FLIPQUEUELENGTH;
237 l_vioConfig.vioConfig.outConfig.flipQueueLength = options->
flipQueueLength;
240 l_vioConfig.fields |= NVVIOCONFIG_FULL_COLOR_RANGE;
241 l_vioConfig.vioConfig.outConfig.enableFullColorRange =
TRUE;
244 l_ret = NvAPI_VIO_SetConfig( m_vioHandle, ( NVVIOCONFIG* )&l_vioConfig );
245 if ( l_ret != NVAPI_OK )
257 NVVIOSTATUS l_vioStatus;
258 l_vioConfig.fields = 0;
261 if ( NvAPI_VIO_SyncFormatDetect( m_vioHandle, &l_wait ) != NVAPI_OK )
270 l_vioStatus.version = NVVIOSTATUS_VER;
271 if ( NvAPI_VIO_Status( m_vioHandle, &l_vioStatus ) != NVAPI_OK )
279 if ( l_vioStatus.vioStatus.outStatus.syncFormat !=
280 l_vioConfig.vioConfig.outConfig.signalFormat )
282 LOG_ERROR(
"Incoming sync does not match outgoing video signal." );
285 l_vioConfig.vioConfig.outConfig.frameLockEnable =
FALSE;
286 l_vioConfig.fields |= NVVIOCONFIG_FRAMELOCKENABLE;
291 if ( NvAPI_VIO_IsFrameLockModeCompatible( m_vioHandle,
292 l_vioStatus.vioStatus.outStatus.syncFormat,
293 l_vioConfig.vioConfig.outConfig.signalFormat,
294 &l_compatible ) != NVAPI_OK )
301 l_vioConfig.vioConfig.outConfig.frameLockEnable =
TRUE;
302 l_vioConfig.fields |= NVVIOCONFIG_FRAMELOCKENABLE;
306 LOG_ERROR(
"Incoming sync not compatible with outgoing video format." );
311 l_vioConfig.vioConfig.outConfig.syncEnable = l_vioStatus.vioStatus.outStatus.syncEnable;
312 l_vioConfig.vioConfig.outConfig.syncSource = l_vioStatus.vioStatus.outStatus.syncSource;
314 switch( l_vioStatus.vioStatus.outStatus.syncSource )
316 case NVVIOSYNCSOURCE_SDISYNC:
317 l_vioConfig.fields |= NVVIOCONFIG_SYNCSOURCEENABLE;
319 case NVVIOSYNCSOURCE_COMPSYNC:
320 l_vioConfig.vioConfig.outConfig.compositeSyncType = NVVIOCOMPSYNCTYPE_AUTO;
321 l_vioConfig.fields |= ( NVVIOCONFIG_SYNCSOURCEENABLE | NVVIOCONFIG_COMPOSITESYNCTYPE );
326 NVVIOSYNCDELAY l_vioSyncDelay;
327 memset( &l_vioSyncDelay, 0,
sizeof( l_vioSyncDelay ) );
328 l_vioSyncDelay.version = NVVIOSYNCDELAY_VER;
329 l_vioSyncDelay.horizontalDelay = options->
hDelay;
330 l_vioSyncDelay.verticalDelay = options->
vDelay;
331 l_vioConfig.fields |= NVVIOCONFIG_SYNCDELAY;
332 l_vioConfig.vioConfig.outConfig.syncDelay = l_vioSyncDelay;
335 if ( NvAPI_VIO_SetConfig( m_vioHandle, ( NVVIOCONFIG* )&l_vioConfig ) != NVAPI_OK )
342 NVVIOSIGNALFORMATDETAIL l_vioSignalFormatDetail;
343 memset( &l_vioSignalFormatDetail, 0,
sizeof( l_vioSignalFormatDetail ) );
345 ULONG l_vioSignalFormatIndex = (
ULONG )NVVIOSIGNALFORMAT_NONE;
351 l_ret = NvAPI_VIO_EnumSignalFormats( m_vioHandle,
352 l_vioSignalFormatIndex,
353 &l_vioSignalFormatDetail );
354 if ( l_ret == NVAPI_END_ENUMERATION || l_ret != NVAPI_OK )
360 if ( l_vioSignalFormatDetail.signalFormat ==
361 l_vioConfig.vioConfig.outConfig.signalFormat )
366 l_vioSignalFormatIndex++;
371 if ( l_vioSignalFormatDetail.videoMode.interlaceMode == NVVIOINTERLACEMODE_INTERLACE )
373 m_frameRate = l_vioSignalFormatDetail.videoMode.fFrameRate / 2.0f;
377 m_frameRate = l_vioSignalFormatDetail.videoMode.fFrameRate;
381 m_videoWidth = l_vioSignalFormatDetail.videoMode.horizontalPixels;
382 m_videoHeight = l_vioSignalFormatDetail.videoMode.verticalLines;
385 if ( ( l_vioSignalFormatDetail.videoMode.interlaceMode == NVVIOINTERLACEMODE_INTERLACE ) ||
386 ( l_vioSignalFormatDetail.videoMode.interlaceMode == NVVIOINTERLACEMODE_PSF ) )
388 m_bInterlaced =
TRUE;
392 m_bInterlaced =
FALSE;
401 if ( NvAPI_VIO_Close( m_vioHandle,
TRUE ) != NVAPI_OK )
426 return m_videoHeight;
432 std::stringstream ss;
435 ss <<
"NvAPI_VIO_IsRunning(): ";
437 if ( NvAPI_VIO_IsRunning( m_vioHandle ) == NVAPI_DRIVER_RUNNING )
439 ss <<
"NVAPI_DRIVER_RUNNING";
441 else if ( NvAPI_VIO_IsRunning( m_vioHandle ) == NVAPI_DRIVER_NOTRUNNING )
443 ss <<
"NVAPI_DRIVER_NOTRUNNING";
454 if ( NvAPI_VIO_SyncFormatDetect( m_vioHandle, &l_wait ) != NVAPI_OK )
463 NVVIOSTATUS l_vioStatus;
464 l_vioStatus.version = NVVIOSTATUS_VER;
465 if ( NvAPI_VIO_Status( m_vioHandle, &l_vioStatus ) != NVAPI_OK )
470 ss <<
". Video 1 Out: ";
471 switch( l_vioStatus.vioStatus.outStatus.vid1Out )
473 case NVINPUTOUTPUTSTATUS_OFF:
474 ss <<
"NVINPUTOUTPUTSTATUS_OFF";
476 case NVINPUTOUTPUTSTATUS_ERROR:
477 ss <<
"NVINPUTOUTPUTSTATUS_ERROR";
479 case NVINPUTOUTPUTSTATUS_SDI_SD:
480 ss <<
"NVINPUTOUTPUTSTATUS_SDI_SD";
482 case NVINPUTOUTPUTSTATUS_SDI_HD:
483 ss <<
"NVINPUTOUTPUTSTATUS_SDI_HD";
489 ss <<
". Video 2 Out: ";
490 switch( l_vioStatus.vioStatus.outStatus.vid2Out )
492 case NVINPUTOUTPUTSTATUS_OFF:
493 ss <<
"NVINPUTOUTPUTSTATUS_OFF";
495 case NVINPUTOUTPUTSTATUS_ERROR:
496 ss <<
"NVINPUTOUTPUTSTATUS_ERROR";
498 case NVINPUTOUTPUTSTATUS_SDI_SD:
499 ss <<
"NVINPUTOUTPUTSTATUS_SDI_SD";
501 case NVINPUTOUTPUTSTATUS_SDI_HD:
502 ss <<
"NVINPUTOUTPUTSTATUS_SDI_HD";
508 if ( l_vioStatus.vioStatus.outStatus.syncEnable )
510 ss <<
". Sync Source: ";
511 switch( l_vioStatus.vioStatus.outStatus.syncSource )
513 case NVVIOSYNCSOURCE_SDISYNC:
514 ss <<
"NVVIOSYNCSOURCE_SDISYNC";
516 case NVVIOSYNCSOURCE_COMPSYNC:
517 ss <<
"NVVIOSYNCSOURCE_COMPSYNC";
523 ss <<
". Sync Format: ";
524 switch( l_vioStatus.vioStatus.outStatus.syncFormat )
526 case NVVIOSIGNALFORMAT_NONE:
527 ss <<
"NVVIOSIGNALFORMAT_NONE";
529 case NVVIOSIGNALFORMAT_487I_59_94_SMPTE259_NTSC:
530 ss <<
"NVVIOSIGNALFORMAT_487I_59_94_SMPTE259_NTSC";
532 case NVVIOSIGNALFORMAT_576I_50_00_SMPTE259_PAL:
533 ss <<
"NVVIOSIGNALFORMAT_576I_50_00_SMPTE259_PAL";
535 case NVVIOSIGNALFORMAT_720P_59_94_SMPTE296:
536 ss <<
"NVVIOSIGNALFORMAT_720P_59_94_SMPTE296";
538 case NVVIOSIGNALFORMAT_720P_60_00_SMPTE296:
539 ss <<
"NVVIOSIGNALFORMAT_720P_60_00_SMPTE296";
541 case NVVIOSIGNALFORMAT_1035I_59_94_SMPTE260:
542 ss <<
"NVVIOSIGNALFORMAT_1035I_59_94_SMPTE26";
544 case NVVIOSIGNALFORMAT_1035I_60_00_SMPTE260:
545 ss <<
"NVVIOSIGNALFORMAT_1035I_60_00_SMPTE260";
547 case NVVIOSIGNALFORMAT_1080I_50_00_SMPTE295:
548 ss <<
"NVVIOSIGNALFORMAT_1080I_50_00_SMPTE295";
550 case NVVIOSIGNALFORMAT_1080I_50_00_SMPTE274:
551 ss <<
"NVVIOSIGNALFORMAT_1080I_50_00_SMPTE274";
553 case NVVIOSIGNALFORMAT_1080I_59_94_SMPTE274:
554 ss <<
"NVVIOSIGNALFORMAT_1080I_59_94_SMPTE274";
556 case NVVIOSIGNALFORMAT_1080I_60_00_SMPTE274:
557 ss <<
"NVVIOSIGNALFORMAT_1080I_60_00_SMPTE274";
559 case NVVIOSIGNALFORMAT_1080PSF_23_98_SMPTE274:
560 ss <<
"NVVIOSIGNALFORMAT_1080PSF_23_98_SMPTE274";
562 case NVVIOSIGNALFORMAT_1080PSF_24_00_SMPTE274:
563 ss <<
"NVVIOSIGNALFORMAT_1080PSF_24_00_SMPTE274";
565 case NVVIOSIGNALFORMAT_1080PSF_25_00_SMPTE274:
566 ss <<
"NVVIOSIGNALFORMAT_1080PSF_25_00_SMPTE274";
568 case NVVIOSIGNALFORMAT_1080P_23_976_SMPTE274:
569 ss <<
"NVVIOSIGNALFORMAT_1080P_23_976_SMPTE274";
571 case NVVIOSIGNALFORMAT_1080P_24_00_SMPTE274:
572 ss <<
"NVVIOSIGNALFORMAT_1080P_24_00_SMPTE274";
574 case NVVIOSIGNALFORMAT_1080P_25_00_SMPTE274:
575 ss <<
"NVVIOSIGNALFORMAT_1080P_25_00_SMPTE274";
577 case NVVIOSIGNALFORMAT_1080P_29_97_SMPTE274:
578 ss <<
"NVVIOSIGNALFORMAT_1080P_29_97_SMPTE274";
580 case NVVIOSIGNALFORMAT_1080P_30_00_SMPTE274:
581 ss <<
"NVVIOSIGNALFORMAT_1080P_30_00_SMPTE274";
587 ss <<
". Composite Sync In: ";
588 switch( l_vioStatus.vioStatus.outStatus.compSyncIn )
590 case NVVIOSYNCSTATUS_OFF:
591 ss <<
"NVVIOSYNCSTATUS_OFF";
593 case NVVIOSYNCSTATUS_ERROR:
594 ss <<
"NVVIOSYNCSTATUS_ERROR";
596 case NVVIOSYNCSTATUS_SYNCLOSS:
597 ss <<
"NVVIOSYNCSTATUS_SYNCLOSS";
599 case NVVIOSYNCSTATUS_COMPOSITE:
600 ss <<
"NVVIOSYNCSTATUS_COMPOSITE";
602 case NVVIOSYNCSTATUS_SDI_SD:
603 ss <<
"NVVIOSYNCSTATUS_SDI_SD";
605 case NVVIOSYNCSTATUS_SDI_HD:
606 ss <<
"NVVIOSYNCSTATUS_SDI_HD";
610 ss <<
". SDI Sync In: ";
611 switch( l_vioStatus.vioStatus.outStatus.sdiSyncIn )
613 case NVVIOSYNCSTATUS_OFF:
614 ss <<
"NVVIOSYNCSTATUS_OFF";
616 case NVVIOSYNCSTATUS_ERROR:
617 ss <<
"NVVIOSYNCSTATUS_ERROR";
619 case NVVIOSYNCSTATUS_SYNCLOSS:
620 ss <<
"NVVIOSYNCSTATUS_SYNCLOSS";
622 case NVVIOSYNCSTATUS_COMPOSITE:
623 ss <<
"NVVIOSYNCSTATUS_COMPOSITE";
625 case NVVIOSYNCSTATUS_SDI_SD:
626 ss <<
"NVVIOSYNCSTATUS_SDI_SD";
628 case NVVIOSYNCSTATUS_SDI_HD:
629 ss <<
"NVVIOSYNCSTATUS_SDI_HD";
635 ss <<
". Sync Source: Disabled";
638 if ( l_vioStatus.vioStatus.outStatus.frameLockEnable )
640 ss <<
". Framelock: Enabled";
644 ss <<
". Framelock: Disabled";
647 if ( l_vioStatus.vioStatus.outStatus.outputVideoLocked )
649 ss <<
". Output Video: Locked";
653 ss <<
". Output Video: Not Locked";
656 LOG_INFO( ss.str() );
665 NVVIOCONFIG_V1 l_vioConfig;
666 memset( &l_vioConfig, 0,
sizeof( l_vioConfig ) );
667 l_vioConfig.version = NVVIOCONFIG_VER1;
668 l_vioConfig.fields = NVVIOCONFIG_SIGNALFORMAT;
669 if ( NvAPI_VIO_GetConfig( m_vioHandle, ( NVVIOCONFIG* )&l_vioConfig ) != NVAPI_OK )
671 LOG_ERROR(
"Unable to get video config." );
676 NVVIOSIGNALFORMATDETAIL l_vioSignalFormatDetail;
677 memset( &l_vioSignalFormatDetail, 0,
sizeof( l_vioSignalFormatDetail ) );
679 ULONG l_vioSignalFormatIndex = (
ULONG )NVVIOSIGNALFORMAT_NONE;
686 l_ret = NvAPI_VIO_EnumSignalFormats( m_vioHandle,
687 l_vioSignalFormatIndex,
688 &l_vioSignalFormatDetail );
689 if ( l_ret == NVAPI_END_ENUMERATION || l_ret != NVAPI_OK )
695 if ( l_vioSignalFormatDetail.signalFormat ==
696 l_vioConfig.vioConfig.outConfig.signalFormat )
701 l_vioSignalFormatIndex++;
704 std::stringstream ss;
706 ss <<
". Horizontal Pixels = " << l_vioSignalFormatDetail.videoMode.horizontalPixels;
707 ss <<
". Vertical Lines = " << l_vioSignalFormatDetail.videoMode.verticalLines;
708 ss <<
". Frame Rate = " << l_vioSignalFormatDetail.videoMode.fFrameRate;
710 switch ( l_vioSignalFormatDetail.videoMode.interlaceMode )
712 case NVVIOINTERLACEMODE_PROGRESSIVE:
713 ss <<
". Interlace mode: Progressive";
716 case NVVIOINTERLACEMODE_INTERLACE:
717 ss <<
". Interlace mode: Interlace";
720 case NVVIOINTERLACEMODE_PSF:
721 ss <<
". Interlace mode: Progressive Segment Frame";
725 switch ( l_vioSignalFormatDetail.videoMode.videoStandard )
727 case NVVIOVIDEOSTANDARD_SMPTE259:
728 ss <<
". Video standard: SMPTE259";
731 case NVVIOVIDEOSTANDARD_SMPTE260:
732 ss <<
". Video standard: SMPTE260";
735 case NVVIOVIDEOSTANDARD_SMPTE274:
736 ss <<
". Video standard: SMPTE274";
739 case NVVIOVIDEOSTANDARD_SMPTE295:
740 ss <<
". Video standard: SMPTE295";
743 case NVVIOVIDEOSTANDARD_SMPTE296:
744 ss <<
". Video standard: SMPTE296";
747 case NVVIOVIDEOSTANDARD_SMPTE372:
748 ss <<
". Video standard: SMPTE372";
752 switch ( l_vioSignalFormatDetail.videoMode.videoType )
754 case NVVIOVIDEOTYPE_HD:
755 ss <<
". Video type: High-Definition";
758 case NVVIOVIDEOTYPE_SD:
759 ss <<
". Video type: Standard-Definition";
763 LOG_INFO( ss.str() );
772 NVVIOCONFIG_V1 l_vioConfig;
773 memset( &l_vioConfig, 0,
sizeof( l_vioConfig ) );
774 l_vioConfig.version = NVVIOCONFIG_VER1;
775 l_vioConfig.fields = NVVIOCONFIG_ALLFIELDS;
776 if ( NvAPI_VIO_GetConfig( m_vioHandle, ( NVVIOCONFIG* )&l_vioConfig ) != NVAPI_OK )
778 LOG_ERROR(
"Unable to get video config." );
783 NVVIODATAFORMATDETAIL l_dataFormatDetail;
784 if ( NvAPI_VIO_EnumDataFormats( m_vioHandle,
785 l_vioConfig.vioConfig.outConfig.dataFormat,
786 &l_dataFormatDetail ) != NVAPI_OK )
788 LOG_ERROR(
"Unable to enum video data formats." );
792 std::stringstream ss;
793 if ( l_dataFormatDetail.vioCaps != 0 )
795 if ( l_dataFormatDetail.vioCaps & NVVIOCAPS_VIDOUT_SDI )
797 ss <<
"VIDOUT_SDI" << std::endl;
799 if ( l_dataFormatDetail.vioCaps & NVVIOCAPS_OUTPUTMODE_DESKTOP )
801 ss <<
"OUTPUTMODE_DESKTOP" << std::endl;
803 if ( l_dataFormatDetail.vioCaps & NVVIOCAPS_OUTPUTMODE_OPENGL )
805 ss <<
"OUTPUTMODE_OPENGL" << std::endl;
807 if ( l_dataFormatDetail.vioCaps & NVVIOCAPS_SYNC_INTERNAL )
809 ss <<
"SYNC_INTERNAL" << std::endl;
811 if ( l_dataFormatDetail.vioCaps & NVVIOCAPS_SYNC_GENLOCK )
813 ss <<
"SYNC_GENLOCK" << std::endl;
815 if ( l_dataFormatDetail.vioCaps & NVVIOCAPS_SYNCSRC_SDI )
817 ss <<
"SYNCSRC_SDI" << std::endl;
819 if ( l_dataFormatDetail.vioCaps & NVVIOCAPS_SYNCSRC_COMP )
821 ss <<
"SYNCSRC_COMP" << std::endl;
827 LOG_INFO( ss.str() );
838 NVVIOCONFIG_V1 l_vioConfig;
839 memset( &l_vioConfig, 0,
sizeof( l_vioConfig ) );
840 l_vioConfig.version = NVVIOCONFIG_VER1;
841 l_vioConfig.fields = NVVIOCONFIG_SIGNALFORMAT;
842 if ( NvAPI_VIO_GetConfig( m_vioHandle, ( NVVIOCONFIG* )&l_vioConfig ) != NVAPI_OK )
844 LOG_ERROR(
"Unable to get video config." );
850 NVVIOSIGNALFORMATDETAIL l_vioSignalFormatDetail;
851 memset( &l_vioSignalFormatDetail, 0,
sizeof( l_vioSignalFormatDetail ) );
853 ULONG l_vioSignalFormatIndex = (
ULONG )NVVIOSIGNALFORMAT_NONE;
857 NvAPI_Status l_ret = NVAPI_OK;
858 l_ret = NvAPI_VIO_EnumSignalFormats( m_vioHandle,
859 l_vioSignalFormatIndex,
860 &l_vioSignalFormatDetail );
861 if ( l_ret == NVAPI_END_ENUMERATION || l_ret != NVAPI_OK )
867 if ( l_vioSignalFormatDetail.signalFormat ==
868 l_vioConfig.vioConfig.outConfig.signalFormat )
873 l_vioSignalFormatIndex++;
877 *rate = l_vioSignalFormatDetail.videoMode.fFrameRate;
891 return m_bInterlaced;
897 NVVIOCONFIG_V1 l_vioConfig;
900 memset( &l_vioConfig, 0,
sizeof( l_vioConfig ) );
901 l_vioConfig.version = NVVIOCONFIG_VER1;
903 l_vioConfig.fields = NVVIOCONFIG_CSCOVERRIDE;
909 l_vioConfig.vioConfig.outConfig.cscOverride =
FALSE;
913 l_vioConfig.vioConfig.outConfig.cscOverride =
TRUE;
915 l_vioConfig.fields |= NVVIOCONFIG_COLORCONVERSION;
918 l_vioConfig.vioConfig.outConfig.colorConversion.colorOffset[0] = csc->colorOffset[0];
919 l_vioConfig.vioConfig.outConfig.colorConversion.colorOffset[1] = csc->colorOffset[1];
920 l_vioConfig.vioConfig.outConfig.colorConversion.colorOffset[2] = csc->colorOffset[2];
923 l_vioConfig.vioConfig.outConfig.colorConversion.colorScale[0] = csc->colorScale[0];
924 l_vioConfig.vioConfig.outConfig.colorConversion.colorScale[1] = csc->colorScale[1];
925 l_vioConfig.vioConfig.outConfig.colorConversion.colorScale[2] = csc->colorScale[2];
926 l_vioConfig.vioConfig.outConfig.colorConversion.compositeSafe =
TRUE;
929 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[0][0] = csc->colorMatrix[0][0];
930 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[0][1] = csc->colorMatrix[0][1];
931 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[0][2] = csc->colorMatrix[0][2];
932 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[1][0] = csc->colorMatrix[1][0];
933 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[1][1] = csc->colorMatrix[1][1];
934 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[1][2] = csc->colorMatrix[1][2];
935 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[2][0] = csc->colorMatrix[2][0];
936 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[2][1] = csc->colorMatrix[2][1];
937 l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[2][2] = csc->colorMatrix[2][2];
941 l_ret = NvAPI_VIO_SetConfig( m_vioHandle, ( NVVIOCONFIG* )&l_vioConfig );
942 if ( l_ret != NVAPI_OK )
945 NvAPI_ShortString l_desc;
946 NvAPI_GetErrorMessage( l_ret, l_desc );
958 NVVIOCONFIG_V1 l_vioConfig;
961 memset( &l_vioConfig, 0,
sizeof( l_vioConfig ) );
962 l_vioConfig.version = NVVIOCONFIG_VER1;
963 l_vioConfig.fields = NVVIOCONFIG_COLORCONVERSION | NVVIOCONFIG_CSCOVERRIDE;
966 l_ret = NvAPI_VIO_GetConfig( m_vioHandle, ( NVVIOCONFIG* )&l_vioConfig );
967 if ( l_ret != NVAPI_OK )
973 *enable = l_vioConfig.vioConfig.outConfig.cscOverride;
976 csc->colorOffset[0] = l_vioConfig.vioConfig.outConfig.colorConversion.colorOffset[0];
977 csc->colorOffset[1] = l_vioConfig.vioConfig.outConfig.colorConversion.colorOffset[1];
978 csc->colorOffset[2] = l_vioConfig.vioConfig.outConfig.colorConversion.colorOffset[2];
981 csc->colorScale[0] = l_vioConfig.vioConfig.outConfig.colorConversion.colorScale[0];
982 csc->colorScale[1] = l_vioConfig.vioConfig.outConfig.colorConversion.colorScale[1];
983 csc->colorScale[2] = l_vioConfig.vioConfig.outConfig.colorConversion.colorScale[2];
986 csc->compositeSafe = l_vioConfig.vioConfig.outConfig.colorConversion.compositeSafe;
989 csc->colorMatrix[0][0] = l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[0][0];
990 csc->colorMatrix[0][1] = l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[0][1];
991 csc->colorMatrix[0][2] = l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[0][2];
992 csc->colorMatrix[1][0] = l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[1][0];
993 csc->colorMatrix[1][1] = l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[1][1];
994 csc->colorMatrix[1][2] = l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[1][2];
995 csc->colorMatrix[2][0] = l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[2][0];
996 csc->colorMatrix[2][1] = l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[2][1];
997 csc->colorMatrix[2][2] = l_vioConfig.vioConfig.outConfig.colorConversion.colorMatrix[2][2];
1005 NVVIOCONFIG_V1 l_vioConfig;
1008 memset( &l_vioConfig, 0,
sizeof( l_vioConfig ) );
1009 l_vioConfig.version = NVVIOCONFIG_VER1;
1010 l_vioConfig.fields = NVVIOCONFIG_SYNCDELAY;
1013 l_vioConfig.vioConfig.outConfig.syncDelay.version = delay->version;
1014 l_vioConfig.vioConfig.outConfig.syncDelay.horizontalDelay = delay->horizontalDelay;
1015 l_vioConfig.vioConfig.outConfig.syncDelay.verticalDelay = delay->verticalDelay;
1018 l_ret = NvAPI_VIO_SetConfig( m_vioHandle, ( NVVIOCONFIG* )&l_vioConfig );
1019 if ( l_ret != NVAPI_OK )
1030 NVVIOCONFIG_V1 l_vioConfig;
1033 memset( &l_vioConfig, 0,
sizeof( l_vioConfig ) );
1034 l_vioConfig.version = NVVIOCONFIG_VER1;
1035 l_vioConfig.fields = NVVIOCONFIG_SYNCDELAY;
1038 l_ret = NvAPI_VIO_GetConfig( m_vioHandle, ( NVVIOCONFIG* )&l_vioConfig );
1039 if ( l_ret != NVAPI_OK )
1045 delay->version = l_vioConfig.vioConfig.outConfig.syncDelay.version;
1046 delay->horizontalDelay = l_vioConfig.vioConfig.outConfig.syncDelay.horizontalDelay;
1047 delay->verticalDelay = l_vioConfig.vioConfig.outConfig.syncDelay.verticalDelay;
1072 delete dynamic_cast<CNvSDIoutGpu*>(
m_lGpu[
i] );
1088 if( CreateDummyGLWindowWin32( &hWnd, &hGLRC ) ==
false )
1098 LOG_ERROR(
"Could not load OpenGL Affinity extension" );
1104 if ( NvAPI_Initialize() != NVAPI_OK )
1109 NVVIOTOPOLOGY l_vioTopologies;
1110 memset( &l_vioTopologies, 0,
sizeof( l_vioTopologies ) );
1111 l_vioTopologies.version = NVVIOTOPOLOGY_VER;
1113 if ( NvAPI_VIO_QueryTopology( &l_vioTopologies ) != NVAPI_OK )
1118 if ( l_vioTopologies.vioTotalDeviceCount == 0 )
1123 LOG_INFO(
"Listing GPUs available for OpenGL GPU Affinity" );
1125 unsigned int GPUIdx = 0;
1127 GPU_DEVICE gpuDevice;
1128 gpuDevice.cb =
sizeof( gpuDevice );
1133 NvVioHandle hVioHandle;
1137 LOG_DEBUG(
"GPU# " << GPUIdx <<
":" );
1145 int DisplayDeviceIdx = 0;
1148 LOG_DEBUG(
" Display# " << DisplayDeviceIdx );
1149 LOG_DEBUG(
" Name: " << gpuDevice.DeviceName );
1150 LOG_DEBUG(
" String: " << gpuDevice.DeviceString );
1154 if ( gpuDevice.Flags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP )
1156 LOG_DEBUG(
" Attached to the desktop: LEFT=" << gpuDevice.rcVirtualScreen.left <<
", RIGHT=" << gpuDevice.rcVirtualScreen.right
1157 <<
", TOP=" << gpuDevice.rcVirtualScreen.top <<
", BOTTOM=" << gpuDevice.rcVirtualScreen.bottom );
1161 LOG_DEBUG(
" Not attached to the desktop." );
1165 if ( gpuDevice.Flags & DISPLAY_DEVICE_PRIMARY_DEVICE )
1167 LOG_DEBUG(
" This is the PRIMARY Display Device." );
1172 NvDisplayHandle hNvDisplay;
1173 NvAPI_Status status;
1174 status = NvAPI_GetAssociatedNvidiaDisplayHandle( gpuDevice.DeviceName, &hNvDisplay );
1175 if( status != NVAPI_OK )
1181 NvPhysicalGpuHandle hNvPhysicalGPU;
1182 status = NvAPI_GetPhysicalGPUsFromDisplay( hNvDisplay, &hNvPhysicalGPU, &
count );
1183 if( status != NVAPI_OK )
1192 NVVIOCAPS l_vioCaps;
1193 while ( (
i < l_vioTopologies.vioTotalDeviceCount ) && ( !l_bFound ) )
1195 if( l_vioTopologies.vioTarget[
i].hPhysicalGpu == hNvPhysicalGPU )
1198 memset( &l_vioCaps, 0,
sizeof( l_vioCaps ) );
1199 l_vioCaps.version = NVVIOCAPS_VER;
1200 if ( NvAPI_VIO_GetCapabilities( l_vioTopologies.vioTarget[
i].hVioHandle,
1201 &l_vioCaps ) != NVAPI_OK )
1207 if ( l_vioCaps.adapterCaps & NVVIOCAPS_VIDOUT_SDI )
1210 hVioHandle = l_vioTopologies.vioTarget[
i].hVioHandle;
1226 LOG_DEBUG(
" SDI out: yes" );
1230 LOG_DEBUG(
" SDI out: no" );
1232 if( gpuDevice.Flags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP )
1234 LOG_DEBUG(
" Attached to the desktop: LEFT=" << gpuDevice.rcVirtualScreen.left <<
", RIGHT=" << gpuDevice.rcVirtualScreen.right
1235 <<
", TOP=" << gpuDevice.rcVirtualScreen.top <<
", BOTTOM=" << gpuDevice.rcVirtualScreen.bottom );
1239 LOG_DEBUG(
" Not attached to the desktop." );
1243 gpu->
Init( hGPU, bPrimary, bDisplay, bSDIoutput, hVioHandle );
1254 if( DestroyGLWindowWin32( &hWnd, &hGLRC ) ==
false )
1276 if( index >= 0 && index <
m_nGpu )
1278 return dynamic_cast<CNvSDIoutGpu*>(
m_lGpu[index] );
1290 return dynamic_cast<CNvSDIoutGpu*>(
m_lGpu[
i] );
1309 bool CNvSDIoutGpu::Init( HGPUNV gpuAffinityHandle,
bool bPrimary,
bool bDisplay,
bool bSDIoutput, NvVioHandle hVioHandle )
PFNWGLENUMGPUSNVPROC wglEnumGpusNV
HRESULT DisplaySignalFormatInfo()
NVVIODATAFORMAT dataFormat
NVVIOSYNCSOURCE syncSource
virtual CNvSDIoutGpu * GetGpu(int index)
std::string DataFormatToString(NVVIODATAFORMAT format)
CNvSDIoutGpu CNvSDIoutGpu
CNvGpu * m_lGpu[MAX_GPUS]
HRESULT SetCSC(NVVIOCOLORCONVERSION *csc, bool enable)
bool Init(HGPUNV gpuAffinityHandle, bool bPrimary, bool bDisplay, bool bSDIOutput, NvVioHandle hVioHandle)
HRESULT GetCSC(NVVIOCOLORCONVERSION *csc, bool *enable)
bool Init(HGPUNV gpuAffinityHandle, bool bPrimary, bool bDisplay)
NVVIOSIGNALFORMAT videoFormat
Phidget_ChannelClass uint32_t * count
PFNWGLENUMGPUDEVICESNVPROC wglEnumGpuDevicesNV
HRESULT DisplayDataFormatInfo()
static CNvSDIoutGpuTopology & Instance()
virtual ~CNvSDIoutGpuTopology()
NvVioHandle GetVioHandle()
std::string SignalFormatToString(NVVIOSIGNALFORMAT format)
bool loadAffinityExtension()
HRESULT SetSyncDelay(NVVIOSYNCDELAY *delay)
HRESULT DisplayVideoStatus()
HRESULT GetSyncDelay(NVVIOSYNCDELAY *delay)
HRESULT Init(nvOptions *options, CNvSDIoutGpu *SdiOutGpu=NULL)
virtual CNvSDIoutGpu * GetPrimaryGpu()