亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cvc_headset.c

?? bluelab 3.52 里面的立體聲程序源代碼
?? C
字號:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2006
Part of BlueLab 3.5.2-release

FILE NAME
	cvc_headset.c        

DESCRIPTION
    Support for CVC in av_headset_hfp
	
	Only active if INCLUDE_CVC is defined in the project properties.
	
NOTES
	The supporting DSP code is supplied as a preassembled .kap file and is
	time limited until licenced.
*/

#ifdef INCLUDE_CVC

/****************************************************************************
	Header files
*/

#include "headset_codec.h"
#include "headset_private.h"
#include "headset_tones.h"
#include "headset_volume.h"
#include "cvc_headset.h"
#include "cvcdsp.h"


#include <codec.h>
#include <file.h>
#include <kalimba.h>
#include <kalimba_standard_messages.h>
#include <pcm.h>
#include <stdlib.h>
#include <string.h>
#include <transform.h>
#include <panic.h>
#include <ps.h>
#include <pio.h>
#include <message.h>
#include <stream.h>


#ifdef DEBUG_CVC
#define CVC_DEBUG(x) DEBUG(x)
#else
#define CVC_DEBUG(x) 
#endif

/* 5 Minute Demonstration Mode */
/* If ENABLE_DEMO_MODE is defined the audio will mute in 5 minutes */
/* if the CVC security signature is invalid.					   */
/* If ENABLE_DEMO_MODE is not defined the audio will mute 		   */
/* immediately if the CVC security signature is invalid.  This	   */
/* can be used for immediate notification of an invalid security   */
/* signature during production testing.							   */

#define ENABLE_DEMO_MODE	 

/* CVC Message IDs From Kalimba */
#define CVC_READY				0x1000
#define CVC_SETMODE				0x1001
#define CVC_VOLUME				0x1002

#define CVC_CODEC				0x1006
#define CVC_STATUS		        0x1007
#define CVC_SECPASSED			0x100c

/* CVC Message IDs Not From Kalimba */
/* Security Failure Message ID */
#define	CVC_SECFAILED			0x1000

/* System Modes */
#define SYSMODE_HFK			1
#define SYSMODE_ASR			2
#define SYSMODE_PSTHRGH		3
#define SYSMODE_STANDBY	    6

/* Call State */
#define CALLST_CONNECTED	1
#define CALLST_MUTE         3


/* Filename containing the CHF DSP code.	*/
static const char enc_codec[] = "cvc/cvc.kap";

static bool cvc_init(headsetTaskData* app);
static void start_kalimba(headsetTaskData* app);
static void connect_streams(headsetTaskData *app);
static void dsp_handler(Task, MessageId, Message);

/* This is the table of codec gain values used with CVC */
/* Table entries are configurable, but the maximum value cannot exceed 15 */
static const uint8 vgsToCodecGainCvc[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};

/* The Sidetone level can be controlled 3 different ways:                                 */
/* 1) The VM application can send the level as a parameter to the CVC_VOLUME message.     */
/* 2) The level can be specified in the cvc "parameters.psr" file.                        */
/* 3) The value specified in the cvc "parameter.psr" file can be auto leveled by the      */
/*    dsp such that the level is always constant or it can be made to change with volume. */
/*                                                                                        */
/* The cvc ParamMgr.exe is used to write a psr file that specifies which method is being  */
/* used.  Regardless of the method, the maximum level that the sidetone gain can be is    */
/* -11 dBFS.                                                                              */

/* If the sidetone level is being controlled by the VM application the following table    */
/* will be used.  Otherwise, the values sent from this table will be ignored by the dsp.  */
/* Note if a value larger than 0x23D7 is used, it will be limited to 0x23D7 by the dsp.   */
/* This corresponds to a limit -11 dBFS.                                                  */

static const uint8 SideToneGain[16] = {0x23D7, 0x23D7, 0x23D7, 0x23D7, 0x23D7, 0x23D7, 0x23D7, 0x23D7,  	
									   0x23D7, 0x23D7, 0x23D7, 0x1CA7, 0x1449, 0x0E5C, 0x0A2A, 0x0732};



static bool cvc_init(headsetTaskData* app)
{
    bool ret = FALSE;

    if (!app->cvc.hfkdspready)
    {
        start_kalimba(app);
        codec_configure_mono_8000(app);
        ret = TRUE;        
    }
   
    return ret;
}

/* The following function is used to start the DSP code.  The code    */
/* for the DSP resides in the constant data area as a file in a file  */
/* system.  Once the file is located, the file is loaded into the DSP */
/* and started.                                                       */

static void start_kalimba(headsetTaskData* app)
{
    /* Find the codec file in the file system */
    FILE_INDEX index = FileFind(FILE_ROOT,enc_codec,sizeof(enc_codec)-1/*don't pass terminator*/);

    if(index == FILE_NONE)
    {
        /* Error - can't find file        */
        CVC_DEBUG(("CVC: CHF file index = %x \n",index));
	   Panic();
    }
    
    (void) MessageCancelAll(&app->cvc.task, MESSAGE_FROM_KALIMBA);
    MessageKalimbaTask(&app->cvc.task);
   
    /* Load the cvc algorithm into Kalimba */
    if(!KalimbaLoad(index))
    {
        CVC_DEBUG(("CVC: Kalimba load fail\n"));
        Panic();
    }
   
    /* Now the kap file has been loaded, wait for the CVC_READY message from the */
    /* dsp to be sent to the dsp_handler function.                               */  
}

static void connect_streams(headsetTaskData *app)
{
    bool r1, r2, r3, r4;

    /* Mute audio before connecting the stream */
	
	 CodecSetOutputGainNow(app->codec_task, 0, left_and_right_ch); 
	/* Connect the stream from the Mic to the DSP and the stream  */
    /* from the DSP to the Speaker.                               */
    r1 = StreamConnect(StreamPcmSource(0),StreamKalimbaSink(0));
    r2 = StreamConnect(StreamKalimbaSource(0),StreamPcmSink(0));
    
	/* Plug Incoming SCO link into DSP Channel 1 Input. */
	r3 = StreamConnect(StreamSourceFromSink(app->sco_sink),StreamKalimbaSink(1));
	/* Plug DSP Channel 1 Output into Outoing SCO Link. */
	r4 = StreamConnect(StreamKalimbaSource(1),app->sco_sink);
    
    CVC_DEBUG(("CVC: connect_streams %d %d %d %d\n",r1,r2,r3,r4));
    
	/* Tell cvc to set the DAC gain */
    CvcHeadsetVolume(app);
    
    /* Set the Dsp mode */
    CvcSetMode(app); 
}

/* The following function is used to handle messages that are        */
/* dispatched from the DSP.                                          */

typedef struct
{
    uint16 id;
    uint16 a;
    uint16 b;
    uint16 c;
    uint16 d;
} DSP_REGISTER_T;


static void dsp_handler(Task task, MessageId id, Message message) 
{
	
	headsetTaskData *app = getApp();
	switch(id)
	{
	case MESSAGE_FROM_KALIMBA:
		{
			const DSP_REGISTER_T *m = (const DSP_REGISTER_T *) message;
			uint16 a      = m->a;
			uint16 b      = m->b;
	        
	        CVC_DEBUG(("CVC: dsp_handler dsp_id = %x a= %x b= %x c= %x d= %x\n" ,m->id,a,b,m->c,m->d));
		
			switch (m->id) 
			 {
	         case CVC_READY:
	            /* This command is sent to us to indicate that the DSP is      */
	            /* initialized and ready.  At this point we need to send the   */
	            /* configuration parameters to the DSP and allocate memory to  */
	            /* hold a configuration record.  This is done within the       */
				/* CvcConfigureDsp() function which is defined in the          */ 
                /* libcvcdsp.a file.                                           */
                /*                                                             */
                /* If multiple sets of parameters are required,  Persistent    */
				/* Store Keys can be defined for each and CvcConfigureDsp can  */
                /* be called to load the various parameter sets.  Note that    */
			    /* the first call to CvcConfigureDsp must be done here as a    */
				/* response to the CVC_READY message, but that successive      */
				/* calls do not need to be here.                               */
					
				a = CvcConfigureDsp(PS_PARAM_BASE,NULL,0,PS_PARAM_BASE2,NULL,0);

	            CVC_DEBUG(("CVC: CVC_READY: DSP is initialized and ready (%x)\n",a));
	            
	            /* DSP is up and running */
	   			app->cvc.hfkdspready = 1;

	            if (app->sco_sink && (app->pcm_audio_state == pcm_sco))
	            {
	                CVC_DEBUG(("CVC: Ok to connect streams\n"));
	    			connect_streams(app);
	            }
				
				
				/* Set timer for security fail condition					*/
				/* If the security check on the kalimba passes this mesage  */
				/* will be cancelled - see CVC_SECPASSED below.				*/
				app->cvc.sec_mute = 0;			
				MessageSendLater(task, CVC_SECFAILED, 0, 500);
			    break;
				
			case CVC_CODEC:
	            /* We have received a message that defines the values that  */
	            /* are to be loaded for gain levels.  Parameter 1 (a)       */
	            /* defines the DAC (speaker) gain.  Parameter 2 (b) defines */
	            /* the ADC (microphone gain).  The mic level is meant to be */
	            /* fixed throughout CVC operation.  The DAC level changes   */
	            /* in correspondace with volume changes.  When using the    */
	            /* CVC algorithm, the DAC gain should always be set using   */
				/* the CvcHeadsetVolume message so that CVC is aware of the */
				/* DAC gain.												*/
	 			
				app->cvc.cvc_output_codec_gain = a;
	            app->cvc.cvc_input_codec_gain = b;
	   			CodecSetOutputGainNow(app->codec_task, a, left_and_right_ch);
	            CVC_DEBUG(("CVC: CVC_CODEC: Input gain = 0x%x  Output gain = 0x%x\n",b,a));
	            if((b & 0x8000)  == 0x8000)
				{
					CodecEnableMicInputGainA(1);
					CodecEnableMicInputGainB(1);
				}
				else
				{
					CodecEnableMicInputGainA(0);
					CodecEnableMicInputGainB(0);
				}
				
				/* Clear the upper bytes of the input gain argument */
				b &= 0xff;			
	            CodecSetInputGainNow(app->codec_task, b, left_and_right_ch);
	            break;
				
			case CVC_SECPASSED:
				CVC_DEBUG(("CVC:  Security passed.\n"));
				MessageCancelAll(task, CVC_SECFAILED);
				break;
	      }
		}
		break;
	
	case	CVC_SECFAILED:	/* message not from kalimba */
		
#ifdef	ENABLE_DEMO_MODE
		CVC_DEBUG(("CVC:  Running in Demo Mode.\n"));

#else
		CVC_DEBUG(("CVC:  Security failed.\n"));		
		app->cvc.sec_mute = 1;
		CvcSetMode(app);
#endif
		break;
		
	}
		
}

	
	
void CvcInitialise(headsetTaskData *app)
{
    app->cvc.task.handler = dsp_handler;    
    app->cvc.cvc_output_codec_gain = 0;
    app->cvc.cvc_input_codec_gain = 0;
}

void CvcHeadsetConnect(headsetTaskData *app)
{
	CVC_DEBUG(("CVC: hfkdspready = %x\n",app->cvc.hfkdspready));
	CVC_DEBUG(("CVC: hfp_state = %x\n",app->hfp_state));
	if (!cvc_init(app))
    {
        /* Disconnect anything already connected to PCM slots 0 and 1 */
        StreamDisconnect(StreamPcmSource(0), StreamPcmSink(0));
        /* Now connect up the new streams */
    	connect_streams(app);
        CVC_DEBUG(("CVC: Cvc sco connected\n"));
    }
}

void CvcHeadsetUnloaded(headsetTaskData *app)
{
    /* The DSP has been reloaded by some other part of the application */
    app->cvc.hfkdspready = 0;	
    CVC_DEBUG(("CVC: Cvc unloaded\n"));
}

void CvcHeadsetVolume(headsetTaskData *app)
{
    uint16 volume_index = app->speaker_volume.hfp_volume;
	if(app->cvc.hfkdspready)
    {
       CVC_DEBUG(("CVC: Cvc volume = %x\n",volume_index));
	   CVC_DEBUG(("CVC: Cvc DAC gain = %x\n",app->cvc.cvc_output_codec_gain)); 
	   if(!KalimbaSendMessage(CVC_VOLUME, volume_index, 0, vgsToCodecGainCvc[volume_index], SideToneGain[volume_index]))
	   {
		  CVC_DEBUG(("CVC: SetVolume FAILURE\n"));
	   }
   }
}

void CvcSetMode(headsetTaskData *app)
{
    if (!app->cvc.hfkdspready)
        return;
    
	if(app->cvc.sec_mute)
	{
		if(!KalimbaSendMessage(CVC_SETMODE, SYSMODE_STANDBY, 0, 0, 0))
        {
		    CVC_DEBUG(("CVC: SetMode SYSMODE_STANDBY\n"));
        }
	}
    else if (app->voice.voice_recognition_enabled)
    {
        CVC_DEBUG(("CVC: SetMode SYSMODE_ASR\n"));
        /* Set the DSP mode to apply noise reduction only. */
        if(!KalimbaSendMessage(CVC_SETMODE, SYSMODE_ASR, 0, 0, 0))
        {
		    CVC_DEBUG(("CVC: SetMode SYSMODE_ASR FAILURE\n"));
        }
    }
    else
    { 
        CVC_DEBUG(("CVC: Set mode SYSMODE_HFK "));
        if (app->mic_mute_on)
        {
            CVC_DEBUG(("(CALLST_MUTE)\n"));
            if (!KalimbaSendMessage(CVC_SETMODE, SYSMODE_HFK, 0, CALLST_MUTE, 0))
            {
                CVC_DEBUG(("CVC: Set Mode SYSMODE_HFK (CALLST_MUTE) FAILURE\n"));
            }
        }
        else
        {   
            CVC_DEBUG(("(CALLST_CONNECTED)\n"));
            /* Set the DSP mode to apply echo cancellation and noise reduction. */
            if(!KalimbaSendMessage(CVC_SETMODE, SYSMODE_HFK, 0, CALLST_CONNECTED, 0))
            {
		        CVC_DEBUG(("CVC: SetMode SYSMODE_HFK (CALLST_CONNECTED) FAILURE\n"));
            }
        }
    }
}

#else /* ifndef INCLUDE_CVC */

extern int cvc_headset_dummy_int; /* Suppress empty-file error */

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线观看欧美精品| 美国十次综合导航| 国产精品护士白丝一区av| 久久久精品日韩欧美| 欧美高清在线精品一区| 中文字幕在线播放不卡一区| 一区二区三区高清| 久久99在线观看| 91免费视频网| 欧美一区二区三区精品| 国产日韩影视精品| 亚洲一二三四区不卡| 久久www免费人成看片高清| 99久久久久免费精品国产| 91精品麻豆日日躁夜夜躁| 国产婷婷色一区二区三区四区| 亚洲人精品一区| 国产一区二区免费在线| 制服丝袜亚洲精品中文字幕| 国产精品久99| 国产精品 欧美精品| 欧美人狂配大交3d怪物一区| 国产精品全国免费观看高清 | 日韩精品免费专区| 99精品久久99久久久久| 欧美成人三级电影在线| 同产精品九九九| 在线播放/欧美激情| 亚洲一区二区中文在线| 99国产精品国产精品毛片| 欧美激情一区二区三区全黄| 久久www免费人成看片高清| 欧美草草影院在线视频| 久久国产精品区| 精品久久久久av影院| 精品一区二区综合| 欧美成人一区二区三区片免费| 婷婷久久综合九色综合伊人色| 欧美视频在线一区二区三区 | 欧美日韩一区二区三区视频| 一区二区三区四区在线免费观看 | 日韩一区欧美一区| 成年人国产精品| 一区二区三区鲁丝不卡| 欧美精品自拍偷拍| 国产精品中文有码| 亚洲视频在线观看三级| 在线免费观看成人短视频| 日本亚洲电影天堂| 国产欧美日韩在线| 欧美伊人精品成人久久综合97 | 2024国产精品视频| 91丨porny丨中文| 日本 国产 欧美色综合| 久久久亚洲精品一区二区三区 | 蜜臀国产一区二区三区在线播放| 久久久久久日产精品| 在线免费观看日本欧美| 九九在线精品视频| 一区二区三区丝袜| 国产精品污网站| 日韩欧美国产一区二区在线播放 | 久久久久久一二三区| 欧美少妇bbb| 成人免费视频网站在线观看| 日本麻豆一区二区三区视频| 一区二区三区av电影| 国产精品久久久久影院亚瑟| 精品国产sm最大网站| 欧美久久久一区| 欧美性色黄大片| 在线观看亚洲精品| 色综合天天狠狠| 日本怡春院一区二区| 亚洲一区二区三区在线看| 中文字幕制服丝袜成人av| 欧美韩国日本不卡| 国产蜜臀97一区二区三区| 欧美成人综合网站| 中文字幕av一区二区三区高| 久久综合九色综合97婷婷女人 | 亚洲一本大道在线| 日韩福利电影在线观看| 视频在线在亚洲| 三级不卡在线观看| 久久激情综合网| 九九久久精品视频| 972aa.com艺术欧美| 欧美日韩国产一区| 精品美女被调教视频大全网站| 91精品国产91综合久久蜜臀| 久久免费电影网| 亚洲欧美激情插| 欧美a级理论片| 久久成人免费网| 99久久亚洲一区二区三区青草| 色哟哟一区二区在线观看| 91精品一区二区三区久久久久久 | 欧美精品在线一区二区三区| 中文字幕亚洲在| 亚洲va韩国va欧美va| 国产偷国产偷亚洲高清人白洁| 91一区二区三区在线观看| 极品少妇一区二区| 奇米888四色在线精品| 亚洲精品精品亚洲| 欧美国产国产综合| 亚洲精品一区二区在线观看| 7777精品久久久大香线蕉| 福利一区二区在线| 国产美女主播视频一区| 免费成人结看片| 国产在线精品一区在线观看麻豆| 性欧美大战久久久久久久久| 日日夜夜精品视频免费| 视频在线在亚洲| 免费观看一级特黄欧美大片| 经典三级视频一区| 国产成人亚洲综合a∨婷婷图片 | 亚洲美女视频一区| 亚洲成av人片在线观看无码| 亚洲成人免费在线| 国模套图日韩精品一区二区| 国产aⅴ精品一区二区三区色成熟| 国产成都精品91一区二区三| 色婷婷激情一区二区三区| 欧美日韩精品高清| 欧美激情在线一区二区| 中文字幕在线观看不卡| 亚洲五码中文字幕| 国产成人亚洲精品狼色在线 | 国产综合久久久久久鬼色| 成人美女视频在线观看18| 欧美日韩国产一区二区三区地区| 日韩一区二区电影在线| 久久亚洲一区二区三区四区| 亚洲美女淫视频| 国产福利一区二区| 欧美日韩国产欧美日美国产精品| 久久这里只有精品首页| 亚洲国产欧美日韩另类综合 | 中文字幕中文乱码欧美一区二区| 裸体健美xxxx欧美裸体表演| 在线免费观看日本欧美| 亚洲欧洲成人精品av97| 国产a精品视频| 国产精品久久久一本精品| 日韩高清中文字幕一区| 国产亚洲人成网站| 国产成人亚洲综合色影视| 久久综合av免费| 激情综合一区二区三区| 日韩欧美国产一区二区在线播放| 午夜精品久久久久久久| 欧美日韩一区二区在线观看视频| 一片黄亚洲嫩模| 欧美日韩在线观看一区二区 | 精品国产一区二区三区久久久蜜月 | 99久久伊人久久99| 亚洲日本一区二区| 欧美日韩在线三级| 久久99精品网久久| 国产精品久久久爽爽爽麻豆色哟哟| av电影天堂一区二区在线观看| 亚洲人精品午夜| 欧美性一级生活| 国内外成人在线| 亚洲精品欧美在线| 日韩精品一区二区三区视频在线观看| 久久精品噜噜噜成人av农村| 精品处破学生在线二十三| 99精品视频中文字幕| 日韩av中文在线观看| 亚洲国产成人午夜在线一区| 欧美性色黄大片手机版| 国产盗摄一区二区| 日韩精品国产精品| 亚洲欧洲一区二区在线播放| 在线播放91灌醉迷j高跟美女 | 午夜精品123| 一区在线观看免费| 欧美一区二区三区影视| 成人av动漫网站| 国产一区欧美一区| 日韩成人免费电影| 天堂资源在线中文精品| 一区二区三区欧美视频| 中文字幕欧美日本乱码一线二线| 欧美一级理论性理论a| 欧美三级乱人伦电影| 日本高清视频一区二区| 成人黄色777网| 国产成人免费视频精品含羞草妖精| 在线不卡免费欧美| 毛片基地黄久久久久久天堂| 日韩成人一级片| 亚洲国产日韩a在线播放| 五月婷婷另类国产| 一区二区三区在线看| 亚洲成a人v欧美综合天堂下载|