213 ULONG Width, ULONG Height, ULONG RefreshRate)
215 BOOL32 Interlaced_B =
FALSE;
216 ULONG Result = VHDERR_NOERROR;
218 struct timeval t0, t;
220 gettimeofday(&t0, NULL);
222 if(!have_dvi_a_format) {
224 printf(
"Waiting for incoming signal...\n");
227 Result = VHD_GetStreamProperty(s->
StreamHandle, VHD_DV_SP_MODE, (ULONG *) &DviMode);
228 gettimeofday(&t, NULL);
229 if(
tv_diff(t, t0) > 1.0)
break;
230 }
while (Result != VHDERR_NOERROR);
232 if(Result != VHDERR_NOERROR)
236 printf(
"\nIncoming Dvi mode detected: ");
239 case VHD_DV_MODE_DVI_D : printf(
"DVI-D\n");
break;
240 case VHD_DV_MODE_DVI_A : printf(
"DVI-A\n");
break;
241 case VHD_DV_MODE_ANALOG_COMPONENT_VIDEO : printf(
"Analog component video\n");
break;
242 case VHD_DV_MODE_HDMI : printf(
"HDMI\n");
break;
247 Result = VHD_SetStreamProperty(s->
StreamHandle,VHD_DV_SP_DISABLE_EDID_AUTO_LOAD,
TRUE);
248 if(Result != VHDERR_NOERROR)
252 Result = VHD_SetStreamProperty(s->
StreamHandle,VHD_DV_SP_MODE, DviMode);
253 if(Result != VHDERR_NOERROR)
256 if(DviMode == VHD_DV_MODE_DVI_A)
258 VHD_DV_DVI_A_STANDARD DviAStd = VHD_DV_DVIA_STD_DMT;
259 if(!have_dvi_a_format) {
270#if ! defined DELTA_DVI_DEPRECATED
271 Result = VHD_DetectDviAFormat(s->
StreamHandle,&DviAStd,&Width,&Height,&RefreshRate,
274 Result = VHDERR_NOTIMPLEMENTED;
277 if(Result == VHDERR_NOERROR)
279 printf(
"\nDVI-A format detected: %" PRIu_ULONG "x%" PRIu_ULONG " @%" PRIu_ULONG "Hz (%s)\n", Width, Height, RefreshRate, Interlaced_B ?
"Interlaced" :
"Progressive");
280 Result = VHD_PresetDviAStreamProperties(s->
StreamHandle, DviAStd,Width,Height,
281 RefreshRate,Interlaced_B);
282 if(Result != VHDERR_NOERROR) {
283 printf(
"ERROR : Cannot set incoming DVI-A format. Result = 0x%08" PRIX_ULONG "\n", Result);
287 printf(
"ERROR : Cannot detect incoming DVI-A format. Result = 0x%08" PRIX_ULONG ". Use 'preset=' option.\n", Result);
291 else if(DviMode == VHD_DV_MODE_DVI_D)
295 Result = VHD_GetStreamProperty(s->
StreamHandle,VHD_DV_SP_ACTIVE_WIDTH,&Width);
296 if(Result == VHDERR_NOERROR)
297 Result = VHD_GetStreamProperty(s->
StreamHandle,VHD_DV_SP_ACTIVE_HEIGHT,&Height);
299 printf(
"ERROR : Cannot detect incoming active width from RX0. "
301 if(Result == VHDERR_NOERROR)
302 Result = VHD_GetStreamProperty(s->
StreamHandle,VHD_DV_SP_INTERLACED,(ULONG*)&Interlaced_B);
304 printf(
"ERROR : Cannot detect incoming active height from RX0. "
306 if(Result == VHDERR_NOERROR)
307 Result = VHD_GetStreamProperty(s->
StreamHandle,VHD_DV_SP_REFRESH_RATE,&RefreshRate);
309 printf(
"ERROR : Cannot detect if incoming stream from RX0 is "
310 "interlaced or progressive. Result = 0x%08" PRIX_ULONG "\n", Result);
311 if(Result == VHDERR_NOERROR)
312 Result = VHD_GetStreamProperty(s->
StreamHandle,VHD_DV_SP_DUAL_LINK,(ULONG*)&Dual_B);
314 printf(
"ERROR : Cannot detect incoming refresh rate from RX0. "
317 if(Result == VHDERR_NOERROR)
318 printf(
"\nIncoming graphic resolution : %" PRIu_ULONG "x%" PRIu_ULONG " @%" PRIu_ULONG "Hz (%s) %s link\n", Width, Height, RefreshRate, Interlaced_B ?
"Interlaced" :
"Progressive", Dual_B ?
"Dual" :
"Single");
320 printf(
"ERROR : Cannot detect if incoming stream from RX0 is dual or simple link. Result = 0x%08" PRIX_ULONG "\n", Result);
322 if(Result != VHDERR_NOERROR) {
333 VHD_SetStreamProperty(s->
StreamHandle,VHD_DV_SP_ACTIVE_WIDTH,Width);
334 VHD_SetStreamProperty(s->
StreamHandle,VHD_DV_SP_ACTIVE_HEIGHT,Height);
335 VHD_SetStreamProperty(s->
StreamHandle,VHD_DV_SP_INTERLACED,Interlaced_B);
336 VHD_SetStreamProperty(s->
StreamHandle,VHD_DV_SP_REFRESH_RATE,RefreshRate);
337 VHD_SetStreamProperty(s->
StreamHandle,VHD_DV_SP_DUAL_LINK,Dual_B);
339 else if(DviMode == VHD_DV_MODE_HDMI || DviMode == VHD_DV_MODE_ANALOG_COMPONENT_VIDEO)
344 Result = VHD_GetStreamProperty(s->
StreamHandle,VHD_DV_SP_ACTIVE_WIDTH,&Width);
345 if(Result == VHDERR_NOERROR)
346 Result = VHD_GetStreamProperty(s->
StreamHandle,VHD_DV_SP_ACTIVE_HEIGHT,&Height);
348 printf(
"ERROR : Cannot detect incoming active width from RX0. "
350 if(Result == VHDERR_NOERROR)
351 Result = VHD_GetStreamProperty(s->
StreamHandle,VHD_DV_SP_INTERLACED,(ULONG*)&Interlaced_B);
353 printf(
"ERROR : Cannot detect incoming active height from RX0. "
355 if(Result == VHDERR_NOERROR)
356 Result = VHD_GetStreamProperty(s->
StreamHandle,VHD_DV_SP_REFRESH_RATE,&RefreshRate);
358 printf(
"ERROR : Cannot detect if incoming stream from RX0 is "
359 "interlaced or progressive. Result = 0x%08" PRIX_ULONG "\n", Result);
361 if (Result == VHDERR_NOERROR) {
362 Result = VHD_GetStreamProperty(s->
StreamHandle,VHD_DV_SP_REFRESH_RATE,&RefreshRate);
364 Result = VHD_GetStreamProperty(s->
StreamHandle,VHD_DV_SP_INPUT_CS,(ULONG*)&InputCS);
366 printf(
"ERROR : Cannot detect incoming color space from RX0. Result = 0x%08" PRIX_ULONG " (%s)\n", Result,
370 if (Result == VHDERR_NOERROR) {
372 Result = VHD_GetStreamProperty(s->
StreamHandle,VHD_DV_SP_PIXEL_CLOCK,&PxlClk);
374 printf(
"ERROR : Cannot detect incoming pixel clock from RX0. Result = 0x%08" PRIX_ULONG " (%s)\n", Result,
378 if(Result == VHDERR_NOERROR)
379 printf(
"\nIncoming graphic resolution : %" PRIu_ULONG "x%" PRIu_ULONG " @%" PRIu_ULONG "Hz (%s)\n", Width, Height, RefreshRate, Interlaced_B ?
"Interlaced" :
"Progressive");
381 printf(
"ERROR : Cannot detect incoming refresh rate from RX0. "
384 if(Result != VHDERR_NOERROR) {
394 VHD_SetStreamProperty(s->
StreamHandle,VHD_DV_SP_ACTIVE_WIDTH,Width);
395 VHD_SetStreamProperty(s->
StreamHandle,VHD_DV_SP_ACTIVE_HEIGHT,Height);
396 VHD_SetStreamProperty(s->
StreamHandle,VHD_DV_SP_INTERLACED,Interlaced_B);
397 VHD_SetStreamProperty(s->
StreamHandle,VHD_DV_SP_REFRESH_RATE, RefreshRate);
398 if (s->
BoardType == VHD_BOARDTYPE_HDMI) {
399 VHD_SetStreamProperty(s->
StreamHandle,VHD_DV_SP_INPUT_CS, InputCS);
400 VHD_SetStreamProperty(s->
StreamHandle,VHD_DV_SP_PIXEL_CLOCK, PxlClk);
406 if(Result != VHDERR_NOERROR) {
447 ULONG Width = 0, Height = 0, RefreshRate = 0;
448 ULONG Result = VHDERR_NOERROR,DllVersion,NbBoards;
451 int edid_preset = -1;
452 BYTE pEEDIDBuffer[256];
453 ULONG pEEDIDBufferSize=256;
456 bool have_custom_edid =
false;
457 bool have_dvi_a_format =
false;
458 VHD_DV_MODE DviMode = NB_VHD_DV_MODES;
460 printf(
"vidcap_deltacast_dvi_init\n");
466 char *init_fmt = NULL,
470 if(init_fmt && strcmp(init_fmt,
"help") == 0) {
478 printf(
"Unable to allocate DELTACAST state\n");
488 char *save_ptr = NULL;
491 while((tok = strtok_r(init_fmt,
":", &save_ptr)) != NULL) {
492 if (strncasecmp(tok,
"device=", strlen(
"device=")) == 0) {
493 BrdId = atoi(tok + strlen(
"device="));
494 }
else if(strncasecmp(tok,
"board=", strlen(
"board=")) == 0) {
496 BrdId = atoi(tok + strlen(
"board="));
497 }
else if(strncasecmp(tok,
"codec=", strlen(
"codec=")) == 0) {
498 char *codec_str = tok + strlen(
"codec=");
506 }
else if (strncasecmp(tok,
"edid=", strlen(
"edid=")) == 0) {
507 if (!
load_custom_edid(strchr(tok,
'=') + 1, pEEDIDBuffer, &pEEDIDBufferSize)) {
510 have_custom_edid =
true;
511 }
else if(strncasecmp(tok,
"preset=", strlen(
"preset=")) == 0) {
512 edid_preset = atoi(strchr(tok,
'=') + 1);
513 if (edid_preset < 0 || edid_preset >= NB_VHD_DV_EEDID_PRESET) {
515 "EDID entered on commandline. "
516 "Expected 0-%d, got %d.\n",
517 (
int) NB_VHD_DV_EEDID_PRESET - 1, edid_preset);
521 }
else if(strncasecmp(tok,
"channel=", strlen(
"channel=")) == 0) {
522 channel = atoi(tok + strlen(
"channel="));
523 }
else if(strncasecmp(tok,
"format=", strlen(
"format=")) == 0) {
524 have_dvi_a_format =
true;
525 char *ptr = strchr(tok,
'=') + 1;
526 char *save_ptr, *
item;
527 if((
item = strtok_r(ptr,
"x@", &save_ptr))) {
530 if((
item = strtok_r(NULL,
"x@", &save_ptr))) {
533 if((
item = strtok_r(NULL,
"x@", &save_ptr))) {
534 RefreshRate = atof(
item);
538 "trailing parameter %s\n", tok);
545 printf(
"[DELTACAST] Automatically choosen device nr. 0\n");
551 Result = VHD_GetApiInfo(&DllVersion,&NbBoards);
552 if (Result != VHDERR_NOERROR) {
554 " information. Result = 0x%08" PRIX_ULONG "\n",
563 if(BrdId >= NbBoards) {
569 Result = VHD_OpenBoardHandle(BrdId,&s->
BoardHandle,NULL,0);
570 if (Result != VHDERR_NOERROR)
583 ChannelId = VHD_ST_RX0;
586 ChannelId = VHD_ST_RX1;
589 ChannelId = VHD_ST_RX2;
592 ChannelId = VHD_ST_RX3;
598 Result = VHD_OpenStreamHandle(s->
BoardHandle, ChannelId,
599 s->
BoardType == VHD_BOARDTYPE_HDMI ? VHD_DV_STPROC_JOINED : VHD_DV_STPROC_DEFAULT,
601 if (Result != VHDERR_NOERROR)
616 Result = VHD_SetStreamProperty(s->
StreamHandle,VHD_CORE_SP_BUFFER_PACKING,
618 if(Result != VHDERR_NOERROR) {
622 VHD_SetStreamProperty(s->
StreamHandle,VHD_CORE_SP_TRANSFER_SCHEME,
623 VHD_TRANSFER_SLAVED);
625 Result = VHD_SetStreamProperty(s->
StreamHandle, VHD_CORE_SP_BUFFERQUEUE_DEPTH,
627 if(Result != VHDERR_NOERROR) {
631 if(have_dvi_a_format) {
632 DviMode = VHD_DV_MODE_DVI_A;
634 if (edid_preset >= 0 && edid_preset < NB_VHD_DV_EEDID_PRESET) {
635 VHD_PresetEEDID((VHD_DV_EEDID_PRESET)edid_preset,pEEDIDBuffer,256);
638 if (have_custom_edid) {
639 VHD_LoadEEDID(s->
StreamHandle,pEEDIDBuffer,pEEDIDBufferSize);
642 Result = VHD_ReadEEDID(s->
BoardHandle,VHD_ST_RX0,pEEDIDBuffer,&pEEDIDBufferSize);
659 gettimeofday(&s->
t0, NULL);