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

📄 tmicp.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              : tmICP.c    1.69
 *
 *  Last update              : 19:32:34 - 00/11/09
 *
 *
 *  Description              :
 *
 *      This is ICP device library file.
 *
 *
 *  Revision                 :
 *
 */

/*-----------------------------includes-------------------------------------*/

#include <tm1/tmAssert.h>
#include <stdio.h>
#include <tm1/mmio.h>
#include <ops/custom_defs.h>
#include <tm1/tmICP.h>
#include <string.h>
#include <math.h>
#include <tm1/tmInterrupts.h>
#include <tmlib/AppModel.h>

/*-----------------------------defines---------------------------------------*/
/*
 * NOTE: Ensure ACTUAL_MICROCODE_SIZE + 128 <= MAX_MICROCODE_SIZE
 *
 */
#define  MAX_MICROCODE_SIZE    4096     /* maximum of 1024 words or 4k bytes */
#define  ACTUAL_MICROCODE_SIZE 0x680
#define  WORDSIZE            sizeof(Pointer)

#define icpStart()           (MMIO(ICP_SR) |= ( ICP_INTERRUPT | ICP_BUSY) )

/*-----------------------------defines---------------------------------------*/

/*------------------------------types----------------------------------------*/

#ifdef __LITTLE_ENDIAN__

typedef struct {
    UInt32          image_in;       /* Start address of the input image */
    UInt16          lineOffset;     /* Offset in bytes, 0->no offset */
    Int16           yCntStFrac;     /* Y counter start fraction */
    UInt32          fracInc;        /* Increment value for Y=1/scale */
    UInt16          widthIn;        /* Input image width in pixels */
    UInt16          heightIn;       /* Input image height in pixels */
    UInt32          image_out;      /* Start address of the output image */
    UInt16          lineOffsetOut;  /* Output image line offset */
    UInt16          control;        /* Control bits; 0 default */
    UInt16          widthOut;       /* Output image width in pixels */
    UInt16          heightOut;      /* Output image height in pixels */
}               icpParamTable_t;

typedef struct {

    UInt32          yimage_in;      /* Start address of the Y input image */
    UInt16          yLineOffset;    /* Offset in bytes, 0->no offset */
    Int16           yCntStFrac;     /* Y counter start fraction */
    UInt32          yFracInc;       /* Increment value for Y=1/scale */
    UInt16          yWidthIn;       /* Input image width in pixels */
    UInt16          yHeightIn;      /* Input image height in pixels */
    UInt32          uimage_in;      /* Start address of the U input image */
    UInt16          uLineOffset;    /* Offset in bytes, 0->no offset */
    Int16           uCntStFrac;     /* Y counter start fraction */
    UInt32          uFracInc;       /* Increment value for U=1/scale */
    UInt16          uWidthIn;       /* Input image width in pixels */
    UInt16          uHeightIn;      /* Input image height in pixels */
    UInt32          vimage_in;      /* Start address of the V input image */
    UInt16          vLineOffset;    /* Offset in bytes, 0->no offset */
    Int16           vCntStFrac;     /* Y counter start fraction */
    UInt32          vFracInc;       /* Increment value for V=1/scale */
    UInt16          vWidthIn;       /* Input image width in pixels */
    UInt16          vHeightIn;      /* Input image height in pixels */
    UInt32          image_out;      /* Start address of the output image */
    UInt16          lineOffsetOut;  /* Output line width */
    UInt16          control;        /* Control bits */
    UInt16          widthOut;       /* Output image width in pixels */
    UInt16          heightOut;      /* Output image weight in lines */
    UInt32          bmpAddress;     /* Bit map image start address */
    UInt16          bmpLineOffset;  /* Bit map image line offset */
    UInt16          reserved;       /* Reserved bits */
    UInt32          rgbAddress;     /* RGB overlay start address */
    UInt16          rgbLineOffset;  /* RGB line offset */
    UInt16          alpha;          /* Alpha 0 and alpha 1 blend code 
                                     * for RGB 15+alpha etc. */
    UInt16          overStartPix;   /* Overlay start pixel */
    UInt16          overEndPix;     /* Overlay end pixel */
    UInt16          overStartLine;  /* Overlay start line */
    UInt16          overEndLine;    /* Overlay end line */
}               icpParamTableConvert_t;

#else               /* #ifdef __LITTLE_ENDIAN__ */

typedef struct {

    UInt32          image_in;       /* Start address of the input image */
    Int16           yCntStFrac;     /* Y counter start fraction */
    UInt16          lineOffset;     /* Offset in bytes, 0->no offset */
    UInt32          fracInc;        /* Increment value for Y=1/scale */
    UInt16          heightIn;       /* Input image height in pixels */
    UInt16          widthIn;        /* Input image width in pixels */
    UInt32          image_out;      /* Start address of the output image */
    UInt16          control;        /* Control bits; 0 default */
    UInt16          lineOffsetOut;  /* Output image line offset */
    UInt16          heightOut;      /* Output image height in pixels */
    UInt16          widthOut;       /* Output image width in pixels */

}               icpParamTable_t;

typedef struct {

    UInt32          yimage_in;      /* Start address of the Y input image */
    Int16           yCntStFrac;     /* Y counter start fraction */
    UInt16          yLineOffset;    /* Offset in bytes, 0->no offset */
    UInt32          yFracInc;       /* Increment value for Y=1/scale */
    UInt16          yHeightIn;      /* Input image height in pixels */
    UInt16          yWidthIn;       /* Input image width in pixels */
    UInt32          uimage_in;      /* Start address of the U input image */
    Int16           uCntStFrac;     /* Y counter start fraction */
    UInt16          uLineOffset;    /* Offset in bytes, 0->no offset */
    UInt32          uFracInc;       /* Increment value for U=1/scale */
    UInt16          uHeightIn;      /* Input image height in pixels */
    UInt16          uWidthIn;       /* Input image width in pixels */
    UInt32          vimage_in;      /* Start address of the V input image */
    Int16           vCntStFrac;     /* Y counter start fraction */
    UInt16          vLineOffset;    /* Offset in bytes, 0->no offset */
    UInt32          vFracInc;       /* Increment value for V=1/scale */
    UInt16          vHeightIn;      /* Input image height in pixels */
    UInt16          vWidthIn;       /* Input image width in pixels */
    UInt32          image_out;      /* Start address of the output image */
    UInt16          control;        /* Control bits */
    UInt16          lineOffsetOut;  /* Output line width */
    UInt16          heightOut;      /* Output image weight in lines */
    UInt16          widthOut;       /* Output image width in pixels */
    UInt32          bmpAddress;     /* Bit map image start address */
    UInt16          reserved;       /* Reserved bits */
    UInt16          bmpLineOffset;  /* Bit map image line offset */
    UInt32          rgbAddress;     /* RGB overlay start address */
    UInt16          alpha;          /* Alpha 0 and alpha 1 blend code for 
                                     * RGB 15+alpha etc. */
    UInt16          rgbLineOffset;  /* RGB line offset */
    UInt16          overEndPix;     /* Overlay end pixel */
    UInt16          overStartPix;   /* Overlay start pixel */
    UInt16          overEndLine;    /* Overlay end line */
    UInt16          overStartLine;  /* Overlay start line */

}               icpParamTableConvert_t;

#endif              /* #ifdef __LITTLE_ENDIAN__ */

extern UInt32   micro_code[];

static icpParamTable_t        blk;
static icpParamTableConvert_t blk3;

static Int      icp_instance;
static Int      instance_counter    = 0;
static Int      interrupt_installed = 0;
static Int      icp_setup           = 0;
static Int      icp_open            = 0;
static Int      overlay_used        = 0;
static Int      bitmask_used        = 0;


static icpCapabilities_t capabilities =
{
     /* version                      */ {0, 0, 1},
     /* numSupportedInstances        */ 1,
     /* numCurrentInstances          */ 0
};

/*
 * Standard coefficients provided with the icp
 * Coefficient array, contains maximum of
 * 32 filters of 5 taps. Each filter is contained in 3 words.
 */

#ifdef __LITTLE_ENDIAN__
Int16           icpFilterCoeff[] =
{
    0, 0, 511, 0, 0, 0,
    -1, 12, 510, -10, 1, 0,
    -3, 24, 507, -19, 2, 0,
    -5, 38, 502, -27, 3, 0,
    -7, 53, 495, -34, 4, 0,
    -9, 69, 486, -39, 4, 0,
    -12, 87, 475, -44, 5, 0,
    -15, 105, 463, -47, 5, 0,
    -18, 124, 449, -50, 5, 0,
    -21, 144, 434, -51, 5, 0,
    -24, 165, 417, -52, 5, 0,
    -27, 186, 399, -52, 5, 0,
    -31, 208, 380, -51, 5, 0,
    -34, 229, 360, -50, 5, 0,
    -37, 252, 339, -48, 5, 0,
    -40, 274, 318, -46, 5, 0,
    5, -43, 296, 296, -43, 0,
    5, -46, 318, 274, -40, 0,
    5, -48, 339, 252, -37, 0,
    5, -50, 360, 229, -34, 0,
    5, -51, 380, 208, -31, 0,
    5, -52, 399, 186, -27, 0,
    5, -52, 417, 165, -24, 0,
    5, -51, 434, 144, -21, 0,
    5, -50, 449, 124, -18, 0,
    5, -47, 463, 105, -15, 0,
    5, -44, 475, 87, -12, 0,
    4, -39, 486, 69, -9, 0,
    4, -34, 495, 53, -7, 0,
    3, -27, 502, 38, -5, 0,
    2, -19, 507, 24, -3, 0,
    1, -10, 510, 12, -1, 0
};

/*
 * Deinterlace coeficients.
 */
Int16 icpDeinterlaceCoeff [] = {
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0,
  -160, 256, 320, 256, -160, 0
};


#else               /* Big endian */

Int16           icpFilterCoeff[] =
{
    0, 0, 0, 511, 0, 0,
    12, -1, -10, 510, 0, 1,
    24, -3, -19, 507, 0, 2,
    38, -5, -27, 502, 0, 3,
    53, -7, -34, 495, 0, 4,
    69, -9, -39, 486, 0, 4,
    87, -12, -44, 475, 0, 5,
    105, -15, -47, 463, 0, 5,
    124, -18, -50, 449, 0, 5,
    144, -21, -51, 434, 0, 5,
    165, -24, -52, 417, 0, 5,
    186, -27, -52, 399, 0, 5,
    208, -31, -51, 380, 0, 5,
    229, -34, -50, 360, 0, 5,
    252, -37, -48, 339, 0, 5,
    274, -40, -46, 318, 0, 5,
    -43, 5, 296, 296, 0, -43,
    -46, 5, 274, 318, 0, -40,
    -48, 5, 252, 339, 0, -37,
    -50, 5, 229, 360, 0, -34,
    -51, 5, 208, 380, 0, -31,
    -52, 5, 186, 399, 0, -27,
    -52, 5, 165, 417, 0, -24,
    -51, 5, 144, 434, 0, -21,
    -50, 5, 124, 449, 0, -18,
    -47, 5, 105, 463, 0, -15,
    -44, 5, 87, 475, 0, -12,
    -39, 4, 69, 486, 0, -9,
    -34, 4, 53, 495, 0, -7,
    -27, 3, 38, 502, 0, -5,
    -19, 2, 24, 507, 0, -3,
    -10, 1, 12, 510, 0, -1
};

/*
 * Deinterlace coeficients.
 */
Int16 icpDeinterlaceCoeff [] = {
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,
  256, -160, 256, 320, 0, -160,

⌨️ 快捷键说明

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