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

📄 philips_iref.c

📁 用于TM1300/PNX1300系列DSP(主要用于视频处理)的设备库的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
/*
 * Copyright (c) 1995,1996,1997 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_iref.c  1.70                 
 *
 *  Last update              : 19:12:53  -  00/11/09         
 *
 *  Description              :
 *
 * Board Support Package for Trimedia peripherals. This particular file supports
 * the Philips IREF board. The purpose of this file is to define
 * philips_iref_config. This board config structure will be included in a
 * table in boardcfg.c
 *
 * This file also defines many of the functions and structures which are
 * referenced in the board config structure.
 *
 * Revision                 : Built for the TCS 1.1 release
 *
 *
 */

/* includes of system H files */

#include <tm1/mmio.h>
#include <tm1/tmProcessor.h>
#include <tm1/tmBoard.h>
#include <tm1/tmAvFormats.h>
#include <tm1/tmAImmio.h>
#include <tm1/tmAOmmio.h>
#include <tm1/tmVImmio.h>
#include <tm1/tmVOmmio.h>
#include <tm1/tmAssert.h>
#include <tm1/tmIIC.h>
#include <tm1/tsaComponent.h>

#include <tm1/tsaReg.h>

#include <unistd.h>
#include <tmlib/tmlibc.h>
#include <string.h>

/* only for initial debugging */
#include <tmlib/dprintf.h>    /* for debugging with DP(()) */


/* includes of local H files */
#include "philips_iref.h"
#include "ad1847.h"
#include "6ch.h"
#include "saa7111.h"        /* defines for video in decoder */
#include "saa7125.h"        /* defines for video out encoder */
#include "st7545.h"         /* defines for AFE */
#include "voSupport.h"

#define MYDP(x) do { \
printf x ; \
} while (0) 


#define DEBUG_LEVEL 0

/* Debug Level 
 * 0 : Only error and warning messages that are useful to debug a component
 *     are displayed.
 * 1 : Report the function calls
 * 2 : Various stuff necessary to debug this lib, like intermediate values
 * 3 : Add verbosity ... complete
*/

#if (DEBUG_LEVEL == 0)
#define L1_DP(x)
#define L2_DP(x)
#endif

#if (DEBUG_LEVEL == 1)
#define L1_DP(x)  DP(x) 
#define L2_DP(x)        
#endif

#if (DEBUG_LEVEL == 2)
#define L1_DP(x)  
#define L2_DP(x)  DP(x)      
#endif

#if (DEBUG_LEVEL == 3)
#define L1_DP(x) DP(x)
#define L2_DP(x) DP(x)
#endif

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

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

#define VO_INIT_FREQ    27000000.0    /* 27 MHz */




/* forward declarations of functions defined in this module */

/* board specific functions */
/* This function is run by the component handler */
static tmLibdevErr_t iref_board_activate(pcomponent_t comp);
/* these three functions are run by the activate function */
static tmLibdevErr_t iref_board_init(void);
static tmLibdevErr_t iref_board_detect(void);
static tmLibdevErr_t iref_board_register(pcomponent_t comp);

static tmLibdevErr_t iref_AO_init(pboardAOParam_t param);
static tmLibdevErr_t iref_AO_term(void);
static tmLibdevErr_t iref_AO_start(void);
static tmLibdevErr_t iref_AO_stop(void);
static tmLibdevErr_t iref_AO_SetVolume(Int lGain, Int rGain);
static tmLibdevErr_t iref_AO_GetVolume(Int * lGain, Int * rGain);
static tmLibdevErr_t iref_AO_SetSRate(Float srate);
static tmLibdevErr_t iref_AO_GetSRate(Float * srate);

static tmLibdevErr_t iref_AI_init(pboardAIParam_t param);
static tmLibdevErr_t iref_AI_term(void);
static tmLibdevErr_t iref_AI_start(void);
static tmLibdevErr_t iref_AI_stop(void);
static tmLibdevErr_t iref_AI_SetInput(tmAudioAnalogAdapter_t input);
static tmLibdevErr_t iref_AI_GetInput(tmAudioAnalogAdapter_t * input);
static tmLibdevErr_t iref_AI_SetVolume(Int lGain, Int rGain);
static tmLibdevErr_t iref_AI_GetVolume(Int * lGain, Int * rGain);
static tmLibdevErr_t iref_AI_SetSRate(Float sRate);
static tmLibdevErr_t iref_AI_GetSRate(Float * sRate);
static UInt          hertz2Control(Float rate, Int sckdiv, Int wsdiv, Int sfdiv);

static tmLibdevErr_t iref_VI_Init (pboardVIParam_t param); 
static tmLibdevErr_t iref_VI_Configure(UInt32 subaddr, UInt32 value);
static tmLibdevErr_t iref_VI_GetStandard(tmVideoAnalogStandard_t *standard);
static tmLibdevErr_t iref_VI_GetAdapterStandard(pboardVIDec_t pVD, tmVideoAnalogAdapter_t adapter, UInt adapterNum, tmVideoAnalogStandard_t *standard);static tmLibdevErr_t iref_VI_SetBrightness(UInt val);
static tmLibdevErr_t iref_VI_SetContrast(UInt val);
static tmLibdevErr_t iref_VI_SetSaturation(UInt val);
static tmLibdevErr_t iref_VI_SetHue(UInt val);


/* Describe audio out. */
static boardAOConfig_t iref_ao = 
{
    "Unknown",                      /* name of the codec */
    iref_AO_init,          /* init */
    iref_AO_term,          /* close */

    iref_AO_start,         /* start */
    iref_AO_stop,          /* stop */
    iref_AO_SetSRate,      /* set srate */
    iref_AO_GetSRate,      /* get srate */
    iref_AO_SetVolume,     /* set volume */
    iref_AO_GetVolume,     /* get volume */
    Null,                  /* set output */
    Null,                  /* get output */
    Null,                  /* config */    


    IREF_SUPPORTED_STREAM_FORMATS,  /* audioTypeFormats */
    IREF_SUPPORTED_PCM_OUT_FORMATS, /* audioSubtypeFormats*/
    IREF_OUTPUT_AUDIO_ADAPTERS,     /* audioAdapters */
    intAUDIOOUT,                    /* interrupt */
    AO_STATUS,                      /* mmioBase */
    CS4333_MAX_SRATE,               /* max sRate */
    CS4333_MIN_SRATE,               /* min sRate */
    0,                              /* gpio first pin */
    0                               /* gpio last pin */
};




/* describe audio in */
static boardAIConfig_t iref_ai =
{
    "AD1847",                       /* codec name */
    iref_AI_init,        /* init */
    iref_AI_term,        /* term */
    iref_AI_start,       /* start */
    iref_AI_stop,        /* stop */
    iref_AI_SetSRate,    /* set srate */
    iref_AI_GetSRate,    /* get srate */
    iref_AI_SetVolume,   /* set volume */
    iref_AI_GetVolume,   /* get volume */
    iref_AI_SetInput,    /* set input */
    iref_AI_GetInput,    /* get input */
    Null,                /* config */
    Null,                /* getFormat */


    IREF_SUPPORTED_STREAM_FORMATS,  /* audioTypeFormats */
    IREF_SUPPORTED_PCM_IN_FORMATS,  /* audioSubtypeFormats*/
    IREF_INPUT_AUDIO_ADAPTERS,      /* audioAdapters */
    intAUDIOIN,                     /* interrupt number */
    AI_STATUS,                      /* mmioBase */
    AD1847_MAX_SRATE,               /* max sRate */
    AD1847_MIN_SRATE,               /* min sRate */
    0,                              /* gpio first pin */
    0                               /* gpio last pin */
};

/* 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 iref_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 */
    0,                              /* gpio first pin */
    0                               /* gpio last pin */
};

static Bool Is7111Initialized = False;

#define NO_OF_VIDEO_ADAPTERS 2 
static boardVIAdapterEntry_t iref_vi_adapters [NO_OF_VIDEO_ADAPTERS] =
{
    { vaaCVBS,   0, 0 },           /* CVBS    adapter 0 at input mode 1 */
    { vaaSvideo, 0, 5 }            /* S-Video adapter 0 at input mode 9 */
};

/* Describe video in. */
static boardVIConfig_t iref_vi =
{
    "SAA 7111A",                   /* decoder name */
    iref_VI_Init,                  /* decode init */
    Null,                          /* decoder term */
    iref_VI_GetStandard,           /* get standard */
    iref_VI_SetHue,
    iref_VI_SetSaturation,
    iref_VI_SetBrightness,
    iref_VI_SetContrast,
    iref_VI_Configure,              /* config */

    SAA7111_SUPPORTED_STANDARDS,    /* supported color standards */
    SAA7111_SUPPORTED_ADAPTERS,     /* supported adapters */
    intVIDEOIN,                     /* interrupt number */
    VI_STATUS,                      /* mmioBase */
    0,                              /* gpio first pin */
    0,                              /* gpio last pin */
    SAA7111_CAPABILITIES_FLAGS,     /* saa7111 capabilities */
    SAA7111_OUTPUT_FORMATS,         /* saa7111 output formats */
    saa7111GetVSyncFallingEdge,     /* returns line number of VSync falling edge */
    saa7111GetSlicedData,           /* returns sliced Closed Caption data */
    saa7111GetStatus,               /* gives information if CC data have been available */
    saa7111GetSupportedDataServices,/* returns supported services for each VBI line */
    saa7111SetDataServices,         /* sets data services to be sliced */
    saa7111EnableSlicing,           /* enables HW slicing */
    Null,                           /* set video standard for slicer */
    Null,                           /* get slicer's video standard */
    Null,                           /* toggle slicer's field ID */
    Null,          /* set input of slicer */
    Null,          /* get slicer's input */
    saa7111SetVideoColor,           /* set BCSH for active video */
    saa7111GetVideoColor,           /* get BCSH for active video */
    Null,          /* set video input mode */
    Null,          /* get video input mode */
    saa7111SetStandard,             /* set video standard */
    saa7111SetSourceType,           /* set video source type */
    saa7111GetSourceType,           /* get video source type */
    saa7111SetOutputFormat,         /* set the video's output format */
    saa7111GetOutputFormat,         /* get the video's output format */
    Null,                           /* set video acquisition window */
    Null,                           /* get video acquisition window */
    saa7111GetDefaultAcquisitionWnd,/* get the default acquisition window */
    Null,                           /* set video output size */
    Null,                           /* set interlaced mode */
    saa7111DisableDecoder,          /* disable video decoder */
    saa7111EnablePowerSaveMode,     /* set power save mode */
    saa7111GetGPIOCount,            /* get number of GPIOs on decoder */
    saa7111SetGPIOState,            /* set the state of one GPIO pin */
    saa7111GetGPIOState,            /* get a GPIO pin's state */
    Null,                           /* open VBI decoder */
    Null,                           /* enable VBI */
    Null,                           /* set VBI mode */
    Null,                           /* set the slicer's mode */
    Null,                           /* close VBI decoder */
    Null,                           /* get the slicer's line flags */
    { 0x48,                         /* decoder's I2C slave address */
      NO_OF_VIDEO_ADAPTERS,         /* number of adapters          */
      iref_vi_adapters },           /* mapping table of adapters to inputs */
    iref_VI_GetAdapterStandard  /* Get the standard for a specific adapter */
};


/* describe telecom's Analog Front End (AFE) */
static boardSSIConfig_t iref_afe =
{
    "st7545 IREF",
    st7545Setup,     /* setup */
    st7545Term,      /* term */
    Null,            /* hook */
    Null,            /* config */
    sacConnectToPOTS,/* connection flags */
    Null,            /* reserved */
    intINT_15,       /* interrupt number */
    0,               /* gpio first pin */
    0                /* gpio last pin */
};


/* static variables that reflect the current state of the audio units */

⌨️ 快捷键说明

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