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

📄 l2_cdsp.c

📁 台湾凌阳方案300万数码相机源代码
💻 C
📖 第 1 页 / 共 5 页
字号:

  for(tmp=0; tmp<256; tmp++)
    if(XBYTE[0x2100+tmp]!=0xFF&Mask)
      status = 1;

  //test 0xFF->0x00
  for(tmp=0; tmp<256; tmp++)
    XBYTE[0x2100+tmp] = 0x00;

  for(tmp=0; tmp<256; tmp++)
    if(XBYTE[0x2100+tmp]!=0x00)
      status = 1;

  // test SRAM disable
  XBYTE[0x20E0] = 0x00;

  // return
  PRINT_L2("            L3_TestCDSPSRAM: Exit\n");

  return(status);
}

UCHAR L2_TestCDSP(UCHAR TestLevel) USING_0
{
  UCHAR status100, status101, status102, status103, status104;
  UCHAR status110, status111, status112, status113, status114;
  UCHAR status200, status201, status202, status203, status204;
  UCHAR status210, status211, status212, status213, status214;
  UCHAR status300, status301, status302, status303, status304;
  UCHAR status310, status311, status312, status313, status314;
  UCHAR status400, status401, status402;
  UCHAR status410, status411, status412;
  UCHAR status500, status501, status502;
  UCHAR status;

  status = L2K_SUCCESS;

  //body
  PRINT_L2("        L2_TestCDSP: Enter\n");

  if((TestLevel==0) || (TestLevel==2))
  {
    //SRAM 1 ~ 2: SRAM512X40 for interpolation
    //SRAM 3    : SRAM512X40 for Y 2D edge
    //SRAM 4    : SRAM512X20 for UV average
    //SRAM 5    : SRAM256X24 for bad pixel compensation

    //test SRAM
    status100 = L3_TestCDSPSRAM(1, 0, 0, 0xFF); //SRAM1, page0, byte0
    status101 = L3_TestCDSPSRAM(1, 0, 1, 0xFF); //SRAM1, page0, byte1
    status102 = L3_TestCDSPSRAM(1, 0, 2, 0xFF); //SRAM1, page0, byte2
    status103 = L3_TestCDSPSRAM(1, 0, 3, 0xFF); //SRAM1, page0, byte3
    status104 = L3_TestCDSPSRAM(1, 0, 4, 0xFF); //SRAM1, page0, byte4

    status110 = L3_TestCDSPSRAM(1, 1, 0, 0xFF); //SRAM1, page1, byte0
    status111 = L3_TestCDSPSRAM(1, 1, 1, 0xFF); //SRAM1, page1, byte1
    status112 = L3_TestCDSPSRAM(1, 1, 2, 0xFF); //SRAM1, page1, byte2
    status113 = L3_TestCDSPSRAM(1, 1, 3, 0xFF); //SRAM1, page1, byte3
    status114 = L3_TestCDSPSRAM(1, 1, 4, 0xFF); //SRAM1, page1, byte4

    status200 = L3_TestCDSPSRAM(2, 0, 0, 0xFF); //SRAM2, page0, byte0
    status201 = L3_TestCDSPSRAM(2, 0, 1, 0xFF); //SRAM2, page0, byte1
    status202 = L3_TestCDSPSRAM(2, 0, 2, 0xFF); //SRAM2, page0, byte2
    status203 = L3_TestCDSPSRAM(2, 0, 3, 0xFF); //SRAM2, page0, byte3
    status204 = L3_TestCDSPSRAM(2, 0, 4, 0xFF); //SRAM2, page0, byte4

    status210 = L3_TestCDSPSRAM(2, 1, 0, 0xFF); //SRAM2, page1, byte0
    status211 = L3_TestCDSPSRAM(2, 1, 1, 0xFF); //SRAM2, page1, byte1
    status212 = L3_TestCDSPSRAM(2, 1, 2, 0xFF); //SRAM2, page1, byte2
    status213 = L3_TestCDSPSRAM(2, 1, 3, 0xFF); //SRAM2, page1, byte3
    status214 = L3_TestCDSPSRAM(2, 1, 4, 0xFF); //SRAM2, page1, byte4

    status300 = L3_TestCDSPSRAM(3, 0, 0, 0xFF); //SRAM3, page0, byte0
    status301 = L3_TestCDSPSRAM(3, 0, 1, 0xFF); //SRAM3, page0, byte1
    status302 = L3_TestCDSPSRAM(3, 0, 2, 0xFF); //SRAM3, page0, byte2
    status303 = L3_TestCDSPSRAM(3, 0, 3, 0xFF); //SRAM3, page0, byte3
    status304 = L3_TestCDSPSRAM(3, 0, 4, 0xFF); //SRAM3, page0, byte4

    status310 = L3_TestCDSPSRAM(3, 1, 0, 0xFF); //SRAM3, page1, byte0
    status311 = L3_TestCDSPSRAM(3, 1, 1, 0xFF); //SRAM3, page1, byte1
    status312 = L3_TestCDSPSRAM(3, 1, 2, 0xFF); //SRAM3, page1, byte2
    status313 = L3_TestCDSPSRAM(3, 1, 3, 0xFF); //SRAM3, page1, byte3
    status314 = L3_TestCDSPSRAM(3, 1, 4, 0xFF); //SRAM3, page1, byte4

    status400 = L3_TestCDSPSRAM(4, 0, 0, 0xFF); //SRAM4, page0, byte0
    status401 = L3_TestCDSPSRAM(4, 0, 1, 0xFF); //SRAM4, page0, byte1
    status402 = L3_TestCDSPSRAM(4, 0, 2, 0xFF); //SRAM4, page0, byte2
    status410 = L3_TestCDSPSRAM(4, 1, 0, 0xFF); //SRAM4, page1, byte0
    status411 = L3_TestCDSPSRAM(4, 1, 1, 0xFF); //SRAM4, page1, byte1
    status412 = L3_TestCDSPSRAM(4, 1, 2, 0xFF); //SRAM4, page1, byte2

    status500 = L3_TestCDSPSRAM(5, 0, 0, 0xFF); //SRAM5, page0, byte0
    status501 = L3_TestCDSPSRAM(5, 0, 1, 0xFF); //SRAM5, page0, byte1
    status502 = L3_TestCDSPSRAM(5, 0, 2, 0xFF); //SRAM5, page0, byte2
  }

  status = status100|status101|status102|status103|status104|
           status110|status111|status112|status113|status114|
           status200|status201|status202|status203|status204|
           status210|status211|status212|status213|status214|
           status300|status301|status302|status303|status304|
           status310|status311|status312|status313|status314|
           status400|status401|status402|status410|status411|status412|
           status500|status501|status502;

  // return
  PRINT_L2("        L2_TestCDSP: Exit\n");

  return(status);
}

#endif

//-----------------------------------------------------------------------------
//L2_SetSignalGen
//-----------------------------------------------------------------------------
/*
routine description:
  Set the signal generator that can generate RGB or YUV422 data.

arguments:
  OprMode:
        0: disable
        1: enable RGB data
        2: enable YUV422 data
  SigMode:
    Bit 4: determine the color saturation
        0: 100% saturation
        1: 75% saturation
 Bit 3 ~ Bit 0: pattern
             0: Still, White
             1: Still, Yellow
             2: Still, Cyan
             3: Still, Green
             4: Still, Magenta
             5: Still, Red
             6: Still, Blue
             7: Still, Black
             8: Still, Gray level
             9: horizontal count
             10: vertical count
             11: horizontal count-17 (0, 1, 2, ...)
             12: Still vertical color bar
             13: Still horizontal color bar
             14: Red, Green, Blue and White flashing
             15: Moving horizontal color bar

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

UCHAR L2_SetSignalGen(UCHAR OprMode, UCHAR SigMode) USING_0
{
  UCHAR status;

  status = L2K_SUCCESS;

  //body
  PRINT_L2("        L2_SetSignalGen: Enter\n");

  if(OprMode==2)
    XBYTE[0x27E1] = 0x03;
  else
    XBYTE[0x27E1] = OprMode;

  XBYTE[0x27E3] = SigMode;

  // return
  PRINT_L2("        L2_SetSignalGen: Exit\n");

  return(status);
}

//-----------------------------------------------------------------------------
//L2_SetMenuBar
//-----------------------------------------------------------------------------
/*
routine description:
    Define a rectangle area to that the graphic OSD is put. The input data of
  YUV data will be skipped when update the new pixel value.

arguments:
  Mode: the menu bar function
     0: disable
     1: enable
  MenuHoff: The horizontal offset of the menu bar on the buffer to display image
  MenuVoff: The vertical offset of the menu bar on the buffer to display image
  MenuHsize: The horizontal size of the menu bar on the buffer to display image
  MenuVsize: The vertical size of the menu bar on the buffer to display image

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

UCHAR L2_SetMenuBar(UCHAR Mode, USHORT MenuHoff, USHORT MenuVoff,
                    USHORT MenuHsize, USHORT MenuVsize) USING_0
{
  UCHAR status;

  status = L2K_SUCCESS;

  //body
  PRINT_L2("        L2_SetMenuBar: Enter\n");

  //offset
  XBYTE[0x27E8] = M_LoByteOfWord(MenuHoff);
  XBYTE[0x27E9] = M_HiByteOfWord(MenuHoff);

  XBYTE[0x27EA] = M_LoByteOfWord(MenuVoff);
  XBYTE[0x27EB] = M_HiByteOfWord(MenuVoff);

  //size
  XBYTE[0x27EC] = M_LoByteOfWord(MenuHsize);
  XBYTE[0x27ED] = M_HiByteOfWord(MenuHsize);

  XBYTE[0x27EE] = M_LoByteOfWord(MenuVsize);
  XBYTE[0x27EF] = M_HiByteOfWord(MenuVsize);

  //mode
  XBYTE[0x27E7] = Mode;

  // return
  PRINT_L2("        L2_SetMenuBar: Exit\n");

  return(status);
}

//-----------------------------------------------------------------------------
//L2_SetYlut
//-----------------------------------------------------------------------------
/*
routine description:
    Define a 16 piecewise linear segaments to build the luminance gamma
correction curve.

arguments:
  Ylut0: Point 0 of Y lookup table for gamma correction (unit:4)
  Ylut1: Point 1 of Y lookup table for gamma correction (unit:4)
  Ylut2: Point 2 of Y lookup table for gamma correction (unit:4)
  Ylut3: Point 3 of Y lookup table for gamma correction (unit:4)
  Ylut4: Point 4 of Y lookup table for gamma correction (unit:4)
  Ylut5: Point 5 of Y lookup table for gamma correction (unit:4)
  Ylut6: Point 6 of Y lookup table for gamma correction (unit:4)
  Ylut7: Point 7 of Y lookup table for gamma correction (unit:4)
  Ylut8: Point 8 of Y lookup table for gamma correction (unit:4)
  Ylut9: Point 9 of Y lookup table for gamma correction (unit:4)
  Ylut10: Point 10 of Y lookup table for gamma correction (unit:4)
  Ylut11: Point 11 of Y lookup table for gamma correction (unit:4)
  Ylut12: Point 12 of Y lookup table for gamma correction (unit:4)
  Ylut13: Point 13 of Y lookup table for gamma correction (unit:4)
  Ylut14: Point 14 of Y lookup table for gamma correction (unit:4)
  Ylut15: Point 15 of Y lookup table for gamma correction (unit:4)
  Ylut16: Point 16 of Y lookup table for gamma correction (unit:4)

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

UCHAR L2_SetYlut(UCHAR Ylut0, UCHAR Ylut1, UCHAR Ylut2, UCHAR Ylut3,
                 UCHAR Ylut4, UCHAR Ylut5, UCHAR Ylut6, UCHAR Ylut7,
                 UCHAR Ylut8, UCHAR Ylut9, UCHAR Ylut10, UCHAR Ylut11,
                 UCHAR Ylut12, UCHAR Ylut13, UCHAR Ylut14, UCHAR Ylut15,
                 UCHAR Ylut16) USING_0
{
  UCHAR status;

  status = L2K_SUCCESS;

  //body
  PRINT_L2("        L2_SetYlut: Enter\n");

  //Y lookup table
  XBYTE[0x2160] = Ylut0;
  XBYTE[0x2161] = Ylut1;
  XBYTE[0x2162] = Ylut2;
  XBYTE[0x2163] = Ylut3;
  XBYTE[0x2164] = Ylut4;
  XBYTE[0x2165] = Ylut5;
  XBYTE[0x2166] = Ylut6;
  XBYTE[0x2167] = Ylut7;
  XBYTE[0x2168] = Ylut8;
  XBYTE[0x2169] = Ylut9;
  XBYTE[0x216a] = Ylut10;
  XBYTE[0x216b] = Ylut11;
  XBYTE[0x216c] = Ylut12;
  XBYTE[0x216d] = Ylut13;
  XBYTE[0x216e] = Ylut14;
  XBYTE[0x216f] = Ylut15;
  XBYTE[0x2170] = Ylut16;

  // return
  PRINT_L2("        L2_SetYlut: Exit\n");

  return(status);
}

//-----------------------------------------------------------------------------
//L2_SetHorFilter
//-----------------------------------------------------------------------------
/*
routine description:
    Define a 5x5 horizontal edge filter.

arguments:
  Fac[0]:  The factor 00 of horizontal edge filter
  Fac[1]:  The factor 01 of horizontal edge filter
  Fac[2]:  The factor 02 of horizontal edge filter
  Fac[3]:  The factor 03 of horizontal edge filter
  Fac[4]:  The factor 04 of horizontal edge filter
  Fac[5]:  The factor 10 of horizontal edge filter
  Fac[6]:  The factor 11 of horizontal edge filter
  Fac[7]:  The factor 12 of horizontal edge filter
  Fac[8]:  The factor 13 of horizontal edge filter
  Fac[9]:  The factor 14 of horizontal edge filter
  Fac[10]: The factor 20 of horizontal edge filter
  Fac[11]: The factor 21 of horizontal edge filter
  Fac[12]: The factor 22 of horizontal edge filter
  Fac[13]: The factor 23 of horizontal edge filter
  Fac[14]: The factor 24 of horizontal edge filter
  Fac[15]: The factor 30 of horizontal edge filter
  Fac[16]: The factor 31 of horizontal edge filter
  Fac[17]: The factor 32 of horizontal edge filter
  Fac[18]: The factor 33 of horizontal edge filter
  Fac[19]: The factor 34 of horizontal edge filter
  Fac[20]: The factor 40 of horizontal edge filter
  Fac[21]: The factor 41 of horizontal edge filter
  Fac[22]: The factor 42 of horizontal edge filter
  Fac[23]: The factor 43 of horizontal edge filter
  Fac[24]: The factor 44 of horizontal edge filter
  Fdiv:    The division factor of horizontal edge filter

  The selection of filter factor 02, 12, 22, 32 and 42 is
  {16, 8, 4, 3, 2, 1, 0, -1, -2, -3, -4, -8, -16}. The others
  of filter factor is {4, 3, 2, 1, 0, -1, -2, -3, -4}. The
  selection of division factor is {1, 2, 4, 8, 16, 32, 64, 128}.

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

UCHAR L2_SetHorFilt(PCHAR Fac, UCHAR Fdiv) USING_0
{
  UCHAR i,j,n;
  CHAR stmp0;
  UCHAR tmp0,tmp1,tmp[2];

  //body
  PRINT_L2("        L2_SetHorFilt: Enter\n");

  //check parameter
  for(i=0;i<5;i++)
    for(j=0;j<5;j++)
    {
      n = i*5+j;
      stmp0 = Fac[n];

      if(!((stmp0>=-4) && (stmp0<=4)) &&
         !((j==2) && ((stmp0==-8)  ||
                      (stmp0==-16) ||
                      (stmp0==8)   ||
                      (stmp0==16)))) return(L2K_ERROR_PARAMETER);
    }

  if(Fdiv==1)        tmp1 = 0;
  else if(Fdiv==2)   tmp1 = 1;
  else if(Fdiv==4)   tmp1 = 2;
  else if(Fdiv==8)   tmp1 = 3;
  else if(Fdiv==16)  tmp1 = 4;
  else if(Fdiv==32)  tmp1 = 5;
  else if(Fdiv==64)  tmp1 = 6;
  else if(Fdiv==128) tmp1 = 7;
  else return(L2K_ERROR_PARAMETER);

  //set register
  if(Fac[24]<0) tmp0 = -Fac[24]+8;
  else          tmp0 = Fac[24];

  XBYTE[0x218c] = tmp1<<4|tmp0;

  for(i=0;i<12;i++)
  {
    for(j=0;j<2;j++)
    {
      n = (i<<1)+j;
      stmp0 = Fac[n];

      if(stmp0==-8)       tmp[j] = 0x0d;
      else if(stmp0==-16) tmp[j] = 0x0e;
      else if(stmp0==8)   tmp[j] = 0x05;
      else if(stmp0==16)  tmp[j] = 0x06;
      else if(stmp0<0)    tmp[j] = -stmp0+8;
      else                tmp[j] = stmp0;
    }

    XBYTE[0x2180+i] = tmp[1]<<4|tmp[0];
  }

  // return
  PRINT_L2("        L2_SetHorFilt: Exit\n");

  return(L2K_SUCCESS);
}

//-----------------------------------------------------------------------------
//L2_SetVerFilter
//-----------------------------------------------------------------------------
/*
routine description:
    Define a 5x5 vertical edge filter.

arguments:
  Fac[0]:  The factor 00 of vertical edge filter
  Fac[1]:  The factor 01 of vertical edge filter
  Fac[2]:  The factor 02 of vertical edge filter
  Fac[3]:  The factor 03 of vertical edge filter
  Fac[4]:  The factor 04 of vertical edge filter
  Fac[5]:  The factor 10 of vertical edge filter
  Fac[6]:  The factor 11 of vertical edge filter
  Fac[7]:  The factor 12 of vertical edge filter
  Fac[8]:  The factor 13 of vertical edge filter
  Fac[9]:  The factor 14 of vertical edge filter
  Fac[10]: The factor 20 of vertical edge filter
  Fac[11]: The factor 21 of vertical edge filter
  Fac[12]: The factor 22 of vertical edge filter
  Fac[13]: The factor 23 of vertical edge filter
  Fac[14]: The factor 24 of vertical edge filter
  Fac[15]: The factor 30 of vertical edge filter
  Fac[16]: The factor 31 of vertical edge filter
  Fac[17]: The factor 32 of vertical edge filter
  Fac[18]: The factor 33 of vertical edge filter
  Fac[19]: The factor 34 of vertical edge filter
  Fac[20]: The factor 40 of vertical edge filter
  Fac[21]: The factor 41 of vertical edge filter
  Fac[22]: The factor 42 of vertical edge filter
  Fac[23]: The factor 43 of vertical edge filter
  Fac[24]: The factor 44 of vertical edge filter
  Fdiv:    The division factor of vertical edge filter

  The selection of filter factor 20, 21, 22, 23 and 24 is
  {16, 8, 4, 3, 2, 

⌨️ 快捷键说明

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