⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vpc3230.c

📁 GM5621原代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*
	$Workfile:   vpc3230.c  $
	$Revision:   1.15  $
	$Date:   May 21 2004 09:51:48  $
*/

#define __VPC3230_C__

//******************************************************************************
//
//         Copyright (C) 2003.  GENESIS MICROCHIP INC. CONFIDENTIAL
//     All rights reserved.  No part of this program may be reproduced.
//
//	Genesis Microchip Inc, 2150 Gold Street, Alviso, CA - 95002
//
//==============================================================================
//
// MODULE:	VPC3230.c
//
// USAGE:	This file has functions for the VPC3230 video decoder.
//
//******************************************************************************

//******************************************************************************
//  I N C L U D E    F I L E S
//******************************************************************************

#include "inc\all.h"

//******************************************************************************
//  L O C A L    D E F I N I T I O N S
//******************************************************************************
#if (USE_VPORT && USE_GSEL_DRVR_MODEL)

#define I2C_PORT	0 //typically: 0 -hardware I2C, 1 -when using software I2C

#define VID_DECODER_ID_0        0x88
#define VID_DECODER_ID_1        0x8e
#define VID_DECODER_ID_2        0x8c

BYTE 	VID_DECODER_ID;

#define DEBUG_VDD 0

#if DEBUG_VDD && DEBUG_MSG
	#define	msg_vdd(a,b)	gm_Print((const char far *)a,b)
#else
	#define msg_vdd(a,b)
#endif

//******************************************************************************
//  G L O B A L    V A R I A B L E S
//******************************************************************************

//******************************************************************************
//  S T A T I C    V A R I A B L E S
//******************************************************************************

//******************************************************************************
//  S T A T I C    F U N C T I O N    P R O T O T Y P E S
//******************************************************************************
// appstest.c uses the driver read/write functions, so if DEBUG_MSG is defined,
// so is appstest.c, and therefore the driver functions have to be made far.
#if DEBUG_MSG
	#define static
	#define __near
#endif
static void __near dev_vpc323FPWrite	(WORD addr, WORD wrdata);
static WORD __near dev_vpc323FPRead	(WORD addr);
static BYTE __near dev_vpc323GetVideoInput( void );
static void __near dev_vpc323_WordWrite	(BYTE addr, WORD wrdata);
static void __near dev_vpc323_ByteWrite	(BYTE addr, BYTE wrdata);
static WORD __near dev_vpc323_WordRead(BYTE addr);

#if DEBUG_MSG
static BYTE __near dev_vpc323_ByteRead(BYTE addr);
#endif
//******************************************************************************
//  C O D E
//******************************************************************************

//******************************************************************************
//
// FUNCTION     :   static void dev_vpc323_WordWrite(BYTE VidDecId,BYTE addr,WORD wrdata)
// USAGE        :   Write 16-bit data to a location on vpc323
// INPUT        :   VidDecId - video decoder device ID (SAA7115, vpc323)
//					addr - location on the device to write data to
//          		wrdata - data
// OUTPUT       :   None
// GLOBALS      :   None
// USED_REGS    :   None
//
//******************************************************************************
static void __near dev_vpc323_WordWrite(BYTE addr,WORD wrdata)
{
	DWORD temp;

  ((BYTE *)&temp)[0] = addr;
  ((BYTE *)&temp)[1] = wrdata >> 8;
  ((BYTE *)&temp)[2] = wrdata & 0xff;
	gm_WriteI2cBlock(I2C_PORT,VID_DECODER_ID,(BYTE *)&temp, 3, 1);
}

//******************************************************************************
//
// FUNCTION     :   static void dev_vpc323_ByteWrite(BYTE VidDecId,BYTE addr,BYTE wrdata)
// USAGE        :   Write 8-bit data to a location on vpc323
// INPUT        :   VidDecId - video decoder device ID (SAA7115, vpc323)
//					addr - location on the device to write data to
//          		wrdata - data
// OUTPUT       :   None
// GLOBALS      :   None
// USED_REGS    :   None
//
//******************************************************************************
static void __near dev_vpc323_ByteWrite(BYTE addr,BYTE wrdata)
{
	WORD temp;

  ((BYTE *)&temp)[0] = addr;
  ((BYTE *)&temp)[1] = wrdata;
	gm_WriteI2cBlock(I2C_PORT,VID_DECODER_ID,(BYTE *)&temp, 2, 1);

}


//******************************************************************************
//
// FUNCTION     :   static WORD dev_vpc323_WordRead(BYTE VidDecId, BYTE addr)
// USAGE        :   Read 16-bit data from a location on vpc323
// INPUT        :   VidDecId - video decoder device ID (SAA7115, vpc323)
//					addr - location on the device to write data to
// OUTPUT       :   Data read
// GLOBALS      :   None
// USED_REGS    :   None
//
//******************************************************************************
static WORD __near dev_vpc323_WordRead(BYTE addr)
{
	WORD rdata;
	WORD temp;

	gm_WriteI2cBlock(I2C_PORT,VID_DECODER_ID, &addr, 1, 0);
	gm_ReadI2cBlock(I2C_PORT,VID_DECODER_ID,(BYTE *)&temp, 2, 1);
	rdata = (temp << 8) & 0xff00;
	rdata = rdata | ((temp >>8) & 0x00ff);
	return rdata;
}

//******************************************************************************
//
// FUNCTION     :   static BYTE dev_vpc323_ByteRead(BYTE VidDecId, BYTE addr)
// USAGE        :   Read 8-bit data from a location on vpc323
// INPUT        :   VidDecId - video decoder device ID (SAA7115, vpc323)
//					addr - location on the device to write data to
// OUTPUT       :   Data read
// GLOBALS      :   None
// USED_REGS    :   None
//
//******************************************************************************
#if DEBUG_MSG
static BYTE __near dev_vpc323_ByteRead(BYTE addr)
{
	BYTE rdata;

	gm_WriteI2cBlock(I2C_PORT,VID_DECODER_ID, &addr, 1, 0);

	gm_ReadI2cBlock(I2C_PORT,VID_DECODER_ID, &rdata, 1, 1);

	return rdata;
}
#endif

//******************************************************************************
//
// FUNCTION     :   void dev_vpc323FPWrite(WORD addr,WORD wrdata)
// USAGE        :   Write 16-bit data to a location on video decoder device
// INPUT        :   addr - location on the device to write data to
//          		wrdata - data
// OUTPUT       :   None
// GLOBALS      :   None
// USED_REGS    :   None
//
//******************************************************************************
static void __near dev_vpc323FPWrite(WORD addr,WORD wrdata)
{
  dev_vpc323_WordWrite(VPC_FPWRITE_ADDR_TWC_REG,addr);
  dev_vpc323_WordWrite(VPC_FPDATA_TWC_REG,wrdata);
}

//******************************************************************************
//
// FUNCTION     :   WORD dev_vpc323FPRead(WORD addr)
// USAGE        :   Read 16-bit data from a location on video decoder device
// INPUT        :   addr - location on the device to write data to
// OUTPUT       :   Data read
// GLOBALS      :   None
// USED_REGS    :   None
//
//******************************************************************************
static WORD __near dev_vpc323FPRead(WORD addr)
{
  dev_vpc323_WordWrite(VPC_FPREAD_ADDR_TWC_REG,addr);
  return dev_vpc323_WordRead(VPC_FPDATA_TWC_REG);
}


//******************************************************************************
//
// FUNCTION     :   void dev_vpc323SetVideoInput(BYTE VidDecId,BYTE InType)
// USAGE        :   Set video input type for video decoder device
// INPUT        :   VidDecId - video decoder device ID (SAA7115, vpc323)
//					InType - video input type: VDD_INTYP_NONE, VDD_INTYP_COMPOSITE,
//          		VDD_INTYP_SVIDEO, VDD_INTYP_COMPOSITE2, VDD_INTYP_TUNER, VDD_INTYP_COMPONENT
// OUTPUT       :   None
// GLOBALS      :   None
// USED_REGS    :   None
//
//******************************************************************************
static void __near dev_vpc323SetVideoInput(BYTE InType)
{
  WORD temp;

  //Disable ASR Detection
  dev_vpc323FPWrite(VPC_ASR_ENABLE_FP_REG,0x0000);
//  GVideoDecoder[VidDecId].InpType = InType;         //Commented for testing..............

  switch (InType)
  {
    case VDD_INTYP_COMPOSITE:
		 //msg_vdd("CVBS1 ",0);
         temp = dev_vpc323FPRead(VPC_SDT_FP_REG);
		temp &= 0x70f;
		temp |= 0x020;
	     //Comb Filter Active Selection
         dev_vpc323FPWrite(VPC_SDT_FP_REG,temp);

		//NOTE: This can change from one card to another
		//luma select from VIN2

         temp = dev_vpc323FPRead(VPC_INSEL_FP_REG);

		temp &= 0x7fc;
		temp |= 0x01;
		temp = (0x0766 & 0x7fc ) | 0x01;
		dev_vpc323FPWrite(VPC_INSEL_FP_REG,temp);

		gm_Delay1ms(20);
		dev_vpc323_ByteWrite(VPC_CIPMIX2_TWC_REG,0xDF);
        dev_vpc323_ByteWrite(VPC_CIPCNTL_TWC_REG,0x40);
		break;


    case VDD_INTYP_SVIDEO:
		msg_vdd("SVIDEO ",0);
         temp = dev_vpc323FPRead(VPC_SDT_FP_REG);
		temp &= 0x70f;
		temp |= 0x040;
	     //Comb Filter Active Selection
		msg_vdd("FP @ x20 to be sent =%x", temp);
		//S-VHS input
         dev_vpc323FPWrite(VPC_SDT_FP_REG,temp);
		 //temp = dev_vpc323FPRead(VidDecId,VPC_SDT_FP_REG);
		 //msg_vdd("FP @ x20 read =%x", temp);
		//NOTE: This can change from one card to another
		//luma selct from VIN1 and chroma select from CIN
         temp = dev_vpc323FPRead(VPC_INSEL_FP_REG);
		temp &= 0x7fc;
		temp |= 0x02;
		temp = (0x0766 & 0x7fc ) | 0x02;
		 //msg_vdd("FP @ x21 to be sent =%x", temp);
         dev_vpc323FPWrite(VPC_INSEL_FP_REG,temp);

		gm_Delay1ms(20);
		//         temp = dev_vpc323FPRead(VidDecId,VPC_INSEL_FP_REG);
		//		 msg_vdd("FP @ x21 read =%x", temp);
		dev_vpc323_ByteWrite(0x95,0xDF);
        dev_vpc323_ByteWrite(0x96,0x40);
		break;

    case VDD_INTYP_TUNER:
		msg_vdd("TUNER",0);
         temp = dev_vpc323FPRead(VPC_SDT_FP_REG);
		temp &= 0x70f;
		temp |= 0x020;
		//comb filter active
         dev_vpc323FPWrite(VPC_SDT_FP_REG,temp);

//		temp = dev_vpc323FPRead(VidDecId,0x0021);
//		temp &= 0x7fc;
//		temp |= 0x03;
		temp = (0x0766 & 0x7fc ) | 0x03;
		//NOTE: This can change from one card to another
		//luma select from VIN4
		dev_vpc323FPWrite(VPC_INSEL_FP_REG,temp);

		gm_Delay1ms(20);
		dev_vpc323_ByteWrite(VPC_CIPMIX2_TWC_REG,0xDF);
        dev_vpc323_ByteWrite(VPC_CIPCNTL_TWC_REG,0x40);
  		break;

	case VDD_INTYP_COMPONENT:
		msg_vdd("COMPONENT",0);
         temp = dev_vpc323FPRead(VPC_SDT_FP_REG);
		temp &= 0x70f;
		temp |= 0x020;
		//comb filter active
		dev_vpc323FPWrite(VPC_SDT_FP_REG, temp);

		//NOTE: This can change from one card to another
		// luma select from VIN3
		// used as sync source, even if the mixer use only the yuv path

		temp = dev_vpc323FPRead(VPC_INSEL_FP_REG);
		temp &= 0x7fc;
		temp |= 0x00;
//		temp = (0x0766 & 0x7fc ) | 0x00;
		dev_vpc323FPWrite(VPC_INSEL_FP_REG,temp);

		gm_Delay1ms(20);
		// force the mixer for yuv input path
		dev_vpc323_ByteWrite(VPC_CIPMIX2_TWC_REG,0x1F);
		//enable the bypass filter
        dev_vpc323_ByteWrite(VPC_CIPCNTL_TWC_REG,0x84);
		break;

    default:
         break;
  }
  //Enable ASR (automat standard recognisition) Detection for all of them
  dev_vpc323FPWrite(VPC_ASR_ENABLE_FP_REG,0x7f);
}

//******************************************************************************
//
// FUNCTION     :   BYTE dev_vpc323GetVideoInput(BYTE VidDecId)
// USAGE        :   Get video input type of video decoder device
// INPUT        :   VidDecId - video decoder device ID (SAA7115, vpc323)
// OUTPUT		:	InType - video input type: VDD_INTYP_NONE, VDD_INTYP_COMPOSITE,
//          		VDD_INTYP_SVIDEO, VDD_INTYP_COMPOSITE2, VDD_INTYP_TUNER, VDD_INTYP_COMPONENT
// GLOBALS      :   None
// USED_REGS    :   None
//
//******************************************************************************
static BYTE __near dev_vpc323GetVideoInput()
{
	//VidDecId = VidDecId+0;
	return 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -