Summary of the invention
For overcoming the deficiency of above-mentioned prior art, the technical problem to be solved in the present invention provides player method and this mobile phone of bluetooth MP3 on a kind of low-end mobile phone, and the high-end Bluetooth stereo of realization is answered the function that MP3 plays on the cell phone platform of low side.
For solving the problems of the technologies described above, technical scheme of the present invention is:
The player method of bluetooth MP3 on a kind of mobile phone is characterized in that may further comprise the steps:
Step 1: under the multimedia menu of mobile phone, add the Bluetooth function menu option, and create activation and this bluetooth module that corresponding interfaces windows is used for bluetooth module and be connected with the coupling of bluetooth earphone;
Step 2: baseband chip is controlled described bluetooth module and bluetooth earphone mates in the mobile phone, starts the bluetooth earphone stereo function then;
Step 3: the user starts the MP3 play button, and baseband chip triggers and uses the bluetooth earphone passage to play MP3;
Step 4: baseband chip starts dsp chip to mp3 file broadcasts of decoding, and dsp chip carries out SBC to the audio data stream of playing encodes, and the SBC audio data stream after will encoding is stored in the buffer memory that the internal RAM of dsp chip own distributes;
Step 5: after the SBC voice data in the internal RAM of dsp chip reached first buffer memory, baseband chip was read the SBC voice data from the dsp chip internal RAM, and these data was write in the SRAM named cache of baseband chip;
Step 6: after the SBC data volume in the SRAM of the baseband chip named cache reaches second buffering capacity, baseband chip is read and is carried out transfer encoding once more getting the SBC voice data from the SRAM named cache, and the UART mouth of startup baseband chip, the SBC voice data is sent to bluetooth module;
Step 7: bluetooth module send on the bluetooth earphone, thereby the stereo MP3 that realizes bluetooth earphone is answered after the SBC voice data is handled by the A2DP protocol stack.
The SRAM named cache of base band FLASH chip in the step 5 just distributes from SRAM when definite MP3 uses the bluetooth earphone passage, and this buffer memory is the 400K byte.
Baseband chip is according to the Maximum Bit Rate that the form and the UART mouth data transmissions of SBC coding reaches in the step 6, calculates the data volume of SBC transfer of data and the time interval of transmission each time.
A kind of mobile phone that is used for the player method of above-mentioned bluetooth MP3, comprise baseband chip, bluetooth module and bluetooth earphone, described bluetooth module links to each other with described baseband chip by the UART mouth, it is characterized in that this UART is also multiplexing uses as voice-grade channel, described baseband chip also links to each other by data/address bus with dsp chip, and this dsp chip is used for audio coding decoding.
Described baseband chip can be the GSM6600D baseband chip of Spreadtrum Communications Inc., and platform software is based on the application software of this 6600D platform.
Described bluetooth module can be the Audio Processing chip of the BC41B143A model of CSR company.
Described dsp chip can be the dsp chip of the AIT706P model of AIT company.
Compared with prior art, the invention has the beneficial effects as follows:
The invention provides a kind of low-cost method that realizes that Bluetooth of mobile phone MP3 plays, be implemented on the cell phone platform of low side and realize high-end multimedia application.Key technology of the present invention is with baseband chip as master control side, the control dsp chip carries out the SBC coding to the MP3 that plays, sub-band coding behind the coding (Sub-Band Coding, abbreviation SBC) data flow is read buffer memory among the SRAM by the data/address bus that baseband chip is connected with dsp chip by baseband chip, pass through the coordination system of real time operating system in the base band again, the SBC data flow that is buffered among the SRAM is sent on the Bluetooth chip by the UART mouth, and the A2DP agreement by bluetooth module sends to realization broadcast on the bluetooth earphone again.
Embodiment
Specific embodiments of the present invention are further described in detail below in conjunction with drawings and Examples, but should not limit protection scope of the present invention with this.
See also Fig. 2.The present invention is used to realize the mobile phone of the player method of bluetooth MP3 cheaply, comprise baseband chip, bluetooth module and bluetooth earphone, described bluetooth module links to each other with described baseband chip by the UART mouth, this UART is also multiplexing to be used as voice-grade channel, described baseband chip also links to each other by data/address bus with dsp chip, and this dsp chip is used for audio coding decoding.
Baseband chip adopts the GSM 6600D baseband chip of Spreadtrum Communications Inc., and platform software is based on the application software of this 6600D platform.Bluetooth module adopts the Audio Processing chip of the BC41B143A model of CSR (Cambri dgeSilicon Radio Limited) company.Dsp chip adopts the dsp chip of the AIT706P model of AIT (Alpha Imaging Technology Corp) company.
As shown in Figure 2, the invention provides and realize that MP3 A2DP plays hardware signal frame diagram cheaply, represented the transmission course of sound intermediate frequency data flow of the present invention on hardware link.At first, baseband chip calls coupling and associated program mates by UART mouth control bluetooth module and bluetooth earphone, and after having mated, same mode has started the Bluetooth stereo ear-phone function.When carrying out the MP3 broadcast, be to carry out MP3 decoding by the controlled DSP in outside to play at this moment, under the situation that the Bluetooth stereo earphone is arranged, baseband chip sends instructions and allows it that decoded audio data stream is not directly outputed to loud speaker with the form of analog signal from the audio frequency simulation passage, but handle through internal processes, decoded audio data coding is become the SBC audio data stream, be buffered in the internal RAM of DSP.And the system data bus (BUS) of B/B by 8 or 16 read out the SBC data from DSP, and also be cached among the SRAM of B/B inside.B/B takes out the SBC data in the internal RAM of timesharing again and sends on the A2DP link of bluetooth module from the UART mouth through after the transfer encoding, sends on the bluetooth earphone number with wireless mode again, realizes that A2DP MP3 plays.
See also Fig. 4.The player method of bluetooth MP3 on the low-end mobile phone of the present invention may further comprise the steps:
Step 1: under the multimedia menu of mobile phone, add the Bluetooth function menu option, and create activation and this bluetooth module that corresponding interfaces windows is used for bluetooth module and be connected with the coupling of bluetooth earphone and other bluetooth equipments (such as other bluetooth cellular phones or PC or the like);
Step 2: baseband chip is controlled described bluetooth module and bluetooth earphone mates in the mobile phone, starts the bluetooth earphone stereo function then;
Step 3: the user starts the MP3 play button, and baseband chip triggers and uses the bluetooth earphone passage to play MP3;
Step 4: baseband chip starts dsp chip to mp3 file broadcasts of decoding, and dsp chip carries out SBC to the audio data stream of playing encodes, and the SBC audio data stream after will encoding is stored in the buffer memory that the internal RAM of dsp chip own distributes;
Step 5: after the SBC voice data in the internal RAM of dsp chip reaches first buffer memory, be 32KB as buffer memory, baseband chip is read the SBC voice data from the dsp chip internal RAM, and these data is write in the SRAM named cache of baseband chip;
Step 6: after the SBC data volume in the SRAM of the baseband chip named cache reaches second buffering capacity, present embodiment has used the data buffering of 32K, baseband chip handle from the SRAM named cache is got the transfer encoding that A2DP was read and transmitted once more to the SBC voice data, promptly be transformed into and meet A2DP host-host protocol coded system, and the UART mouth of startup baseband chip, the SBC voice data is sent to bluetooth module;
Step 7: bluetooth module send on the bluetooth earphone, thereby the stereo MP3 that realizes bluetooth earphone is answered after the SBC voice data is handled by the A2DP protocol stack.
The SBC cataloged procedure is in the step 4:
This part be operated in DSP in finish, by firmware program with the PCM signal that obtains after the mp3 file decoding, be sent in the hardware audio data processing module of DSP, and the SBC coded message of configuration module, the form of being pressed SBC by the hardware audio data processing module produces the SBC audio data stream.And under the control of firmware program, be stored among the RAM of DSP, wait for the processing of next one.
As shown in Figure 4, be that the inventive method provides and realizes MP3A2DP Play Control flow chart cheaply.When MP3 plays beginning, at first judge whether A2DP equipment (the stereophone whether bluetooth that has matched is arranged in other words, and whether this stereo function is opened) on the flow process.If do not have, just get through the analog channel of local loud speaker, export from this machine.If have A2DP equipment, judge that current whether permission of this equipment use.Use if allow, the function that asynchronous call A2DP equipment is opened in the program (promptly triggers message mechanism so, in the AUDIO flow of task, call the OPEN function of A2DP, and the information that whether wait A2DP is opened in this task), and the feedback information in the judgement Bluetooth protocol, after successfully opening, base band control DSP enters the MP3 playing flow, start the inner SBC coded program of DSP, and start B/B read data scheduling flow simultaneously, timer (TIMER), the information of using DSP end buffer memory to expire simultaneously triggers the action of reading of data scheduling flow, and what voice data can not had delay reads from DSP and deposits in the B/B internal RAM.After the data of B/B internal RAM reach certain buffer memory, call the voice frequency link of asynchronous process function configuration A2DP equipment immediately, this is an asynchronous process process.After the information that this A2DP equipment voice frequency link of feedback has successfully configured from Bluetooth protocol, start the bluetooth task, trigger the transmission link of the audio data stream of bluetooth, enter simultaneously in the bluetooth task, obtain the current bluetooth equipment state and the rate parameter of UART mouth, calculate the time interval of from the B/B internal RAM, next time reading audio frequency parameter and the data volume that ought last time send.Read the SBC voice data of current less important transmission, and it is carried out necessary transfer encoding, restart the UART mouth, it is transferred to the protocol stack end of bluetooth module.Configuration uses the time interval that calculates to configure the scheduling parameter that bluetooth sends incident next time.Bluetooth module is delivered to data on the link of A2DP, realizes that MP3 A2DP plays.And need change the A2DP running status of current bluetooth task simultaneously.
The object of the present invention is to provide a kind of low-cost method that realizes that Bluetooth of mobile phone MP3 plays, be implemented on the cell phone platform of low side and realize high-end multimedia application.The inventive method is to use existing low-end mobile phone platform resource, utilizes existing plug-in dsp chip sound intermediate frequency codec functions, and uniting and adjustment Bluetooth function module realizes the stereosonic broadcast of MP3 A2DP.Its key technology is with baseband chip as master control side, DSP carries out the SBC coding to the MP3 that plays by software flow control, the data/address bus (BUS) that SBC data flow behind the coding is connected with dsp chip by baseband chip is read buffer memory among the SRAM by baseband chip, pass through the coordination system of RTOS in the base band (real time operating system) again, the SBC data flow that is buffered among the SRAM is sent on the Bluetooth chip by the UART mouth, and the A2DP agreement by bluetooth module sends to realization broadcast on the bluetooth earphone again.Technological difficulties and innovation be following some, the first, SBC coding control flow during MP3 plays and the SBC data behind the coding read the base band sram cache from DSP.The second, mode and flow process that the SBC audio data stream is transferred on the Bluetooth chip are controlled.The 3rd, the scheduling mechanism control and the main control process flow of the system that whole functional realizes are realized.
The specific implementation of the inventive method, need finish the software/hardware treatment step of following six aspects:
(1) the functional software control interface of cell phone platform and interface are set up;
(2) bluetooth module hard/software integrates;
(3) broadcast of the MP3 of DSP end and the control of SBC coding;
(4) buffer memory in SDRAM of the transmission control flow of SBC audio data stream and SBC voice data;
(5) transmission means of SBC voice data from SRAM to the Bluetooth chip handled and dispatched bluetooth protocol repertory and transmit voice data with the A2DP protocol mode to bluetooth earphone;
(6) the machine-processed scheduling controlling of RTOS and the realization of main control process flow in the software systems;
Below, the present invention will be described in detail above-mentioned 6 performing step.
(1) the functional software control interface of cell phone platform and interface are set up
At first, under the multimedia menu of cell phone platform, add the Bluetooth function menu option, and create corresponding interfaces windows and be used for the activation of bluetooth module and be connected with the coupling of blue clamp lug machine/other bluetooth equipments.
(2) bluetooth module hard/software integrates;
At first, on the hardware, need on mobile phone board, be integrated into bluetooth module, and the connection of relevant communication/voice-grade channel and auxiliary circuit configuration, and in the present embodiment, bluetooth module and baseband chip are by the UART port communications.The audio signal of general bluetooth module and source of sound end all is through linear impulsive coded modulation (the Linear Pulse Code Modlation on the chip, be called for short PCM) etc. the pure audio channel transfer, but in the cell phone platform of low side, can not all have such condition, use as voice-grade channel so the UART mouth that has used baseband chip to communicate by letter with bluetooth module in this scheme is multiplexing.In addition, on software, general purpose control program module transplanting such as the relevant chip reset of bluetooth module (control pin configuration, control function is write), activation and protocol stack transmission are incorporated on our the existing platform software.With the interface correlation of setting up in the preceding step one.
(3) broadcast of the MP3 of DSP end and the control of SBC coding
Be provided with in the program, activated at bluetooth earphone under the state of Bluetooth stereo function and play MP3, will trigger automatically and use the bluetooth earphone passage to play.And DSP carries out hardware decoding broadcast to mp3 file when, need control by flow process, the firmware program of scheduling DSP inside carries out the SBC coding to the audio data stream of playing simultaneously, and the back SBC audio data stream of will encode is stored among the BUFFER that the internal RAM of DSP own distributes.
if(MP3_GetBTPlayState())
{
SbcPtrBase=BL_Malloc(BLOCK_MEM_POOL_2);//500Kb?size????
sprate=mp3_fi?leinfo.samprate;
SBC_getConfig(mp3_sbc_config);
//AIT_Message(″mp3_sbc_config->channel_mode
is:%d,,mp3_sbc_config->alloc_method?is?%d?\n″,
mp3_sbc_config->channel_mode,mp3_sbc_config->alloc_method);
AITS_Audio_SBC_Encode_Config(mp3_sbc_config->channel_mode,(mp3_sbc_config->alloc_method+1),16,8,SBCTargetBitrate,sprate);
AITS_Audio_SBC_Init(&host_buf_refsize);
if(host_buf_refsize>SBC_POOL_SIZE)
{
AIT_Message(″NOTE.SBC?HOST?BUF?SIZE?too?small!!\r\n″);
return;
}
SbcPtr=SbcPtrBase;
host_sbc_buf=(u_char*)SbcPtr;
mmp_sbc_info.buf=(u_short*)host_sbc_buf;
mmp_sbc_info.buf_len=host_buf_refsize;
//AIT_Message(″SBC?Host(addr,size)=(0x%08x,%d)\n″,
host_sbc_buf,host_buf_refsize);
//setting?for?pf_a2dp
g_adm_dec_output_buf.buffer_size=84*1024;
g_adm_dec_output_buf.data_buffer_ptr=(int16*)SbcPtrBase;
g_adm_dec_output_buf.data_count=0;
g_adm_dec_output_buf.data_in_pos=0;
g_adm_dec_output_buf.data_out_pos=0;
open_flag=FALSE;
AITS_Audio_SBC_Encode_Enable(1);
}
(4) buffer memory in SDRAM of the transmission control flow of SBC audio data stream and SBC voice data;
By the firmware information exchanging mechanism among base band program and the DSP, when among the DSP MP3 being carried out the SBC coding and being stored in after SBC voice data in the DSP internal RAM reaches certain buffer memory.The base band primary control program uses regularly and the mechanism of message trigger.From the DSP internal RAM, the SBC voice data is read by the data/address bus that DSP is connected with base band, and these data are write in the SRAM appointed area (being BUFFER) of base band FLASH chip.The appointed area of this SRAM must just distribute from SRAM when definite MP3 uses the bluetooth earphone passage, being used for the SBC data fully uses at base band the processing/buffer memory here, for the performance index such as fluency that the stable and MP3 that takes into account system itself plays, determine in this scheme to use the SRAM space of a 400K byte as buffer memory.In this step, coordinate the buffer memory at the DSP/ base band two ends of MP3 broadcast, SBC coding, SBC audio data stream, be the key point of technology, for the smoothness that makes MP3 play/answer, we have used timer Timing Processing and two kinds of mechanism of message-driven to guarantee unobstructed audio data transmission.
PUBLIC?uint?16?MP3_BTSBC_DataPooling(void)
{
uint16?status;
AIT_EnterActive();
if((SBC_POOL_SIZE-g_adm_dec_output_buf.data_count)>=64*1024)
{
mmp_sbc_info.buf=(u_short*)SbcPtr;
status=AITS_Audio_SBC_GetFrames(&mmp_sbc_info);
if((g_adm_dec_output_buf.data_count>=32*1024)&&(open_flag==0))
{
if(!A2DP_IsAudioOpen())
{
A2DP_Play(115200);
}
open_flag=1;
}
if(status==AUDIO_NO_ERROR)
{
int?size=mmp_sbc_info.ret_get_frames*
mmp_sbc_info.size_per_frame;
int?allow_size=SBC_POOL_SIZE-(SbcPtr-SbcPtrBase);
AIT_Message("sizze=ox%x,frames?is?%d,per_frames?is:0x%x\n",
size,mmp_sbc_info.ret_get_frames,mmp_sbc_info.size_per_frame);
if(allow_size<size)
{
SbcPtr+=size;
size=(SbcPtr-(SbcPtrBase+SBC_POOL_SIZE));
SbcPtr=SbcPtrBase;
SCI_MEMCPY(SbcPtr,SbcPtrBase+SBC_POOL_SIZE,size);
}
SbcPtr+=size;
g_adm_dec_output_buf.data_count+=size;
}
}
else
{
}
AITS_ACTIVE_CLK_ON_BYPASS_DRAWLCD(1);
AIT_EnterBypass();
}
(5) transmission means of SBC voice data from SRAM to the Bluetooth chip handled and dispatched bluetooth protocol repertory and transmit voice data with the A2DP protocol mode to bluetooth earphone;
In order to make the more smooth of Bluetooth audio frequency transmission, to handle just trigger the audio transmission of bluetooth protocol repertory after the SBC data volume in base band end internal SRAM buffer memory reaches certain buffering capacity.At first to start the audio data stream transmission process flow process of bluetooth protocol repertory, in this handling process, data pointer be pointed to the SBC metadata cache of base band internal SRAM again.The Maximum Bit Rate that reaches according to the form and the UART mouth data transmissions of SBC coding, transform operation through data processing algorithm, mainly be to convert the A2DP transformat to, on existing SBC data, add seeker information necessary in the A2DP transformat and in the fixed block information of each payload (data block), and, calculate the time interval of data quantity transmitted and transmission each time to the compensating of the influence of current various factors.To set the event trigger mechanism configuration parameter in the bluetooth task among the RTOS (real time operating system) this blanking time, be used for smooth link up the SBC data are taken out and carried out transfer encoding once more from the base band internal SRAM.These send in the bluetooth module from the hardware interface UART mouth that is used for communicating by letter between bluetooth module and base band through the audio data stream after transfer encodings, handle via the A2DP protocol stack that is specifically designed to the stereo audio transmission in the bluetooth module protocol stack again, send on the bluetooth earphone, thereby the stereo MP3 that realizes bluetooth earphone answers.This A2DP protocol stack is existing functional block.
bool_t?SBC_getPacket(void**packet,uint16_t*packetSize,uint16_t*frames)
{
ADM_DecOutputBuf_T*audio_buf;
uint8_t *pkt_ptr;
uint8_t *frame_ptr;
uint8_t *left_ptr;
uint8_t *payload_ptr;
if(!sbcStarted)
{
return?FALSE;
}
audio_buf=A2DP_GetAudioData();
if(!audio_buf‖(audio_buf->data_count<
activeConfig->bytes_per_payload))
{
return?FALSE;
}
pkt_ptr=pmalloc(activeConfig->bytes_per_payload+1+
AV_FIXED_MEDIA_PACKET_HDR_SIZE);
frame_ptr=pkt_ptr+AV_FIXED_MEDIA_PACKET_HDR_SIZE+1;
payload_ptr=pkt_ptr+AV_FIXED_MEDIA_PACKET_HDR_SIZE;
left_ptr=(uint8_t*)audio_buf->data_buffer_ptr+audio_buf->data_out_pos;
if((audio_buf->data_out_pos+activeConfig->bytes_per_payload)<=
AUDIO_BUF_SIZE(audio_buf->buffer_size))
{
SCI_MEMCPY(frame_ptr,left_ptr,activeConfig->bytes_per_payload);
}
else
{
uint32_tcopy_count;/*in?bytes*/
copy_count=AUDIO_BUF_SIZE(audio_buf->buffer_size)-
audio_buf->data_out_pos;
SCI_MEMCPY(frame_ptr,left_ptr,copy_count);
SCI_MEMCPY(frame_ptr+copy_count,
(uint8_t*)&audio_buf->data_buffer_ptr[0],
activeConfig->bytes_per_payload-copy_count);
}
audio_buf->data_out_pos+=activeConfig->bytes_per_payload;
if(audio_buf->data_out_pos>=
AUDIO_BUF_SIZE(audio_buf->buffer_size))
audio_buf->data_out_pos-=
AUDIO_BUF_SIZE(audio_buf->buffer_size);
SCI_DisableIRQ();
audio_buf->data_count-=activeConfig->bytes_per_payload;
SCI_RestoreIRQ();
*payload_ptr=activeConfig->frames_per_payload;
*packet=pkt_ptr;
*packetSize=activeConfig->bytes_per_payload+1+
AV_FIXED_MEDIA_PACKET_HDR_SIZE;
*frames=activeConfig->frames_per_payload;
return?TRUE;
}
static?uint16_ttransmitAudioPacket(void)
{
a2InstData_t *instData;
uint16_t totalFrames;
uint16_t i,count;
instData=&globalInstData;
if((instData->con[0].state!=connected_streaming)
&&(instData->con[1].state!=connected_streaming))
{
return?FALSE;
}
count=2;
totalFrames=0;
for(i=0;i<count;++i){
uint16_tframes;
void *data;
uint16_tdataLen;
if(!SBC_getPacket(&data,&dataLen,&frames))
{
break;
}
if(instData->con[0].state==connected_streaming)
{
AvStreamDataReqSend(instData->con[0].streamHandle,
FALSE,
FALSE,
96,/*any?dynamic?PT?in?the?range?96-127
*/
instData->time_stamp,
dataLen,
data);
}
else?if(instData->con[1].state==connected_streaming)
{
AvStreamDataReqSend(instData->con[1].streamHandle,
FALSE,
FALSE,
96,/*any?dynamic?PT?in?the?range?96-127
*/
instData->time_stamp,
dataLen,
data);
}
else
{
A2DP_ASSERT(0?&&"transmitAudioPacket:no?valid?con");
}
/*prepare?fornext?packet*/
instData->time_stamp+=frames*
instData->ActiveConfig.data_per_encoding;
totalFrames+=frames;
}
return?totalFrames;
}
(6) the machine-processed scheduling controlling of RTOS and the realization of main control process flow in the software systems
The main effect of this work is for the effectively transmission of control data stream, makes audio data transmission unobstructed, keeps the coherent of sound playing not stop.The main effect that technology weighs this work is for the effectively transmission of control data stream, makes audio data transmission unobstructed, keeps the coherent of sound playing not stop.Technology focuses on: 1, need handle the task of bluetooth among the RTOS and the priority relationship and the coordination system of MP3 playing task well, and these are handled in the configuration of system, revise in the uniting and adjustment.2, the switching that data flow each task in transmission course is handled and in the successive processing of data flow some in each task.3, voice data is handled at the read-write operation of each buffer area, to the round-robin of the space piece section of each buffer area, the i.e. alternating movement writing and read of data flow in a certain amount of cache blocks.And the above all is embedded in each functional module control of main control process flow.
static?void?audioInterruptHandler(void)
{
a2InstData_t*instData=&globalInstData;
if(instData->isAudioOpen){
instData->time_stamp=0;
instData->packetRefTime=SCI_GetTickCount();
SBC_startEncode();
audioSamplesHandler(0,0);
}else{
bool_tret
A2DP_ASSERT(instData->audio_timer);
ret=cancel_timed_event(instData->audio_timer,0,0);
A2DP_ASSERT(ret);
instData->audio_timer=0;
SBC_stopEncode();
}
}
The above is preferred embodiment of the present invention only, is not to be used for limiting practical range of the present invention.Be that all equivalences of doing according to the content of the present patent application claim change and modification, all should be technology category of the present invention.