sound.c
上传用户:caisangzi8
上传日期:2013-10-25
资源大小:15756k
文件大小:59k
- /*****************************************************
- Creater: Terry
- Date : 2001/5/11 12:49PM
- Description: Setup menu using
- *****************************************************/
- #include "global.h"
- #include "func.h"
- #include "ircmd.h"
- #include "memmap.h"
- #include "dsp3_if.h"
- #include "auddrv.h" //2004AUDDRV oliver 20041012 for using audio driver purpose
- #include "stdlib.h"
- #include "osd.h"
- #include "osdsup.h"
- #include "cchar.h"
- #ifdef DVD_SETUP_REENG
- #include "setup_VA.h"
- #else
- #include "setup_page.h"
- #endif
- #include "audcodec.h"
- //#define MONE_sound
- #ifdef OSD_BMP_SOUND
- #include "osd_BmpUI.h"
- #endif
- #define DISP_R 0
- #define SURROUND_R 2
- #ifdef OSD_BMP_SOUND
- #define EQ_R 4
- #define BAND_R 4
- #else
- #define EQ_R 3
- #define BAND_R 3
- #endif
- #define BAND_NO 5
- void SettingEqLevel(BYTE *);
- void SettingEQType(BYTE type);
- void EQ_init(void);
- void sound_draw_title(BYTE ,BYTE , BYTE);
- void sound_draw_tab(void);
- void sound_func_set_EQ(BYTE EQitem);//nono 4-7-22 18:10
- void sound_set_EQ_again(void);//nono 4-7-22 18:10
- #ifdef OSD_BMP_SOUND
- #define SRND_PAGE 0
- #define EQ_PAGE 1
- #define BAND_PAGE 2
- #define KEY_PAGE 3
- #define ITEM_NUM 6
- void ShowBmpSoundPage(void);
- void sound_bmp_draw_tab(void);
- void sound_bmp_draw_item_cursor(void);
- void sound_bmp_func_right(void);
- void sound_bmp_func_left(void);
- void sound_bmp_func_up(void);
- void sound_bmp_func_down(void);
- void sound_bmp_func_select(void);
- void OSD_LayoutSoundRegionA(void);
- void OSD_LayoutSoundRegionB(void);
- void OSD_LayoutSoundRegionD(void);
- void OSD_LayoutSoundRegionE(void);
- void OSD_LayoutSoundRegionF(void);
- void show_bmp_band(void);
- void EQ_bmp_init(void);
- void sound_bmp_draw_key(UINT8 up_down, UINT8 refresh);
- const OSD_REGIONA_LAYOUT_S g_aOsdSoundRegionA =
- {
- //sound 3d osd
- OSD_BG_BMP_A,//Bg bmp,
- SOUND_LINE1_A, //Line Left,
- OSD_DOWN_BG_BMP_A, //Down Bg bmp,
- SOUND_LINE2_A, // Line Right,
- SOUND_SHADOW_A, // Shadow rect
- };
- const OSD_REGIONB_LAYOUT_S g_aOsdSoundRegionB =
- {
- SOUND_RECT_BG_B,
- SOUND_BG_LINE_B,//Bg Line
- SOUND_LINE1_B, //Line Left
- SOUND_DOWN_B, //Down bg
- OSD_CURSOR_1_BMP_B,//Curosr 1
- SOUND_SEL_STR_B, //selected string
- SOUND_UNSEL_STR_B, //unselected string
- SOUND_LINE2_B, //right line
- SOUND_SHADOW_B,//shadow
- };
- const OSD_REGIOND_LAYOUT_S g_aOsdSoundRegionD =
- {
- OSD_4_1_BMP_D,//Left bg
- OSD_4_2_BMP_D,//Middle bg
- SOUND_LINE1_D, //Line left
- SOUND_DOWN_D, //Down bg rect
- OSD_CURSOR_2_BMP_D,//Curosr 2
- SOUND_LINE2_D, //right line
- SOUND_SHADOW_D,//shadow
- OSD_4_3_BMP_D,//RightBg
- };
- const OSD_REGIONE_LAYOUT_S g_aOsdSoundRegionE=
- {
- OSD_5_1_BMP_E, //left bg
- SOUND_BG_RECT_E4, //middle bg
- OSD_5_3_BMP_E, //right bg
- };
- const OSD_REGIONF_LAYOUT_S g_aOsdSoundRegionF =
- {
- OSD_6_1_BMP_F,
- OSD_6_2_BMP_F,
- OSD_6_3_BMP_F,
- };
- #endif
- #ifdef PROLOGICII_3D_MUTEX
- BYTE soundGetSurroundType(void);
- BYTE soundGetEQType(void);
- BYTE soundGetEQType(void);
- #endif//PROLOGICII_3D_MUTEX
- #ifdef DYNAMIC_SPECTRUM
- void Show3dspectrum(void); //fengjl 3-10-30 14:58
- void ClearShowSpectrum(void);
- extern void SetEQ(void);
- #endif
- #define MAX_PAGE_ITEM 4
- #define MAX_ITEM_SEL 11
- #define MIN_ITEM_SEL 2
- #define MAX_BAND 7
- #ifdef SEVEN_OPTIONS_IN_EQ
- #define MAX_MUSIC 7
- #else
- #define MAX_MUSIC 5
- #endif
- extern void InitSW_region(void);
- extern void osd_print_eq_setting(UINT8 r,UINT8 unSele);
- extern void osd_print_eq(UINT8 r,BYTE *p);
- #ifndef OSD_BMP
- extern void osd_DrawRegionString(BYTE xStart, BYTE yStart, BYTE *str, BYTE fontColor, BYTE bkColor, BYTE r);
- #endif
- extern void osd_DrawRegionLine(UINT32 xStart, UINT32 yStart, UINT32 xEnd, UINT32 yEnd, BYTE color, BYTE lineWidth, BYTE r);
- extern void osd_draw_region_rect(UINT32 xStart, UINT32 yStart, UINT32 xLen, UINT32 yLen, BYTE bkColor, BYTE r);
- extern void osd_draw_sound_button(BYTE xStart, BYTE yStart, BYTE xLen, BYTE color, BYTE bDown);
- extern int IsOSDChinese();
- extern UINT8 setup_sel[7][8];
- extern void run_save_romChk_cmd(void);
- extern void run_save_unChk_cmd(void);
- //extern int CheckDspCtrlRdy();
- //extern void osd_restore();
- extern void run_save_sel_cmd(BYTE, BYTE);
- extern void setup_eq_display(UINT8 val);
- /*********** Item description **********************
- BYTE function
- 0 mode(MSB 4bits) ==>show direction picture
- 0x0:no effect
- 0x1:basic select function
- 0x2:can enter number
- 0x3:need run function by osd id
-
- 1 title ---sw region 1
- 2~6 select item ---sw region 2
-
- ******************************************************/
- enum
- {
- SET_NE=0,
- SET_BS=0x1,
- SET_FUNC=0x2,
- SET_CHART=0x3,
- SET_SCALE=0x4
- };
- #ifdef SUPPORT_3DSOUND
- UINT8 sound_sel[MAX_PAGE_ITEM]={2, 2, 0,6};//Item number
- const UINT8 sound_item[MAX_PAGE_ITEM][MAX_ITEM_SEL]=
- {
- {SET_BS,STR_OS_SURR,STR_OS_OFF,STR_OS_CONCERT,STR_OS_CHURCH,STR_OS_PASSIVE,STR_OS_WIDE, STR_OS_LIVE,0,0,0},
- #ifdef BBK_DVD
- {SET_FUNC,STR_OS_EQ,STR_OS_STANDARD,STR_OS_CLASSIC,STR_OS_ROCK,STR_OS_JAZZ,STR_OS_POP, STR_OS_ELECTRON,STR_OS_LIGHT_MUSIC,0,0},
- #else
- {SET_FUNC,STR_OS_EQ,STR_OS_STANDARD,STR_OS_CLASSIC,STR_OS_ROCK,STR_OS_JAZZ,STR_OS_POP, STR_OS_USER,0,0,0},
- #endif//end BBK_DVD
- {SET_CHART,STR_OS_BAND,0,0,0,0,0,0,0,0,0},
- #ifndef SOUND_NO_KEYPAGE //wanghaoying 2003-9-10 10:59
- {SET_SCALE,STR_OS_KEY,0,0,0,0,0,0,0,0,0}
- #endif
- };
- const UINT8 music_osd_set[MAX_MUSIC][MAX_BAND]=
- {
- //These EQ setting is from WinAmp
- // 0 1 2 3 4 5 6 7
- {13,13,13,13,13,13,13},//standard
- //{23,18,7,5,7,18,23},//classic
- {13,13,13,13,13,10,3},//classic
- //{23,18,7,2,7,18,23},//rock
- //{21,21,15,13,11,13,23},//rock //WinAmp
- {21,21,15,11,7,11,23},//rock
- //{3,7,18,23,18,7,3},//jazz
- //{21,19,16,13,18,13,23},//jazz //WinAmp
- {21,19,16,9,18,9,23},//jazz
- //{18,23,18,16,7,15,18},//pop
- //{15,19,11,13,19,15,13},//pop //WinAmp
- {15,21,7,13,21,15,11},//pop
- #ifdef SEVEN_OPTIONS_IN_EQ
- {14,13,12,13,15,17,19},// electric //johnwu
- {17,14,10,13,17,19,19},// soft //johnwu
- #endif //SEVEN_OPTIONS_IN_EQ axel 2004/2/17 09:52AM
- };
- UINT8 user_osd_set[MAX_BAND]={13,13,13,13,13,13,13};
- #define SW_REGION1 0x10
- #define SW_REGION2 0x20
- #define SW_REGION3 0x30
- #define SW_REGION_ANTI 0x20
- #define SW_REGION_OFF 0x10
- UINT8 id,sel;
- BYTE page=0,sound_level=1; // 0:tab 1:item selection 2:EQ adjustment
- #ifdef REMB_3DSOUND //define it to remember 3D Sound yanlb 2004/07/06
- #define Addr_REMB_3D 0xD0
- #define SAVE_NUM 2
- void run_sound_save(BYTE *p)
- {
- #ifdef MONE_sound
- UINT8 i;
- for (i=0;i<SAVE_NUM;i++)
- printf("run_sound_save:sound_save:%2d,,,,,,,,,,,n",*(p+i));
- #endif
-
-
- //save surround&eq page,but not user setup
- WriteToI2c(0xa0,Addr_REMB_3D, p, SAVE_NUM);
-
- #ifdef GBM_DVD
- if(1) //modified by wangwei,2004-9-17 16:04(save 3Dsound EQ user setting whenever)
- #else
- if(p[1]==MAX_MUSIC+2) //save user set
- #endif
- {
- p=(UINT8 *)user_osd_set;
- WriteToI2c(0xa0,Addr_REMB_3D+SAVE_NUM, p, MAX_BAND);
- #ifdef MONE_sound
- ReadFromI2c(0xa0,Addr_REMB_3D+SAVE_NUM, p, MAX_BAND);
- for (i=0;i<MAX_MUSIC;i++)
- printf("run_sound_save-user_osd_set:%2d,,,,,,,,,,,n",(p+i));
- #endif
- }
- }
- //parameter: save_3d--user set sound;band_set--user_osd_set
- //return
- int load_3Dsound(UINT8 *save_3d,UINT8 *band_set)
- {
- #ifdef MONE_sound
- printf("load 3Dsound,inn");
- #endif
- int iResult=-1;
- UINT8 *p;
- p=(BYTE *)save_3d;
-
- //load surround&eq page,but not user setup
- iResult=ReadFromI2c(0xa0,Addr_REMB_3D, p, SAVE_NUM);
- #ifdef MONE_sound
- UINT8 i;
- for (i=0;i<SAVE_NUM;i++)
- printf("load_3Dsound-sound_saved:%2dn",save_3d[i]);
- #endif
- if (iResult==-1)
- {
- #ifdef MONE_sound
- printf("load_3Dsound-ReadFromI2c fail!!n");
- #endif
- return iResult;
- }
-
- #ifdef GBM_DVD
- if(1) //modified by wangwei,2004-9-17 16:04(load 3Dsound EQ user setting whenever)
- #else
- if(save_3d[1]==MAX_MUSIC+2) //load user setup
- #endif
- {
- p=(UINT8 *)band_set;
- iResult=ReadFromI2c(0xa0,Addr_REMB_3D+SAVE_NUM, p, MAX_BAND);
- }
- #ifdef MONE_sound
- for (i=0;i<MAX_BAND;i++)
- printf("load_3Dsound-sound_saved:%2dn",band_set[i]);
- #endif
- if (iResult==-1)
- {
- #ifdef MONE_sound
- printf("load_user set-ReadFromI2c fail!!n");
- #endif
- return iResult;
- }
- return iResult=1;
- }
- void exe_3Dsound(UINT8 *sound_save,UINT8 *user_osd_set)
- {
- if (sound_save[0]>2){
- AUDIF_Set_Surround(sound_save[0]-2);//2004AUDDRV AudioSetSurround(sound_save[0]-2);
- AUDIF_Set_EQType(0);//2004AUDDRV AudioSetEQType(0);
- #ifdef MONE_sound
- printf(" 1===============Load 3Dsound Surround!===============n");
- #endif
- }
- else if((sound_save[1]>2)&&(sound_save[1]<MAX_MUSIC+2)){
- AUDIF_Set_EQType(sound_save[1]-2);//AudioSetEQType(sound_save[1]-2);
- AUDIF_Set_Surround(0);//2004AUDDRV AudioSetSurround(0);
- #ifdef MONE_sound
- printf(" 2==============Load 3Dsound EQ!===============n");
- #endif
- }
- else {
- SettingEqLevel(user_osd_set);
- SettingEqLevel(user_osd_set); //for cover err
- AUDIF_Set_Surround(0);//2004AUDDRV AudioSetSurround(0);
- #ifdef MONE_sound
- printf(" 3==============Load 3Dsound BAND!===============n");
- #endif
- }
- }
- #endif //#ifdef REMB_3DSOUND yanlb 2004/07/07
- void sound_init(void)
- {
- // initialize page and sound_level, in order to dsiplay correctly next time ShowSoundPage
- page=0;
- sound_level=0;
- sound_sel[3]=(UINT8)(6-audio_key);
- OSD1000ISP_STATUS((page<<6)|(sound_level<<4)|(sound_sel[page]&0x0f), OSDIR_3D);
- }
- #ifdef SOUND_NO_KEYPAGE //wanghaoying 2003-9-10 11:00
- void sound_init_2(void)
- {
- // initialize page and sound_level, in order to dsiplay correctly next time ShowSoundPage
- page=1;
- sound_level=0;
- sound_sel[3]=(UINT8)(6-audio_key);
-
- }
- #endif
- void show_band(void)
- {
- char str[6];
- memcpyS(&RegionValStr[BAND_R], user_osd_set, MAX_BAND);
- osd_print_eq_setting(BAND_R, index_x*2);
-
- if ((index_y-13)<-9)
- psprintf(str,"%d DB", (index_y-13));
- else if ((index_y-13)<0)
- psprintf(str,"%d DB ", (index_y-13));
- else if ((index_y-13)>9)
- psprintf(str," %d DB", (index_y-13));
- else
- psprintf(str," %d DB ", (index_y-13));
-
- osd_DrawRegionString(80,6,str,7,11,3);
- }
- #define SBLACKCOLOR 11
- #define SWHITECOLOR 2
- #ifdef SETUP_COLOR_TYPE2 //3-10-16 8:37张宇P
- #ifdef NINTAUS_DVD
- #define SDISABLECOLOR 14//0
- #else//#ifdef NINTAUS_DVD
- #define SDISABLECOLOR 0
- #endif//#ifdef NINTAUS_DVD
- #else
- #define SDISABLECOLOR 1
- #endif
- #define SBGCOLOR 6
- #define SANTIBGCOLOR 5
- #define BUTTON_UP 0
- #define BUTTON_DOWN 1
- void sound_draw_key(UINT8 up_down, UINT8 refresh)
- {
- BYTE buf[15];
- BYTE fnColor, bgColor;
-
- if (up_down) {
- fnColor=SWHITECOLOR;
- bgColor=SANTIBGCOLOR;
- } else {
- fnColor=SBLACKCOLOR;
- bgColor=SBGCOLOR;
- }
-
- if (refresh) {
- osd_draw_region_rect(140, 14, 180, 194, bgColor,EQ_R);
- osd_draw_button_outline(140,14,320,208,up_down,0x0f,EQ_R);
- psprintf(buf, " - %s", Ch_ukey);
- osd_DrawRegionString(9, 6, buf, fnColor, bgColor, EQ_R);
- psprintf(buf, " - - +4");
- osd_DrawRegionString(9, 12, buf, fnColor, bgColor, EQ_R);
- buf[9]='2';//psprintf(buf, " - - +2");
- osd_DrawRegionString(9, 18, buf, fnColor, bgColor, EQ_R);
- psprintf(buf, " - - 0");
- osd_DrawRegionString(9, 24, buf, fnColor, bgColor, EQ_R);
- psprintf(buf, " - - -2");
- osd_DrawRegionString(9, 30, buf, fnColor, bgColor, EQ_R);
- buf[9]='4';//psprintf(buf, " - - -4");
- osd_DrawRegionString(9, 36, buf, fnColor, bgColor, EQ_R);
- psprintf(buf, " - %s", Ch_dkey);
- osd_DrawRegionString(9, 42, buf, fnColor, bgColor, EQ_R);
- } else {
- UINT32 y=35+sound_sel[page]*12;
- //osd_draw_region_rect(188, y-18, 40, 48, bgColor,EQ_R);
- osd_draw_region_rect(188, y-14, 40, 40, bgColor,EQ_R); // alan, 2003/10/21 10:41