- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
Jpg.c
资源名称:SDK_M5661.rar [点击查看]
上传用户:hjhsjcl
上传日期:2020-09-25
资源大小:11378k
文件大小:30k
源码类别:
压缩解压
开发平台:
C++ Builder
- /*==========================================================================
- Copyright (c) 2004 ALi Corporation. All Rights Reserved
- File: Jpg.c
- content:
- History: Created by Walace 2005/01/12
- ==========================================================================*/
- #define _JPG_H_
- #include <DP8051XP.H>
- #include "TypeDef.h"
- #include "Const.h"
- #include "Reg5661.h"
- #include "Common.h"
- #include "OledString.h"
- #include "Key.h"
- #include "Idma.h"
- #include "FileSystem.h"
- #include "IconDefine.h"
- #include "OLED.h"
- #include "UiCommon.h"
- #if(PHOTO_BMP_DSP_DECODE)
- #include "Bmp.h"
- #endif
- #if(PHOTO_SUPPORT_JPG)
- #include "Jpg.h"
- #include "UiPhoView.h"
- #include "VideoDsp.h" //Walace060309#3
- //3 ================================
- #define DSP_BLOCK_SIZE 256
- //3==== JPGGetImageFromDsp =========
- #define IMG_PRC_ERR 0x00
- #define IMG_PRC_NOP 0x00
- #define IMG_PRC_SUCCESS 0x01
- #define IMG_PRC_COMPLETE 0x02
- //3 == Dsp command ===============
- #define DSP_REQ_START 0x01
- #define DSP_REQ_END 0x02
- //3 ==== gxbJpgProcState ============
- #define JPG_PRC_IDLE 0x00
- #define JPG_PRC_INITIAL 0x01
- #define JPG_PRC_DATA_TO_DSP 0x02
- #define JPG_PRC_GET_FROM_DSP 0x03
- #define JPG_PRC_SHOW 0x04
- #define JPG_PRC_ERR 0x05
- #define JPG_PRC_END 0x06
- #define DSP_JPG_COLOR_CODE_RGB 0
- #define DSP_JPG_COLOR_CODE_BGR 1
- #define DSP_JPG_START_FLAG 0x0000
- //Walace051214#FullScreen
- #define DSP_JPG_NO_SHRINK_FLAG 0x1FF0 // 0:Dsp shrink 1:Dsp no shrink
- #define DSP_JPG_PHOTO_WIDTH 0x1FF1 //The real pixel number of one row
- #define DSP_JPG_PHOTO_HEIGHT 0x1FF2 //The real pixel number of one column
- #define DSP_JPG_WIDTH_SIZE 0x1FF3 // set lcd width size
- #define DSP_JPG_HEIGHT_SIZE 0x1FF4 // set lcd height size
- #define DSP_JPG_LCD_TYPE 0x1FF5 // 0:STN 1:OLED
- #define DSP_JPG_ERR_MSG 0x1FF6 // 0:No error 1:format not support
- #define JPEG_DSP_NO_ERR 0x00 //Walace060816#4
- #define JPEG_FORMAT_NOT_SUPPORT 0x01 //Walace060816#4
- #define DSP_JPG_INPUT_ADDR 0x1FF7 // Dsp inbuffer address
- #define DSP_JPG_INPUT_FLAG 0x1FF8 // 1:FW write 512 bytes to DSP 2: FW write complete
- #define DSP_JPG_OUTPUT_ADDR 0x1FF9 // Dsp outbuffer address
- #define DSP_JPG_OUTPUT_FLAG 0x1FFA // 1:FW could get 512 bytes form dsp 2: get data complete
- #define DSP_JPG_DEC_FINISH 0x1FFB // 0: image decode not finish 1:image decode finish
- #define DSP_JPG_BLOCK_WIDTH 0x1FFC // MCU width
- #define DSP_JPG_BLOCK_HEIGHT 0x1FFD // MCU Height
- #define DSP_JPG_BLOCK_COLS 0x1FFE // Image total coloumns
- #define DSP_JPG_BLOCK_PAGES 0x1FFF // Image total pages
- XBYTE gxbJpgProcState = JPG_PRC_IDLE;
- //Walace061018#2 bmp dsp decode start
- BOOL JpgShow(void);
- #if(PHOTO_BMP_DSP_DECODE)
- BOOL BmpShow(void);
- #endif
- #if(DSP_BMP_DEBUG)
- void BmpDspDebug(void);
- #endif
- //Walace061018#2 bmp dsp decode end
- //Walace051214#FullScreen move to UiPhotoView.h
- /*
- BOOL gfGetPhoConfig;
- //3 == Photo process parameters =================
- //XDWORD gxdwBlockTotalNum; //Walace051202#2
- XWORD gxwMcuSize;
- XWORD gxwBlockHeight;
- XWORD gxwBlockWidth;
- XWORD gxwBlockColNum;
- XWORD gxwBlockPageNum;
- XDWORD gxdwCurrentBlockNum; //Walace051202#2 word->dword
- */
- //3==============================================================
- void JpgSetMonitorSizeTypeToDsp(BYTE bWidth,BYTE bHeight,BYTE bLcdType)
- {
- WORD wDspVal;
- wDspVal = (WORD)bWidth;
- IdmaPioDmxW(&wDspVal, DSP_JPG_WIDTH_SIZE, 1, DSP_W16); //Set finish data transfer
- wDspVal = (WORD)bHeight;
- IdmaPioDmxW(&wDspVal, DSP_JPG_HEIGHT_SIZE, 1, DSP_W16); //Set finish data transfer
- wDspVal = (WORD)bLcdType;
- IdmaPioDmxW(&wDspVal, DSP_JPG_LCD_TYPE, 1, DSP_W16); //Walace051115#1
- wDspVal = (WORD)FALSE; // shrink //Walace051212#FullScreen
- //wDspVal = (WORD)TRUE; // no shrink //Walace051212#FullScreen
- IdmaPioDmxW(&wDspVal, DSP_JPG_NO_SHRINK_FLAG,1,DSP_W16);
- }
- BYTE CheckImageIn(void) large
- {
- WORD wDspVal;
- IdmaPioDmxR(DSP_JPG_INPUT_FLAG, &wDspVal, 1,DSP_W16);
- return (BYTE)wDspVal;
- }
- //==============================================================
- BYTE CheckImageOut(void) large
- {
- WORD wDspVal;
- IdmaPioDmxR(DSP_JPG_OUTPUT_FLAG, &wDspVal, 1,DSP_W16);
- return (BYTE)wDspVal;
- }
- //==============================================================
- BOOL JpgFillDataToDsp(void)
- {
- WORD wDspVal;
- //2 fill sram buffer from file with 512 bytes
- // gdwFileSectory : current sector number send to dsp
- if(gdwFileSector<(stPhoFileInf.dwFileTotalSector))
- {
- if(CheckImageIn()!=DSP_REQ_START) //check dsp request data
- return TRUE;
- if(FsReadFileSectorNew(gdwFileSector++,FS_DATA_0_0)) //read a sector
- {
- IdmaPioDmxR(DSP_JPG_INPUT_ADDR,&wDspVal,1,DSP_W16); //get DSP write index
- //Send 512 bytes to DSP
- obRACTL |= RA_INIT;
- obSOURCEPATHCTRL &= 0xef; //source buffer disable
- obTARGETPATHCTRL &= 0xef; //target buffer disable
- obRACTL &= RA_NORMAL_J;
- obRACTL |= RA_COPY_MODE_EN;
- obRAINIADRL = (SRAM_DATA_ADDR+gxwOffsetDataSec) & 0xFF; //set RA sddress
- obRAINIADRH = (((SRAM_DATA_ADDR+gxwOffsetDataSec) >> 8) & 0x1F);
- obRAINIADRH |= 0x80;
- obTARGETPATHCTRL=0x36; //set Target IDMA, buffer EN
- IdmaDmxW(wDspVal,256,DSP_W16); //IDMA from SRAM to DSP
- obRACTL |= 0x80; //DMA EN
- while(obIDMAREQ) //polling IDMA request inactive
- {;}
- obRACTL &= 0x7F; //DMA Dis
- obRACTL &= RA_COPY_MODE_DIS;
- wDspVal=DSP_REQ_END;
- IdmaPioDmxW(&wDspVal, DSP_JPG_INPUT_FLAG, 1, DSP_W16); //Set finish data transfer
- return TRUE;
- }
- else
- {
- // Warring! this retun value must be return with FALSE,but now return TRUE for the bug of DSP
- // return TRUE; //Walace060816#4
- return FALSE;
- }
- }
- return TRUE;
- }
- //==============================================================
- BOOL JpgGetConfig(void) //Walace051202#4
- {
- //WORD wDspVal; //Walace051202#4
- IdmaPioDmxR(DSP_JPG_BLOCK_PAGES, &gxwBlockPageNum, 1,DSP_W16);
- IdmaPioDmxR(DSP_JPG_BLOCK_COLS, &gxwBlockColNum, 1,DSP_W16);
- IdmaPioDmxR(DSP_JPG_BLOCK_WIDTH, &gxwBlockWidth, 1,DSP_W16);
- IdmaPioDmxR(DSP_JPG_BLOCK_HEIGHT, &gxwBlockHeight, 1,DSP_W16);
- IdmaPioDmxR(DSP_JPG_PHOTO_WIDTH, &gxwPhoWidth, 1,DSP_W16);
- IdmaPioDmxR(DSP_JPG_PHOTO_HEIGHT, &gxwPhoHeight, 1,DSP_W16);
- /* //Walace051202#4
- IdmaPioDmxR(DSP_JPG_ERR_MSG,&wDspVal,1,DSP_W16);
- if(wDspVal!=JPEG_DSP_NO_ERR)
- {
- gxbErrCode = ERR_PE_UNSUPPORT_FORMAT;
- return FALSE;
- }
- */
- // gxdwBlockTotalNum =gxwBlockPageNum*gxwBlockColNum; //Walace051202#2
- gxwMcuSize = gxwBlockWidth * gxwBlockHeight;
- // OledShowNumber(gxwPhoWidth,WORD0,LINE0,6);
- // OledShowNumber(gxwPhoHeight,WORD0,LINE1,6);
- GetPhoCommonConfig();
- /*
- OledShowNumber(gxwPhoWidth,WORD0,PAGE0,6);
- OledShowNumber(gxwPhoHeight,WORD0,PAGE1,6);
- OledShowNumber(gxwBlockColNum,WORD0,PAGE2,6);
- OledShowNumber(gxwBlockPageNum,WORD0,PAGE3,6);
- OledShowNumber(gxwBlockWidth,WORD0,PAGE4,6);
- OledShowNumber(gxwBlockHeight,WORD0,PAGE5,6);
- OledShowNumber(gxwPhotoDispWidth,WORD0,PAGE6,6);
- OledShowNumber(gxwPhotoDispHeight,WORD0,PAGE7,6);
- OledShowNumber(gxwSampleSize,WORD3,PAGE0,6);
- OledShowNumber(gxbfRotPhoto,WORD3,PAGE1,6);
- */
- /*
- OledShowNumber(gxwBlockColNum,WORD3,PAGE2,6);
- OledShowNumber(gxwBlockPageNum,WORD3,PAGE3,6);
- OledShowNumber(gxwBlockWidth,WORD3,PAGE4,6);
- OledShowNumber(gxwBlockHeight,WORD3,PAGE5,6);
- OledShowNumber(gxwPhotoDispWidth,WORD3,PAGE6,6);
- OledShowNumber(gxwPhotoDispHeight,WORD3,PAGE7,6);
- gxbLcdCounter=0;
- while(1)
- {}
- */
- return TRUE; //Walace051202#4
- }
- //Walace061018#2 bmp dsp decode
- #if(PHOTO_BMP_DSP_DECODE)
- BOOL BmpGetConfig(void)
- {
- IdmaPioDmxR(DSP_JPG_PHOTO_WIDTH, &gxwPhoWidth, 1,DSP_W16);
- IdmaPioDmxR(DSP_JPG_PHOTO_HEIGHT, &gxwPhoHeight, 1,DSP_W16);
- gxbfRotPhoto=FALSE; //Walace070108#2
- #if(UI_PHOTO_DISP_SIZE_COL>UI_PHOTO_DISP_SIZE_ROW)
- gxbfRotPhoto = (gxwPhoWidth<gxwPhoHeight) //Walace070108#2
- && ((gxwPhoWidth>UI_PHOTO_DISP_SIZE_COL)||(gxwPhoHeight>UI_PHOTO_DISP_SIZE_ROW));
- #else
- gxbfRotPhoto = (gxwPhoWidth>gxwPhoHeight) //Walace070108#2
- && ((gxwPhoWidth>UI_PHOTO_DISP_SIZE_COL)||(gxwPhoHeight>UI_PHOTO_DISP_SIZE_ROW));
- #endif
- gxwXPixel = 0;
- gxwYPixel = gxwPhoHeight-1;
- return TRUE;
- }
- #endif
- //--------------------------------------------------------------------------------
- //Walace060816#4
- #define GET_JPEG_DATA_NONE 0x00
- #define GET_JPEG_DATA_DONE 0x01
- #define GET_JPEG_CONFIG_ERR 0x02
- BYTE JpgGetImageFromDsp() //Walace060816#4
- {
- //2 Get image data from dsp 512 bytes to Sram
- WORD wDspVal;
- WORD SramAddr=SRAM_PHOTO_DATA_START;
- if(CheckImageOut()==DSP_REQ_START) //DSP request send out a sector
- {
- GPIOA_ON(5);
- if (!gfGetPhoConfig) // browse image at firt times need to get required parameter
- {
- //Walace061018#2 bmp dsp decode start
- #if(PHOTO_BMP_DSP_DECODE)
- switch(gxbPhotoType)
- {
- case PHO_TYPE_JPG:
- if(!JpgGetConfig()) //Walace060816#4
- return GET_JPEG_CONFIG_ERR;
- break;
- case PHO_TYPE_BMP:
- if(!BmpGetConfig())
- return GET_JPEG_CONFIG_ERR;
- break;
- }
- #else
- if(!JpgGetConfig()) //Walace060816#4
- return GET_JPEG_CONFIG_ERR;
- #endif
- //Walace061018#2 bmp dsp decode end
- gfGetPhoConfig=TRUE;
- }
- // get image output address
- IdmaPioDmxR(DSP_JPG_OUTPUT_ADDR,&wDspVal,1,DSP_W16);
- //Get 512 bytes from DSP
- obRACTL = RA_INIT;
- //obSOURCEPATHCTRL &= 0xef; //source buffer disable
- //obTARGETPATHCTRL &= 0xef; //target buffer disable
- obRACTL &= RA_NORMAL_J;
- obRAINIADRL = SRAM_DMA_ADDRESS & 0xFF; //set RA address
- obRAINIADRH = ((SRAM_DMA_ADDRESS >> 8) & 0x1F);
- obRAINIADRH |= 0x80;
- obRABANKSIZEL=0x00; //Set RA size 512B
- obRABANKSIZEH=0x02;
- obMODSEL3 &= NOTBYPASS_RAJ; //allen050601: force NotBypassRa
- obSOURCEPATHCTRL=0x36; //set Source IDMA, buffer EN
- obTARGETPATHCTRL=0x37; //Target SRAM
- obDOWNLOADADDRL=(SramAddr>>3)&0xFF; //SRAM Address
- obDOWNLOADADDRH=(SramAddr>>11)&0x3f;
- obDOWNLOADADDRH |= 0xc0;//to sram, reload address
- obDOWNLOADADDRH&=0xBF; //normal
- // obTARGETPATHCTRL=0x37; //set Target RA, buffer EN
- IdmaDmxR(wDspVal,256); //IDMA from DSP to SRAM
- obRACTL |= 0x80; //DMA EN
- while(obIDMAREQ) //polling IDMA request inactive
- {;}
- obRACTL |= 0x10; //DMA SEND
- while(!(obRASTATUS & 0x80))
- {;}
- obRACTL &= 0x7F; //DMA Dis
- obIDMACTRL&=IDMA_ACT_DIS;
- wDspVal=DSP_REQ_END;
- IdmaPioDmxW(&wDspVal, DSP_JPG_OUTPUT_FLAG, 1,DSP_W16); //Set finish data transfer
- GPIOA_OFF(5);
- return GET_JPEG_DATA_DONE; //Walace060816#4 start
- }
- return GET_JPEG_DATA_NONE; //Walace060816#4 start
- }
- //==============================================================
- //Walace061018#2 bmp dsp decode
- BOOL JpgBmpShow(void)
- {
- switch(gxbPhotoType)
- {
- case PHO_TYPE_JPG:
- return JpgShow();
- #if(PHOTO_BMP_DSP_DECODE)
- case PHO_TYPE_BMP:
- return BmpShow();
- #endif
- }
- }
- //Walace051212#FullScreen
- BOOL JpgShow(void)
- {
- //2 2 Send Sram data to OLED
- WORD McuNum;
- WORD wBi,wXi,wYi;
- WORD wCol,wRow;
- PWORD pwData;
- pwData=(PWORD)gxbPhoData;
- McuNum=DSP_BLOCK_SIZE/gxwMcuSize;
- OledCtrlEn();
- #if(LCD_TYPE==TFT_ORISE||LCD_TYPE==TFT_TOPPOLY||LCD_TYPE==TFT_SOLOMON) // Jeff070125#2
- LCD_ROT90_DISPLAY_EN();
- #endif
- for(wBi=0;wBi<McuNum;wBi++)
- {
- if((gxdwCurrentBlockNum%gxwBlockColNum)==0)
- {
- gxwXStart=0;
- gxwXStep=0;
- gxwYStart=gxwYPixel;
- gxwYStepStart = gxwYStep;
- }
- else
- {
- gxwYStep = gxwYStepStart;
- }
- gxwXStepStart=gxwXStep;
- gxwYPixel = gxwYStart;
- for(wYi=0;wYi<gxwBlockHeight;wYi++)
- {
- gxwYStep+=gxwSampleSize;
- if(!(gxwYStep&0x8000))
- {
- pwData+=gxwBlockWidth;
- continue;
- }
- gxwYPixel++;
- gxwYStep&=(~0x8000);
- gxwXPixel = gxwXStart;
- gxwXStep=gxwXStepStart;
- for(wXi=0;wXi<gxwBlockWidth;wXi++)
- {
- gxwXStep+=gxwSampleSize;
- if(!(gxwXStep&0x8000))
- {
- pwData++;
- continue;
- }
- gxwXPixel++;
- gxwXStep&=(~0x8000);
- //if((gxwXPixel<=gxwPhoWidth)&&(gxwYPixel<=gxwPhoHeight)) //Walace060320#1 //Walace060713#1
- if((gxwXPixel<=gxwPhotoDispWidth)&&(gxwYPixel<=gxwPhotoDispHeight))
- {
- //Walace060713#1 start
- //wCol=gxwXPixel;
- //wRow=gxwYPixel;
- wCol=gxwXPixel-1;
- wRow=gxwYPixel-1;
- //Walace060713#1 end
- if(gxbfRotPhoto) //Walace070108#2
- RotToCenter(gxwPhotoDispWidth,gxwPhotoDispHeight,&wCol,&wRow);
- else //if(gxwSampleSize<0x8000) //Walace060725#2
- MoveToCenter(gxwPhotoDispWidth,gxwPhotoDispHeight,&wCol,&wRow);
- //if((wCol<OLED_MAX_COL)&&(wRow<OLED_MAX_ROW)) //Walace060320#3 //Walace060713#1
- if((wCol<UI_PHOTO_DISP_SIZE_COL)&&(wRow<UI_PHOTO_DISP_SIZE_ROW)) //Walace070103#2
- {
- #if(LCD_TYPE==TFT_ORISE||LCD_TYPE==TFT_TOPPOLY) // Jeff070125#2
- TftSetWindow(wCol,wRow,1,1);
- TFT_MEMORY_WRITE_START();
- OLED_WRITE(*((PBYTE)(pwData)+1)) ;
- OLED_WRITE(*((PBYTE)pwData)) ;
- #elif(LCD_TYPE==TFT_SOLOMON) //Jim#TftSolomn
- TftSetWindow(wRow,UI_PHOTO_DISP_SIZE_COL-wCol-1,1,1);
- TFT_MEMORY_WRITE_START();
- LCD_WRITE(*((PBYTE)(pwData)+1)) ;
- LCD_WRITE(*((PBYTE)pwData)) ;
- #else
- OLED_WRITE(OLED_CMD_SET_COL_ADDR) ;
- OLED_WRITE(wCol);
- OLED_WRITE(wCol);
- OLED_WRITE(OLED_CMD_SET_ROW_ADDR) ;
- OLED_WRITE(wRow);
- OLED_WRITE(wRow);
- OLED_SET_DAT();
- #if(OLED_COLOR_FIELD_TYPE==OLED_FIELD_BGR565)
- OLED_WRITE(*((PBYTE)pwData)) ;
- OLED_WRITE(*((PBYTE)(pwData)+1)) ;
- #else
- OLED_WRITE(*((PBYTE)(pwData)+1)) ;
- OLED_WRITE(*((PBYTE)pwData)) ;
- #endif
- OLED_SET_CMD();
- #endif
- }
- }
- pwData++;
- }
- }
- // CommonDelay(0xFFFF);
- // CommonDelay(0xFFFF);
- gxwXStart = gxwXPixel;
- gxwXStepStart = gxwXStep;
- gxdwCurrentBlockNum++;
- ////Walace051202#2
- //if(gxwCurrentBlockNum>=gxwBlockTotalNum))
- if(gxdwCurrentBlockNum>=((DWORD)gxwBlockPageNum*gxwBlockColNum))
- {
- #if(LCD_TYPE==TFT_ORISE||LCD_TYPE==TFT_TOPPOLY||LCD_TYPE==TFT_SOLOMON) //Walace061020#1 // Jeff070125#2
- LCD_ROT90_DISPLAY_DIS();
- #endif
- OledCtrlDis();
- return TRUE;
- }
- }
- #if(LCD_TYPE==TFT_ORISE||LCD_TYPE==TFT_TOPPOLY||LCD_TYPE==TFT_SOLOMON) //Walace061020#1 // Jeff070125#2
- LCD_ROT90_DISPLAY_DIS();
- #endif
- OledCtrlDis();
- return FALSE;
- }
- //Walace061018#2 bmp dsp decode start
- #if(PHOTO_BMP_DSP_DECODE)
- BOOL BmpShow(void)
- {
- WORD wBi;
- WORD wCol,wRow;
- PWORD pwData;
- pwData=(PWORD)gxbPhoData;
- OledCtrlEn();
- #if(LCD_TYPE==TFT_ORISE||LCD_TYPE==TFT_TOPPOLY||LCD_TYPE==TFT_SOLOMON) // Jeff070125#2
- LCD_ROT90_DISPLAY_EN();
- #endif
- //GPIOA_ON(6); //Walace070117#6 remove
- for(wBi=0;wBi<DSP_BLOCK_SIZE;wBi++)
- {
- wCol=gxwXPixel;
- wRow=gxwYPixel;
- if(gxbfRotPhoto) //Walace070108#2
- RotToCenter(gxwPhoWidth,gxwPhoHeight,&wCol,&wRow);
- else
- MoveToCenter(gxwPhoWidth,gxwPhoHeight,&wCol,&wRow);
- //if((wCol<OLED_MAX_COL)&&(wRow<OLED_MAX_ROW)) //Walace060320#3 //Walace060713#1
- if((wCol<UI_PHOTO_DISP_SIZE_COL)&&(wRow<UI_PHOTO_DISP_SIZE_ROW)) //Walace070103#2
- {
- #if(LCD_TYPE==TFT_ORISE||LCD_TYPE==TFT_TOPPOLY||LCD_TYPE==TFT_SOLOMON) // Jeff070125#2
- TftSetWindow(wCol,wRow,1,1);
- TFT_MEMORY_WRITE_START();
- OLED_WRITE(*((PBYTE)(pwData)+1)) ;
- OLED_WRITE(*((PBYTE)pwData)) ;
- #else
- OLED_WRITE(OLED_CMD_SET_COL_ADDR) ;
- OLED_WRITE(wCol);
- OLED_WRITE(wCol);
- OLED_WRITE(OLED_CMD_SET_ROW_ADDR) ;
- OLED_WRITE(wRow);
- OLED_WRITE(wRow);
- OLED_SET_DAT();
- #if(OLED_COLOR_FIELD_TYPE==OLED_FIELD_BGR565)
- OLED_WRITE(*((PBYTE)pwData)) ;
- OLED_WRITE(*((PBYTE)(pwData)+1)) ;
- #else
- OLED_WRITE(*((PBYTE)(pwData)+1)) ;
- OLED_WRITE(*((PBYTE)pwData)) ;
- #endif
- OLED_SET_CMD();
- #endif
- }
- pwData++;
- gxwXPixel++;
- if(gxwXPixel>=gxwPhoWidth)
- {
- if(gxwYPixel==0)
- {
- #if(LCD_TYPE==TFT_ORISE||LCD_TYPE==TFT_TOPPOLY||LCD_TYPE==TFT_SOLOMON) // Jeff070125#2
- LCD_ROT90_DISPLAY_DIS();
- #endif
- GPIOA_OFF(6);
- OledCtrlDis();
- return TRUE;
- }
- gxwXPixel=0;
- gxwYPixel--;
- }
- }
- #if(LCD_TYPE==TFT_ORISE||LCD_TYPE==TFT_TOPPOLY||LCD_TYPE==TFT_SOLOMON) // Jeff070125#2
- LCD_ROT90_DISPLAY_DIS();
- #endif
- //GPIOA_OFF(6); //Walace070117#6 remove
- OledCtrlDis();
- return FALSE;
- }
- #endif
- //Walace061018#2 bmp dsp decode end
- //==============================================================
- /* //Walace060309#3
- void SetDspStart(void)
- {
- BYTE cbDspSt[3]={0x18,0x03,0x0f};
- IdmaPioPmW(cbDspSt, 0, 1);
- }
- */
- //==============================================================
- //Walace060309#3
- void JpegDspInit(void)
- {
- IDMA_READY_EN();
- DSP_CLK_SET_49(); //Walace060804#2
- DSP_RESET();
- DSP_ENABLE();
- }
- //Walace060309#3
- BOOL DownloadJpegDsp(void)
- {
- //WORD wDspPmIdx,wDspDmxIdx,wDspDmy1Idx;
- WORD wDmyStrAddr;
- WORD wProgAddr;
- BYTE bProgLen;
- DSP_RESET(); //Walace060309#3
- DSP_ENABLE();
- DSP_PM_SIZE(DSP_PM_16BIT|DSP_PM_SIZE_6K); //set pm size 6k 24bit mode
- DSP_DMX_SIZE(DSP_DMX_24B_8K|DSP_DMX_16B_5K);
- DSP_DMY_SIZE(DSP_DMY_24B_4K|DSP_DMY_16B_6K);
- wDmyStrAddr=0x2000;
- //SET_DSP_16_MODE();
- /* //Walace060309#3
- switch(bPhotoType)
- {
- case PHO_TYPE_JPG:
- wDspPmIdx=PM_DSP_JPG_PM;
- wDspDmxIdx=PM_DSP_JPG_DMX;
- wDspDmy1Idx=PM_DSP_JPG_DMY;
- break;
- default:
- return FALSE;
- break;
- }
- */
- if(NandReadPhySec(gxwAddrPMI,1,SRAM_DATA_ADDR)) //Download PM
- {
- wProgAddr=(((WORD)gxbFsData[PM_DSP_JPG_PM+1])<<8)|gxbFsData[PM_DSP_JPG_PM];
- bProgLen=gxbFsData[PM_DSP_JPG_PM+2];
- IdmaPmW(1,((((DWORD)bProgLen)<<9)/3)-1); //set idma and change length from sector to PM word(24bit)
- if(!NandReadPhySec(wProgAddr,bProgLen,0xFFFF))
- goto Err_Dsp_Download;
- }
- if(NandReadPhySec(gxwAddrPMI,1,SRAM_DATA_ADDR)) //Download DMX
- {
- wProgAddr=(((WORD)gxbFsData[PM_DSP_JPG_DMX+1])<<8)|gxbFsData[PM_DSP_JPG_DMX];
- bProgLen=gxbFsData[PM_DSP_JPG_DMX+2];
- //IdmaDmxW(0,((DWORD)bProgLen)<<8,DSP_W16); //set idma and change length from sector to 16bis
- if(obPMSIZE&0x80) //16bit mode
- IdmaDmxW(0,((DWORD)bProgLen)<<8,DSP_W16); //set idma and change length from sector to 16bis
- else //24bit mode
- IdmaDmxW(0,(((DWORD)bProgLen)<<9)/3,DSP_W24);
- if(!NandReadPhySec(wProgAddr,bProgLen,0xFFFF))
- goto Err_Dsp_Download;
- }
- if(NandReadPhySec(gxwAddrPMI,1,SRAM_DATA_ADDR)) //Download DMY
- {
- wProgAddr=(((WORD)gxbFsData[PM_DSP_JPG_DMY+1])<<8)|gxbFsData[PM_DSP_JPG_DMY];
- bProgLen=gxbFsData[PM_DSP_JPG_DMY+2];
- //IdmaDmyW(0x2000,(((DWORD)bProgLen)<<9)/3,DSP_W24); //set idma and change length from sector to 24 bits
- IdmaDmyW(wDmyStrAddr,(((DWORD)bProgLen)<<9)/3,DSP_W24);
- if(!NandReadPhySec(wProgAddr,bProgLen,0xFFFF))
- goto Err_Dsp_Download;
- }
- obIDMACTRL&=IDMA_ACT_DIS;
- return TRUE;
- Err_Dsp_Download:
- IDMA_REQUEST_DISABLE();
- DSP_RESET();
- DSP_ENABLE(); //Dsp normal
- return FALSE;
- }
- //void JpgInitial() //Walace060816#4
- BOOL JpgInitial()
- {
- //3. == file variable initial and open file ==========
- gfGetPhoConfig=FALSE;
- // gxdwBlockTotalNum =0; //Walace051202#2
- gxwMcuSize=0;
- gxwBlockHeight=0;
- gxwBlockWidth=0;
- gxwBlockColNum=0;
- gxwBlockPageNum=0;
- gxdwCurrentBlockNum=0;
- gdwFileSector=0;
- gxwPhoWidth=0;
- gxwPhoHeight=0;
- //Walace05121#FullScreen
- gxwXStart=0;
- gxwYStart=0;
- gxwXPixel=0;
- gxwYPixel=0;
- gxwXStep=0;
- gxwYStep=0;
- gxwXStepStart=0;
- gxwYStepStart=0;
- //==========================
- //Walace060309#3 start
- obSYSINT0MASK &= (~(CDC_INT_EN|I2S_INT_EN));
- JpegDspInit();
- ClkDspEn();
- if(!DownloadJpegDsp()) //Walace060816#4 start
- {
- gxbErrCode = ERR_PE_DSP_CODE_ERROR;
- return FALSE;
- }
- //Walace060309#3 end
- #if(OLED_COLOR_FIELD_TYPE==OLED_FIELD_BGR565) //Walace051115#1
- JpgSetMonitorSizeTypeToDsp(UI_PHOTO_DISP_SIZE_COL,UI_PHOTO_DISP_SIZE_ROW,DSP_JPG_COLOR_CODE_BGR); //Walace060320#3
- #else
- JpgSetMonitorSizeTypeToDsp(UI_PHOTO_DISP_SIZE_COL,UI_PHOTO_DISP_SIZE_ROW,DSP_JPG_COLOR_CODE_RGB); //Walace060320#3
- #endif
- SetDspStart();
- return TRUE; //Walace060816#4
- }
- //Walace060816#4 start
- #define JPEG_FORMAT_CHECK_TAG 0x01
- #define JPEG_FORMAT_CHECK_TYPE 0x02
- //===================================
- // No differential , Huffman coding
- #define JPEG_FORMAT_HUFF_BASELINE 0xC0
- #define JPEG_FORMAT_HUFF_SEQ 0xC1
- #define JPEG_FORMAT_HUFF_PRG 0xC2
- #define JPEG_FORMAT_HUFF_LOSS 0xC3
- //===================================
- // Differential , Huffman coding
- #define JPEG_FORMAT_HUFF_DIFF_SEQ 0xC5
- #define JPEG_FORMAT_HUFF_DIFF_PRG 0xC6
- #define JPEG_FORMAT_HUFF_DIFF_LOSS 0xC7
- //===================================
- // No differential , Arithmetic coding
- #define JPEG_FORMAT_RESERVED 0xC8
- #define JPEG_FORMAT_ARI_SEQ 0xC9
- #define JPEG_FORMAT_ARI_PRG 0xCA
- #define JPEG_FORMAT_ARI_LOSS 0xCB
- //===================================
- // Differential , Arithmetic coding
- #define JPEG_FORMAT_ARI_DIFF_SEQ 0xCD
- #define JPEG_FORMAT_ARI_DIFF_PRG 0xCE
- #define JPEG_FORMAT_ARI_DIFF_LOSS 0xCF
- #if(1) //Walace060915#1 start
- //Walace060926#1 VideoResume
- //Remove ParserGetField() to Common.c and Common.h
- #define JPEG_MAKER 0xFF
- #define SOF0 0xFFC0
- #define SOF1 0xFFC1
- #define SOF2 0xFFC2
- #define SOF3 0xFFC3
- #define SOF5 0xFFC5
- #define SOF6 0xFFC6
- #define SOF7 0xFFC7
- #define JPEG_RESERVE 0xFFC8
- #define SOF9 0xFFC9
- #define SOF10 0xFFCA
- #define SOF11 0xFFCB
- #define SOF13 0xFFCD
- #define SOF14 0xFFCE
- #define SOF15 0xFFCF
- #define DHT 0xFFC4
- #define DAC 0xFFCC
- #define RST0 0xFFD0
- #define RST1 0xFFD1
- #define RST2 0xFFD2
- #define RST3 0xFFD3
- #define RST4 0xFFD4
- #define RST5 0xFFD5
- #define RST6 0xFFD6
- #define RST7 0xFFD7
- #define SOI 0xFFD8
- #define EOI 0xFFD9
- #define SOS 0xFFDA
- #define DQT 0xFFDB
- #define DNL 0xFFDC
- #define DRI 0xFFDD
- #define DHP 0xFFDE
- #define EXP 0xFFDE
- #define APP0 0xFFE0
- #define APP1 0xFFE1
- #define JPG0 0xFFF0 //0xFFF0~0xFFFD
- #define COM 0xFFFE
- #define FIRST_SEARCH TRUE
- #define CONT_SEARCH FALSE
- #define REVERSE_DATA TRUE
- #define NORMAL_DATA FALSE
- #define GET_MARKER 0x01
- #define GET_SOI_MAKER 0x02
- BOOL SearchSoiInAppn(PWORD pwAddrOffset)
- {
- BYTE bStates;
- WORD wLength;
- BYTE bTemp;
- ParserGetField(&wLength, 2, pwAddrOffset, FIRST_SEARCH, NORMAL_DATA);
- wLength -= 2; //substract 2 bytes length field
- //Walace070429#1
- (*pwAddrOffset)+=wLength;
- return TRUE;
- bStates=GET_MARKER;
- while(wLength)
- {
- ParserGetField(&bTemp, 1, pwAddrOffset, FIRST_SEARCH, NORMAL_DATA);
- wLength--;
- switch(bStates)
- {
- case GET_MARKER:
- if(bTemp==JPEG_MAKER)
- bStates=GET_SOI_MAKER;
- break;
- case GET_SOI_MAKER:
- if(bTemp==(SOI&JPEG_MAKER))
- {
- return TRUE;
- }
- else if(bTemp!=JPEG_MAKER)
- {
- bStates=GET_MARKER;
- }
- break;
- }
- }
- return FALSE;
- }
- BOOL JpegFormatCheck()
- {
- WORD wMaker,wAddrOffset,wLength;
- BYTE bKeepSpeed;
- //BYTE bKey;
- //WORD wCounter;
- BOOL fAppSpace;
- bKeepSpeed = obCLKMCUDIVF;
- SetSysSpeed(0x02);
- gxbErrCode = ERR_NO_ERROR;
- wLength=0;
- wAddrOffset = 512; //for read a sector in ParserGetField
- gdwFileSector = 0;
- //wCounter=0;
- if(!ParserGetField(&wMaker, 2, &wAddrOffset, FIRST_SEARCH, NORMAL_DATA))
- goto END_PARSE;
- //bKey=KEY_INVALID;
- fAppSpace = FALSE;
- if(wMaker!=SOI)
- {
- gxbErrCode = ERR_PE_UNSUPPORT_FORMAT;
- goto END_PARSE;
- }
- while(TRUE)
- {
- if(!ParserGetField(&wMaker, 2, &wAddrOffset, FIRST_SEARCH, NORMAL_DATA))
- goto END_PARSE;
- switch(wMaker)
- {
- case SOF0:
- case SOF2: //Walace070103#1
- goto END_PARSE;
- case SOF1:
- //case SOF2: //Walace070103#1
- case SOF3:
- case SOF5:
- case SOF6:
- case SOF7:
- case SOF9:
- case SOF10:
- case SOF11:
- case SOF13:
- case SOF14:
- case SOF15:
- gxbErrCode = ERR_PE_UNSUPPORT_FORMAT;
- goto END_PARSE;
- case SOI:
- case EOI:
- case SOS:
- break;
- case APP0:
- case APP1:
- if(!fAppSpace)
- {
- fAppSpace = SearchSoiInAppn(&wAddrOffset);
- break;
- }
- default:
- if(!ParserGetField(&wLength, 2, &wAddrOffset, FIRST_SEARCH, NORMAL_DATA))
- goto END_PARSE;
- wAddrOffset += wLength-2;
- break;
- }
- }
- END_PARSE:
- gdwFileSector=0;
- SetSysSpeed(bKeepSpeed);
- if(gxbErrCode==ERR_FS_EOF)
- {
- gxbErrCode=ERR_PE_UNSUPPORT_FORMAT;
- }
- return (gxbErrCode==ERR_NO_ERROR);
- }
- #else
- BOOL JpegFormatCheck()
- {
- BYTE bKeepSpeed;
- BYTE bCheckState;
- WORD wDataIndex;
- bCheckState = JPEG_FORMAT_CHECK_TAG;
- bKeepSpeed = obCLKMCUDIVF;
- SetSysSpeed(0x02);
- gdwFileSector=0;
- while(gdwFileSector<(stPhoFileInf.dwFileTotalSector))
- {
- if(!FsReadFileSectorNew(gdwFileSector++,FS_DATA_0_0)) //read a sector
- return FALSE;
- wDataIndex=0;
- while(wDataIndex<512)
- {
- switch(bCheckState)
- {
- case JPEG_FORMAT_CHECK_TAG:
- if(gxbFsData[wDataIndex+gxwOffsetDataSec]==0xFF)
- bCheckState=JPEG_FORMAT_CHECK_TYPE;
- break;
- case JPEG_FORMAT_CHECK_TYPE:
- switch(gxbFsData[wDataIndex+gxwOffsetDataSec])
- {
- case JPEG_FORMAT_HUFF_BASELINE:
- /* Walace060818#1
- case JPEG_FORMAT_HUFF_SEQ:
- case JPEG_FORMAT_HUFF_LOSS:
- case JPEG_FORMAT_HUFF_DIFF_SEQ:
- case JPEG_FORMAT_HUFF_DIFF_LOSS:
- case JPEG_FORMAT_ARI_SEQ:
- case JPEG_FORMAT_ARI_LOSS:
- case JPEG_FORMAT_ARI_DIFF_SEQ:
- case JPEG_FORMAT_ARI_DIFF_LOSS:
- */
- gdwFileSector=0;
- SetSysSpeed(bKeepSpeed);
- return TRUE;
- case JPEG_FORMAT_HUFF_PRG:
- case JPEG_FORMAT_HUFF_DIFF_PRG:
- case JPEG_FORMAT_ARI_PRG:
- case JPEG_FORMAT_ARI_DIFF_PRG:
- // Walace060818#1
- case JPEG_FORMAT_HUFF_SEQ:
- case JPEG_FORMAT_HUFF_LOSS:
- case JPEG_FORMAT_HUFF_DIFF_SEQ:
- case JPEG_FORMAT_HUFF_DIFF_LOSS:
- case JPEG_FORMAT_ARI_SEQ:
- case JPEG_FORMAT_ARI_LOSS:
- case JPEG_FORMAT_ARI_DIFF_SEQ:
- case JPEG_FORMAT_ARI_DIFF_LOSS:
- //
- goto JPEG_TYPE_CHECK_END;
- default:
- bCheckState=JPEG_FORMAT_CHECK_TAG;
- break;
- }
- break;
- }
- wDataIndex++;
- }
- }
- JPEG_TYPE_CHECK_END:
- gdwFileSector=0;
- gxbErrCode = ERR_PE_UNSUPPORT_FORMAT;
- SetSysSpeed(bKeepSpeed);
- return FALSE;
- }
- #endif
- //Walace060816#4 end
- //Walace060915#1 end
- //Walace060816#4 start
- BOOL JpgDispProcess(BYTE bJpgCmd)
- {
- if(bJpgCmd==JPG_CMD_START)
- {
- gxbJpgProcState = JPG_PRC_INITIAL;
- }
- else if(bJpgCmd==JPG_CMD_CHECK_FORMAT)
- {
- gxbJpgProcState=JPG_PRC_IDLE;
- switch(gxbPhotoType)
- {
- case PHO_TYPE_JPG:
- return JpegFormatCheck();
- #if(PHOTO_BMP_DSP_DECODE)
- case PHO_TYPE_BMP:
- return BmpFormatCheck();
- #endif
- }
- }
- switch(gxbJpgProcState)
- {
- case JPG_PRC_IDLE:
- break;
- case JPG_PRC_INITIAL:
- #if(DSP_BMP_DEBUG)
- BmpDspDebug();
- #endif
- if(JpgInitial())
- gxbJpgProcState = JPG_PRC_DATA_TO_DSP;
- else
- gxbJpgProcState = JPG_PRC_END;
- break;
- case JPG_PRC_DATA_TO_DSP:
- if(JpgFillDataToDsp())
- gxbJpgProcState = JPG_PRC_GET_FROM_DSP;
- else
- //gxbJpgProcState = JPG_PRC_ERR;
- gxbJpgProcState = JPG_PRC_END;
- break;
- case JPG_PRC_GET_FROM_DSP:
- /*
- if(JpgGetImageFromDsp())
- gxbJpgProcState = JPG_PRC_SHOW;
- else
- gxbJpgProcState = JPG_PRC_DATA_TO_DSP;
- break;
- */
- switch(JpgGetImageFromDsp())
- {
- case GET_JPEG_DATA_NONE:
- gxbJpgProcState = JPG_PRC_DATA_TO_DSP;
- break;
- case GET_JPEG_DATA_DONE:
- gxbJpgProcState = JPG_PRC_SHOW;
- break;
- case GET_JPEG_CONFIG_ERR:
- gxbJpgProcState = JPG_PRC_END;
- break;
- }
- break;
- case JPG_PRC_SHOW:
- if(JpgBmpShow()) //Walace061018#2 bmp dsp decode
- gxbJpgProcState = JPG_PRC_END;
- else
- gxbJpgProcState = JPG_PRC_DATA_TO_DSP;
- break;
- case JPG_PRC_END:
- gxbJpgProcState = JPG_PRC_IDLE;
- return TRUE;
- }
- return FALSE;
- }
- //Walace060816#4 ebd
- #endif //#if(PHOTO_SUPPORT_JPG)
- #if(DSP_BMP_DEBUG)
- void BmpDspDebug(void)
- {
- WORD wDspVal;
- SetSysSpeed(0x02);
- JpgInitial();
- while(1)
- {
- JpgFillDataToDsp();
- if(CheckImageOut()==DSP_REQ_START)
- {
- wDspVal=DSP_REQ_END;
- IdmaPioDmxW(&wDspVal, DSP_JPG_INPUT_FLAG, 1, DSP_W16); //Set finish data transfer
- }
- if(gdwFileSector<(stPhoFileInf.dwFileTotalSector))
- {
- OledShowNumber(1234,WORD0,LINE0,4);
- while(1){}
- }
- }
- }
- #endif
- //================= =============================================