Programming the CG2

Mike Muuss mike at BRL.MIL
Thu May 10 09:19:13 AEST 1990


Hi Lance!  I did some hacking with a CG2;  they are a pain, mainly in that
they don't put out bi-polar NTSC, which results in a grey-level shift
that is quite objectionable, and the internal sync generator is so awful
as to be unusable without a time-base corrector.

Here is a fragment of code (from BRL-CAD libfb/if_4d.c) that shows how
I run ours.

I understand that the CG3 is vastly improved over the CG2, but ours has
not yet been delivered.

	Best,
	 -Mike


	/*
	 *  Take inventory of the hardware
	 */
	while( (inv = getinvent()) != (inventory_t *)0 )  {
		if( inv->class != INV_GRAPHICS )  continue;
		switch( inv->type )  {
		case INV_GMDEV:
			SGI(ifp)->mi_is_gt = 1;
			break;
		}
	}
	endinvent();		/* frees internal inventory memory */
	if( (ifp->if_mode & MODE_8MASK) == MODE_8NOGT )  {
		SGI(ifp)->mi_is_gt = 0;
	}

/*Note:---->*/
	if( (ifp->if_mode & MODE_5MASK) == MODE_5GENLOCK )  {
		/* NTSC, see below */
		ifp->if_width = ifp->if_max_width = XMAX170+1;	/* 646 */
		ifp->if_height = ifp->if_max_height = YMAX170+1; /* 485 */
	}

	if( width <= 0 )
		width = ifp->if_width;
	if( height <= 0 )
		height = ifp->if_height;
	if ( width > ifp->if_max_width )
		width = ifp->if_max_width;
	if ( height > ifp->if_max_height)
		height = ifp->if_max_height;

	ifp->if_width = width;
	ifp->if_height = height;

	blanktime(0);
	foreground();		/* Direct focus here, don't detach */

	if( (ifp->if_mode & MODE_5MASK) == MODE_5GENLOCK )  {
/*Note:---->*/
		prefposition( 0, XMAX170, 0, YMAX170 );
		SGI(ifp)->mi_curs_on = 0;	/* cursoff() happens below */
	} else if( (ifp->if_mode & MODE_3MASK) == MODE_3WINDOW )  {
		if( sgi_nwindows == 0 ) {
			prefposition( WIN_L, WIN_R, WIN_B, WIN_T );
		} else {
			prefsize( (long)width, (long)height );
		}
		SGI(ifp)->mi_curs_on = 1;	/* Mex usually has it on */
	}  else  {
		/* MODE_3MASK == MODE_3FULLSCR */
		prefposition( 0, XMAXSCREEN, 0, YMAXSCREEN );
		SGI(ifp)->mi_curs_on = 0;	/* cursoff() happens below */
	}

	/*
	 *  This is where the window constraints specified above
	 *  are bound to a new window.  The return code is
	 *  the "graphics id" that identifies this window.
	 *  winset(gr_id) is used to select a window for drawing in.
	 */
	if( (ifp->if_fd = winopen( "Frame buffer" )) == -1 )  {
		fb_log( "winopen() failed, no more windows available.\n" );
		return(-1);
	}
	sgi_nwindows++;		/* track # of simultaneous windows */

	/*  Establish operating mode (Hz, GENLOCK).
	 *  The assumption is that the device is always in the
	 *  "normal" mode to start with.  The mode will only
	 *  be saved and restored when 30Hz operation is specified;
	 *  on GENLOCK operation, valid NTSC sync pulses must be present
	 *  for downstream equipment;  user should run "Set60" when done.
	 */
	if( (ifp->if_mode & MODE_4MASK) == MODE_4HZ30 )  {
		SGI(ifp)->mi_der1 = getvideo(DE_R1);
		setvideo( DE_R1, DER1_30HZ|DER1_UNBLANK);	/* 4-wire RS-343 */
	} else if( (ifp->if_mode & MODE_5MASK) == MODE_5GENLOCK )  {
/*Note:---->*/
		SGI(ifp)->mi_der1 = getvideo(DE_R1);
		if( (SGI(ifp)->mi_der1 & DER1_VMASK) == DER1_170 )  {
			/* 
			 *  Current mode is DE3 board internal NTSC sync.
			 *  Doing a setmonitor(NTSC) again will cause the
			 *  sync generator to drop out for a moment.
			 *  So, in this case, do nothing.
			 */
		} else if( getvideo(CG_MODE) != -1 )  {
		    	/*
			 *  Optional CG2 GENLOCK board is installed.
			 *
			 *  Mode 2:  Internal sync generator is used.
			 *
			 *  Note that the stability of the sync generator
			 *  on the GENLOCK board is *worse* than the sync
			 *  generator on the regular DE3 board.  The GENLOCK
			 *  version "twitches" every second or so.
			 *
			 *  Mode 3:  Output is locked to incoming
			 *  NTSC composite video picture
		    	 *  for sync and chroma (on "REM IN" connector).
		    	 *  Color subcarrier is phase and amplitude locked to
		    	 *  incomming color burst.
		    	 *  The blue LSB has no effect on video overlay.
			 *
			 *  Note that the generated composite NTSC output
			 *  (on "VID OUT" connector) is often a problem,
			 *  since it has a DC offset of +0.3V to the base
			 *  of the sync pulse, while other studio eqiupment
			 *  often expects the blanking level to be at
			 *  exactly 0.0V, with sync at -0.3V.
			 *  In this case, the black levels are ruined.
			 *  Also, the inboard encoder chip isn't very good.
			 *  Therefore, it is necessary to use an outboard
			 *  RS-170 to NTSC encoder to get useful results.
		    	 */
			if( (ifp->if_mode & MODE_6MASK) == MODE_6EXTSYNC )  {
				/* external sync via GENLOCK board REM IN */
			    	setvideo(CG_MODE, CG2_M_MODE3);
			    	setvideo(DE_R1, DER1_G_170|DER1_UNBLANK );
			} else {
				/* internal sync */
#ifdef GENLOCK_SYNC
				/* GENLOCK sync, found to be highly unstable */
			    	setvideo(CG_MODE, CG2_M_MODE2);
			    	setvideo(DE_R1, DER1_G_170|DER1_UNBLANK );
#else
				/* Just use DE3 sync generator.
				 * For this case, GENLOCK board does nothing!
				 * Equiv to setmonitor(NTSC);
				 */
				setvideo(DE_R1, DER1_170|DER1_UNBLANK);
#endif
			}
		} else {
			/*
			 *  No genlock board is installed, produce RS-170
			 *  video at NTSC rates with separate sync,
			 *  and hope that they have an outboard NTSC
			 *  encoder device.  Equiv to setmonitor(NTSC);
			 */
			setvideo(DE_R1, DER1_170|DER1_UNBLANK);
		}
	}



More information about the Comp.sys.sgi mailing list