Commit 8457dfec18892c35dcf043968a6758ff3c2c1f89

Authored by luozhesi
1 parent 4638f117

1,finish bt source in wireless subwoofer mode

2,fixed a sound distorted issue  in aux source
... ... @@ -219,8 +219,8 @@ lib/optek_lib_freeRTOS.a
219 219 /*lib/optek_lib_freeRTOS_Debug.a*/
220 220
221 221
222   -lib/optek_link_5ms.a
223   -
  222 +/*lib/optek_link_5ms.a*/
  223 +lib/optek_link_5ms_for_swf.a
224 224 /*
225 225 lib/optek_link_7p5ms.a
226 226 */
... ...
No preview for this file type
... ... @@ -109,7 +109,7 @@ int xa_pcm_downsample_dec_frame (U8 **pout,U16 *plen)
109 109 void *mem,*d2as_obj;
110 110 int frame_len;
111 111
112   - if (optek_link_mode == TWS_SUBW_W_BT_SF44K || optek_link_mode == TWS_SUBW_W_BT_T6_SF44K || optek_link_mode == TWS_SUBW_W_BT_SF48K || optek_link_mode == TWS_SUBW_W_BT_T6_SF48K)
  112 + if (0)//(optek_link_mode == TWS_SUBW_W_BT_SF44K || optek_link_mode == TWS_SUBW_W_BT_T6_SF44K || optek_link_mode == TWS_SUBW_W_BT_SF48K || optek_link_mode == TWS_SUBW_W_BT_T6_SF48K)
113 113 {
114 114 frame_len = 240;
115 115 }
... ...
... ... @@ -133,7 +133,7 @@ typedef struct{
133 133
134 134 const APP_NAV_SOURCE source_table[] =
135 135 {
136   -// {MEDIA_BT_HCI,app_nav_rmt_convert_bt_hci},
  136 + {MEDIA_BT_HCI,app_nav_rmt_convert_bt_hci},
137 137 {MEDIA_AUX,app_nav_rmt_convert_aux},
138 138 {MEDIA_OPTICAL,app_nav_rmt_convert_spdif},
139 139
... ... @@ -694,7 +694,7 @@ void app_nav_rmt_convert_aux(void)
694 694 app_dac_receive_pcm_enable(FALSE);
695 695
696 696 #if defined OPL_MODE_TWO_WAY || defined OPL_MODE_SINGLE_WAY
697   - #if 1
  697 + #if 0
698 698 app_change_mode_req(GAME_HEADPHONE_PT_5MS_LP,100,50);
699 699 #else
700 700 if (optek_link_mode == GAME_HEADPHONE_PT_5MS_LP || optek_link_mode == BC_SF48K_PT5MS)
... ... @@ -826,8 +826,11 @@ void app_nav_rmt_convert_aux(void)
826 826 app_main_data.ui_background = app_nav_ad_pcm_pocess;
827 827
828 828 uDecSend (DECODE_SET, DECODE_PCM);
829   - //uDecSend (DECODE_INIT, 0);
830   - uDecSend (DECODE_FRAME, TRUE); //start to decode
  829 + uDecSend (DECODE_INIT, 0);
  830 +
  831 + #ifndef OPTEK_LINK_ENABLE
  832 + uDecSend (DECODE_FRAME, FALSE); //start to decode
  833 + #endif
831 834 app_main_data.playing_stream_status = STREAM_MEDIA;
832 835
833 836 #if defined AUDIO_CODEC_USED_VOL
... ...
... ... @@ -27,7 +27,7 @@
27 27 #include "app_sdram.h"
28 28 #include "Audio_Device.h"
29 29 #include "bt_common.h"
30   -
  30 +#include "optek_link.h"
31 31
32 32 void app_nav_rmt_convert_bt_hci(void)
33 33 {
... ... @@ -46,6 +46,18 @@ void app_nav_rmt_convert_bt_hci(void)
46 46
47 47 DBG_Printf("covert to BT HCI\n");
48 48
  49 +#ifdef OPL_MASTER_ENABLE
  50 + if(app_main_data.share_link_role != SL_ROLE_SLAVE)
  51 + {
  52 + void app_change_mode_req(u8 mode, u8 max_master_tx_len, u8 max_master_rx_len);
  53 + //app_change_mode_req(IDLE_W_BT,6,6);
  54 + app_change_mode_req(TWS_SUBW_W_BT_T6_SF44K,245,6);
  55 + //optek_link_role_stop();
  56 + delayms(100);
  57 + }
  58 +#endif
  59 +
  60 +
49 61 if(app_main_data.share_link_role != SL_ROLE_SLAVE)
50 62 {
51 63 if (bt_status.bt_main_status == enBT_DISCONNECTED)
... ...
... ... @@ -142,11 +142,12 @@ int pcm_dec_decode_frame(U8 **pout,U16 *plen)
142 142
143 143 *pout = pDecOut;
144 144 *plen = AD_PCM_BLOCK_SIZE;
145   - DBG_Printf("dma0:%d\r\n",DMA_0_COUNT);
  145 + //DBG_Printf("dma0:%d\r\n",DMA_0_COUNT);
146 146 return DECODE_SUCCESS;
147 147 }
148 148
149 149 /************sync with dma0************/
  150 +#if 0
150 151 if (inout_dma_sync_flag == FALSE)
151 152 {
152 153 U32 dma0_cnt = DMA_0_COUNT;
... ... @@ -155,7 +156,7 @@ int pcm_dec_decode_frame(U8 **pout,U16 *plen)
155 156 #ifdef OPL_MODE_TWO_WAY
156 157 in_out_offset = 180;
157 158 #else
158   - in_out_offset = 32;
  159 + in_out_offset = 64;
159 160 #endif
160 161 //i32 count = ((AD_PCM_BLOCK_SIZE/2-16) - dma0_cnt);
161 162 i32 count = ((AD_PCM_BLOCK_SIZE/2-in_out_offset) - dma0_cnt);
... ... @@ -166,7 +167,7 @@ int pcm_dec_decode_frame(U8 **pout,U16 *plen)
166 167 {
167 168 //adj_outsamples = count>>1;
168 169 memset(pDecOut,0,AD_PCM_BLOCK_SIZE*2);
169   - DBG_Printf("adj count1:%d\r\n",count);
  170 + //DBG_Printf("adj count1:%d\r\n",count);
170 171
171 172 if (count > AD_PCM_BLOCK_SIZE/4)
172 173 {
... ... @@ -177,11 +178,13 @@ int pcm_dec_decode_frame(U8 **pout,U16 *plen)
177 178 count = (i32)(-in_out_offset);
178 179 }
179 180
180   - DBG_Printf("adj count:%d\r\n",count);
  181 + //DBG_Printf("adj count:%d\r\n",count);
181 182
182 183 *pout = pDecOut;
183 184 *plen = AD_PCM_BLOCK_SIZE + (count/8)*16;
184 185
  186 + DBG_Printf("adj count:%d\r\n");
  187 +
185 188 return DECODE_SUCCESS;
186 189 }
187 190 else
... ... @@ -189,6 +192,7 @@ int pcm_dec_decode_frame(U8 **pout,U16 *plen)
189 192 inout_dma_sync_flag = TRUE;
190 193 }
191 194 }
  195 +#endif
192 196 /************sync with dma0 end********/
193 197
194 198 if (p == NULL)
... ... @@ -1498,18 +1502,37 @@ void taskDec(void *pvParameters)
1498 1502 #ifdef OPL_MODE_SINGLE_WAY
1499 1503 app_change_mode_req(BC_SF48K_PT5MS,100,6);
1500 1504 #elif defined OPL_MODE_SWF
1501   - if (app_main_data.playing_stream_sample_rate == 48000)
1502   - {
1503   - app_change_mode_req(SUBW_SF48K_PT2P5MS,24,6);
1504   - }
1505   - else if (app_main_data.playing_stream_sample_rate == 44100)
  1505 + if (decode_type == DECODE_SBC)
1506 1506 {
1507   - app_change_mode_req(SUBW_SF44K_PT2P5MS,24,6);
  1507 + /*if (app_main_data.playing_stream_sample_rate == 48000)
  1508 + {
  1509 + app_change_mode_req(SUBW_SF48K_PT2P5MS,24,6);
  1510 + }
  1511 + else if (app_main_data.playing_stream_sample_rate == 44100)
  1512 + {
  1513 + app_change_mode_req(SUBW_SF44K_PT2P5MS,24,6);
  1514 + }
  1515 + else
  1516 + {
  1517 + DBG_Printf("optek link not support sample rate\r\n");
  1518 + }*/
1508 1519 }
1509 1520 else
1510 1521 {
1511   - DBG_Printf("optek link not support sample rate\r\n");
  1522 + if (app_main_data.playing_stream_sample_rate == 48000)
  1523 + {
  1524 + app_change_mode_req(SUBW_SF48K_PT2P5MS,24,6);
  1525 + }
  1526 + else if (app_main_data.playing_stream_sample_rate == 44100)
  1527 + {
  1528 + app_change_mode_req(SUBW_SF44K_PT2P5MS,24,6);
  1529 + }
  1530 + else
  1531 + {
  1532 + DBG_Printf("optek link not support sample rate\r\n");
  1533 + }
1512 1534 }
  1535 +
1513 1536 #endif
1514 1537
1515 1538 if (app_main_data.playing_stream_chans == 1)
... ... @@ -1641,9 +1664,6 @@ void taskDec(void *pvParameters)
1641 1664 else
1642 1665 csbm_put_tx_unencoded_data(pOut,len);
1643 1666
1644   - DBG_PIN_HIGH;
1645   - DBG_PIN_LOW;
1646   -
1647 1667 #if 0//(SHARE_LINK_MODE != SL_TWO_WAY_AV && SHARE_LINK_MODE != SL_TWO_WAY_VV)
1648 1668 fifo_put_data(&audio_delay_fifo,pDacbuf,samples<<2);
1649 1669 fifo_get_data(&audio_delay_fifo,pDacbuf,samples<<2);
... ...
... ... @@ -130,9 +130,9 @@
130 130 #define OPL_SLAVE_ENBALE
131 131
132 132 /*********Choose one*************/
133   -//#define OPL_MODE_SINGLE_WAY
134   -//#define OPL_MODE_TWO_WAY
135   -#define OPL_MODE_SWF
  133 +//#define OPL_MODE_SINGLE_WAY // use optek link lib:optek_link_5ms.a
  134 +//#define OPL_MODE_TWO_WAY // use optek link lib:optek_link_5ms.a
  135 +#define OPL_MODE_SWF // use optek link lib:optek_link_5ms_for_swf.a
136 136
137 137 #if (defined OPL_MODE_TWO_WAY || (defined OPL_MODE_SINGLE_WAY && defined OPL_MASTER_ENABLE))
138 138 #define LC3_ENCODE_ENABLE
... ...
... ... @@ -547,7 +547,7 @@ void optek_link_end_cb(u8 id)
547 547 #define OPTEK_LINK_HOPPING_CH 37
548 548
549 549 #define OPTEK_LINK_MAX_CH 37
550   -const u8 optek_link_scan_ch[OPTEK_LINK_MAX_CH] =
  550 +const u8 optek_link_scan_chan[OPTEK_LINK_MAX_CH] =
551 551 {
552 552 0, 1, 2, 3, 4, 5, 6, 7,
553 553 8, 9, 10, 11, 12, 13, 14, 15,
... ... @@ -560,13 +560,12 @@ const u8 optek_link_scan_ch[OPTEK_LINK_MAX_CH] =
560 560 // for philips
561 561 /*
562 562 #define OPTEK_LINK_MAX_CH 8
563   -const u8 optek_link_scan_ch[OPTEK_LINK_MAX_CH] =
  563 +const u8 optek_link_scan_chan[OPTEK_LINK_MAX_CH] =
564 564 {
565 565 9, 10, 21, 22, 33, 34, 35, 36,
566 566 };
567 567 */
568 568
569   -
570 569 u32 optek_link_hopping_table_size_and_base_table_get(u8 *gen_table_size,u8 **base_table,u8 *base_table_size,u8 scan_f) __attribute__ ((section (".internal_ram_1_text")));
571 570 u32 optek_link_hopping_table_size_and_base_table_get(u8 *gen_table_size,u8 **base_table,u8 *base_table_size,u8 scan_f)
572 571 {
... ... @@ -575,7 +574,7 @@ u32 optek_link_hopping_table_size_and_base_table_get(u8 *gen_table_size,u8 **bas
575 574 else
576 575 *gen_table_size = OPTEK_LINK_HOPPING_CH;
577 576
578   - *base_table = optek_link_scan_ch;
  577 + *base_table = optek_link_scan_chan;
579 578 *base_table_size = OPTEK_LINK_MAX_CH;
580 579
581 580 return 0;
... ... @@ -863,24 +862,38 @@ u8 optek_link_tx_data_cb(u8 cpy, u8 *buf, u8 role, u8 ext_frame, u8 id) __attrib
863 862 u8 optek_link_tx_data_cb(u8 cpy, u8 *buf, u8 role, u8 ext_frame, u8 id)
864 863 {
865 864 u8 len = 0;
  865 + U8 packet_len;
866 866
867   - DBG_PIN_HIGH3;
868   - DBG_PIN_LOW3;
  867 + //DBG_PIN_HIGH3;
  868 + //DBG_PIN_LOW3;
869 869
870 870 if (cpy == 1)
871 871 {
872 872 #ifdef OPL_MODE_SWF
873 873 //len = bc_tx_data.tx_len;
874   -
875   - if (fifo_get_data_len(&opl_swf_tx_fifo) >= 24)
  874 +
  875 + if (optek_link_mode == TWS_SUBW_W_BT_T6_SF44K)
  876 + {
  877 + packet_len = 240;
  878 + }
  879 + else if (optek_link_mode == TWS_SUBW_W_BT_T6_SF48K)
  880 + {
  881 + packet_len = 240;
  882 + }
  883 + else
  884 + {
  885 + packet_len = 24;
  886 + }
  887 +
  888 + if (fifo_get_data_len(&opl_swf_tx_fifo) >= packet_len)
876 889 {
877 890 //bc_tx_data.tx_len = 0;
878 891
879 892 //CFasm_memcpy((void *)buf, (void *)bc_tx_data.tx_data,len);
880 893
881   - fifo_get_data(&opl_swf_tx_fifo,buf,24);
  894 + fifo_get_data(&opl_swf_tx_fifo,buf,packet_len);
882 895
883   - bc_tx_data.last_tx_len = 24;
  896 + bc_tx_data.last_tx_len = packet_len;
884 897 }
885 898 else if (bc_tx_data.last_tx_len)
886 899 {
... ... @@ -914,12 +927,34 @@ u8 optek_link_tx_data_cb(u8 cpy, u8 *buf, u8 role, u8 ext_frame, u8 id)
914 927 app_dac_receive_pcm_enable(FALSE);
915 928 spk_out_sync_w_tx_status = SPK_AND_TX_SYNCING_STEP2;
916 929 }
917   - else if ((spk_out_sync_w_tx_status == SPK_AND_TX_SYNCING_STEP2)&&(ext_frame == 0))
  930 + else if (spk_out_sync_w_tx_status == SPK_AND_TX_SYNCING_STEP2)
918 931 {
919   - //DBG_PIN_HIGH;
920   - //DBG_PIN_LOW;
  932 + U32 dma0_count = DMA_0_COUNT;
  933 +
  934 + if (adj_outsamples == 0)
  935 + {
  936 + i32 out_dma_cnt;
  937 +
  938 + out_dma_cnt = 10 - (dma0_count>>1);
  939 +
  940 + //if ((out_dma_cnt < -1) || (out_dma_cnt > 1))
  941 + if (out_dma_cnt == 0)
  942 + {
  943 + spk_out_sync_w_tx_status = SPK_AND_TX_SYNCING_STEP3;
  944 + }
  945 + else
  946 + {
  947 + adj_outsamples = out_dma_cnt;
  948 + //DBG_Printf("req adj:%d,%d,%d\r\n",adj_outsamples,dma0_count,dma8_count);
  949 + }
  950 + }
  951 +
  952 + }
  953 + else if ((spk_out_sync_w_tx_status == SPK_AND_TX_SYNCING_STEP3)&&(ext_frame == 0))
  954 + {
921 955 app_dac_receive_pcm_enable(TRUE);
922 956 spk_out_sync_w_tx_status = SPK_AND_TX_SYNCED;
  957 + uiDecSend (DECODE_FRAME, FALSE);
923 958 }
924 959 //SOFT3_INT_SET;
925 960 }
... ... @@ -1010,6 +1045,16 @@ u8 optek_link_slave_conn_cb (u8 mode, u8 *slave_max_tx_len, u8 *slave_max_rx_len
1010 1045 {
1011 1046 *slave_max_tx_len = OPTEK_LINK_MASTER_NO_RX_LEN;
1012 1047 *slave_max_rx_len = 24;
  1048 + }
  1049 + else if (mode == TWS_SUBW_W_BT_T6_SF44K)
  1050 + {
  1051 + *slave_max_tx_len = OPTEK_LINK_MASTER_NO_RX_LEN;
  1052 + *slave_max_rx_len = 245;
  1053 + }
  1054 + else if (mode == TWS_SUBW_W_BT_T6_SF48K)
  1055 + {
  1056 + *slave_max_tx_len = OPTEK_LINK_MASTER_NO_RX_LEN;
  1057 + *slave_max_rx_len = 245;
1013 1058 }
1014 1059 #endif
1015 1060 else
... ... @@ -1039,7 +1084,7 @@ u8 optek_link_slave_conn_cb (u8 mode, u8 *slave_max_tx_len, u8 *slave_max_rx_len
1039 1084 void optek_link_slave_link_loss_cb (u8 id) __attribute__ ((section (".internal_ram_1_text")));
1040 1085 void optek_link_slave_link_loss_cb (u8 id)
1041 1086 {
1042   - DBG_Printf("slave loss\r");
  1087 + //DBG_Printf("slave loss\r");
1043 1088 csb_rx_count = 0;
1044 1089 app_dac_receive_pcm_enable(FALSE);
1045 1090 //app_main_data.playing_stream_status = STREAM_WAITING_DATA;
... ...
... ... @@ -11,7 +11,8 @@ const char *optek_link_version_get(void);
11 11 typedef enum {
12 12 SPK_AND_TX_NOTSYNC,
13 13 SPK_AND_TX_SYNCING,
14   - SPK_AND_TX_SYNCING_STEP2,
  14 + SPK_AND_TX_SYNCING_STEP2,
  15 + SPK_AND_TX_SYNCING_STEP3,
15 16 SPK_AND_TX_SYNCED,
16 17 }APK_AND_TX_SYNC_STATUS_ENUM;
17 18 extern volatile APK_AND_TX_SYNC_STATUS_ENUM spk_out_sync_w_tx_status;
... ...
Please register or login to post a comment