kernels/linux-2.4.0/drivers/media/video/bttv-driver.c
/*
 *	Set the registers for the size we have specified. Don't bother
 *	trying to understand this without the BT848 manual in front of
 *	you [AC]. 
 *
 *	PS: The manual is free for download in .pdf format from 
 *	www.brooktree.com - nicely done those folks.
 */
Set the registers for the size we have specified. Don't bother
trying to understand this without the BT848 manual in front of
you [AC].


Set the registers for the size we have specified . Don ' t bother trying to understand this without the BT848 manual in front of you [ AC ] .
static inline void bt848_set_eogeo(struct bttv *btv, struct tvnorm *tvn,
				   int odd, int width, int height)
{
        u16 vscale, hscale;
	u32 xsf, sr;
	u16 hdelay;
	u8 crop, vtc;
	int inter = (height>tvn->sheight/2) ? 0 : 1;
        int off = odd ? 0x80 : 0x00;
	xsf = (width*tvn->scaledtwidth)/tvn->swidth;
	hscale = ((tvn->totalwidth*4096UL)/xsf-4096);
	hdelay =  tvn->hdelayx1;
	hdelay =  (hdelay*width)/tvn->swidth;
	hdelay &= 0x3fe;
	sr=((tvn->sheight>>inter)*512)/height-512;
	vscale=(0x10000UL-sr)&0x1fff;
	crop=((width>>8)&0x03)|((hdelay>>6)&0x0c)|
		((tvn->sheight>>4)&0x30)|((tvn->vdelay>>2)&0xc0);
	vscale |= inter ? (BT848_VSCALE_INT<<8) : 0;
	if (combfilter) {
		vtc = (width < 193) ? 2 : ((width < 385) ? 1 : 0);
		if (width < 769)
			btor(BT848_VSCALE_COMB, BT848_E_VSCALE_HI+off);
		else
			btand(~BT848_VSCALE_COMB, BT848_E_VSCALE_HI+off);
	} else {
		vtc = 0;
		btand(~BT848_VSCALE_COMB, BT848_E_VSCALE_HI+off);
	}
	btwrite(vtc, BT848_E_VTC+off);
	btwrite(hscale>>8, BT848_E_HSCALE_HI+off);
	btwrite(hscale&0xff, BT848_E_HSCALE_LO+off);
	btaor((vscale>>8), 0xe0, BT848_E_VSCALE_HI+off);
	btwrite(vscale&0xff, BT848_E_VSCALE_LO+off);
	btwrite(width&0xff, BT848_E_HACTIVE_LO+off);
	btwrite(hdelay&0xff, BT848_E_HDELAY_LO+off);
	btwrite(tvn->sheight&0xff, BT848_E_VACTIVE_LO+off);
	btwrite(tvn->vdelay&0xff, BT848_E_VDELAY_LO+off);
	btwrite(crop, BT848_E_CROP+off);
}
static inline void bt848_set_eogeo ( struct bttv * btv , struct tvnorm * tvn , int odd , int width , int height ) { u16 vscale , hscale ; u32 xsf , sr ; u16 hdelay ; u8 crop , vtc ; int inter = ( height > tvn -> sheight / 2 ) ? 0 : 1 ; int off = odd ? 0x80 : 0x00 ; xsf = ( width * tvn -> scaledtwidth ) / tvn -> swidth ; hscale = ( ( tvn -> totalwidth * 4096UL ) / xsf - 4096 ) ; hdelay = tvn -> hdelayx1 ; hdelay = ( hdelay * width ) / tvn -> swidth ; hdelay &= 0x3fe ; sr = ( ( tvn -> sheight >> inter ) * 512 ) / height - 512 ; vscale = ( 0x10000UL - sr ) & 0x1fff ; crop = ( ( width >> 8 ) & 0x03 ) | ( ( hdelay >> 6 ) & 0x0c ) | ( ( tvn -> sheight >> 4 ) & 0x30 ) | ( ( tvn -> vdelay >> 2 ) & 0xc0 ) ; vscale |= inter ? ( BT848_VSCALE_INT << 8 ) : 0 ; if ( combfilter ) { vtc = ( width < 193 ) ? 2 : ( ( width < 385 ) ? 1 : 0 ) ; if ( width < 769 ) btor ( BT848_VSCALE_COMB , BT848_E_VSCALE_HI + off ) ; else btand ( ~ BT848_VSCALE_COMB , BT848_E_VSCALE_HI + off ) ; } else { vtc = 0 ; btand ( ~ BT848_VSCALE_COMB , BT848_E_VSCALE_HI + off ) ; } btwrite ( vtc , BT848_E_VTC + off ) ; btwrite ( hscale >> 8 , BT848_E_HSCALE_HI + off ) ; btwrite ( hscale & 0xff , BT848_E_HSCALE_LO + off ) ; btaor ( ( vscale >> 8 ) , 0xe0 , BT848_E_VSCALE_HI + off ) ; btwrite ( vscale & 0xff , BT848_E_VSCALE_LO + off ) ; btwrite ( width & 0xff , BT848_E_HACTIVE_LO + off ) ; btwrite ( hdelay & 0xff , BT848_E_HDELAY_LO + off ) ; btwrite ( tvn -> sheight & 0xff , BT848_E_VACTIVE_LO + off ) ; btwrite ( tvn -> vdelay & 0xff , BT848_E_VDELAY_LO + off ) ; btwrite ( crop , BT848_E_CROP + off ) ; }
Set the registers for the size we have specified.
Set the registers for the size we have specified .
/* Some people say interpolation looks bad ... */