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

📄 philips_dtv_ref4.c

📁 用于TM1300/PNX1300系列DSP(主要用于视频处理)的设备库的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
/*
 * Copyright (c) 1995 - 1999 by TriMedia Technologies. 
 *
 * +------------------------------------------------------------------+
 * | This software is furnished under a license and may only be used  |
 * | and copied in accordance with the terms and conditions of  such  |
 * | a license and with the inclusion of this copyright notice. This  |
 * | software or any other copies of this software may not be provided|
 * | or otherwise made available to any other person.  The ownership  |
 * | and title of this software is not transferred.                   |
 * |                                                                  |
 * | The information in this software is subject  to change without   |
 * | any  prior notice and should not be construed as a commitment by |
 * | TriMedia Technologies.                                           |
 * |                                                                  |
 * | this code and information is provided "as is" without any        |
 * | warranty of any kind, either expressed or implied, including but |
 * | not limited to the implied warranties of merchantability and/or  |
 * | fitness for any particular purpose.                              |
 * +------------------------------------------------------------------+
 *
 *  Module name             : philips_dtv_ref4.c    1.31
 *
 *  Last update             : 19:01:56 - 00/11/09
 *
 * Description              :
 *
 * Board Support Package for Trimedia peripherals. This particular file supports
 * the Philips DTV REF 4 (Jupiter).
 *
 *
 */

#include <tm1/mmio.h>
#include <tm1/tmBoardID.h>
#include <tm1/tmBoard.h>
#include <tm1/tmProcessor.h>
#include <tm1/tmVImmio.h>
#include <tm1/tmVOmmio.h>
#include <tm1/tmAssert.h>
#include <tm1/tmHDVOmmio.h>
#include <tm1/tmAvFormats.h>
#include <tmlib/dprintf.h>
#include <tm1/tsaComponent.h>
#include <tm1/tmGPIO.h>
#include <tm1/tmGPIOpins.h>
#include <tm1/tmGPIOmmio.h>
#include <tm1/tsaFlash.h>
#include <tm1/tsaFlashBoard.h>
#include <tm1/tsaPIC.h>
#include <tm1/tsaPICboard.h>
#include <tm1/tsaIR.h>
#include <tm1/tsaIRboard.h>
#include <tm1/tmIIC.h>
#include <tm1/tsaReg.h>
#include <tm1/tsaP1394Board.h>

/* includes of local H files */
#include "philips_dtv_ref4.h"
#include "dtv_ref4_audio.h"
#include "voSupport.h"
#include "saa7125.h"
#include "xioReg.h"
#include "em9010.h"
#include "w83977atf.h"
#include "pdil11.h"
#include "iicDirection.h"

#define IIC_EEPROM_ADDRESS          0xA1        /* address of boot eeprom */
#define NIM_SPDIF_STATUS_ADDRESS    0x72

#define DP_R4(x) /* DP(x) */
#define DP_XX(x) /*  DP(x) */

#define TRY(x) \
do { \
tmLibdevErr_t _err = (x); \
if (_err != TMLIBDEV_OK) { \
DP(("Failed at line %d in file %s. Err = %x\n", __LINE__, __FILE__, _err)); \
return _err; \
}} while (0) 

/* forward declarations of functions defined in this module */
static tmLibdevErr_t dtvRef4_board_activate(pcomponent_t comp);
static tmLibdevErr_t dtvRef4_board_init(void);
static tmLibdevErr_t dtvRef4_board_detect(void);
static tmLibdevErr_t dtvRef4_board_register(pcomponent_t comp);
static tmLibdevErr_t dtvRef4_bankSwitch(UInt32 bank);
static tmLibdevErr_t dtvRef4DirectionSwitch(UInt32 direction);

/* forward declarations of flash functions defined in this module */
static tmLibdevErr_t dtvRef4FlashInit(void);
static tmLibdevErr_t dtvRef4FlashReadWord(UInt32 address, UInt32 * data);
static tmLibdevErr_t dtvRef4FlashWriteWord(UInt32 address, UInt32 data);
static tmLibdevErr_t dtvRef4FlashReadBlock(UInt32 address, UInt32 * data, UInt32 numberOfWords);
static tmLibdevErr_t dtvRef4FlashWriteBlock(UInt32 address, UInt32 * data, UInt32 numberOfWords);
static tmLibdevErr_t dtvRef4FlashEraseSector(UInt32 sector);
static tmLibdevErr_t dtvRef4FlashEraseAll(void);

/* SIO access functions */
static tmLibdevErr_t ref4SioWrite (UInt32 sioAddress, UInt8 data);
static tmLibdevErr_t ref4SioRead (UInt32 sioAddress, UInt32 *data);

/* 1394 mux/reset/access functions */
static tmLibdevErr_t dtvRef4_muxSwitch(UInt32 muxConfig);
static void dtvRef4_AVReset();
static tmLibdevErr_t ref4P1394Write (UInt32 p1394Address, UInt8 data);
static tmLibdevErr_t ref4P1394Read (UInt32 p1394Address, UInt8 *data);

/* declaration of PIC functions */
static tmLibdevErr_t dtvRef4PICInit(UInt32 source);
static tmLibdevErr_t dtvRef4PICTerm(UInt32 source);
static tmLibdevErr_t dtvRef4PICStart(UInt32 source);
static tmLibdevErr_t dtvRef4PICStop(UInt32 source);
static tmLibdevErr_t dtvRef4PICAck(UInt32 source);
static Bool dtvRef4PICSourceDetect(UInt32 * source);

/* declaration of IR functions */
static tmLibdevErr_t dtvRef4IRInit(pboardIRParam_t params);
static tmLibdevErr_t dtvRef4IRTerm(void);
static tmLibdevErr_t dtvRef4IRStart(void);
static tmLibdevErr_t dtvRef4IRStop(void);
static void dtvRef4IRGetEvent(tsaIREvent_t *event, UInt32 *value);

/* declaration of UART functions */
static tmLibdevErr_t dtvRef4UARTInit(unitSelect_t portID, pboardUartParam_t params);
static tmLibdevErr_t dtvRef4UARTTerm(unitSelect_t portID);

static UInt boardID = 0;

/* PIC support */
#define DTV_REF4_PIC_NUM_SUPPORTED_INTS 1
#define DTV_REF4_PIC_SOURCE_COMM1       0
#define DTV_REF4_PIC_SOURCE_COMM2       1
#define DTV_REF4_PIC_SOURCE_IR_IN0      2
#define DTV_REF4_PIC_SOURCE_AUDIO1      3
#define DTV_REF4_PIC_SOURCE_AUDIO2      4
#define DTV_REF4_PIC_SOURCE_1394        5
#define DTV_REF4_PIC_NUM_SRCS           6
/* these are the sources supported by the PIC */
static tsaPICSource_t dtvRef4PICSrcTable[DTV_REF4_PIC_NUM_SRCS] = 
{
    picSourceComm1, 
    picSourceComm2, 
    picSourceIrIn0, 
    picSourceAudio1, 
    picSourceAudio2,
    picSource1394
};

static boardPICIntCaps_t dtvRef4PICIntCaps[DTV_REF4_PIC_NUM_SUPPORTED_INTS] =
{
{
    intGPIO,                /* interrupt */
    True,                  /* levelTriggered */
    intPRIO_3,              /* interrupt priority */
    DTV_REF4_PIC_NUM_SRCS,  /* numSources */
    dtvRef4PICSrcTable,
    dtvRef4PICInit,         /* initFunc */
    dtvRef4PICTerm,         /* termFunc */
    dtvRef4PICSourceDetect, /* sourceDetectFunc */
    dtvRef4PICStart,        /* startFunc */
    dtvRef4PICStop,         /* stopFunc */
    dtvRef4PICAck,          /* ackFunc */
}
};

static boardPICConfig_t dtvRef4PIC =
{
    "REF4 PIC",
    DTV_REF4_PIC_NUM_SUPPORTED_INTS,
    dtvRef4PICIntCaps
};

static Int          IicInstance = 0;
static Bool         NimInstalled = True;
static UInt8        iicData;
static iicRequest_t req;

/* IR support */
#define DTV_REF4_IR_SUPPORTED_DEVICES (irdRC5)
static boardIRConfig_t dtvRef4IR =
{
    "SIO IR",
    dtvRef4IRInit,     /* initFunc */
    dtvRef4IRTerm,     /* termFunc */
    dtvRef4IRStart,    /*startFunc */
    dtvRef4IRStop,     /* stopFunc */
    Null,              /* config not supported */
    dtvRef4IRGetEvent, /* getEventFunc */
    DTV_REF4_IR_SUPPORTED_DEVICES
};

/* flash support */
static boardFlashConfig_t dtvRef4Flash = 
{
    "Am29F032B",
    dtvRef4FlashInit,
    dtvRef4FlashReadWord,
    dtvRef4FlashWriteWord,
    dtvRef4FlashReadBlock,
    dtvRef4FlashWriteBlock,
    dtvRef4FlashEraseSector,
    dtvRef4FlashEraseAll,
    DTV_REF4_FLASH_SIZE,
    DTV_REF4_FLASH_SECTOR_NR,
    DTV_REF4_FLASH_SECTOR_SIZE,
    0xffffffff
};

/* Describe audio out. */
static boardAOConfig_t dtvRef4_ao_1 =
{
    "DTV REF4 AO1",        /* determined in init */
    dtvRef4_AO_Init_1,     /* init */
    dtvRef4_AO_Term_1,     /* term */
    dtvRef4_AO_Start_1,    /* start */
    dtvRef4_AO_Stop_1,     /* stop */
    dtvRef4_AO_SetSRate_1, /* set srate */
    dtvRef4_AO_GetSRate_1, /* get srate */
    Null,                      /* set volume */
    Null,                      /* get volume */
    Null,                      /* set output */
    Null,                      /* get output */
    Null,                      /* config */
    DTV_REF4_SUPPORTED_AUDIO_OUT_TYPES_1,    /* audioTypeFormats */
    DTV_REF4_SUPPORTED_AUDIO_OUT_SUBTYPES_1, /* audioSubtypeFormats*/
    DTV_REF4_OUTPUT_AUDIO_ADAPTERS_1,       /* audioAdapters */
    intAUDIOOUT,               /* interrupt number */
    AO1_STATUS,                /* mmioBase */
    50000,                     /* max sample rate */
    20000,                     /* min sample rate */
    GPIO_AO1_OSCLK,            /* gpio first pin */
    GPIO_AO1_SD4               /* gpio last pin */
};

static boardAOConfig_t dtvRef4_ao_2 =
{
    "DTV REF4 AO2",        /* determined in init */
    dtvRef4_AO_Init_2,     /* init */
    dtvRef4_AO_Term_2,     /* term */
    dtvRef4_AO_Start_2,    /* start */
    dtvRef4_AO_Stop_2,     /* stop */
    dtvRef4_AO_SetSRate_2, /* set srate */
    dtvRef4_AO_GetSRate_2, /* get srate */
    Null,                      /* set volume */
    Null,                      /* get volume */
    Null,                      /* set output */
    Null,                      /* get output */
    Null,                      /* config */
    DTV_REF4_SUPPORTED_AUDIO_OUT_TYPES_2,    /* audioTypeFormats */
    DTV_REF4_SUPPORTED_AUDIO_OUT_SUBTYPES_2, /* audioSubtypeFormats*/
    DTV_REF4_OUTPUT_AUDIO_ADAPTERS_2,       /* audioAdapters */
    intAUDIOOUT2,              /* interrupt number */
    AO2_STATUS,                /* mmioBase */
    50000,                     /* max sample rate */
    20000,                     /* min sample rate */
    GPIO_AO2_OSCLK,            /* gpio first pin */
    GPIO_AO2_SD1               /* gpio last pin */
};

static boardSPDOConfig_t dtvRef4_spdo =
{
    "DTV REF4 SPDO",         /* determined in init */
    dtvRef4_SPDO_Init,     /* init */
    dtvRef4_SPDO_Term,     /* term */
    dtvRef4_SPDO_Start,    /* start */
    dtvRef4_SPDO_Stop,     /* stop */
    dtvRef4_SPDO_SetSRate, /* set srate */
    dtvRef4_SPDO_GetSRate, /* get srate */
    Null,                      /* config */
    DTV_REF4_SUPPORTED_SPDO_TYPES,    /* audioTypeFormats */
    DTV_REF4_SUPPORTED_SPDO_SUBTYPES, /* audioSubtypeFormats*/
    DTV_REF4_OUTPUT_SPDO_ADAPTERS,    /* audioAdapters */
    intSPDIFOUT,               /* interrupt number */
    SPDO_STATUS,               /* mmioBase */
    50000,                     /* max sample rate */
    20000,                     /* min sample rate */
    GPIO_SPDO,                 /* gpio first pin */
    GPIO_SPDO                  /* gpio last pin */
};

/* UART support */
static boardUartConfig_t dtvRef4Uart1 = 
{
    "REF4 com1 RS232",
    dtvRef4UARTInit,
    dtvRef4UARTTerm,
    w83977atfUartReadData,
    w83977atfUartSetTxInt,
    w83977atfUartWriteData,
    w83977atfUartSetRxInt,
    w83977atfUartGetEvent,
    w83977atfUartConfig,
    W83977ATF_SUPPORTED_BAUD_RATES
};

static boardUartConfig_t dtvRef4Uart2 = 
{
    "REF4 com2 RS232",
    dtvRef4UARTInit,
    dtvRef4UARTTerm,
    w83977atfUartReadData,
    w83977atfUartSetTxInt,
    w83977atfUartWriteData,
    w83977atfUartSetRxInt,
    w83977atfUartGetEvent,
    w83977atfUartConfig,
    W83977ATF_SUPPORTED_BAUD_RATES
};

static boardP1394Config_t dtvRef4P1394 = 
{
    "DTV_REF4_1394",        /* determined in init */
    pdil11InitFunc,     /* init */
    Null,     /* term */
    Null,    /* start */
    Null,     /* stop */
    pdil11Config,   /* Config */
    Null, 		/* Warning bogus!! get event */
    pdil11PayLoadRead,
    pdil11PayLoadGet32, /* payLoadRead */
    pdil11Read,      /* AV Link Read*/
    pdil11Write,     /* AV Link Write  */
    pdil11Put32,     /* quad write */
    pdil11BRead,     /* read byte */
    dtvRef4_muxSwitch,	/* switch the mux */
    dtvRef4_AVReset,	/* Reset AV */
    picSource1394,   /* interrupt number */
    0xFC800000,	     /* avBase */
    0xFC800400	     /* shadow */
};

/* VO + SAA 7125 init */
static tmLibdevErr_t 
boardVOInit(pboardVOParam_t param)
{
    tmLibdevErr_t       rval;

    rval = saa7125Init(param);
    
    voSetFREQUENCY__CHECK(param->ddsFrequency);
    voSetPLL_S__CHECK(1);
    voSetPLL_T__CHECK(1);
    voSetCLKOUT__CHECK(1);
    voSetSYNC_MASTER__CHECK(1);

    switch (param->videoStandard)
    {
    case vasNTSC:
        voSupportNTSC();
        break;
    case vasPAL:
        voSupportPAL();
        break;
    case vasNone:
        break;
    default:
        return BOARD_ERR_UNSUPPORTED_STANDARD;
    }
    
    return rval;
}

/* Describe video out. */
static boardVOConfig_t dtvRef4_vo =
{
    "SAA 7125",                     /* encoder name */
    boardVOInit,                    /* init */
    Null,                           /* term */
    Null,                           /* Hue  */
    Null,                           /* Saturation   */
    saa7125SetBrightness,
    Null,                           /* Contrast */
    saa7125Configure,               /* config */
    SAA7125_SUPPORTED_STANDARDS,    /* supported color standards */
    SAA7125_SUPPORTED_ADAPTERS,     /* supported adapters */
    intVIDEOOUT,                    /* interrupt number */
    VO_STATUS,                      /* mmioBase */
    GPIO_SDVO_CLK,                  /* gpio first pin */
    GPIO_SDVO_D7                    /* gpio last pin */
};

/* describe telecom's Analog Front End (AFE) */
static boardSSIConfig_t dtvRef4_afe =
{
    "none",
    Null,                    /* setup */
    Null,                    /* term */
    Null,                    /* hook */
    Null,                    /* config */
    sacNoConnection,         /* connection flags */
    Null,                    /* reserved */
    intINT_15,
    GPIO_SSI_CLK,            /* gpio first pin */
    GPIO_SSI_IO2             /* gpio last pin */
};

/*
 * HDVO
 */
tmLibdevErr_t dtvRef4_HDVO_Init (tmVideoAnalogStandard_t standard,
				     tmVideoAnalogAdapter_t  adapterType,
				     tmVideoTypeFormat_t     videoType,
				     hdvoImageOutputMode_t   videoSubtype,
				     UInt32                  description)
{
  /*
   * HDVO is Clk and Sync master
   */
  hdvoEnableMCP_CTRL_ClkOut();
  hdvoEnableMCP_CTRL_Sync_Master();

  return TMLIBDEV_OK;
}

tmLibdevErr_t dtvRef4_HDVO_Term(void) 
{ 
  return TMLIBDEV_OK;
}

tmLibdevErr_t dtvRef4_HDVO_Config(UInt32 address, UInt32 value)
{
  return TMLIBDEV_OK;
}

static boardHDVOConfig_t dtvRef4_hdvo =

⌨️ 快捷键说明

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